[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Duration of a flow
Hello everybody !
I will really appreciate your answer if you can help me for this
problem : In my script (below), I generate 10 sources which send Expoo
traffic. I'd like to know how can I obtain the trace of each flow.
I'd like to obtain something like that :
_________ ___________ ______ flow 0
____________ _________ flow 1
__________ _____________ flow 2
---------------------------------> time
The problem is that I don't know if I can obtain for each flow
several sequences, and the second thing is that I don't know (I can't
represent in xgraph) the end of each flow.
I hope you can help me !
Thanx a lot for that !!!
Sincerely,
Leyla
**********************************************************************************
set ns [new Simulator]
# Create trace-files
set zini [open out.tr w]
$ns trace-all $zini
set king [open flow.stat w]
set flowmon1 [$ns makeflowmon Fid]
proc monitoring {flowmon output} {
$flowmon attach $output
set bytesInt_ [new Integrator]
set pktsInt_ [new Integrator]
$flowmon set-bytes-integrator $bytesInt_
$flowmon set-pkts-integrator $pktsInt_
return $flowmon
}
proc go {} {
global ns flowmon1
$flowmon1 dump
$ns after 0.25 "go"
}
#for {set i 0} {$i <= 9} {incr i} {
# set zini_($i) [open out_($i).tr w]
#}
# Random parameters
set rnd [new RNG]
$rnd seed 0
# Create nodes
for {set i 0} {$i <= 9} {incr i} {
set n_($i) [$ns node]
}
set r1 [$ns node]
set sink [$ns node]
# Create links
for {set i 0} {$i <= 9} {incr i} {
$ns duplex-link $n_($i) $r1 10Mb 20ms DropTail
}
$ns duplex-link $r1 $sink 10Mb 20ms DropTail
$ns duplex-link $sink $r1 10Mb 20ms DropTail
# Create sinks (LossMonitor)
for {set i 0} {$i <= 9} {incr i} {
set null_($i) [new Agent/LossMonitor]
$ns attach-agent $sink $null_($i)
}
$ns attach-fmon [$ns link $r1 $sink] $flowmon1 0
# Create agents
for {set i 0} {$i <= 9} {incr i} {
set source_($i) [new Agent/CBR/UDP]
$source_($i) set class_ $i
$ns attach-agent $n_($i) $source_($i)
set expoo_($i) [new Traffic/Expoo]
$expoo_($i) attach-agent $source_($i)
$expoo_($i) set packet-size [expr [$rnd uniform 100 150]]
$expoo_($i) set burst-time [expr [$rnd uniform 1 10]]
$expoo_($i) set idle-time [expr [$rnd uniform 0.5 3]]
$ns connect $source_($i) $null_($i)
}
# Finish procedure
proc finish {} {
global king
set f [open temp.rands w]
exec rm -f temp.p1 temp.p2 temp.p3 temp.p4
exec touch temp.p1 temp.p2 temp.p3 temp.p4
exec awk {
{
if (($2 == "0")) \
print $1, 0
}
} flow.stat > temp.p1
exec awk {
{
if (($2 == "1")) \
print $1, 1
}
} flow.stat > temp.p2
exec awk {
{
if (($2 == "2")) \
print $1, 2
}
} flow.stat > temp.p3
exec awk {
{
if (($2 == "3")) \
print $1, 3
}
} flow.stat > temp.p4
puts $f [format "\n\"flow 0"]
flush $f
exec cat temp.p1 >@ $f
puts $f [format "\n\"flow 1"]
flush $f
exec cat temp.p2 >@ $f
puts $f [format "\n\"flow 2"]
flush $f
exec cat temp.p3 >@ $f
puts $f [format "\n\"flow 3"]
flush $f
exec cat temp.p4 >@ $f
close $f
exec rm -f temp.p1 temp.p2 temp.p3 temp.p4
exec xgraph -bb -tk -nl -m -x time -y "flow number x :" temp.rands &
exit 0
}
monitoring $flowmon1 $king
# Start and stop
for {set i 0} {$i <= 9} {incr i} {
$ns at [expr [$rnd uniform 0.5 10]] "$expoo_($i) start"
$ns at [expr [$rnd uniform 10 15.5]] "$expoo_($i) stop"
}
$ns at 0.0 "go"
$ns at 20.0 "finish"
$ns run