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

[ns] Flow monitoring problem



Dear all,
I was trying to monitor flows on a cbq link using a
flow monitor.
However in my file dumping function the flow
classifier is not returning the flow and as a result
nothing is being dumped in the dumpfile..
can anyone please take a look and tell me what is
going wromd...i suspect the problem is not in cdump
but even earlier null values are being returned..
Please help!!
The code is as follows-
set opt(stop)       30

set ns_ [new Simulator]
set tracefd [open sim6.tr w]
$ns_ trace-all $tracefd

set s1 [$ns_ node]
set s2 [$ns_ node]
set s3 [$ns_ node]
set s4 [$ns_ node]
set r1 [$ns_ node]
set k1 [$ns_ node]

$ns_ duplex-link $s1 $r1 10Mb 5ms DropTail
$ns_ duplex-link $s2 $r1 10Mb 5ms DropTail
$ns_ duplex-link $s3 $r1 10Mb 5ms DropTail
$ns_ duplex-link $s4 $r1 10Mb 5ms DropTail
set quiet false
set cbqlink [ns link $r1 $k1 wrr-cbq]
$cbqlink set bandwidth 1.5Mb
set maxBytes 187500
# for a maxburst of 5, 1000-byte packets, set maxidle
to
#       0.002 (1/p - 1)
$cbqlink set delay 5ms
set qlim 20
set cbq_qtype_ DropTail
set topclass_ [new CBQClass]
$topclass_ setparams none 0 0.98 auto 8 2 0
set vidclass_ [new CBQClass]
$vidclass_ setparams $topclass_ true 0.32 auto 1 1 0
set q1 [new Queue/$cbq_qtype_]
$q1 set limit_ $qlim
$vidclass_ install-queue $q1
set audioclass_ [new CBQClass]
$audioclass_ setparams $topclass_ true 0.03 auto 1 1 0
set q2 [new Queue/$cbq_qtype_]
$q2 set limit_ $qlim
$audioclass_ install-queue $q2
set dataclass_ [new CBQClass]


$dataclass_ setparams $topclass_ true 0.65 auto 2 1 0
set q3 [new Queue/$cbq_qtype_]
$q3 set limit_ $qlim
$dataclass_ install-queue $q3




$cbqlink insert $topclass_
$cbqlink insert $vidclass_
$cbqlink insert $audioclass_
$cbqlink insert $dataclass_

$cbqlink bind $vidclass_ 2;# fid 2
$cbqlink bind $audioclass_ 1;# fid 1
$cbqlink bind $dataclass_ 3; # fid 3


#set ls1 [new Agent/LossMonitor]
#$ns_ attach-agent $W(1) $ls1

# setup CBR connections between a wired node and the
MobileHost
set udp1 [$ns_ create-connection UDP $s1 LossMonitor
$r1 1]
set cbr1 [new Application/Traffic/CBR]



$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 190
$cbr1 set rate_ 1.52Mb; # interval of 0.001
set udp2 [$ns_ create-connection UDP $s2 LossMonitor
$r1 2]
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
$cbr2 set packetSize_ 500
$cbr2 set rate_ 2Mb; # interval of 0.002



set udp3 [$ns_ create-connection UDP $s3 LossMonitor
$r1 3]
#set udp3 [new Agent/UDP]
#$ns_ attach-agent $W(3) $udp3


set cbr3 [new Application/Traffic/CBR]
$cbr3 attach-agent $udp3
$cbr3 set packetSize_ 1000
$cbr3 set rate_ 1.6Mb; # interval of 0.005

set fmon_ [$ns_ makeflowmon Fid]
$ns_ attach-fmon $cbqlink $fmon_

$ns_ at 0.0 "$cbr1 start; $cbr2 start; $cbr3 start"
$ns_ at 4.0 "$cbr3 stop"
$ns_ at 8.0 "$cbr3 start"
$ns_ at 12.0 "$cbr2 stop"
$ns_ at 18.0 "$cbr2 start"
$ns_ at 20.0 "$cbr1 stop"
$ns_ at 24.0 "$cbr1 start"


[$cbqlink queue] algorithm top-level

set stopTime 28.1
set maxBytes 187500
set linkno $cbqlink
set interval 1.0

set dumpfile temp.s
set fcl [$fmon_ classifier]


set fids { 1 2 3 4 }
foreach i $fids {
    set oldbytes_($i) 0
}
set f [open $dumpfile w]
puts $f "maxbytes $maxBytes"

$ns_ at 0.0 " cdump $linkno $interval $f"

set f1 [open temp.q w]
set tmpqchan_ $f1
puts $f1 "delay"
$ns_ at $opt(stop) " cdumpdel $f1"


$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_
halt"

$ns_ at $opt(stop).0001 "finish"

proc finish {} {
     global cbqlink quiet 
    set graphfile temp.rands
        set bw 1500000 
#[[$cbqlink set link_] set bandwidth_]
        set maxbytes [expr $bw / 8.0]
        
        


        set awkCode  {
                $2 == fid { print $1, $3/maxbytes }
        }
 set awkCodeAll {
                $2 == fid { print time, sum; sum = 0 }
                {
                        sum += $3/maxbytes;
                        if (NF==3)
                                time = $1;
                        else
                                time = 0;
                }
        }



        set f [open $graphfile w]
       # puts $f "TitleText: $testname"
       # puts $f "Device: Postscript"

        exec rm -f temp.p
 exec touch temp.p
        foreach i { 1 2 3 4 } {
                exec echo "\n\"flow $i" >> temp.p
                exec awk $awkCode fid=$i
maxbytes=$maxbytes temp.s > temp.$i
                exec cat temp.$i >> temp.p
                exec echo " " >> temp.p
        }

        exec awk $awkCodeAll fid=1 maxbytes=$maxbytes
temp.s > temp.all
        exec echo "\n\"all " >> temp.p
        exec cat temp.all >> temp.p

        exec cat temp.p >@ $f
        close $f
        if {$quiet == "false"} {
                exec xgraph -bb -tk -x time -y
bandwidth $graphfile &
        }
#       exec csh figure2.com $file

        exit 0
}

proc cdump { lnk interval file }  {
         
          global fcl  ns_ fmon_ cbqlink fids quiet
oldbytes_ 
          set now [$ns_ now]
          set fcl [$fmon_ classifier]
          set fids { 1 2 3 4 }

          if {$quiet == "false"} {
                puts "$now"
          }
          foreach i $fids {
	          
                  set flow($i) [$fcl lookup auto 0 0
$i]
	     

                  if { $flow($i) != "" } {
		
                          set bytes($i) [$flow($i) set
bdepartures_]
                          puts $file "$now $i [expr
$bytes($i) - $oldbytes_($i)]"
                          set oldbytes_($i) $bytes($i)
                  }
	      }
	  $ns_ at [expr $now + $interval] " cdump $lnk
$interval $file"
	  }
      
proc cdumpdel file {
          global ns_ fmon_
          set now [$ns_ now]
          set fcl [$fmon_ classifier]

          set fids { 1 2 3 4 }
          foreach i $fids {
                  set flow [$fcl lookup auto 0 0 $i]
                  if { $flow != "" } {
                          set dsamp [$flow
get-delay-samples]
                          puts $file "$now $i [$dsamp
mean]"
                  }
          }
      }
      

puts "Starting Simulation..."
$ns_ run
       


Thanks in advance..
cheers
Prashant

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/