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

[ns] X-Mailer: Infom@il (correo con interfaz WEB)



Hi all,

I'm trying to simulate CBQ. I think I know how to create the class strcture, but I don't know how to tell NS "create a link and apply this class-sharing policy to that particular link". Can anybody help me?


This is my code:

#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


Alternatively, if someone has been using CBQ and has a basic CBQ script from which I could learn I would be grateful to him/her.

Please help me, as I am starting to get a bit desperate with CBQ. Best regards,

Jorge