# HUST # 2001 # Xuan xiaoying and Zengkai # simulation script for CIF-Q. source utils.tcl # create an instance of the simulator set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf $ns color 0 red $ns color 1 black $ns color 2 blue # create nodes set n0 [$ns node] set n1 [$ns node] debug 1 $ns duplex-link $n0 $n1 1.5Mb 10ms CIFQ # NOTE: first we get a handle to the RR queue discipline set q [$ns get-queue $n0 $n1] $q ranvar 0 [new RandomVariable/Uniform] 0.0 $q ranvar 1 [new RandomVariable/Uniform] 0.4 $q ranvar 2 [new RandomVariable/Uniform] 0.2 $q set-queue-size 0 5000 $q set-queue-size 1 5000 # Set the weight of the flows $q set-flow-weight 0 2 $q set-flow-weight 1 2 $q set-flow-weight 2 2 #create UDP flows set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 $udp0 set class_ 0 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 $cbr0 set packetSize_ 1000 $cbr0 set interval_ 0.008 set null0 [new Agent/Null] $ns attach-agent $n1 $null0 $ns connect $udp0 $null0 $ns at 0 "$cbr0 start" set udp1 [new Agent/UDP] $ns attach-agent $n0 $udp1 $udp1 set class_ 1 set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1 $cbr1 set packetSize_ 1000 $cbr1 set interval_ 0.008 set null1 [new Agent/Null] $ns attach-agent $n1 $null1 $ns connect $udp1 $null1 $ns at 0.1 "$cbr1 start" set udp2 [new Agent/UDP] $ns attach-agent $n0 $udp2 $udp2 set class_ 2 set cbr2 [new Application/Traffic/CBR] $cbr2 attach-agent $udp2 $cbr2 set packetSize_ 500 $cbr2 set interval_ 0.0067 set null2 [new Agent/Null] $ns attach-agent $n1 $null2 $ns connect $udp2 $null2 $ns at 0.8 "$cbr2 start" # Create a trace and arrange for all link # events to be dumped to "out.tr" set tf [open out.tr w] $ns trace-queue $n0 $n1 $tf $ns at 10.0 "finish" # flush all trace data when finish proc finish {} { global ns tf nf $ns flush-trace close $tf close $nf puts "running nam ...." exec nam out.nam & exit 0 } # start simulation $ns run