[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Need help with CBQ



Hi all,

I'm trying to simulate WFQ by using CBQ and assigning different weights to each flow class. I'm using 4 nodes, in which 2 "generator nodes" create traffic, another node aggregates it and the 4th node receives the traffic. The link from the aggregator node is very congested, so I expected packets of the higher weight class the receive a preferential treatment and being transmitted more often (more than 50% of the time). However I see that the two classes are sharing the link equally, as packets of the two classes are transmited alternatively. How is that possible?

My code:

#Create a simulator object
set ns [new Simulator]

$ns color 50 Red
$ns color 100 Blue

#Open the nam trace file
set nf [open david.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 david.nam &
        exit 0}

for {set i 0} {$i < 4 } {incr i} {
	set int_nodes($i) [$ns node]
    }
    # modified to star topology

    $ns duplex-link $int_nodes(1) $int_nodes(0) 400Kb 10ms CBQ
    set cbqlink(2) [$ns link $int_nodes(1) $int_nodes(0)]
    set cbqlink(3) [$ns link $int_nodes(0) $int_nodes(1)]
    
    $ns duplex-link $int_nodes(2) $int_nodes(0) 400Kb 10ms CBQ
    set cbqlink(4) [$ns link $int_nodes(2) $int_nodes(0)]
    set cbqlink(5) [$ns link $int_nodes(0) $int_nodes(2)]
    
    $ns duplex-link $int_nodes(3) $int_nodes(0) 400Kb 10ms CBQ
    set cbqlink(6) [$ns link $int_nodes(3) $int_nodes(0)]
    set cbqlink(7) [$ns link $int_nodes(0) $int_nodes(3)]
    $ns queue-limit $int_nodes(3) $int_nodes(0)  10
    $ns duplex-link-op $int_nodes(3) $int_nodes(0) queuePos 0.3
    
    
for {set i 2} {$i < 8} {incr i} {
	set topclass($i) [new CBQClass]
	$topclass($i) setparams none 0 1 auto 8 2 1

	set class1($i) [new CBQClass]
	set queue1($i) [new Queue/DropTail]
	$class1($i) install-queue $queue1($i)
	$class1($i) setparams $topclass($i) true 0.01 auto 1 1 0
	
	set class2($i) [new CBQClass]
	set queue2($i) [new Queue/DropTail]
	$class2($i) install-queue $queue2($i)
	$class2($i) setparams $topclass($i) true 0.99 auto 1 1 0

	$cbqlink($i) insert $topclass($i)
	$cbqlink($i) insert $class1($i)
	$cbqlink($i) insert $class2($i)

	$cbqlink($i) bind $class1($i) 50  
	#cbr traffic only..
	$cbqlink($i) bind $class2($i) 100 
	# everything else..

    }


#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$udp0 set fid_ 100
$ns attach-agent $int_nodes(1) $udp0

# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 400
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

#Create a UDP agent and attach it to node n1
set udp1 [new Agent/UDP]
$udp1 set fid_ 50
$ns attach-agent $int_nodes(2) $udp1

# Create a CBR traffic source and attach it to udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 400
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1

#Create a Null agent (a traffic sink) and attach it to node n3
set null0 [new Agent/Null]
$ns attach-agent $int_nodes(3) $null0
set null1 [new Agent/Null]
$ns attach-agent $int_nodes(3) $null1

#Connect the traffic sources with the traffic sink
$ns connect $udp0 $null0  
$ns connect $udp1 $null1


#Schedule events for the CBR agent
$ns at 0.5 "$cbr0 start"
$ns at 0.6 "$cbr1 start"
$ns at 4.5 "$cbr0 stop"
$ns at 4.6 "$cbr1 stop"

#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run



Thanks a lot. Best regards,

Jorge

PD: David, thanks for your code, it has a been a good point to start from.