[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Problems with CBQ
Hi all,
I'm trying to configure CBQ. I think I know how to define the classes, but I don't know how to tell the simulator "apply all these classes on that link". What should I add to this code to create a link and share it applying the classes I have defined?
#Create a simulator object
set ns [new Simulator]
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0}
#Create nodespen
set n1 [$ns node]
set n2 [$ns node]
for {set i 1} {$i < 4} {incr i} {
#Create a UDP agent and attach it to node n0
set udp($i) [new Agent/UDP]
$udp($i) set class_ ($i)
$ns attach-agent $n1 $udp($i)
# Create a CBR traffic source and attach it to udp0
set cbr($i) [new Application/Traffic/CBR]
$cbr($i) set packetSize_ 500
$cbr($i) set interval_ 0.005
$cbr($i) attach-agent $udp($i)
#Create a Null agent (a traffic sink) and attach it to node n1
set null($i) [new Agent/Null]
$ns attach-agent $n2 $null($i)
#Connect the traffic source with the traffic sink
$ns connect $udp($i) $null($i)
}
set topclass [new CBQClass]
$topclass setparams none 0 1 auto 8 4 0
set class1 [new CBQClass]
set queue1 [new Queue/DropTail]
$queue1 set limit_ 3
$class1 install-queue $queue1
$class1 setparams $topclass true 0.33 auto 1 3 0
set class2 [new CBQClass]
set queue2 [new Queue/DropTail]
$queue2 set limit_ 3
$class2 install-queue $queue2
$class2 setparams $class1 true 0.33 auto 2 2 0
set class3 [new CBQClass]
set queue3 [new Queue/DropTail]
$queue3 set limit_ 3
$class3 install-queue $queue3
$class3 setparams $class2 true 0.33 auto 3 1 0
#Schedule events for the CBR agent
for {set i 1} {$i < 4} {incr i} {
$ns at 0.5 "$cbr($i) start"
$ns at 4.5 "$cbr($i) stop"
}
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run
Has anyone tested CBQ and has a simple source file which I could study to learn CBQ?
#Create a simulator object
set ns [new Simulator]
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0}
#Create nodespen
set n1 [$ns node]
set n2 [$ns node]
for {set i 1} {$i < 4} {incr i} {
#Create a UDP agent and attach it to node n0
set udp($i) [new Agent/UDP]
$udp($i) set class_ ($i)
$ns attach-agent $n1 $udp($i)
# Create a CBR traffic source and attach it to udp0
set cbr($i) [new Application/Traffic/CBR]
$cbr($i) set packetSize_ 500
$cbr($i) set interval_ 0.005
$cbr($i) attach-agent $udp($i)
#Create a Null agent (a traffic sink) and attach it to node n1
set null($i) [new Agent/Null]
$ns attach-agent $n2 $null($i)
#Connect the traffic source with the traffic sink
$ns connect $udp($i) $null($i)
}
set topclass [new CBQClass]
$topclass setparams none 0 1 auto 8 4 0
set class1 [new CBQClass]
set queue1 [new Queue/DropTail]
$queue1 set limit_ 3
$class1 install-queue $queue1
$class1 setparams $topclass true 0.33 auto 1 3 0
set class2 [new CBQClass]
set queue2 [new Queue/DropTail]
$queue2 set limit_ 3
$class2 install-queue $queue2
$class2 setparams $class1 true 0.33 auto 2 2 0
set class3 [new CBQClass]
set queue3 [new Queue/DropTail]
$queue3 set limit_ 3
$class3 install-queue $queue3
$class3 setparams $class2 true 0.33 auto 3 1 0
#Schedule events for the CBR agent
for {set i 1} {$i < 4} {incr i} {
$ns at 0.5 "$cbr($i) start"
$ns at 4.5 "$cbr($i) stop"
}
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run
Is there anyone who has tested CBQ and has a simple source file which I could study to learn the basics of CBQ-configuring?
Thanks a lot and best regards,
Jorge