When setting the queue size at the MAC layer of Wifinetdevice, do we also need to fix the queue at the Traffic Control Layer?

378 views
Skip to first unread message

Boong Baang

unread,
Oct 25, 2019, 5:45:17 PM10/25/19
to ns-3-users
In Sec 6.4 of the tutorial, it says there are 2 places where NS3 uses queuing:
  1. Traffic Control Layer - Device Independent and used for QoS prioritization
  2. NetDeviceObjects - Device Dependendent
Now I set my queue size to 1 packet and generate 10 packets at once, hoping that 9 of them will be dropped. But I receive all 10 packets. IS it because when I use   
Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/$ns3::OcbWifiMac/Txop/Queue/MaxSize", StringValue ("1p"));


to make the queue size, it is only acting as the 2nd point and I haven't done anything regarding the Traffic Control Layer? The Traffic Control Layer queuing is device independent and seems unrelated to what I am trying to do, but I don't understand why the queue size is not getting changed to 1?
my-wave-simple-80211p.cc

Tom Henderson

unread,
Oct 25, 2019, 8:51:33 PM10/25/19
to ns-3-...@googlegroups.com

I suspected that perhaps the above statement is not enough to accomplish what you want, not because it looked wrong, but because this is a complicated part of the ns-3 code to modify.  So I gave it a try myself to see what might be going wrong.

By default, when using the IP layer, a traffic control layer is inserted with Linux-like defaults.  This will allow packets to queue up even if you make a small device queue.  So, disable it after the IP addresses are set in your scenario:

  Ipv4AddressHelper ipv4;
  NS_LOG_INFO ("Assign IP Addresses.");
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer i = ipv4.Assign (devices);

+  TrafficControlHelper tch;
+  tch.Uninstall (devices);

  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");

If you place this Uninstall() method earlier in the scenario setup, it will cause an error.

Next, I tried your program but saw, as you did, that there are still 10 packets getting through.  It seemed like your Config::Set() statement was OK, but I checked by using the ConfigStore module to dump all of the attribute values in use. 

If you add this include:

#include "ns3/config-store-module.h"

and then add this code just before Simulator::Run ():

  AnimationInterface anim("first.xml");

+  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue ("output-attributes.txt"));
+  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
+  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
+ ConfigStore outputConfig;
+ outputConfig.ConfigureAttributes ();

  Simulator::Run ();


Then it will dump out all of the attribute paths into a file called 'output-attributes.txt'.

I checked this, and the path that you used seemed correct.  You are using the Nqos configuration (non-QoS).

So I had to go into the C++ code to further debug this.  I found a couple of things.

In the method

 WifiMacQueue::Insert (ConstIterator pos, Ptr<WifiMacQueueItem> item)
 {
   NS_LOG_FUNCTION (this << *item);
   NS_ASSERT_MSG (GetMaxSize ().GetUnit () == QueueSizeUnit::PACKETS,
                  "WifiMacQueues must be in packet mode");
 
   QueueBase::SetMaxSize (GetMaxQueueSize ()); //Make sure QueueBase has the same maximum queue size
 
   // insert the item if the queue is not full
   if (QueueBase::GetNPackets () < GetMaxSize ().GetValue ())

there is an interesting statement to set the max size to some value GetMaxQueueSize().  This, I found, was an attribute on WifiMacQueue called 'MaxQueueSize', defaulting to 500p.  When I stepped through this code, I found that the Config::Set had set the queue size to 1 packet, but then upon the first insertion, the queue size was reset to 500 packets based on this 'QueueBase::SetMaxSize (GetMaxQueueSize());' statement.

I then looked for the config path for MaxQueueSize in the output-attributes.txt file, and didn't find it.  Puzzled, I went to the attribute definition, and found this:

     .AddAttribute ("MaxQueueSize",
                    "The max queue size",
                    QueueSizeValue (QueueSize ("500p")),
                    MakeQueueSizeAccessor (&WifiMacQueue::SetMaxQueueSize),
                    MakeQueueSizeChecker ())

There is a 'setter' but not a getter, for some reason.  I added the getter:

     .AddAttribute ("MaxQueueSize",
                    "The max queue size",
                    QueueSizeValue (QueueSize ("500p")),
-                   MakeQueueSizeAccessor (&WifiMacQueue::SetMaxQueueSize),
+                   MakeQueueSizeAccessor (&WifiMacQueue::SetMaxQueueSize,
+                                          &WifiMacQueue::GetMaxQueueSize),
                    MakeQueueSizeChecker ())

I reran the program.  Now, the MaxQueueSize values were dumped into the output-attributes.txt file. I found the config path that I wanted:

  Config::Set ("/NodeList/*/$ns3::Node/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::OcbWifiMac/Txop/$ns3::Txop/Queue/$ns3::WifiMacQueue/MaxQueueSize", StringValue ("1p"));

Once I added this after your previous Config::Set statement, it started to work.  It now lets through two packets, which I believe is because the first one is immediately dequeued for transmission at time 1s, the second one is queued in the single packet queue, and the rest are discarded.

See attached revised program.

So, I think there are two problems with ns-3:

1) MaxQueueSize is missing an attribute accessor

