How to set packet expiration time?

186 views
Skip to first unread message

Shivam Garg

unread,
Feb 20, 2020, 12:42:50 AM2/20/20
to ns-3-users
Hi all,

I am using NS-3.29. I want to discard data packets at the MAC that did not reach the destination in time, i.e., discard those packets for which the Packet generation time + maxTimeAllowed < current time. I know that WifiMacQueue has MaxDelay (which means: If a packet stays longer than this delay in the queue, it is dropped). However, this discards a data packet when the time this packet is queued in this queue at this node + MaxDelay < current time. Whereas I want something similar to MaxNetworkQueueDelay (The max time for a packet to stay in the network queue) which is defined for DSR routing protocol.

I also found that DSDV and AODV routing algorithms use MaxQueueTime: Maximum time packets can be queued (in seconds), but there is no similar thing for OLSR.

I was unable to find a similar inquiry on this group. Therefore, I am posting this question. Please guide me to the post if this has already been answered. Is there any way to find packet generation time inside WifiMacQueue::Ttlexceeded (ConstIterator &it) function which is defined in wifi-mac-queue.cc file? Any help will be appreciated.

Thanks,
Shivam


Adil Alsuhaim

unread,
Feb 27, 2020, 3:25:56 AM2/27/20
to ns-3-users
I suggest you use a packet tags. Basically, you create a C++ class, call it CreationTimeStampTag as a subclass of ns3::Tag and add it with AddPacketTag at creation, and check for it using PeekPacketTag at nodes in the middle. 

An example of such packet tag can be found in the examples ./examples/stats/wifi-example-apps.cc

I am not familiar with the routing algorithms, but I think you have nodes in the middle that receive packets, and then enqueue them in their WifiMacQueue for transmission. You can utilize the WifiMacQueue trace named Enqueue which is invoked every time a packet gets enqueued for transmission. For a WifiNetDevice, the path to connect to that trace source would be:

path_str = "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/Queue/Enqueue";

and connect that to a function (let's call it EnqueueTrace)
Config::Connect (path_str, MakeCallback (&EnqueueTrace));

The function must have the signature:
void EnqueueTrace(std::string context, Ptr<const WifiMacQueueItem> item)
{
 
//your code to extract the "packet" from the queue item, then PeekPacketTag to check creation timestamp
}

I am not sure if I got the syntax 100%, but this is what I would try.

Cheers,
Adil


Adil Alsuhaim

unread,
Feb 27, 2020, 3:43:38 AM2/27/20
to ns-3-users
Correction, I think the path should be
path_str = "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/*/Queue/Enqueue";

The * after the "Mac" should match the outgoing queue (VI, VO, BE, or BK)

Shivam Garg

unread,
Mar 4, 2020, 3:55:09 PM3/4/20
to ns-3-users
Hi Adil,

Thanks for the suggestion. It worked. I created a new subclass of ns3::Tag by which I associated the timestamp (i.e., time at which the packet is enqueued at the MAC of the originator node) with the packet inside SendDataAfterCts() function located inside mac-low.cc file. Upon receiving a data packet, an intermediate node peeks the timestamp value using GetTimeStamp() (it is a user-defined function which returns the timestamp value) and stores the packet only if the packet lifetime is not yet expired. 

Suggestions for interested people: 
1. In my simulation, I am generating an ACK even if the packet is not stored due to packet lifetime expiration to prevent the source node from retransmitting the same packet. 
2. While transmitting a data packet, a node X can check if the packet is new (i.e., node X is the originator) or old (i.e., node X is an intermediate node) using PeekPacketTag(TagType). Add timestamp only for new data packets.
3. Do not forget to add your subclass files (i.e., .h and .cc files) in wscript file located inside wifi folder. 

Regards,
Shivam
Reply all
Reply to author
Forward
0 new messages