[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Application/Traffic/CBR bug ?
Hi all,
I need to simulate a VBR source on UDP with changes its sending rate every
1/24 sec. ( 24 fps ). To do it i'm using a CBR traffic generator and i
change its sending rate ( rate_ variable ) every 1/24 second. The new
sending rate is a random variable generated by a RandomVariable/Exponential
object.
Sometimes the CBR generator seems not to work because it stops itself and if
i change its sending rate it seems do nothing.
To see what i'm trying to say please take a look to the following
Tcl-script.
set ns [new Simulator]
set file1 [open /home/federico/ns-result/out.nam w]
set filetrace [open /home/federico/ns-result/delme.tr w]
set cbrfile [open /home/federico/ns-result/cbr.tr w] ; # This file is used
to collect CBR Source's data
$ns namtrace-all $file1
set NumBytePrec1 0
set TimePrec1 0
set node1 [$ns node]
set node2 [$ns node]
$ns simplex-link $node1 $node2 110Mb 10ms DropTail
set agent1 [new Agent/UDP]
$ns attach-agent $node1 $agent1
set traffic [new Application/Traffic/CBR]
$traffic attach-agent $agent1
set agent2 [new Agent/Null]
$ns attach-agent $node2 $agent2
$ns connect $agent1 $agent2
set AvgRate 3000000
proc finish {} {
global ns file1 filetrace cbrfile
$ns flush-trace
close $cbrfile
close $filetrace
close $file1
exec /home/federico/ns-allinone-2.1b5/nam-1.0a7/nam
/home/federico/ns-result/out.nam &
exec /home/federico/ns-allinone-2.1b5/xgraph/xgraph
/home/federico/ns-result/delme.tr -geometry 400x400 &
exit 1
}
############################################################################
###########
# This procedure inserts a snooper between node1 and node2 to read the
number of packets sending from CBR#
############################################################################
###########
SimpleLink instproc attach-snooper-in { SrcNode DstNode } {
global ns
$self instvar Snooper Entry Link TtlPointer Monitor
# Create a SnoopQueue/In object
set Snooper [new SnoopQueue/In]
puts stdout "Create Snooper $Snooper"
# Get reference to the entry point for DstNode
set Entry [$DstNode entry]
# Get reference to the ttl block
set Link [$ns link $SrcNode $DstNode]
set TtlPointer [$Link set ttl_]
#Insert the snooper between ttl and entry-point
$lPointer target $Snooper
$Snooper target $Entry
# Creating a Queuemonitor to collect data
set Monitor [new QueueMonitor]
puts "Create Monitor : $Monitor"
$Snooper set-monitor $Monitor
return $Monitor
}
##########################################################################
# This procedure read statistics and write it in a file
#
##########################################################################
proc ReadMonitorData { File Fileb Monitor Stop Step } {
global ns NumBytePrec1 TimePrec1
# Leggiamo il tempo
set now [$ns now]
# Leggiamo il numero di bytes arrivati
set Bytes [$Monitor set barrivals_]
# Controlliamo quali dati dobbiamo processare
if {$File != "NULL"} then {
# Scriviamo i dati nel file d'uscita
puts $File "$now $Bytes"
# puts stdout "Monitor Data : $Bytes" Utile per il Debug
}
if {$Fileb != "NULL"} then {
set DeltaByte [expr $Bytes-$NumBytePrec1]
set DeltaTime [expr $now-$TimePrec1]
puts $Fileb "$now [expr $DeltaByte/$DeltaTime]"
# puts stdout "Monitor Band : [expr $DeltaByte/$DeltaTime]" Per il Debug
}
if {$File == "NULL" && $FIleb == "NULL"} then {
puts stdout "Error : procedure ReadMonitorData can't collect
data."
puts stdout " Both args are NULL."
exit 1 ;
}
# Rischeduliamo il processo solo se non eccede la fine della simulazione
set Next [expr $now+$Step]
if { $Next > $Stop } then { return }
$ns at $Next "ReadMonitorData $File $Fileb $Monitor $Stop $Step"
# Aggiorniamo i dati NumBytePrec1 e TimePrec1
set $NumBytePrec1 $Bytes
set $TimePrec1 $now
}
Application/Traffic/CBR instproc Prepara {} {
global ns AvgRate
$self instvar rate_
$self set Rng [new RNG]
$self instvar Rng
$Rng seed 1
$self set RndGen [new RandomVariable/Exponential]
$self instvar RndGen
$RndGen use-rng $Rng
$RndGen set avg_ $AvgRate
}
set link [$ns link $node1 $node2]
set monitor [$link attach-snooper-in $node1 $node2]
$ns at 0.0 "$traffic start"
$ns at 0.0 "$traffic Prepara"
$ns at 0.0 "ReadMonitorData $filetrace NULL $monitor 100.0 0.01"
$ns at 0.0 "$traffic set rate_ 1Mb"
$ns at 5.0 "$traffic set rate_ 10000" ; # <--- Try to change this rate , for
example 10 , 100 , 1000 ,.....
$ns at 6.0 "$traffic set rate_ 1Mb"
$ns at 100.0 "$traffic stop"
$ns at 100.1 "finish"
$ns run
If you see the graph generated you can see that at 6.0 the rate not change
although we command it to change the cbr sending rate.
Do you think it is a bug or i'm wronging something ?
Thank you and have a happy new year.
Federico Orlandini
E-Mail : [email protected]