Bug 1034

Summary: No trace source for packet dropping from WifiMacQueue
Product: ns-3 Reporter: Quincy Tse <quincy.tse>
Component: wifiAssignee: sebastien.deronne
Status: RESOLVED FIXED    
Severity: minor CC: beycanbeycan, ns-bugs, sebastien.deronne, stavallo, tomh, tommaso.pecorella
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: Proposed patch to add trace source to WifiMacQueue
Patch creating and linking a chain of trace sources back to NotifyTxDrop
Connect the MacTxDrop trace of WifiMac to the Drop trace of the wifi MAC queues

Description Quincy Tse 2010-11-28 18:22:25 UTC
WifiMacQueue have various means of dropping frames from the queue, however when packets are dropped, they are dropped silently (no trace or LOG messages), making it difficult to diagnose problems.
Comment 1 Nicola Baldo 2010-11-29 04:06:57 UTC
Could you please point out the line(s) of code you are referring to?
Comment 2 Quincy Tse 2010-12-01 19:47:24 UTC
WifiMacQueue::Enqueue - packet is only pushed onto the queue at line 101 if the queue is not full. Otherwise function returns at line 98 with absolutely no indication that the packet was dropped.

WifiMacQueue::Cleanup - packets currently on the queue may be dropped at line 123 if its lifetime expired. This function is called in many places within the class, and there are no indication that packets have been dropped.
Comment 3 Quincy Tse 2010-12-08 19:55:45 UTC
Created attachment 1015 [details]
Proposed patch to add trace source to WifiMacQueue
Comment 4 Quincy Tse 2010-12-08 22:24:41 UTC
On another related note - WifiMac have the capability to trace packet drops during Tx (WifiMac::NotifyTxDrop, wifi-mac.cc:237), but is never used anywhere other than for the packet not being queued when not associated in the STA mode. Getting these packet drops to trigger the WifiMac's trace source would be good.
Comment 5 Quincy Tse 2010-12-09 00:17:33 UTC
Created attachment 1016 [details]
Patch creating and linking a chain of trace sources back to NotifyTxDrop

Here, I've created trace sources at Dcf and WifiMacQueue, as well as the associated Notifyxxx functions that abstracts the triggering of the traces.

RegularWifiMac and DcaTxop subscribes to the trace sources down the chain and forwards notifications up through the Notifyxxx functions.
Comment 6 Bicer Iskrenov 2012-05-10 02:39:14 UTC
I can't reach the accessor "PacketDrop" from my NS3 code patched in attachment 1015 [details] in comment 3. I try something like this: 
Config::Connect("/WifiMacQueue/PacketDrop", MakeCallback(&DequeueFirstAvailable)); 
What is the correct way of reaching this callback function for different sender nodes / access categories?
Comment 7 Quincy Tse 2012-05-10 03:11:02 UTC
(In reply to comment #6)
> I can't reach the accessor "PacketDrop" from my NS3 code patched in attachment
> 1015 [details] in comment 3. I try something like this: 
> Config::Connect("/WifiMacQueue/PacketDrop",
> MakeCallback(&DequeueFirstAvailable)); 
> What is the correct way of reaching this callback function for different sender
> nodes / access categories?

It's been a very long while since I've touched NS3 code. I recall I've always just attached the traces the long way - first get a Ptr<WifiMacQueue>, then call the TraceConnectWithoutContext function.

I can't remember using Config::Connect. In any case, this TraceSource will tell you when a specific MAC queue drops a packet (not when any que drops a packet). Therefore you actually need to connect to a specific WifiMacQueue (ie. the queue that is attached to a specific MAC of a specific Node).

Unfortunately I can't give any more help than this other than referring you to http://www.nsnam.org/docs/release/3.13/manual/singlehtml/index.html#overview
Comment 8 Nicola Baldo 2012-05-10 05:23:01 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > I can't reach the accessor "PacketDrop" from my NS3 code patched in attachment
> > 1015 [details] in comment 3. I try something like this: 
> > Config::Connect("/WifiMacQueue/PacketDrop",
> > MakeCallback(&DequeueFirstAvailable)); 
> > What is the correct way of reaching this callback function for different sender
> > nodes / access categories?
> 

may I suggest this:
http://www.nsnam.org/wiki/index.php/HOWTO_determine_the_path_of_an_attribute_or_trace_source
Comment 9 Tommaso Pecorella 2014-07-25 15:02:52 UTC
I've spent four years on your trail 
Four long years 
On your trail 

This bug is still relevant, see https://groups.google.com/forum/?hl=en#!topic/ns-3-users/47_F14UMlFE
Comment 10 Stefano Avallone 2017-04-20 12:37:39 UTC
Created attachment 2833 [details]
Connect the MacTxDrop trace of WifiMac to the Drop trace of the wifi MAC queues

Recently, WifiMacQueue has been made a Queue subclass and therefore it gained a Drop trace that is fired every time a packet is removed from the queue (e.g., the case for stale packets) and every time a packet is dropped because the queue is full. The proposed patch connects such Drop trace to the MacTxDrop trace of the WifiMac class, meaning that every time the Drop trace is fired, the MacTxDrop trace is fired as well.
Comment 11 sebastien.deronne 2017-04-21 05:59:38 UTC
Thanks, I do not have much comment on this. Can the other patches be discarded?
Comment 12 Stefano Avallone 2017-04-21 06:42:14 UTC
(In reply to sebastien.deronne from comment #11)
> Thanks, I do not have much comment on this. Can the other patches be
> discarded?

Yes. The first patch (which is included in the second one) is not needed anymore because WifiMacQueue now inherits the Drop trace (and others) from the Queue base class. The second patch follows the same approach as mine, but it is not applicable because lots of things changed since then.
Comment 13 Stefano Avallone 2017-04-21 06:43:17 UTC
If you agree, I will push my patch (after applying a few cosmetic changes).
Comment 14 Tom Henderson 2017-04-21 14:40:13 UTC
(In reply to Stefano Avallone from comment #13)
> If you agree, I will push my patch (after applying a few cosmetic changes).

+1
Comment 15 Stefano Avallone 2017-04-26 13:58:37 UTC
Fixed with changeset 12844:0b63167eadc5.