How to set Queue size and add propagation/transmission delays in the MAC layer for Wave model ?

451 views
Skip to first unread message

Boong Baang

unread,
Sep 15, 2019, 3:04:02 PM9/15/19
to ns-3-users
I am writing a program in which I am trying to see the effect of queue size in the total delay. I am attaching the modified wave-simple-80211p file where I have added the formula to calculate delay.
I have a few questions regarding that:

1. In the list of attributes here in this link (link), ns3::WifiMacQueue object is shown to have this attribute as MaxQueueSize, so I want to know how to access and set it to a value?

2. In the attached file, I have calculated delay between two devices as (PacketReceptionTime - PacketGenerationTime_FromTimeStampInHeader). I want to know how this can be modified so that I can calculate the Age of Information (Age is defined per time slot, unlike delay which is calculated for each packet. It is incremented by one step for every time slot that there is no reception, and gets decremented to the delay at the instants of reception.

3. Currently my delay is coming to be 0 as reception and arrival times are the same. I think this is due to the absence of any transmission, propagation and queuing delay. So how do I add them to the model?


Any relevant insight or tips would be extremely helpful. 
Thanks in advance.


my-wave-simple-80211p.cc

Boong Baang

unread,
Sep 15, 2019, 5:13:21 PM9/15/19
to ns-3-users
The transmission delay exists, but transmission delay is not getting calculated by the formula I mentioned above.

Adil Alsuhaim

unread,
Sep 22, 2019, 4:40:47 AM9/22/19
to ns-3-users
Hello, 

I was working on something like that few weeks ago 
1. In the list of attributes here in this link (link), ns3::WifiMacQueue object is shown to have this attribute as MaxQueueSize, so I want to know how to access and set it to a value?

For a WaveNetDevice, the value can be accessed using the Attribute
"/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/MacEntities/*/$ns3::OcbWifiMac/*/Queue"

I think the example you show is using WifiNetDevice, so the path will differ. I personally prefer using WaveNetDevice.

Note that "Attributes" defined in a parent class of a given class are also accessible. If you look at the code for OcbWifiMac (ocb-wifi-mac.cc), which is the Mac used for 802.11p/Wave, you notice it doesn't define any attributes. If you look into its parent class, RegularWifiMac, you will notice that it defines attributes (of type ns3::Txop & ns3::QosTxop) and that's where we get the attribute "Queue", which is defined in Txop.

So, RegularWifiMac has 5 queues denoted by the attributes VO_Txop, VI_Txop, BE_Txop, BK_Txop and "Txop", the last one is the non-QoS queue. 

The way ns3 implements the queuing, it attaches a timestamp to WifiMacQueueItem objects as they're en queued. You can trace queuing & de-queuing using the traces sources. After you create the devices, and before starting the simulation add:
  std::string enqueue_path= "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/*/$ns3::OcbWifiMac/*/Queue/Enqueue";
  std
::string dequeue_path= "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/*/$ns3::OcbWifiMac/*/Queue/Dequeue";
 
Config::Connect (enqueue_path, MakeCallback (&EnqueueTrace));
 
Config::Connect (dequeue_path, MakeCallback (&DequeueTrace));

and add these two functions to the file
void EnqueueTrace(std::string context, Ptr<const WifiMacQueueItem> item) {
 
//what to do when a packet is enqueued
 
//You can print the context (what nodes, what channel, etc)
  std
::cout << "Context : " << context << std::endl;
}
void DequeueTrace(std::string context, Ptr<const WifiMacQueueItem> item) {
 
//what to do when the packet is dequeued. You can do something like
 
Time delay = Simulator::Now() - item->GetTimeStamp();
  std
::cout << "Delay : " << delay << std::endl;
}


3. Currently my delay is coming to be 0 as reception and arrival times are the same. I think this is due to the absence of any transmission, propagation and queuing delay. So how do I add them to the model?

Replace GetMilliSeconds with GetNanoSeconds. A packet will not remain in the queue if it can be sent out. You can try to schedule sending multiple packets at the same time to cause packets to be queued. 

Boong Baang

unread,
Sep 23, 2019, 10:54:20 AM9/23/19
to ns-3-users
Thank you so much for the detailed response, I will do the things you posted and update here.

Boong Baang

unread,
Oct 21, 2019, 2:03:07 PM10/21/19
to ns-3-users
I got most of it working, thanks. Is there a way to make the queue behave in a Last-In_First-Out policy rather than FIFO. I also want to do Drop_Olderst instead of Drop_Newest, and that can be directly set but I am unable to see how the queue can be made a LIFO queue.
Reply all
Reply to author
Forward
0 new messages