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

[ns] using filter,can any body find the error in this code?




hello every body,

we used this peace of code in NS for filtering some packets but it
doesn't work properly, can anybody say what is the problem with that?
it doesn't filter any of the packets.

thank you
Eaman


#Create a simulator object
set ns [new Simulator]

#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedur
proc finish {} {
        global ns nf f1 
        $ns flush-trace
	#Close the trace file
        #close $nf
	#close $f1
	#Execute nam on the trace file
	#exec nam out.nam &
	$ns flush-trace
        exit 
}

$ns trace-all [open output.tr w]

set n0 [$ns node] 
set n4 [$ns node] 
set n5 [$ns node] 
set n6 [$ns node]
set n7 [$ns node]

$ns duplex-link $n0 $n4 1Mb 100ms DropTail
$ns duplex-link $n4 $n5 1Mb 100ms DropTail
$ns duplex-link $n4 $n6 1Mb 100ms DropTail
$ns duplex-link $n5 $n7 1Mb 100ms DropTail



set null1 [new Agent/Null]
$ns attach-agent $n6 $null1


set filter [new Filter/Field]
	$n4 attach $filter
	$filter target $n5
	$filter filter-target $null1
	$filter set offset_ [PktHdr_offset PacketHeader/Common size_]
	$filter set match_ 100
	


  set cbr0 [new Agent/CBR]
  $cbr0 set packetsize_ 100
  $cbr0 set interval_ 0.1
  $ns attach-agent $n0 $cbr0
  set null0 [new Agent/Null]
  $ns attach-agent $n7 $null0
  $ns connect $cbr0 $null0
  $ns at 0 "$cbr0 start"
  $cbr0 set fid_ 1  


$ns at 10.0 "finish"
$ns run