Bug 2564 - Simulation crashes when CtsTimeout is triggered for A-MPDU transmissions
Simulation crashes when CtsTimeout is triggered for A-MPDU transmissions
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: wifi
ns-3.26
All All
: P5 normal
Assigned To: sebastien.deronne
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-11-24 11:47 UTC by Tom Henderson
Modified: 2016-12-01 18:32 UTC (History)
1 user (show)

See Also:


Attachments
proposed patch to fix (1.82 KB, patch)
2016-11-27 05:58 UTC, sebastien.deronne
Details | Diff
proposed patch to fix (3.10 KB, patch)
2016-11-27 09:20 UTC, sebastien.deronne
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Henderson 2016-11-24 11:47:24 UTC
This is possibly a trivial one for Sebastien to double check and commit.

In MacLow::CtsTimeout() method:

diff -r f55df977de28 src/wifi/model/mac-low.cc
--- a/src/wifi/model/mac-low.cc	Tue Nov 22 10:55:49 2016 +0100
+++ b/src/wifi/model/mac-low.cc	Thu Nov 24 08:36:30 2016 -0800
@@ -1749,6 +1749,7 @@
   m_listener = 0;
   m_sentMpdus = 0;
   m_ampdu = false;
+  FlushAggregateQueue ();
   listener->MissedCts ();
 }

All tests pass.
Comment 1 sebastien.deronne 2016-11-24 12:27:44 UTC
Tom, why is this needed? Did you experience a bug?
As far as I remember this queue is used to avoid re-doing aggregation while resending rts frame, otherwise you will get issues.
I need to double check but I am not home right now.
Comment 2 sebastien.deronne 2016-11-24 17:22:23 UTC
Unless a bug has been encountered, I suggest to reject this bug, I confirm we need the queue when RTS/CTS is used:

  else if (m_aggregateQueue->GetSize () > 0)
    {
      //m_aggregateQueue > 0 occurs when a RTS/CTS exchange failed before an A-MPDU transmission.
      //In that case, we transmit the same A-MPDU as previously.
      m_sentMpdus = m_aggregateQueue->GetSize ();
      m_ampdu = true;
      if (m_sentMpdus > 1)
        {
          m_txParams.EnableCompressedBlockAck ();
        }
      else if (m_currentHdr.IsQosData ())
        {
          //VHT single MPDUs are followed by normal ACKs
          m_txParams.EnableAck ();
        }
    }
Comment 3 Tom Henderson 2016-11-25 13:57:03 UTC
I added this statement sometime in the past when debugging an issue in LAA code; it is used in the ns-3-lbt repository.   I don't remember the details so will have to reproduce further.

If I remove the FlushAggregateQueue() statement from ns-3-lbt repository (as of changeset 83:17ed682fdf10) this program configuration will fail:

$ ./waf --run "laa-wifi-indoor --cellConfigA=Wifi --cellConfigB=Wifi"
msg="Invalid WifiPhy state.", file=../src/wifi/model/wifi-phy-state-helper.cc, line=343
terminate called without an active exception

So, I believe there is an issue, but I need to debug further, so let's leave it open in NEEDINFO state.
Comment 4 sebastien.deronne 2016-11-25 15:26:45 UTC
I will also test a-mpdu with rts/cts because I saw something strange when cleaning mac-low. I will also have a look at the FlushAggregateQueue effect.

Note that when we change behavior tests should fail, so I suggest anyway that a test is added because this case is obviously not covered :-)
Comment 5 sebastien.deronne 2016-11-27 05:27:39 UTC
I indeed see issues when CTS timeout is triggered for A-MPDU transmissions, even though the error is different than yours. I am working on a different fix that solves the problem at my side, to be then tested at your side.
Comment 6 sebastien.deronne 2016-11-27 05:53:31 UTC
(In reply to Tom Henderson from comment #0)
> This is possibly a trivial one for Sebastien to double check and commit.
> 
> In MacLow::CtsTimeout() method:
> 
> diff -r f55df977de28 src/wifi/model/mac-low.cc
> --- a/src/wifi/model/mac-low.cc	Tue Nov 22 10:55:49 2016 +0100
> +++ b/src/wifi/model/mac-low.cc	Thu Nov 24 08:36:30 2016 -0800
> @@ -1749,6 +1749,7 @@
>    m_listener = 0;
>    m_sentMpdus = 0;
>    m_ampdu = false;
> +  FlushAggregateQueue ();
>    listener->MissedCts ();
>  }
> 
> All tests pass.

Output showing this is not ok:

