[ns] counting the number of packets sent during the simulation

anas abu_taleb anas_h_82 at yahoo.com
Tue May 6 02:30:27 PDT 2008


Hi all
   
  I am using ns-2.29 and as part of my research I am trying to count the number of packets sent by a node. 
   
  I added a method called counting to count the number of packets to the source code of the UDP agent ( I wonder if this is the right place). And what I want after that is to calculate  the number of packet at some time during the simulation this is as example of what I did: 
   
  set udp_(0) [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp_(0)
set null_(0) [new Agent/Null]
$ns_ attach-agent $node_(1) $null_(0)
  set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 512
$cbr_(0) set rate_ 81920
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 10000
$cbr_(0) attach-agent $udp_(0)
#$ns_ link_lossmodel $val(err) $node_(0) $node_(1)
$ns_ connect $udp_(0) $null_(0)
$ns_ at 0 "$cbr_(0) start"
$ns_ at 90 "$cbr_(0) stop"

  if { [$ns_ at 5 "$udp_(0) counting"] < 120 } {
 set x_coor [$node_(0) getX]
 set y_coor [$node_(0) getY]
 $node_(4) setdest $x_coor $y_coor 15.0
 }
   
  However the code is working fine but it is not recognizing the condition in the if statement. 
   
  I will be grateful for your help 
  Anas

     

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.


More information about the Ns-users mailing list