Bug 2303

Summary: WifiMacQueue::GetSize should cleanup queue beforehand
Product: ns-3 Reporter: Alexander Krotov <krotov>
Component: wifiAssignee: sebastien.deronne
Status: RESOLVED FIXED    
Severity: major CC: ns-bugs
Priority: P5    
Version: pre-release   
Hardware: All   
OS: All   
Attachments: wifi-mac-queue.cc patch

Description Alexander Krotov 2016-02-20 04:51:49 UTC
Created attachment 2286 [details]
wifi-mac-queue.cc patch

All other functions, including WifiMacQueue::IsEmpty, call Cleanup () to emulate removal of all timed out packets. GetSize() lacks Cleanup () call.

In rare cases it results in GetSize returning value > 0, for example at line

http://code.nsnam.org/ns-3-dev/file/5de21182cbb5/src/wifi/model/mac-low.cc#l1641

Then WifiMacQueue::Dequeue is called, which calls Cleanup (), and returns NULL because all packets have timed out:

http://code.nsnam.org/ns-3-dev/file/5de21182cbb5/src/wifi/model/mac-low.cc#l1665

I don't have testcase yet, but it is fairly obvious that GetSize should not count timed out packets. Patch is attached.

The script in which I get this error is still too large to be used as a testcase. If I manage to reduce it to something simple, I will probably post it as another bug, because in my case packets stored in m_aggregateQueue sometimes timeout during RTS-CTS exchange. What should happen if during RTS-CTS all packets in m_aggregate timeout and there is no A-MPDU to send by the time CTS is received? Probably simple vector should be used for m_aggregateQueue so packets prepared for A-MPDU should never timeout or something like this.
Comment 1 sebastien.deronne 2016-02-20 08:11:57 UTC
It looks indeed better to call cleanup before returning the size.
Comment 2 sebastien.deronne 2016-02-22 18:33:26 UTC
changeset 11899:19ad6005e0dc