[mac=00:00:00:00:00:02] MacLow:StartTransmission(0x7fad31608580, 0x7fad31409ff0, 0x7fad3160a988, [send rts=0, next size=0, dur=+0.0ns, ack=normal], 0x7fad31708490)
[mac=00:00:00:00:00:02] MacLow:CancelAllEvents(0x7fad31608580)
[mac=00:00:00:00:00:02] Adding packet with Sequence number 0 to A-MPDU, packet size = 1538, A-MPDU size = 1542
[mac=00:00:00:00:00:02] Adding packet with Sequence number 1 to A-MPDU, packet size = 1538, A-MPDU size = 3086
[mac=00:00:00:00:00:02] Adding packet with Sequence number 2 to A-MPDU, packet size = 1538, A-MPDU size = 4630
[mac=00:00:00:00:00:02] Adding packet with Sequence number 3 to A-MPDU, packet size = 1538, A-MPDU size = 6174
[mac=00:00:00:00:00:02] Adding packet with Sequence number 4 to A-MPDU, packet size = 1538, A-MPDU size = 7718
[mac=00:00:00:00:00:02] Adding packet with Sequence number 5 to A-MPDU, packet size = 1538, A-MPDU size = 9262
[mac=00:00:00:00:00:02] Adding packet with Sequence number 6 to A-MPDU, packet size = 1538, A-MPDU size = 10806
[mac=00:00:00:00:00:02] Adding packet with Sequence number 7 to A-MPDU, packet size = 1538, A-MPDU size = 12350
[mac=00:00:00:00:00:02] Adding packet with Sequence number 8 to A-MPDU, packet size = 1538, A-MPDU size = 13894
[mac=00:00:00:00:00:02] Adding packet with Sequence number 9 to A-MPDU, packet size = 1538, A-MPDU size = 15438
[mac=00:00:00:00:00:02] Adding packet with Sequence number 10 to A-MPDU, packet size = 1538, A-MPDU size = 16982
[mac=00:00:00:00:00:02] Adding packet with Sequence number 11 to A-MPDU, packet size = 1538, A-MPDU size = 18526
[mac=00:00:00:00:00:02] Adding packet with Sequence number 12 to A-MPDU, packet size = 1538, A-MPDU size = 20070
[mac=00:00:00:00:00:02] Adding packet with Sequence number 13 to A-MPDU, packet size = 1538, A-MPDU size = 21614
[mac=00:00:00:00:00:02] Adding packet with Sequence number 14 to A-MPDU, packet size = 1538, A-MPDU size = 23158
[mac=00:00:00:00:00:02] Adding packet with Sequence number 15 to A-MPDU, packet size = 1538, A-MPDU size = 24702
[mac=00:00:00:00:00:02] Adding packet with Sequence number 16 to A-MPDU, packet size = 1538, A-MPDU size = 26246
[mac=00:00:00:00:00:02] Adding packet with Sequence number 17 to A-MPDU, packet size = 1538, A-MPDU size = 27790
[mac=00:00:00:00:00:02] Adding packet with Sequence number 18 to A-MPDU, packet size = 1538, A-MPDU size = 29334
[mac=00:00:00:00:00:02] Adding packet with Sequence number 19 to A-MPDU, packet size = 1538, A-MPDU size = 30878
[mac=00:00:00:00:00:02] Adding packet with Sequence number 20 to A-MPDU, packet size = 1538, A-MPDU size = 32422
[mac=00:00:00:00:00:02] Adding packet with Sequence number 21 to A-MPDU, packet size = 1538, A-MPDU size = 33966
[mac=00:00:00:00:00:02] Adding packet with Sequence number 22 to A-MPDU, packet size = 1538, A-MPDU size = 35510
[mac=00:00:00:00:00:02] Adding packet with Sequence number 23 to A-MPDU, packet size = 1538, A-MPDU size = 37054
[mac=00:00:00:00:00:02] Adding packet with Sequence number 24 to A-MPDU, packet size = 1538, A-MPDU size = 38598
[mac=00:00:00:00:00:02] Adding packet with Sequence number 25 to A-MPDU, packet size = 1538, A-MPDU size = 40142
[mac=00:00:00:00:00:02] Adding packet with Sequence number 26 to A-MPDU, packet size = 1538, A-MPDU size = 41686
[mac=00:00:00:00:00:02] Adding packet with Sequence number 27 to A-MPDU, packet size = 1538, A-MPDU size = 43230
[mac=00:00:00:00:00:02] Adding packet with Sequence number 28 to A-MPDU, packet size = 1538, A-MPDU size = 44774
[mac=00:00:00:00:00:02] Adding packet with Sequence number 29 to A-MPDU, packet size = 1538, A-MPDU size = 46318
[mac=00:00:00:00:00:02] Adding packet with Sequence number 30 to A-MPDU, packet size = 1538, A-MPDU size = 47862
[mac=00:00:00:00:00:02] Adding packet with Sequence number 31 to A-MPDU, packet size = 1538, A-MPDU size = 49406
[mac=00:00:00:00:00:02] Adding packet with Sequence number 32 to A-MPDU, packet size = 1538, A-MPDU size = 50950
[mac=00:00:00:00:00:02] Adding packet with Sequence number 33 to A-MPDU, packet size = 1538, A-MPDU size = 52494
[mac=00:00:00:00:00:02] Adding packet with Sequence number 34 to A-MPDU, packet size = 1538, A-MPDU size = 54038
[mac=00:00:00:00:00:02] Adding packet with Sequence number 35 to A-MPDU, packet size = 1538, A-MPDU size = 55582
[mac=00:00:00:00:00:02] Adding packet with Sequence number 36 to A-MPDU, packet size = 1538, A-MPDU size = 57126
[mac=00:00:00:00:00:02] Adding packet with Sequence number 37 to A-MPDU, packet size = 1538, A-MPDU size = 58670
[mac=00:00:00:00:00:02] Adding packet with Sequence number 38 to A-MPDU, packet size = 1538, A-MPDU size = 60214
[mac=00:00:00:00:00:02] Adding packet with Sequence number 39 to A-MPDU, packet size = 1538, A-MPDU size = 61758
[mac=00:00:00:00:00:02] Adding packet with Sequence number 40 to A-MPDU, packet size = 1538, A-MPDU size = 63302
[mac=00:00:00:00:00:02] Adding packet with Sequence number 41 to A-MPDU, packet size = 1538, A-MPDU size = 64846
[mac=00:00:00:00:00:02] no more packets can be aggregated because the maximum A-MPDU size has been reached
[mac=00:00:00:00:00:02] tx unicast A-MPDU
[mac=00:00:00:00:00:02] startTx size=64846, to=00:00:00:00:00:01, listener=0x7fad31708490
[mac=00:00:00:00:00:02] MacLow:SendRtsForPacket(0x7fad31608580)
[mac=00:00:00:00:00:02] MacLow:ForwardDown(0x7fad31608580, 0x7fad3170eac0, 0x7fff541e0360, mode: HtMcs7 txpwrlvl: 0 retries: 0 preamble: 2 channel width: 20 Short GI: 0 NTx: 1 Nss: 1 Ness: 0 MPDU aggregation: 0 STBC: 0)
[mac=00:00:00:00:00:02] send CTL_RTS, to=00:00:00:00:00:01, size=20, mode=HtMcs7, preamble=2, duration=+8128000.0ns, seq=0x0
Start transmission: signal power before antenna gain=16.0206dBm
[mac=00:00:00:00:00:01] MacLow:ReceiveError(0x7fad3153a280, 0x7fad3140c000, 3.39538e+06)
[mac=00:00:00:00:00:01] rx failed
[mac=00:00:00:00:00:02] MacLow:CtsTimeout(0x7fad31608580)
[mac=00:00:00:00:00:02] cts timeout
[mac=00:00:00:00:00:02] Flush aggregate queue
[mac=00:00:00:00:00:02] MacLow:StartTransmission(0x7fad31608580, 0x7fad31409ff0, 0x7fad3160a988, [send rts=0, next size=0, dur=+0.0ns, ack=normal], 0x7fad31708490)
[mac=00:00:00:00:00:02] MacLow:CancelAllEvents(0x7fad31608580)
[mac=00:00:00:00:00:02] Adding packet with Sequence number 0 to A-MPDU, packet size = 1538, A-MPDU size = 1542
[mac=00:00:00:00:00:02] Adding packet with Sequence number 42 to A-MPDU, packet size = 1538, A-MPDU size = 3086
[mac=00:00:00:00:00:02] Adding packet with Sequence number 43 to A-MPDU, packet size = 1538, A-MPDU size = 4630
[mac=00:00:00:00:00:02] Adding packet with Sequence number 44 to A-MPDU, packet size = 1538, A-MPDU size = 6174
[mac=00:00:00:00:00:02] Adding packet with Sequence number 45 to A-MPDU, packet size = 1538, A-MPDU size = 7718
[mac=00:00:00:00:00:02] Adding packet with Sequence number 46 to A-MPDU, packet size = 1538, A-MPDU size = 9262
[mac=00:00:00:00:00:02] Adding packet with Sequence number 47 to A-MPDU, packet size = 1538, A-MPDU size = 10806
[mac=00:00:00:00:00:02] Adding packet with Sequence number 48 to A-MPDU, packet size = 1538, A-MPDU size = 12350
[mac=00:00:00:00:00:02] Adding packet with Sequence number 49 to A-MPDU, packet size = 1538, A-MPDU size = 13894
[mac=00:00:00:00:00:02] Adding packet with Sequence number 50 to A-MPDU, packet size = 1538, A-MPDU size = 15438
[mac=00:00:00:00:00:02] Adding packet with Sequence number 51 to A-MPDU, packet size = 1538, A-MPDU size = 16982
[mac=00:00:00:00:00:02] Adding packet with Sequence number 52 to A-MPDU, packet size = 1538, A-MPDU size = 18526
[mac=00:00:00:00:00:02] Adding packet with Sequence number 53 to A-MPDU, packet size = 1538, A-MPDU size = 20070
[mac=00:00:00:00:00:02] Adding packet with Sequence number 54 to A-MPDU, packet size = 1538, A-MPDU size = 21614
[mac=00:00:00:00:00:02] Adding packet with Sequence number 55 to A-MPDU, packet size = 1538, A-MPDU size = 23158
[mac=00:00:00:00:00:02] Adding packet with Sequence number 56 to A-MPDU, packet size = 1538, A-MPDU size = 24702
[mac=00:00:00:00:00:02] Adding packet with Sequence number 57 to A-MPDU, packet size = 1538, A-MPDU size = 26246
[mac=00:00:00:00:00:02] Adding packet with Sequence number 58 to A-MPDU, packet size = 1538, A-MPDU size = 27790
[mac=00:00:00:00:00:02] Adding packet with Sequence number 59 to A-MPDU, packet size = 1538, A-MPDU size = 29334
[mac=00:00:00:00:00:02] Adding packet with Sequence number 60 to A-MPDU, packet size = 1538, A-MPDU size = 30878
[mac=00:00:00:00:00:02] Adding packet with Sequence number 61 to A-MPDU, packet size = 1538, A-MPDU size = 32422
[mac=00:00:00:00:00:02] Adding packet with Sequence number 62 to A-MPDU, packet size = 1538, A-MPDU size = 33966
[mac=00:00:00:00:00:02] Adding packet with Sequence number 63 to A-MPDU, packet size = 1538, A-MPDU size = 35510
[mac=00:00:00:00:00:02] tx unicast A-MPDU
[mac=00:00:00:00:00:02] startTx size=35510, to=00:00:00:00:00:01, listener=0x7fad31708490
[mac=00:00:00:00:00:02] MacLow:SendRtsForPacket(0x7fad31608580)
[mac=00:00:00:00:00:02] MacLow:ForwardDown(0x7fad31608580, 0x7fad31528b00, 0x7fff541e0360, mode: HtMcs7 txpwrlvl: 0 retries: 1 preamble: 2 channel width: 20 Short GI: 0 NTx: 1 Nss: 1 Ness: 0 MPDU aggregation: 0 STBC: 0)
[mac=00:00:00:00:00:02] send CTL_RTS, to=00:00:00:00:00:01, size=20, mode=HtMcs7, preamble=2, duration=+4516000.0ns, seq=0x0
Start transmission: signal power before antenna gain=16.0206dBm

