23 #include "ns3/assert.h"
24 #include "ns3/packet.h"
25 #include "ns3/simulator.h"
29 #include "ns3/double.h"
40 #undef NS_LOG_APPEND_CONTEXT
41 #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] "
79 m_overrideDurationId (
Seconds (0))
213 <<
"send rts=" << params.
m_sendRts <<
", "
232 os <<
"basic-block-ack";
235 os <<
"compressed-block-ack";
238 os <<
"multi-tid-block-ack";
286 : m_normalAckTimeoutEvent (),
287 m_fastAckTimeoutEvent (),
288 m_superFastAckTimeoutEvent (),
289 m_fastAckFailedTimeoutEvent (),
290 m_blockAckTimeoutEvent (),
291 m_ctsTimeoutEvent (),
296 m_endTxNoAckEvent (),
344 bool oneRunning =
false;
591 NS_LOG_DEBUG (
"switching channel. Cancelling MAC pending events");
646 else if (hdr.
IsCts ()
657 rxSnr, txMode, tag.Get ());
669 else if (hdr.
IsAck ()
682 rxSnr, txMode, tag.Get ());
736 if ((*it).second.first.IsImmediateBlockAck ())
753 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
761 else if (hdr.
IsCtl ())
977 uint32_t dataSize =
GetSize (packet, hdr);
1021 if (hdr.
IsRts () && navUpdated)
1033 Time navCounterResetCtsMissedDelay =
1057 (*i)->NavReset (duration);
1067 (*i)->NavStart (duration);
1071 if (newNavEnd > oldNavEnd)
1074 m_lastNavDuration = duration;
1084 (*i)->AckTimeoutStart (duration);
1092 (*i)->AckTimeoutReset ();
1100 (*i)->CtsTimeoutStart (duration);
1108 (*i)->CtsTimeoutReset ();
1119 ", size=" << packet->
GetSize () <<
1120 ", mode=" << txMode <<
1412 duration -= txDuration;
1415 duration = std::max (duration, newDuration);
1493 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1497 for (; i != (*it).second.second.end ()
1502 (*it).second.second.insert (i, bufferedPacket);
1507 (*j).second.UpdateWithMpdu (&hdr);
1516 uint16_t startingSeq)
1518 uint8_t tid = respHdr->
GetTid ();
1533 std::list<BufferedPacket> buffer (0);
1578 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1580 uint16_t guard = (*it).second.second.begin ()->second.GetSequenceControl () & 0xfff0;
1584 for (; i != (*it).second.second.end ()
1587 if (guard == (*i).second.GetSequenceControl ())
1589 if (!(*i).second.IsMoreFragments ())
1599 while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1603 if (i != (*it).second.second.end ())
1605 guard = (*i).second.GetSequenceControl () & 0xfff0;
1617 while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1621 if (i != (*it).second.second.end ())
1623 guard = (*i).second.GetSequenceControl () & 0xfff0;
1628 (*it).second.second.erase ((*it).second.second.begin (), i);
1638 uint16_t startingSeqCtrl = ((*it).second.first.GetStartingSequence () << 4) & 0xfff0;
1639 uint16_t guard = startingSeqCtrl;
1643 for (; i != (*it).second.second.end () && guard == (*i).second.GetSequenceControl (); i++)
1645 if (!(*i).second.IsMoreFragments ())
1647 while (lastComplete != i)
1649 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1652 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1655 guard = (*i).second.IsMoreFragments () ? (guard + 1) : ((guard + 16) & 0xfff0);
1657 (*it).second.first.SetStartingSequence ((guard >> 4) & 0x0fff);
1660 (*it).second.second.erase ((*it).second.second.begin (), lastComplete);
1730 bool immediate =
false;
1739 immediate = (*it).second.first.IsImmediateBlockAck ();
1750 (*i).second.FillBlockAckBitmap (&blockAck);
1760 NS_LOG_DEBUG (
"there's not a valid block ack agreement with " << originator);