wifi: Re-compute the A-MPDU after an RTS/CTS exchange fails
If the RTS/CTS exchange initiated to protect an A-MPDU fails, the same A-MPDU is transmitted the next time the QosTxop gains access to the channel. I believe there are many reasons why this may not be the case:
- the lifetime of one or more of the constituent MPDUs expires before the QosTxop gains access to the channel again
- if the subsequent attempt is transmitted at a lower rate, the time to transmit the same A-MPDU may exceed the duration limit
- if the subsequent attempt is transmitted on a smaller bandwidth (think of UL OFDMA), the time to transmit the same A-MPDU may exceed the duration limit
Actually, while debugging my code, I was able to demonstrate the first item (on top of current master):
diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc
index 5b3bb0de2..e65da2590 100644
--- a/src/wifi/model/mac-low.cc
+++ b/src/wifi/model/mac-low.cc
@@ -574,6 +574,8 @@ MacLow::StartTransmission (Ptr<const Packet> packet,
Ptr<Packet> aggregatedPacket = Create<Packet> ();
for (uint32_t i = 0; i < sentMpdus; i++)
{
+ NS_ASSERT_MSG (Simulator::Now () <= m_txPackets[GetTid (packet, *hdr)].at (i).timestamp + MilliSeconds (500),
+ "Now=" << Simulator::Now () << " Tstamp=" << m_txPackets[GetTid (packet, *hdr)].at (i).timestamp);
Ptr<Packet> newPacket = (m_txPackets[GetTid (packet, *hdr)].at (i).packet)->Copy ();
newPacket->AddHeader (m_txPackets[GetTid (packet, *hdr)].at (i).hdr);
AddWifiMacTrailer (newPacket);
[stefano@archlinux ns-3-dev]$ ./waf --run "wifi-multi-tos --simulationTime=4 --nWifi=16 --useRts=1 --useShortGuardInterval=1"
Waf: Leaving directory `/home/stefano/Tools/ns-3-dev/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (12.769s)
assert failed. cond="Simulator::Now () <= m_txPackets[GetTid (packet, *hdr)].at (i).timestamp + MilliSeconds (500)", msg="Now=+3240932206.0ns Tstamp=+2650523987.0ns", file=../src/wifi/model/mac-low.cc, line=578
terminate called without an active exception
Command ['/home/stefano/Tools/ns-3-dev/build/examples/wireless/ns3-dev-wifi-multi-tos-debug', '--simulationTime=4', '--nWifi=16', '--useRts=1', '--useShortGuardInterval=1'] terminated with signal SIGIOT. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").
In my wifi-next branch, I changed the logic for these cases:
- when a CTS timer expires, the constituent MPDUs are stored in the aggregation queue
- when the QosTxop gains access to the channel again, the MPDU aggregator takes MPDUs from the aggregation queue (which, being a WifiMacQueue, discards stale MPDUs) first and, of course, checks that size and duration limits are not exceeded.