?? example.tcl
字號:
## Copyright (c) 2001-2005 Paolo Losi (p.losi@hypersonic.it)# Alexander Sayenko (sayenko@cc.jyu.fi)## All rights reserved## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.### n0# \# \# \# r ------ d# /# / ^# / |# n1 bottleneck## Description: ## There are two CBR sources at nodes n0 and n1. Each CBR source # generates traffic at the rate of 1.1Mbps. The link between nodes r and d is# the bottleneck, which has the throughput of 2Mbps. # See how WFQ shares resources between them before the 1st second of simulation# and after, when weights are changed. Notice the difference in packet sizes.#set ns [new Simulator]# Create trace files set f [open out.tr w]$ns trace-all $fset nam [open out.nam w]$ns namtrace-all $nam# Create nodesset n0 [$ns node]set n1 [$ns node]set r [$ns node]set d [$ns node]$ns color 0 blue$ns color 1 red$ns duplex-link $n0 $r 5Mb 1ms DropTail$ns duplex-link $n1 $r 5Mb 1ms DropTail# install a simplex link with WFQ queue between r and d# when packets move back, simple DropTail is used$ns simplex-link $r $d 2Mb 2ms WFQ$ns simplex-link $d $r 1Mb 2ms DropTail$ns duplex-link-op $n0 $r orient right-down$ns duplex-link-op $n1 $r orient right-up$ns simplex-link-op $r $d orient right$ns simplex-link-op $d $r orient left# create an instance of the classifier suited for flow aggregationset cl [new WFQAggregClassifier]# install the classifier on the WFQ server at node $n0 heading at nt $n1$ns wfqclassifier-install $r $d $cl # in this example we have a flow for each queue but# more than one flow can be assigned to the same WFQ server queue(PGPS session)$cl setqueue 0 3; # fid 0 -> WFQ server queue 3$cl setqueue 1 4; # fid 1 -> WFQ server queue 4#we set WFQ server queue weights$cl setweight 3 0.5; # WFQ server queue 3 has weight 0.5$cl setlength 3 5; # WFQ server queue 3 has length 5 packets$cl setweight 4 0.5; # WFQ server queue 5 has weight 0.5$cl setlength 4 5; # WFQ server queue 5 has length 5 packetsset udp0 [new Agent/UDP]$ns attach-agent $n0 $udp0$udp0 set fid_ 0; # this is the info used by WFQ classifierset cbr0 [new Application/Traffic/CBR]$cbr0 set rate_ 1.1Mb$cbr0 set packetSize_ 100$cbr0 attach-agent $udp0set udp1 [new Agent/UDP]$ns attach-agent $n1 $udp1$udp1 set fid_ 1; # this is the info used by WFQ classifierset cbr1 [new Application/Traffic/CBR]$cbr1 set rate_ 1.1Mb$cbr1 set packetSize_ 200$cbr1 attach-agent $udp1set null [new Agent/Null]$ns attach-agent $d $null$ns connect $udp0 $null$ns connect $udp1 $null$ns at 0.0 "$cbr0 start"$ns at 0.1 "$cbr1 start"#change weights during the simulation$ns at 1 "$cl setweight 3 0.8; $cl setweight 4 0.2"$ns at 2.0 "finish"proc finish {} { global ns f nam $ns flush-trace close $f close $nam exit 0}$ns run
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -