I have a case where I have created a new queuing disipline.
If I run a tracing with nam style tracing everything works.
If I need to run tracing that does tcl at events that reschedule
themself for the next time while the simulator is running,
only a few of these get through (after the traffic starts)
before they stop altogether.
The simulation does run to completion as I have output from
my queue object showing packets are still arriving and leaving.
So, questions: Why would this happen and how do I find and fix it?
Is there another way to generate data for bandwidth graphs on
various flows and queue depths?
simulation file below but it is really just a slightly modified copy
from Marc Greis Tutorial
for xgraph output.
-------------------------
# ns template
# start a new simulator
set ns [new Simulator]
$ns use-scheduler Heap
#setup output file for nam
set nf [open kq_out.nam w]
$ns namtrace-all $nf
# set output files for xplot
set f0 [open kq_out0.tr w]
set f1 [open kq_out1.tr w]
set f2 [open kq_out2.tr w]
#close things out function
proc finish {} {
global f0 f1 f2
close $f0
close $f1
close $f2
#cannot execute display functions in the vm env
#exec xgraph kq_out0.tr kq_out1.tr kq_out2.tr -geometry
800x400 & exit 0
}
#function for recording data to graph
proc record {} {
global sink0 sink1 sink2 f0 f1 f2
set ns [ Simulator instance]
set time 0.3
set bw0 [$sink0 set bytes_]
set bw1 [$sink1 set bytes_]
set bw2 [$sink2 set bytes_]
set now [$ns now]
puts $f0 "$now [expr $bw0/$time*8/1000000]"
puts $f1 "$now [expr $bw1/$time*8/1000000]"
puts $f2 "$now [expr $bw2/$time*8/1000000]"
puts "$now"
$sink0 set bytes_ 0
$sink1 set bytes_ 0
$sink2 set bytes_ 0
$ns at [expr $now+$time] "record"
}
#nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
#links
$ns duplex-link $n0 $n3 1Mb 100ms DropTail
$ns duplex-link $n1 $n3 1Mb 100ms DropTail
$ns duplex-link $n2 $n3 1Mb 100ms DropTail
$ns simplex-link $n3 $n4 1Mb 100ms KQUEUE/K1
$ns simplex-link $n4 $n3 1Mb 100ms DropTail
#function for traffic gen and attachment
proc attach-expoo-traffic { node sink size burst idle rate } {
#get and instance of the simulator
set ns [Simulator instance]
#Create a UDP agent and attach it to the node
set source [new Agent/UDP]
$ns attach-agent $node $source
#create an Expoo traffic agent and set its config
set traffic [new Application/Traffic/Exponential]
$traffic set packetSize_ $size
$traffic set burst_time_ $burst
$traffic set idel_time_ $idle
$traffic set rate_ $rate
#attach traffic source to the traffic generator
$traffic attach-agent $source
#connect the source to the sink
$ns connect $source $sink
return $traffic
}
set sink0 [new Agent/LossMonitor]
set sink1 [new Agent/LossMonitor]
set sink2 [new Agent/LossMonitor]
$ns attach-agent $n4 $sink0
$ns attach-agent $n4 $sink1
$ns attach-agent $n4 $sink2
set source0 [attach-expoo-traffic $n0 $sink0 200 2s 1s 100k]
set source1 [attach-expoo-traffic $n1 $sink1 200 2s 1s 200k]
set source2 [attach-expoo-traffic $n2 $sink2 200 2s 1s 300k]
#now schedule the events/test
$ns at 0.0 "record"
$ns at 10.0 "$source0 start"
$ns at 10.0 "$source1 start"
$ns at 10.0 "$source2 start"
$ns at 50.0 "$source0 stop"
$ns at 50.0 "$source1 stop"
$ns at 50.0 "$source2 stop"
#complete the test
$ns at 60.0 "finish"
#everything above was setup, now run
$ns run