[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Reg: CBQ/WRR
Hi,
I tried running this program which generates a two node topology network
and implements CBQ/WRR. There are 2 queues defined: one for voice packet and
the other for data.
Can someone tell me how to go figure out whether CBQ is being implemented
by looking at the trace file.....
/* Program */
Simulator instproc get-link { node1 node2 } {
$self instvar link_
set id1 [$node1 id]
set id2 [$node2 id]
return $link_($id1:$id2) } #Procedure for naming the link as an object
(taken from Stoica)
Simulator instproc get-queue {node1 node2 } {
global ns
set l [$ns get-link $node1 $node2]
set q [$l queue]
return $q
}
#Procedure for naming the queue as an object (taken from Stoica)
set cbqalgorithm 1
set cbq_type CBQ/WRR
set stopTime 5
set Mbps 1500
set queue_audio 26
set queue_data 12
#############################################
set ns [new Simulator]
ns-random 8
#############################################
set f [open sale4.tr w]
$ns trace-all $f
proc make_queue { dim classe_cbq } {
set q [new Queue/DropTail]
$q set limit_ $dim
$classe_cbq install-queue $q
}
#Makes FIFO queue for each CBQ class
proc build-cbr { src dest pktSize interval random id startTime } {
global ns
set cbr [new Agent/CBR]
$ns attach-agent $src $cbr
#connect cbr sink to cbr null
$ns connect $cbr $dest
# init. cbr parameters
if {$pktSize > 0} {
$cbr set packetSize_ $pktSize
}
$cbr set fid_ $id
$cbr set interval_ $interval
$cbr set random_ $random
$ns at $startTime "$cbr start"
return $cbr
}
proc build-on-off-pareto { src dest pktSize burstTime idleTime rate id
startTime shp} {
global ns
set cbr [new Agent/CBR/UDP]
$ns attach-agent $src $cbr
$ns connect $cbr $dest
set exp1 [new Traffic/Pareto]
$exp1 set packet-size $pktSize
$exp1 set burst-time $burstTime
$exp1 set idle-time $idleTime
$exp1 set rate $rate
$exp1 set shape $shp
$cbr attach-traffic $exp1
$ns at $startTime "$cbr start"
$cbr set fid_ $id
return $cbr
}
#proc attach-expoo-traffic { node sink pktSize burst idle id start rate } {
proc attach-expoo-traffic { node id } {
set ns [Simulator instance]
set source [new Agent/UDP]
$source set fid_ $id
$ns attach-agent $node $source
return $source
}
proc attach-traffic-sale {source traffic sink pktSize burst idle start
rate } {
set ns [Simulator instance]
$traffic set packet-size $pktSize
$traffic set burst-time $burst
$traffic set idle-time $idle
$traffic set rate $rate
$traffic attach-agent $source
$ns connect $source $sink
$ns at $start "$traffic start"
}
proc create_graph { stopTime cbqType} {
global r1 k1 ns Mbps cbqalgorithm
set r1 [$ns node]
set k1 [$ns node]
$ns simplex-link $r1 $k1 1.5Mb 0ms $cbqType
set cbqLink [$ns get-link $r1 $k1]
# [$cbqLink classifier] resize 2000
[$cbqLink queue] algorithm $cbqalgorithm
}
proc finish {} {
global ns f
$ns flush-trace
close $f
exit 0
}
create_graph $stopTime $cbq_type
set link [$ns get-link $r1 $k1]
set topClass [new CBQClass]
set audioClass [new CBQClass]
set dataClass [new CBQClass]
$topClass set maxpkt_ 100
$audioClass set maxpkt_ 100
$dataClass set maxpkt_ 100
$topClass setparams none 0 1.0 0 8 2 0
$audioClass setparams $topClass 1 0.7 1.0 2 1 0.0
$dataClass setparams $topClass 1 0.3 1.0 2 1 0.0
make_queue $queue_audio $audioClass
make_queue $queue_data $dataClass
$link insert $topClass
$link insert $audioClass
$link insert $dataClass
set null(0) [new Agent/Null]
$ns attach-agent $k1 $null(0)
set null(1) [new Agent/Null]
$ns attach-agent $k1 $null(1)
#class1
#32 za 0.7
for {set i 1} {$i < 68} {incr i} {
set source($i) [attach-expoo-traffic $r1 $i]
set exp($i) [new Traffic/Expoo]
#attach-traffic-sale $source($i) $exp($i) $null(0) 500 0.36 0.36 0.0 32k
attach-traffic-sale $source($i) $exp($i) $null(0) 500 0.18 0.54 0.0 64k
}
#class2
#115 za 0.3
for {set i 101} {$i < 124} {incr i} {
set source($i) [attach-expoo-traffic $r1 $i]
set exp($i) [new Traffic/Expoo]
#attach-traffic-sale $source($i) $exp($i) $null(0) 500 0.36 0.36 0.0 32k
attach-traffic-sale $source($i) $exp($i) $null(0) 500 0.18 0.54 0.0 64k
}
$link bind $audioClass 1 100
$link bind $dataClass 101 200
$ns at $stopTime "finish"
$ns run
/* Part of the Trace file output */
+ 0.069106 0 1 exp 500 ------- 55 0.54 1.0 0 0
- 0.069106 0 1 exp 500 ------- 55 0.54 1.0 0 0
+ 0.069927 0 1 exp 500 ------- 56 0.55 1.0 0 1
r 0.071773 0 1 exp 500 ------- 55 0.54 1.0 0 0
- 0.071773 0 1 exp 500 ------- 56 0.55 1.0 0 1
r 0.074439 0 1 exp 500 ------- 56 0.55 1.0 0 1
+ 0.089169 0 1 exp 500 ------- 33 0.32 1.0 0 2
- 0.089169 0 1 exp 500 ------- 33 0.32 1.0 0 2
r 0.091835 0 1 exp 500 ------- 33 0.32 1.0 0 2
+ 0.105936 0 1 exp 500 ------- 121 0.87 1.0 0 3
- 0.105936 0 1 exp 500 ------- 121 0.87 1.0 0 3
+ 0.105938 0 1 exp 500 ------- 20 0.19 1.0 0 4
+ 0.107945 0 1 exp 500 ------- 64 0.63 1.0 0 5
r 0.108603 0 1 exp 500 ------- 121 0.87 1.0 0 3
- 0.108603 0 1 exp 500 ------- 20 0.19 1.0 0 4
r 0.11127 0 1 exp 500 ------- 20 0.19 1.0 0 4
- 0.11127 0 1 exp 500 ------- 64 0.63 1.0 0 5
r 0.113936 0 1 exp 500 ------- 64 0.63 1.0 0 5
+ 0.114547 0 1 exp 500 ------- 108 0.74 1.0 0 6
Preethi.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.