[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cbq/tcp question
Hi - I'm new to ns (and this list), but have exerted great effort
trying to get a simple cbq simulation going with some TCP flows. Ns
version is 1.4 running on sunos 5.5.1.
Topology is:
S1 S2 S3 S4 S?->K1 links are drop-tail 10Mbs
| | | |
| | | |
+--- K1 ---+
|
| K1->K2 is cbq, two classes, 4Mbs
|
+--- K2 ---+
| | | | K2->R? links are drop-tail 10Mbs
| | | |
R1 R2 R3 R4
There are four ftp flows Sn->Rn for n 1-4.
S1->R1 is "Gold", others are "Std".
"Gold" should have .48 of K1->K2
"Std" should have .52 of K1->K2
from stats, it only get's 1/4.
I've tried a ton of stuff, so there may be some ugly artifacts in the
attached script.
any help GREATLY appreciated.
confused,
Jim
----------------------------------------
proc dump { link interval } {
global lp0 lp1 lp2 c1a c2a gcq scq
set stopTime 40.1
set now [ns now]
ns at [expr $now + $interval] "dump $link $interval"
set p0 [$link stat 0 bytes]
set p1 [$link stat 1 bytes]
set p2 [$link stat 2 bytes]
set tp0 [expr $p0 - $lp0]
set tp1 [expr $p1 - $lp1]
set tp2 [expr $p2 - $lp2]
set c1a [expr $c1a*.9 + $tp1*.1]
set c2a [expr $c2a*.9 + $tp2*.1]
puts "$now 0= $tp0 1= $tp1 2= $tp2 1a= $c1a 2a= $c2a"
set lp0 $p0
set lp1 $p1
set lp2 $p2
set q0 [$link get queue-length]
set q1 [$link stat 1 mean-qlen]
set q2 [$link stat 2 mean-qlen]
puts "END Q $q0 Q1 $q1 Q2 $q2"
set q1 [$scq get queue-length]
set q2 [$gcq get queue-length]
puts "END Q $q0 I-Q1 $q1 I-Q2 $q2"
if {$now > $stopTime} {
exit 0
}
}
# Create Nodes
proc create_nodes {} {
global cbqlink rcbqlink s1 s2 s3 s4 r1 r2 r3 r4
set qlen 20
set s1 [ns node]
set s2 [ns node]
set s3 [ns node]
set s4 [ns node]
set k1 [ns node]
set k2 [ns node]
set r1 [ns node]
set r2 [ns node]
set r3 [ns node]
set r4 [ns node]
ns_duplex $s1 $k1 10Mb 5ms drop-tail
ns_duplex $s2 $k1 10Mb 5ms drop-tail
ns_duplex $s3 $k1 10Mb 5ms drop-tail
ns_duplex $s4 $k1 10Mb 5ms drop-tail
ns_duplex $k1 $k2 4Mb 5ms wrr-cbq
set cbqlink [ns link $k1 $k2]
set rcbqlink [ns link $k2 $k1]
ns_duplex $k2 $r1 10Mb 5ms drop-tail
ns_duplex $k2 $r2 10Mb 5ms drop-tail
ns_duplex $k2 $r3 10Mb 5ms drop-tail
ns_duplex $k2 $r4 10Mb 5ms drop-tail
[ns link $s1 $k1] set queue-limit 10
[ns link $s2 $k1] set queue-limit 10
[ns link $s3 $k1] set queue-limit 10
[ns link $s4 $k1] set queue-limit 10
[ns link $k2 $r1] set queue-limit 10
[ns link $k2 $r2] set queue-limit 10
[ns link $k2 $r3] set queue-limit 10
[ns link $k2 $r4] set queue-limit 10
}
# Create a flat link-sharing structure.
#
# 2 leaf classes:
# goldClas (48%)
# stdClass (52%)
#
proc create_classes {} {
global cbqlink rcbqlink gcq scq
set CBQalgorithm 1
set qlen 20
set Mbps 4
set topClass [ns_create_class1 none none 1.0 auto -1.0 8 1 0 $Mbps]
set goldClass [ns_create_class1 $topClass $topClass \
0.48 auto -1.0 1 0 0 $Mbps]
set stdClass [ns_create_class1 $topClass $topClass \
0.52 auto -1.0 1 0 0 $Mbps]
set gcq [$goldClass qdisc]
$gcq set queue-limit $qlen
set scq [$stdClass qdisc]
$scq set queue-limit $qlen
$cbqlink insert $topClass
$cbqlink insert $goldClass
$cbqlink insert $stdClass
$rcbqlink insert $topClass
$rcbqlink insert $goldClass
$rcbqlink insert $stdClass
$cbqlink bind $goldClass 2
$cbqlink bind $stdClass 1
$rcbqlink bind $goldClass 2
$rcbqlink bind $stdClass 1
$cbqlink set queue-limit 90
$rcbqlink set queue-limit 90
}
#
# Create four CBR connections.
#
proc create_sources {} {
global s1 s2 s3 s4 r1 r2 r3 r4
set tcp0 [ns_create_connection tcp $s1 tcp-sink $r1 2]
set tcp1 [ns_create_connection tcp $s2 tcp-sink $r2 1]
set tcp2 [ns_create_connection tcp $s3 tcp-sink $r3 1]
set tcp3 [ns_create_connection tcp $s4 tcp-sink $r4 1]
# set cbr0 [ns_create_cbr $s1 $r1 190 0.001 2]
set ftp0 [$tcp0 source ftp]
set ftp1 [$tcp1 source ftp]
set ftp2 [$tcp2 source ftp]
set ftp3 [$tcp3 source ftp]
# ns at 0.0 "$cbr0 start"
ns at 0.0 "$ftp0 start"
ns at 0.0 "$ftp1 start"
ns at 0.0 "$ftp2 start"
ns at 0.0 "$ftp3 start"
}
#
# Figure 13 from the link-sharing paper.
# WRR, Top link-sharing.
# ~/newr/rm/testA.com
#
global lp0 lp1 lp2 c1a c2a
set ns_link(queue-limit) 40
create_nodes
create_classes
create_sources
set c1a 0
set c2a 0
set lp0 0
set lp1 0
set lp2 0
ns at 0.0 "dump $cbqlink 1"
ns run