2) We need to review this interaction between MaxSize and MaxQueueSize because it is leading to unexpected behavior.

- Tom


my-wave-simple-80211p-revised.cc

Boong Baang

unread,
Oct 28, 2019, 1:44:39 PM10/28/19
to ns-3-users
Is there a way to add some processing to the packets so that when the first packet enters the queue, it stays there for some time until the processing is completed before leaving the queue so that the 2nd packet sees a full queue and is dropped?

Tom Henderson

unread,
Oct 31, 2019, 9:08:22 AM10/31/19
to Boong Baang, ns-3-...@googlegroups.com
On 10/28/19 10:44 AM, Boong Baang wrote:
> Is there a way to add some processing to the packets so that when the
> first packet enters the queue, it stays there for some time until the
> processing is completed before leaving the queue so that the 2nd
> packet sees a full queue and is dropped?

I do not know the answer offhand; I have asked the maintainer about this
in the discussion around merge request 124.

https://gitlab.com/nsnam/ns-3-dev/merge_requests/124

- Tom

Boong Baang

unread,
Nov 27, 2019, 6:22:32 PM11/27/19
to ns-3-users
Hi Tom, I have posted on the group asking this question twice but due to no response I am replying to this old thread. The program that I attached, generated 10 packets and due to MAC size of 1, only 2 packets could pass through. 8 of the other packets would be dropped in the MAC buffer due to o space in the buffer, right ? But when I use the MacTxDrop, it doesn't show any drops there. I am attaching my program, can you have a look.
my-wave-simple-80211p-revised.cc

Gopal Rawat

unread,
Mar 19, 2020, 2:22:45 PM3/19/20
to ns-3-users
hi Boong Bang,

i am facing similar issues while using the similar trace sources for MacTxDrop and PhyTxDrop .. Have you got it working ?

Boong Baang

unread,
Mar 19, 2020, 2:24:44 PM3/19/20
to ns-3-users
Use the code uploaded by Tom Henderson, he corrected it.

Gopal Rawat

unread,
Mar 19, 2020, 2:55:07 PM3/19/20
to ns-3-users
Thanks for replying , i am not sure if i made changes right but after making the necessary changes i am getting zero values for all , earlier i was getting PhyRxDrop value but now its zero too .
Any suggestions?

Boong Baang

unread,
Mar 19, 2020, 3:22:58 PM3/19/20
to ns-3-users
Try to have 2 nodes very far apart and transmit some packets from one to another. Due to the large distance between them, the signal to noise ratio at the receiver should be less than the threshold which should lead to drops at the receiver which you are looking for. So if you are able to get drops in this situation, it means that at the current scenario that you have, the packets can be received at the receiver with sufficient SNR.

Gopal Rawat

unread,
Mar 20, 2020, 1:38:40 PM3/20/20
to ns-3-users
Thanks, it helped i am able to get MacTxDrop too with the 2 node scenario and the trace source work fine.

Boong Baang

unread,
Mar 20, 2020, 2:51:08 PM3/20/20
to ns-3-users
Can you send me your code, I was still unable to get the macrxdrop going even for small queue.

Gopal Rawat

unread,
Mar 22, 2020, 4:50:55 PM3/22/20
to ns-3-users
I did not get MaxRxDrop and PhyTxDrop value too , as per my understanding it doesn’t happen very often in unicast transmission that the MAC address is wrong and this trace is fired I assume only then. In Broadcast transmission this didn’t fire as in my case.
Reply all
Reply to author
Forward
0 new messages