source tb_compat.tcl set ns [new Simulator] # Create four nodes set nodeA [$ns node] set nodeB [$ns node] # Create a RED duplex link set link0 [$ns duplex-link $nodeA $nodeB 100Mb 0ms RED] # Get the queue object for the nodeA/nodeb link and modify its RED params. set queue0 [[$ns link $nodeA $nodeB] queue] $queue0 set gentle_ 1 $queue0 set queue-in-bytes_ 0 $queue0 set limit_ 50 $queue0 set maxthresh_ 20 $queue0 set thresh_ 7 $queue0 set linterm_ 11 $queue0 set q_weight_ 0.004 # Create a UDP agent and attach it to nodeA set udp0 [new Agent/UDP] $ns attach-agent $nodeA $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 # Create a TCP agent and attach it to nodeA set tcp0 [new Agent/TCP] $ns attach-agent $nodeA $tcp0 # Create a CBR traffic source and attach it to tcp0 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 500 $cbr1 set interval_ 0.005 $cbr1 attach-agent $tcp0 # Create a Null agent (a UDP traffic sink) and attach it to node nodeB set null0 [new Agent/Null] $ns attach-agent $nodeB $null0 # Create a TCPSink agent (a TCP traffic sink) and attach it to node nodeB set null1 [new Agent/TCPSink] $ns attach-agent $nodeB $null1 # Connect the traffic sources with the traffic sinks $ns connect $udp0 $null0 $ns connect $tcp0 $null1 # And some events. $ns at 60.0 "$cbr0 start" $ns at 70.0 "$link0 bandwidth 10Mb duplex" $ns at 80.0 "$link0 delay 10ms" $ns at 90.0 "$link0 plr 0.05" $ns at 100.0 "$link0 down" $ns at 110.0 "$link0 up" $ns at 115.0 "$cbr0 stop" $ns at 120.0 "$cbr1 start" $ns at 130.0 "$cbr1 set packetSize_ 512" $ns at 130.0 "$cbr1 set interval_ 0.01" $ns at 140.0 "$link0 down" $ns at 150.0 "$cbr1 stop" #Run the simulation $ns run