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

[ns] About Flow monitoring



Hi all,

This is my first email in ns-mailing list

I 've a very simple topology and I constructed three classes in the
single link of my network...

Then I try to monitor the flow of the first class but I think that what
I get is the traffic of all the classes..
I attach my script.

Could somebody have a look...

I read the manual, my script is based on the test-suites but....

Thanks in advance.

Theodore Kotsilieris

set ns [new Simulator]

$ns color 1 Green
$ns color 2 Blue
$ns color 3 Black


 set n0 [$ns node]
 set n1 [$ns node]



 set f2 [open cbr2.tr w]
 #set nf [open out.nam w]
 set qtrfile [open queue.tr w]
 set flowtr [open flow.tr w]

 $ns trace-all $f2

 #$ns namtrace-all $nf



 $ns simplex-link $n0 $n1 10Mb 10ms CBQ/WRR

#Monitor the queue for the link between node 0 and node 1 
$ns simplex-link-op $n0 $n1 queuePos 0.5 

 set cbqlink [$ns link $n0 $n1]
 set topclass [new CBQClass]
 $topclass setparams none 0 1 auto 0 2 0

 set class1 [new CBQClass]
 set queue1 [new Queue/DropTail]
 $queue1 set limit_ 5
 $class1 install-queue $queue1
 $class1 setparams $topclass true 0.2 auto 1 1 0

 set class2 [new CBQClass]
 set queue2 [new Queue/DropTail]
 $queue2 set limit_ 5
 
 $class2 install-queue $queue2
 $class2 setparams $topclass true 0.3 auto 1 1 0

 set class3 [new CBQClass]
 set queue3 [new Queue/DropTail]
 $queue3 set limit_ 5
 $class3 install-queue $queue3
 
 $class3 setparams $topclass true 0.5 auto 1 1 0


 $cbqlink insert $topclass
 $cbqlink insert $class1
 $cbqlink insert $class2
 $cbqlink insert $class3


 $cbqlink bind $class1 1 ; # fid 1
 $cbqlink bind $class2 2 ; # fid 2
 $cbqlink bind $class3 3 ; # fid 3



set qmon [$ns monitor-queue $n0 $n1 $qtrfile]
set id0 [$n0 id]
set id1 [$n1 id]
set l01 [$ns set link_($id0:$id1)]

set fmon [$ns makeflowmon Fid]
$ns attach-fmon $l01 $fmon


# Agents creation
#1

#create a udp1 agent and attach it to node n0
set udp1 [new Agent/UDP]
$ns attach-agent $n0 $udp1
$udp1 set fid_ 1

#create a CBR traffic source and attach it to udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packet_size_ 1000
$cbr1 set rate_ 4Mb

#create a DelayMonitor agent and attach it to node n1
set sink1 [new Agent/Null]
$ns attach-agent $n1 $sink1

#2
#create a udp2 agent and attach it to node n0
set udp2 [new Agent/UDP]
$ns attach-agent $n0 $udp2
$udp2 set fid_ 2

#create a CBR traffic source and attach it to udp2
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
$cbr2 set packet_size_ 1000
$cbr2 set rate_ 4Mb

#create a DelayMonitor agent and attach it to node n1
set sink2 [new Agent/Null]
$ns attach-agent $n1 $sink2

#3
#create a udp3 agent and attach it to node n0
set udp3 [new Agent/UDP]
$ns attach-agent $n0 $udp3
$udp3 set fid_ 3

#create a CBR traffic source and attach it to udp3
set cbr3 [new Application/Traffic/CBR]
$cbr3 attach-agent $udp3
$cbr3 set packet_size_ 1000
$cbr3 set rate_ 6Mb

#create a DelayMonitor agent and attach it to node n1
set sink3 [new Agent/Null]
$ns attach-agent $n1 $sink3

$ns connect $udp1 $sink1
$ns connect $udp2 $sink2
$ns connect $udp3 $sink3

proc finish {} {


 global ns f2 qtrfile nf flowtr


 
 close $f2
 close $qtrfile
 #close $nf
 close $flowtr

#exec nam out.nam &
exec xgraph flow.tr -geometry 700x400 &
exec xgraph queue.tr -geometry 700x400 &
exit 0
}

proc record {} {
global qtrfile qmon fmon flowtr 
 
        set ns [Simulator instance] 
        set time 0.25 
 
        set now [$ns now] 
        set dsamp [$qmon set pdrops_] 
        set fcl [$fmon classifier]
        set fids {1 2 3}
        foreach i $fids {
            set flow($i) [$fcl lookup auto 0 1 $i]
            if {$i==1} {
                        

        
        set packarrivals [$fmon set pdrops_]
        puts $flowtr "$now $packarrivals"
                puts stdout "$now $packarrivals"
        
}
}
 puts $qtrfile "$now $dsamp" 
        $ns at [expr $now+$time] "record" 
}

#$ns at 0.0 "$l01 start-tracing"
$ns at 0.0 "record" 
$ns at 0.5 "$cbr1 start"
$ns at 0.5 "$cbr2 start"
$ns at 0.5 "$cbr3 start"


$ns at 4.5 "$cbr1 stop"
$ns at 4.5 "$cbr2 stop"
$ns at 4.5 "$cbr3 stop"
$ns at 0.5 "$fmon dump" 
$ns at 10.0 "finish"
$ns run