23 #include "ns3/assert.h"
24 #include "ns3/packet.h"
25 #include "ns3/simulator.h"
29 #include "ns3/double.h"
39 #undef NS_LOG_APPEND_CONTEXT
40 #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] "
54 virtual void Print (std::ostream &os)
const;
56 void Set (
double snr);
57 double Get (
void)
const;
67 .AddConstructor<SnrTag> ()
68 .AddAttribute (
"Snr",
"The snr of the last packet received",
71 MakeDoubleChecker<double> ())
84 return sizeof (double);
99 os <<
"Snr=" <<
m_snr;
144 m_waitAck (ACK_NONE),
146 m_overrideDurationId (
Seconds (0))
280 <<
"send rts=" << params.
m_sendRts <<
", "
299 os <<
"basic-block-ack";
302 os <<
"compressed-block-ack";
305 os <<
"multi-tid-block-ack";
353 : m_normalAckTimeoutEvent (),
354 m_fastAckTimeoutEvent (),
355 m_superFastAckTimeoutEvent (),
356 m_fastAckFailedTimeoutEvent (),
357 m_blockAckTimeoutEvent (),
358 m_ctsTimeoutEvent (),
363 m_endTxNoAckEvent (),
411 bool oneRunning =
false;
658 NS_LOG_DEBUG (
"switching channel. Cancelling MAC pending events");
713 else if (hdr.
IsCts ()
724 rxSnr, txMode, tag.Get ());
736 else if (hdr.
IsAck ()
749 rxSnr, txMode, tag.Get ());
803 if ((*it).second.first.IsImmediateBlockAck ())
820 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
828 else if (hdr.
IsCtl ())
1044 uint32_t dataSize =
GetSize (packet, hdr);
1088 if (hdr.
IsRts () && navUpdated)
1100 Time navCounterResetCtsMissedDelay =
1124 (*i)->NavReset (duration);
1134 (*i)->NavStart (duration);
1138 if (newNavEnd > oldNavEnd)
1141 m_lastNavDuration = duration;
1151 (*i)->AckTimeoutStart (duration);
1159 (*i)->AckTimeoutReset ();
1167 (*i)->CtsTimeoutStart (duration);
1175 (*i)->CtsTimeoutReset ();
1186 ", size=" << packet->
GetSize () <<
1187 ", mode=" << txMode <<
1479 duration -= txDuration;
1482 duration = std::max (duration, newDuration);
1560 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1564 for (; i != (*it).second.second.end ()
1569 (*it).second.second.insert (i, bufferedPacket);
1574 (*j).second.UpdateWithMpdu (&hdr);
1583 uint16_t startingSeq)
1585 uint8_t tid = respHdr->
GetTid ();
1600 std::list<BufferedPacket> buffer (0);
1645 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1647 uint16_t guard = (*it).second.second.begin ()->second.GetSequenceControl () & 0xfff0;
1651 for (; i != (*it).second.second.end ()
1654 if (guard == (*i).second.GetSequenceControl ())
1656 if (!(*i).second.IsMoreFragments ())
1666 while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1670 if (i != (*it).second.second.end ())
1672 guard = (*i).second.GetSequenceControl () & 0xfff0;
1684 while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1688 if (i != (*it).second.second.end ())
1690 guard = (*i).second.GetSequenceControl () & 0xfff0;
1695 (*it).second.second.erase ((*it).second.second.begin (), i);
1705 uint16_t startingSeqCtrl = ((*it).second.first.GetStartingSequence () << 4) & 0xfff0;
1706 uint16_t guard = startingSeqCtrl;
1710 for (; i != (*it).second.second.end () && guard == (*i).second.GetSequenceControl (); i++)
1712 if (!(*i).second.IsMoreFragments ())
1714 while (lastComplete != i)
1716 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1719 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1722 guard = (*i).second.IsMoreFragments () ? (guard + 1) : ((guard + 16) & 0xfff0);
1724 (*it).second.first.SetStartingSequence ((guard >> 4) & 0x0fff);
1727 (*it).second.second.erase ((*it).second.second.begin (), lastComplete);
1794 bool immediate =
false;
1803 immediate = (*it).second.first.IsImmediateBlockAck ();
1814 (*i).second.FillBlockAckBitmap (&blockAck);
1824 NS_LOG_DEBUG (
"there's not a valid block ack agreement with " << originator);