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 (),
345 bool oneRunning =
false;
629 NS_LOG_DEBUG (
"switching channel. Cancelling MAC pending events");
656 NotifyNav (packet,hdr, txMode, preamble);
684 else if (hdr.
IsCts ()
695 rxSnr, txMode, tag.Get ());
707 else if (hdr.
IsAck ()
720 rxSnr, txMode, tag.Get ());
774 if ((*it).second.first.IsImmediateBlockAck ())
791 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
799 else if (hdr.
IsCtl ())
1055 Time txTime = Seconds (0);
1078 uint32_t dataSize =
GetSize (packet, hdr);
1130 if (hdr.
IsRts () && navUpdated)
1143 Time navCounterResetCtsMissedDelay =
1167 (*i)->NavReset (duration);
1177 (*i)->NavStart (duration);
1181 if (newNavEnd > oldNavEnd)
1184 m_lastNavDuration = duration;
1194 (*i)->AckTimeoutStart (duration);
1202 (*i)->AckTimeoutReset ();
1210 (*i)->CtsTimeoutStart (duration);
1218 (*i)->CtsTimeoutReset ();
1229 ", size=" << packet->
GetSize () <<
1230 ", mode=" << txVector.
GetMode() <<
1324 Time duration = Seconds (0);
1346 dataTxVector, preamble);
1455 Time duration = Seconds (0.0);
1481 dataTxVector, preamble);
1530 Time duration = Seconds (0);
1541 dataTxVector, preamble);
1562 dataTxVector, preamble);
1612 NS_ASSERT (duration >= MicroSeconds (0));
1652 Time newDuration = Seconds (0);
1656 dataTxVector, preamble);
1657 duration -= txDuration;
1660 duration = std::max (duration, newDuration);
1661 NS_ASSERT (duration >= MicroSeconds (0));
1713 NS_ASSERT (duration >= MicroSeconds (0));
1731 ForwardDown (packet, &ack, ackTxVector, preamble);
1744 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1748 for (; i != (*it).second.second.end ()
1753 (*it).second.second.insert (i, bufferedPacket);
1758 (*j).second.UpdateWithMpdu (&hdr);
1767 uint16_t startingSeq)
1769 uint8_t tid = respHdr->
GetTid ();
1784 std::list<BufferedPacket> buffer (0);
1829 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1831 uint16_t guard = (*it).second.second.begin ()->second.GetSequenceControl () & 0xfff0;
1835 for (; i != (*it).second.second.end ()
1838 if (guard == (*i).second.GetSequenceControl ())
1840 if (!(*i).second.IsMoreFragments ())
1850 while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1854 if (i != (*it).second.second.end ())
1856 guard = (*i).second.GetSequenceControl () & 0xfff0;
1868 while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1872 if (i != (*it).second.second.end ())
1874 guard = (*i).second.GetSequenceControl () & 0xfff0;
1879 (*it).second.second.erase ((*it).second.second.begin (), i);
1889 uint16_t startingSeqCtrl = ((*it).second.first.GetStartingSequence () << 4) & 0xfff0;
1890 uint16_t guard = startingSeqCtrl;
1894 for (; i != (*it).second.second.end () && guard == (*i).second.GetSequenceControl (); i++)
1896 if (!(*i).second.IsMoreFragments ())
1898 while (lastComplete != i)
1900 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1903 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1906 guard = (*i).second.IsMoreFragments () ? (guard + 1) : ((guard + 16) & 0xfff0);
1908 (*it).second.first.SetStartingSequence ((guard >> 4) & 0x0fff);
1911 (*it).second.second.erase ((*it).second.second.begin (), lastComplete);
1933 blockAckReqTxVector.
SetMode(blockAckReqTxMode);
1934 blockAckReqTxVector.
SetNss(1);
1935 blockAckReqTxVector.
SetStbc(
false);
1969 NS_ASSERT (duration >= MicroSeconds (0));
1981 ForwardDown (packet, &hdr, blockAckTxVector,preamble);
1992 bool immediate =
false;
2001 immediate = (*it).second.first.IsImmediateBlockAck ();
2012 (*i).second.FillBlockAckBitmap (&blockAck);
2022 NS_LOG_DEBUG (
"there's not a valid block ack agreement with " << originator);