If RTS fails, packets are dropped!
Comment 7 sebastien.deronne 2016-11-27 05:57:02 UTC
(In reply to sebastien.deronne from comment #5)
> I indeed see issues when CTS timeout is triggered for A-MPDU transmissions,
> even though the error is different than yours. I am working on a different
> fix that solves the problem at my side, to be then tested at your side.

Issue seen at my side:
assert failed. cond="remainingAmpduDuration > 0", file=../src/wifi/model/mac-low.cc, line=1606
libc++abi.dylib: terminating

This is because m_currentPacket does no longer contains the aggregated packet:
See MacLow::StartTransmission => m_currentPacket = packet->Copy ();
Comment 8 sebastien.deronne 2016-11-27 05:58:55 UTC
Created attachment 2686 [details]
proposed patch to fix

Tom, could you retry with this fix?
Also, make sure you use the latest baseline.
Comment 9 sebastien.deronne 2016-11-27 09:20:05 UTC
Created attachment 2687 [details]
proposed patch to fix

I fixed an issue when a beacon frame is sent right after CtsTimeout is triggered.

Tom, could you give a try with this latest patch?
Comment 10 Tom Henderson 2016-11-30 23:06:59 UTC
(In reply to sebastien.deronne from comment #9)
> Created attachment 2687 [details]
> proposed patch to fix
> 
> I fixed an issue when a beacon frame is sent right after CtsTimeout is
> triggered.
> 
> Tom, could you give a try with this latest patch?

Yes, it passes all ns-3-lbt tests.
Comment 11 sebastien.deronne 2016-12-01 03:31:22 UTC
Then I suggest to deliver those changes
Comment 12 sebastien.deronne 2016-12-01 18:32:50 UTC
fix pushed in changeset 12439:c0fdcce4fd59