- Home Page of ProjectGuideline.com ›
- Forums ›
- Questions Asked by Students and Scholars ›
- How to Count Packets Actively in Ns2
Tagged: counting packets, ns2, RED Queue
I have to count packets for each incoming flow actively in RED Queue in Ns2. I have to integrate it in the queue algorithm itself so that changes (in variables of active queues) occur when the packet in queued. For simple codes it’s like:
for each incoming packet
count[i]=count[i]+packet[i]
How do I say “for each incoming packet” in NS2, and how do I define [i] such that [i] is the IP Address representing different individual flow?
You can do it by modifying the .cc and .h files of the queue implementation which can be found at
ns-allinone-x.xx\ns-x.xx\queue.
You need to add some private variables and functions to read and write those variable in the class structure.
You should update the value on each en-queue operation.
Instead of using IP address as index, you may use node ID.