24 #include "ns3/simulator.h" 46 #undef NS_LOG_APPEND_CONTEXT 47 #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] " 111 : m_msduAggregator (0),
112 m_mpduAggregator (0),
113 m_normalAckTimeoutEvent (),
114 m_blockAckTimeoutEvent (),
115 m_ctsTimeoutEvent (),
120 m_endTxNoAckEvent (),
124 m_lastNavDuration (
Seconds (0)),
127 m_cfpForeshortening (
Seconds (0)),
129 m_phyMacLowListener (0),
130 m_ctsToSelfSupported (false),
147 .SetGroupName (
"Wifi")
148 .AddConstructor<
MacLow> ()
198 bool oneRunning =
false;
534 if (hdr.IsQosData () && !hdr.GetAddr1 ().IsBroadcast () &&
m_mpduAggregator != 0)
540 uint8_t tid =
GetTid (mpdu->GetPacket (), hdr);
542 std::vector<Ptr<WifiMacQueueItem>> mpduList;
555 if (mpduList.size () > 1)
559 if (qosTxop->GetBaBufferSize (hdr.GetAddr1 (), tid) > 64)
568 NS_LOG_DEBUG (
"tx unicast A-MPDU containing " << mpduList.size () <<
" MPDUs");
569 qosTxop->SetAmpduExist (hdr.GetAddr1 (),
true);
580 NS_LOG_DEBUG (
"tx unicast S-MPDU with sequence number " << hdr.GetSequenceNumber ());
581 qosTxop->SetAmpduExist (hdr.GetAddr1 (),
true);
583 else if (hdr.IsQosData () && !hdr.IsQosBlockAck () && !hdr.GetAddr1 ().IsGroup ())
621 uint32_t ampduSize,
Time ppduDurationLimit)
623 NS_ASSERT (mpdu != 0 && mpdu->GetHeader ().IsQosData ());
626 mpdu->GetHeader ().GetQosTid (), txVector,
627 ampduSize, ppduDurationLimit);
634 NS_LOG_FUNCTION (
this << mpduSize << receiver << +tid << txVector << ampduSize << ppduDurationLimit);
638 uint32_t maxAmpduSize = 0;
641 maxAmpduSize =
GetMpduAggregator ()->GetMaxAmpduSize (receiver, tid, modulation);
645 NS_ASSERT (maxAmpduSize || ampduSize == 0);
647 uint32_t ppduPayloadSize = mpduSize;
652 ppduPayloadSize =
GetMpduAggregator ()->GetSizeIfAggregated (mpduSize, ampduSize);
655 if (maxAmpduSize > 0 && ppduPayloadSize > maxAmpduSize)
657 NS_LOG_DEBUG (
"the frame does not meet the constraint on max A-MPDU size");
669 NS_LOG_DEBUG (
"the frame does not meet the constraint on max PPDU duration");
700 NS_LOG_DEBUG (
"switching channel. Cancelling MAC pending events");
716 NS_LOG_DEBUG (
"Device in sleep mode. Cancelling MAC pending events");
731 NS_LOG_DEBUG (
"Device is switched off. Cancelling MAC pending events");
773 && hdr.GetAddr1 () ==
m_self)
775 NS_LOG_DEBUG (
"rx RTS from=" << hdr.GetAddr2 () <<
", schedule CTS");
788 NS_LOG_DEBUG (
"rx RTS from=" << hdr.GetAddr2 () <<
", cannot schedule CTS");
792 else if (hdr.IsCts ()
793 && hdr.GetAddr1 () ==
m_self 809 rxSnr, txVector.
GetMode (), tag.Get ());
818 else if (hdr.IsAck ()
819 && hdr.GetAddr1 () ==
m_self 832 rxSnr, txVector.
GetMode (), tag.Get (),
875 else if (hdr.IsBlockAck () && hdr.GetAddr1 () ==
m_self 879 NS_LOG_DEBUG (
"got block ack from " << hdr.GetAddr2 ());
905 else if (hdr.IsBlockAckReq () && hdr.GetAddr1 () ==
m_self)
924 if ((*it).second.first.IsImmediateBlockAck ())
926 NS_LOG_DEBUG (
"rx blockAckRequest/sendImmediateBlockAck from=" << hdr.GetAddr2 ());
942 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
950 else if (hdr.IsCtl ())
979 else if (hdr.GetAddr1 () ==
m_self)
1002 if (hdr.IsQosAck () && !ampduSubframe)
1004 NS_LOG_DEBUG (
"rx QoS unicast/sendAck from=" << hdr.GetAddr2 ());
1008 hdr.GetAddr2 (), hdr.GetQosTid ());
1018 else if (hdr.IsQosBlockAck ())
1026 else if (hdr.IsQosData () && hdr.IsQosBlockAck ())
1037 m_edca[ac]->SendDelbaFrame (hdr.GetAddr2 (), hdr.GetQosTid (),
false);
1040 else if (hdr.IsQosData () && hdr.IsQosNoAck ())
1044 NS_LOG_DEBUG (
"rx Ampdu with No Ack Policy from=" << hdr.GetAddr2 ());
1048 NS_LOG_DEBUG (
"rx unicast/noAck from=" << hdr.GetAddr2 ());
1051 else if (hdr.IsData () || hdr.IsMgt ())
1053 if (hdr.IsProbeResp ())
1060 if (hdr.IsMgt () && ampduSubframe)
1062 NS_FATAL_ERROR (
"Received management packet as part of an A-MPDU");
1076 NS_LOG_DEBUG (
"rx unicast/sendAck from=" << hdr.GetAddr2 ());
1089 else if (hdr.GetAddr1 ().IsGroup ())
1093 NS_FATAL_ERROR (
"Received group addressed packet as part of an A-MPDU");
1097 if (hdr.IsData () || hdr.IsMgt ())
1100 if (hdr.IsBeacon ())
1127 NS_LOG_DEBUG (
"rx not for me from=" << hdr.GetAddr2 ());
1270 NS_LOG_DEBUG (
"MacLow::GetControlAnswerMode returning " << mode);
1348 NS_LOG_DEBUG (
"MacLow::GetControlAnswerMode returning " << mode);
1416 uint32_t fragmentSize)
const 1421 if (fragmentSize > 0)
1443 txTime +=
GetCtsDuration (item->GetHeader ().GetAddr1 (), rtsTxVector);
1498 if (hdr.
IsRts () && navUpdated)
1511 Time navCounterResetCtsMissedDelay =
1536 (*i)->NotifyNavResetNow (duration);
1547 (*i)->NotifyNavStartNow (duration);
1551 if (newNavEnd > oldNavEnd)
1565 (*i)->NotifyAckTimeoutStartNow (duration);
1574 (*i)->NotifyAckTimeoutResetNow ();
1583 (*i)->NotifyCtsTimeoutStartNow (duration);
1592 (*i)->NotifyCtsTimeoutResetNow ();
1605 ", to=" << hdr.GetAddr1 () <<
1606 ", size=" << psdu->GetSize () <<
1607 ", mode=" << txVector.
GetMode () <<
1609 ", duration=" << hdr.GetDuration () <<
1610 ", seq=0x" << std::hex << hdr.GetSequenceControl () << std::dec);
1612 if (!psdu->IsAggregate ())
1642 if (psdu->IsSingle ())
1651 if (psdu->GetNMpdus () > 1)
1655 if (mpdu->GetHeader ().IsQosData ())
1658 edcaIt->second->CompleteMpduTx (mpdu);
1674 busy = (*i)->IsBusy ();
1779 ForwardDown (Create<const WifiPsdu> (Create<Packet> (), rts), rtsTxVector);
1812 Time delay = txDuration;
1826 Time delay = txDuration;
1999 ForwardDown (Create<const WifiPsdu> (Create<Packet> (), cts), ctsTxVector);
2020 cts.SetDsNotFrom ();
2022 cts.SetNoMoreFragments ();
2024 cts.SetAddr1 (source);
2028 cts.SetDuration (duration);
2037 ForwardDown (Create<const WifiPsdu> (packet, cts), ctsTxVector);
2087 duration -= txDuration;
2090 duration =
std::max (duration, newDuration);
2156 ForwardDown (Create<const WifiPsdu> (packet, ack), ackTxVector);
2182 uint16_t delta = (seqNumber - (*it).second.first.GetWinEnd () + 4096) % 4096;
2185 (*it).second.first.SetWinEnd (seqNumber);
2186 int16_t winEnd = (*it).second.first.GetWinEnd ();
2187 int16_t bufferSize = (*it).second.first.GetBufferSize ();
2188 uint16_t sum = (
static_cast<uint16_t
> (winEnd - bufferSize + 1 + 4096)) % 4096;
2189 (*it).second.first.SetStartingSequence (sum);
2194 (*it).second.first.SetWinEnd (((*it).second.first.GetStartingSequence () + (*it).second.first.GetBufferSize () - 1) % 4096);
2213 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
2217 for (; i != (*it).second.second.end ()
2221 (*it).second.second.insert (i, bufferedPacket);
2226 (*j).second.UpdateWithMpdu (&hdr);
2234 uint16_t startingSeq)
2237 uint8_t tid = respHdr->
GetTid ();
2252 std::list<BufferedPacket> buffer (0);
2270 m_edca[ac], originator, tid,
false);
2296 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
2300 if (last != (*it).second.second.end ())
2302 guard = (*it).second.second.begin ()->second.GetSequenceControl ();
2305 for (; i != (*it).second.second.end ()
2308 if (guard == (*i).second.GetSequenceControl ())
2310 if (!(*i).second.IsMoreFragments ())
2320 while (i != (*it).second.second.end () && guard == (*i).second.GetSequenceControl ())
2324 if (i != (*it).second.second.end ())
2326 guard = (*i).second.GetSequenceControl ();
2338 while (i != (*it).second.second.end () && guard == (*i).second.GetSequenceControl ())
2342 if (i != (*it).second.second.end ())
2344 guard = (*i).second.GetSequenceControl ();
2349 (*it).second.second.erase ((*it).second.second.begin (), i);
2359 uint16_t guard = (*it).second.first.GetStartingSequenceControl ();
2362 for (; i != (*it).second.second.end () && guard == (*i).second.GetSequenceControl (); i++)
2364 if (!(*i).second.IsMoreFragments ())
2366 while (lastComplete != i)
2368 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
2371 m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
2374 guard = (*i).second.IsMoreFragments () ? (guard + 1) : ((guard + 16) & 0xfff0);
2376 (*it).second.first.SetStartingSequenceControl (guard);
2379 (*it).second.second.erase ((*it).second.second.begin (), lastComplete);
2385 Time duration,
WifiMode blockAckReqTxMode,
double rxSnr)
2428 ForwardDown (Create<const WifiPsdu> (packet, hdr), blockAckReqTxVector);
2439 uint16_t seqNumber = 0;
2442 seqNumber = (*i).second.GetWinStart ();
2444 bool immediate =
true;
2446 blockAck.SetStartingSequence (seqNumber);
2447 blockAck.SetTidInfo (tid);
2448 immediate = (*it).second.first.IsImmediateBlockAck ();
2449 if ((*it).second.first.GetBufferSize () > 64)
2457 NS_LOG_DEBUG (
"Got Implicit block Ack Req with seq " << seqNumber);
2458 (*i).second.FillBlockAckBitmap (&blockAck);
2472 Time duration,
WifiMode blockAckReqTxMode,
double rxSnr)
2477 bool immediate =
false;
2486 immediate = (*it).second.first.IsImmediateBlockAck ();
2501 (*i).second.FillBlockAckBitmap (&blockAck);
2519 (*it).second.first.SetWinEnd (((*it).second.first.GetStartingSequence () + (*it).second.first.GetBufferSize () - 1) % 4096);
2522 (*it).second.first.SetWinEnd (((*it).second.first.GetStartingSequence () + (*it).second.first.GetBufferSize () - 1) % 4096);
2528 NS_LOG_DEBUG (
"there's not a valid block ack agreement with " << originator);
2550 agreement.
GetTid (),
false);
2557 m_edca.insert (std::make_pair (ac, edca));
2564 bool normalAck =
false;
2565 bool ampduSubframe =
false;
2568 ampduSubframe =
true;
2571 auto status = statusPerMpdu.begin ();
2572 NS_ABORT_MSG_IF (packets.size () != statusPerMpdu.size (),
"Should have one receive status per MPDU");
2575 (*n).first->PeekHeader (firsthdr);
2576 NS_LOG_DEBUG (
"duration/id=" << firsthdr.GetDuration ());
2579 if (firsthdr.GetAddr1 () ==
m_self)
2581 bool singleMpdu = (*n).second.GetEof ();
2583 for (;
n != packets.end (); ++
n, ++status)
2585 (*n).first->PeekHeader (firsthdr);
2586 NS_ABORT_MSG_IF (firsthdr.GetAddr1 () !=
m_self,
"All MPDUs of A-MPDU should have the same destination address");
2593 ampduSubframe =
false;
2599 firsthdr.GetQosTid (),
2600 firsthdr.GetAddr2 (),
2601 firsthdr.GetDuration (),
2605 if (firsthdr.IsAck () || firsthdr.IsBlockAck () || firsthdr.IsBlockAckReq ())
2607 ReceiveOk ((*n).first, rxSnr, txVector, ampduSubframe);
2609 else if (firsthdr.IsData () || firsthdr.IsQosData ())
2611 NS_LOG_DEBUG (
"Deaggregate packet from " << firsthdr.GetAddr2 () <<
" with sequence=" << firsthdr.GetSequenceNumber ());
2612 ReceiveOk ((*n).first, rxSnr, txVector, ampduSubframe);
2613 if (firsthdr.IsQosAck ())
2629 if (firsthdr.IsBlockAckReq ())
2631 NS_FATAL_ERROR (
"Sending a BlockAckReq with QosPolicy equal to Normal Ack");
2633 uint8_t tid = firsthdr.GetQosTid ();
2639 NS_LOG_DEBUG (
"rx A-MPDU/sendImmediateBlockAck from=" << firsthdr.GetAddr2 ());
2644 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
2655 ReceiveOk (aggregatedPacket, rxSnr, txVector, ampduSubframe);
2665 return remainingCfpDuration;
void WaitIfsAfterEndTxPacket(void)
Event handler that is usually scheduled to fired at the appropriate time after sending a packet...
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Set(double snr)
Set the SNR to the given value.
Time GetRifs(void) const
Return Reduced Interframe Space (RIFS) of this MacLow.
void SetPifs(Time pifs)
Set PCF Interframe Space (PIFS) of this MacLow.
Time m_ctsTimeout
CTS timeout duration.
bool IsStateOff(void) const
bool GetRifsPermitted(void) const
Return whether the device can use RIFS.
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
Simulation virtual time values and global simulation resolution.
EventId m_navCounterResetCtsMissed
Event to reset NAV when CTS is not received.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
std::vector< Ptr< ChannelAccessManager > >::const_iterator ChannelAccessManagersCI
typedef for an iterator for a list of ChannelAccessManager.
void ResetBlockAckInactivityTimerIfNeeded(BlockAckAgreement &agreement)
Every time that a block ack request or a packet with ack policy equals to block ack are received...
EventId m_blockAckTimeoutEvent
Block ACK timeout event.
Time CalculateOverallTxTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters ¶ms, uint32_t fragmentSize=0) const
void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void ReceiveError(Ptr< Packet > packet)
Ptr< MpduAggregator > GetMpduAggregator(void) const
Returns the aggregator used to construct A-MPDU subframes.
WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
void SendBlockAckAfterBlockAckRequest(const CtrlBAckRequestHeader reqHdr, Mac48Address originator, Time duration, WifiMode blockAckReqTxMode, double rxSnr)
Invoked after that a block ack request has been received.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
void SetPromisc(void)
Enable promiscuous mode.
virtual void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
void DoNavResetNow(Time duration)
Reset NAV with the given duration.
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Ptr< Txop > m_currentTxop
Current TXOP.
virtual void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
void NotifyMaybeCcaBusyStart(Time duration)
void SetupPhyMacLowListener(const Ptr< WifiPhy > phy)
Set up WifiPhy listener for this MacLow.
virtual void StartNextFragment(void)
Start transmission for the next fragment.
uint32_t GetRtsSize(void)
Return the total RTS size (including FCS trailer).
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
Time m_pifs
PCF Interframe Space (PIFS) duration.
void SetPhy(const Ptr< WifiPhy > phy)
Set up WifiPhy associated with this MacLow.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added...
bool DoNavStartNow(Time duration)
Start NAV with the given duration.
void SetSifs(Time sifs)
Set Short Interframe Space (SIFS) of this MacLow.
void NotifySwitchingStart(Time duration)
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr, uint32_t packetSize)
Should be invoked whenever we receive the Ack associated to a data packet we just sent...
std::pair< Mac48Address, uint8_t > AgreementKey
agreement key typedef
void SetReceiveErrorCallback(RxErrorCallback callback)
virtual void MissedAck(void)
Event handler when an ACK is missed.
Time CalculateOverheadTxTime(Ptr< const WifiMacQueueItem > item, const MacLowTransmissionParameters ¶ms) const
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
U * PeekPointer(const Ptr< U > &p)
void Init(uint16_t winStart, uint16_t winSize)
Init function.
WifiMode GetDefaultMcs(void) const
Return the default Modulation and Coding Scheme (MCS) index.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool IsNavZero(void) const
Check if NAV is zero.
static DeaggregatedMpdus Deaggregate(Ptr< Packet > aggregatedPacket)
Deaggregates an A-MPDU by removing the A-MPDU subframe header and padding.
void NotifyOffNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
void NotifySleepNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
void NotifyNav(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Notify NAV function.
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
Mac48Address GetBssid(void) const
Return the Basic Service Set Identification.
std::list< std::pair< Ptr< Packet >, AmpduSubframeHeader > >::const_iterator DeaggregatedMpdusCI
A constant iterator for a list of deaggregated packets and their A-MPDU subframe headers.
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
Sends DELBA frame to cancel a block ack agreement with sta addressed by addr for tid tid...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet. ...
bool IsStrictlyPositive(void) const
virtual void Cancel(void)
Cancel the transmission.
uint32_t GetAckSize(void)
Return the total ACK size (including FCS trailer).
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Callback< R > MakeNullCallback(void)
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
WifiTxVector GetRtsTxVector(Ptr< const WifiMacQueueItem > item) const
Return a TXVECTOR for the RTS frame given the destination.
Mac48Address m_bssid
BSSID address (Mac48Address)
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble, bool useGreenfield)
Return the preamble to be used for the transmission.
bool MustWaitBlockAck(void) const
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
EventId m_sendCtsEvent
Event to send CTS.
MacLowRxCallback m_rxCallback
Callback to pass packet up.
bool appendCfAck
Flag used for PCF to indicate whether a CF-ACK should be appended.
EventId m_sendAckEvent
Event to send ACK.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
WifiMode GetControlAnswerMode(WifiMode reqMode) const
Get control answer mode function.
bool MustSendRts(void) const
void NotifyAckTimeoutResetNow(void)
Notify ChannelAccessManager that ACK timer should be reset.
Time m_cfpMaxDuration
CFP max duration.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Time CalculateTransmissionTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters ¶meters) const
control how a packet is transmitted.
bool IsMandatory(void) const
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self capability.
bool expectCfAck
Flag used for PCF to indicate whether a CF-ACK should be expected.
QueueEdcas m_edca
EDCA queues.
void NormalAckTimeout(void)
Event handler when normal ACK timeout occurs.
void SetBasicBlockAckTimeout(Time blockAckTimeout)
Set Basic Block ACK timeout of this MacLow.
BlockAckCaches m_bAckCaches
block ack caches
uint32_t GetNextPacketSize(void) const
uint16_t GetChannelWidth(void) const
Ptr< WifiMac > m_mac
Pointer to WifiMac (to fetch configuration)
WifiPreamble GetPreambleType(void) const
void RemovePhyMacLowListener(Ptr< WifiPhy > phy)
Remove current WifiPhy listener for this MacLow.
uint8_t GetNMcs(void) const
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
bool IsPromisc(void) const
Check if MacLow is operating in promiscuous mode.
void NotifyOn(void)
Notify listeners that we went to switch on.
WifiTxVector m_currentTxVector
TXVECTOR used for the current packet transmission.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PLCP preambles.
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Time m_lastNavDuration
The duration of the latest NAV.
void SetCfpMaxDuration(Time duration)
Time GetCtsDuration(WifiTxVector ctsTxVector) const
Return the time required to transmit the CTS (including preamble and FCS).
bool IsWithinSizeAndTimeLimits(Ptr< const WifiMacQueueItem > mpdu, WifiTxVector txVector, uint32_t ampduSize, Time ppduDurationLimit)
Check whether the given MPDU, if transmitted according to the given TX vector, meets the constraint o...
std::pair< Ptr< Packet >, WifiMacHeader > BufferedPacket
buffered packet typedef
void SendCtsToSelf(void)
Send CTS for a CTS-to-self mechanism.
bool m_ctsToSelfSupported
Flag whether CTS-to-self is supported.
void SendAckAfterData(Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr)
Send ACK after receiving DATA.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
virtual void StartTransmission(Ptr< WifiMacQueueItem > mpdu, MacLowTransmissionParameters parameters, Ptr< Txop > txop)
void CreateBlockAckAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq)
Time m_lastBeacon
The time when the last beacon frame transmission started.
Time GetCompressedBlockAckTimeout(void) const
Return Compressed Block ACK timeout of this MacLow.
void ReportRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked whenever the RtsTimeout associated to a transmission attempt expires.
bool GetPcfSupported(void) const
Return whether the device has PCF capability support enabled.
uint16_t GetTimeout(void) const
Return the timeout.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
receive notifications about phy events.
void CtsTimeout(void)
Event handler when CTS timeout occurs.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
static const uint16_t MAX_MSDU_SIZE
This value conforms to the 802.11 specification.
Time GetSifs(void) const
Return Short Interframe Space (SIFS) of this MacLow.
void EndTxNoAck(void)
A transmission that does not require an ACK has completed.
uint32_t GetSerializedSize(void) const
void SendBlockAckAfterAmpdu(uint8_t tid, Mac48Address originator, Time duration, WifiTxVector blockAckReqTxVector, double rxSnr)
Invoked after an A-MPDU has been received.
bool MustWaitNormalAck(void) const
std::map< AgreementKey, BlockAckCache >::iterator BlockAckCachesI
block ack caches iterator typedef
virtual bool IsCfPeriod(void) const
This function indicates whether it is the CF period.
void EnableExtendedCompressedBlockAck(void)
Wait COMPRESSEDBLOCKACKTimeout for an Extended Compressed Block Ack Response frame.
void SetAckTimeout(Time ackTimeout)
Set ACK timeout of this MacLow.
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
static TypeId GetTypeId(void)
Register this type.
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the wifimode.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Time GetCtsTimeout(void) const
Return CTS timeout of this MacLow.
WifiMode GetMode(void) const
void NavCounterResetCtsMissed(Time rtsEndRxTime)
Reset NAV after CTS was missed when the NAV was set with RTS.
Ptr< WifiRemoteStationManager > m_stationManager
Pointer to WifiRemoteStationManager (rate control)
void SetMac(const Ptr< WifiMac > mac)
Set up WifiMac associated with this MacLow.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SendDataAfterCts(Time duration)
Send DATA after receiving CTS.
void RegisterEdcaForAc(AcIndex ac, Ptr< QosTxop > edca)
Agreements m_bAckAgreements
block ack agreements
virtual WifiTxVector GetDataTxVector(Ptr< const WifiMacQueueItem > item) const
Return a TXVECTOR for the DATA frame given the destination.
virtual bool IsQosTxop() const
Check for QoS TXOP.
void NotifySwitchingStartNow(Time duration)
WifiModulationClass GetModulationClass() const
bool HasNextPacket(void) const
void NotifyOff(void)
Notify listeners that we went to switch off.
Time GetCfpMaxDuration(void) const
Time m_slotTime
Slot duration.
WifiTxVector GetAckTxVector(Mac48Address to, WifiMode dataTxMode) const
Return a TXVECTOR for the ACK frame given the destination and the mode of the DATA used by the sender...
WifiMode GetDefaultMode(void) const
Return the default transmission mode.
Mac48Address GetPeer(void) const
Return the peer address.
bool m_promisc
Flag if the device is operating in promiscuous mode.
void NotifyRxStart(Time duration)
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
void CancelAllEvents(void)
Cancel all scheduled events.
WifiTxVector GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) const
Return a TXVECTOR for the CTS frame given the destination and the mode of the RTS used by the sender...
std::list< BufferedPacket >::iterator BufferedPacketI
buffered packet iterator typedef
void SetStartingSequence(uint16_t seq)
Set starting sequence number.
void BlockAckTimeout(void)
Event handler when block ACK timeout occurs.
void NotifyCtsTimeoutStartNow(Time duration)
Notify ChannelAccessManager that CTS timer should be started for the given duration.
Time GetAckTimeout(void) const
Return ACK timeout of this MacLow.
void EnableCompressedBlockAck(void)
Wait COMPRESSEDBLOCKACKTimeout for a Compressed Block Ack Response frame.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time GetRemainingCfpDuration(void) const
void GotCfEnd(void)
Event handler when a CF-END frame is received.
void RegisterDcf(Ptr< ChannelAccessManager > dcf)
void SetAggregation(bool aggregation)
Sets if PSDU contains A-MPDU.
void SetBssid(Mac48Address ad)
Set the Basic Service Set Identification.
Time GetBasicBlockAckTimeout(void) const
Return Basic Block ACK timeout of this MacLow.
uint16_t GetFrequency(void) const
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
EventId m_waitIfsEvent
Wait for IFS event.
void ReceiveOk(Ptr< Packet > packet, double rxSnr, WifiTxVector txVector, bool ampduSubframe)
void EnableAck(void)
Wait ACKTimeout for an ACK.
virtual void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
void NotifyMissedCts(std::list< Ptr< WifiMacQueueItem >> mpduList)
Event handler when a CTS timeout has occurred.
EventId m_normalAckTimeoutEvent
Normal ACK timeout event.
bool IsHigherCodeRate(WifiMode mode) const
void StartDataTxTimers(WifiTxVector dataTxVector)
Start a DATA timer by scheduling appropriate ACK timeout.
void NotifyWakeup(void)
Notify listeners that we woke up.
Time m_beaconInterval
Expected interval between two beacon transmissions.
uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxSupportedChannelWidth)
Return the channel width that corresponds to the selected mode (instead of letting the PHY's default ...
bool UseGreenfieldForDestination(Mac48Address dest) const
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
uint32_t RemoveTrailer(Trailer &trailer)
Remove a deserialized trailer from the internal buffer.
Time m_cfpForeshortening
The delay the current CF period should be foreshortened.
void NotifyTxStart(Time duration, double txPowerDbm)
void SendBlockAckResponse(const CtrlBAckResponseHeader *blockAck, Mac48Address originator, bool immediate, Time duration, WifiMode blockAckReqTxMode, double rxSnr)
This method creates block ack frame with header equals to blockAck and start its transmission.
Time GetAckDuration(WifiTxVector ackTxVector) const
Return the time required to transmit the ACK (including preamble and FCS).
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
Time m_ackTimeout
ACK timeout duration.
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr)
Extraction operator for TypeId.
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer)
Return whether the modulation class of the selected mode for the control answer frame is allowed...
static Time Now(void)
Return the current simulation virtual time.
void ReportRtsOk(Mac48Address address, const WifiMacHeader *header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
Should be invoked whenever we receive the Cts associated to an RTS we just sent.
EventId m_ctsTimeoutEvent
CTS timeout event.
void RxCompleteBufferedPacketsWithSmallerSequence(uint16_t seq, Mac48Address originator, uint8_t tid)
void SendCtsAfterRts(Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr)
Send CTS after receiving RTS.
Ptr< MsduAggregator > GetMsduAggregator(void) const
Returns the aggregator used to construct A-MSDU subframes.
Time m_basicBlockAckTimeout
Basic block ACK timeout duration.
bool GetCtsToSelfSupported(void) const
Return whether CTS-to-self capability is supported.
Time m_sifs
Short Interframe Space (SIFS) duration.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetBeaconInterval(Time interval)
void SetDelayedBlockAck(void)
Set Block ACK policy to delayed ACK.
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
void NotifySleep(void)
Notify listeners that we went to sleep.
uint32_t GetCtsSize(void)
Return the total CTS size (including FCS trailer).
Time m_lastNavStart
The time when the latest NAV started.
EventId m_inactivityEvent
inactivity event
bool NeedCtsToSelf(WifiTxVector txVector)
Return if we need to do Cts-to-self before sending a DATA.
void SetAmsduSupport(bool supported)
Enable or disable A-MSDU support.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
handle RTS/CTS/DATA/ACK transactions.
Mac48Address address
Address of the station to be acknowledged.
void SetReceiveOkCallback(RxOkCallback callback)
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
EventId m_sendDataEvent
Event to send DATA.
bool IsStateTx(void) const
bool ReceiveMpdu(Ptr< Packet > packet, WifiMacHeader hdr)
void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
MacLowTransmissionParameters m_txParams
Transmission parameters of the current packet.
void SetRifs(Time rifs)
Set Reduced Interframe Space (RIFS) of this MacLow.
void DoDispose(void)
Destructor implementation.
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
void SetMsduAggregator(const Ptr< MsduAggregator > aggr)
Set the aggregator used to construct A-MSDU subframes.
WifiTxVector GetAckTxVectorForData(Mac48Address to, WifiMode dataTxMode) const
Return a TXVECTOR for the Block ACK frame given the destination and the mode of the DATA used by the ...
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Time GetPpduMaxTime(WifiPreamble preamble)
Get the maximum PPDU duration (see Section 10.14 of 802.11-2016) for the PHY layers defining the aPPD...
Mac48Address m_self
Address of this MacLow (Mac48Address)
Maintains information for a block ack agreement.
WifiTxVector GetBlockAckTxVector(Mac48Address to, WifiMode dataTxMode) const
Return a TXVECTOR for the Block ACK frame given the destination and the mode of the DATA used by the ...
void AddPacketTag(const Tag &tag) const
Add a packet tag.
uint32_t QosUtilsMapSeqControlToUniqueInteger(uint16_t seqControl, uint16_t endSequence)
Next function is useful to correctly sort buffered packets under block ack.
void NotifyAckTimeoutStartNow(Time duration)
Notify ChannelAccessManager that ACK timer should be started for the given duration.
bool CanTransmitNextCfFrame(void) const
This function decides if a CF frame can be transmitted in the current CFP.
void SetSlotTime(Time slotTime)
Set slot duration of this MacLow.
virtual void GotAck(void)
Event handler when an ACK is received.
bool IsPositive(void) const
void Reset(void)
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot. ...
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
virtual void MissedCts(void)
Event handler when a CTS timeout has occurred.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Time m_cfpStart
The time when the latest CF period started.
ns3::MacLow * m_macLow
the MAC
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint32_t GetBlockAckSize(BlockAckType type)
Return the total Block ACK size (including FCS trailer).
Time Seconds(double value)
Construct a Time in the indicated unit.
std::map< AgreementKey, AgreementValue >::iterator AgreementsI
agreements iterator
EventId m_endTxNoAckEvent
Event for finishing transmission that does not require ACK.
virtual Time GetTxopRemaining(void) const
Return the remaining duration in the current TXOP.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
uint8_t GetDefaultTxPowerLevel(void) const
void MissedCfPollResponse(bool expectedCfAck)
Event handler when a response to a CF-POLL frame is missed.
Time GetBlockAckDuration(WifiTxVector blockAckReqTxVector, BlockAckType type) const
Return the time required to transmit the Block ACK to the specified address given the TXVECTOR of the...
CfAckInfo m_cfAckInfo
Info about piggyback ACKs used in PCF.
void SetMpduAggregator(const Ptr< MpduAggregator > aggr)
Set the aggregator used to construct A-MPDU subframes.
void ReportRxOk(Mac48Address address, const WifiMacHeader *header, double rxSnr, WifiMode txMode)
void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
std::list< std::pair< Ptr< Packet >, AmpduSubframeHeader > > DeaggregatedMpdus
A list of deaggregated packets and their A-MPDU subframe headers.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
void SetCtsTimeout(Time ctsTimeout)
Set CTS timeout of this MacLow.
void SetImmediateBlockAck(void)
Set Block ACK policy to immediate ACK.
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
void SendDataPacket(void)
Send DATA packet, which can be DATA-ACK or RTS-CTS-DATA-ACK transaction.
void DeaggregateAmpduAndReceive(Ptr< Packet > aggregatedPacket, double rxSnr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
void SetTimeout(uint16_t timeout)
Set timeout.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time GetPifs(void) const
Return PCF Interframe Space (PIFS) of this MacLow.
void SetAddress(Mac48Address ad)
Set MAC address of this MacLow.
uint32_t GetCfEndSize(void) const
Return the total CF-END size (including FCS trailer).
void ForwardDown(Ptr< const WifiPsdu > psdu, WifiTxVector txVector)
Forward a PSDU down to WifiPhy for transmission.
WifiTxVector GetRtsTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
A base class which provides memory management and object aggregation.
void WaitIfsAfterEndTxFragment(void)
Event handler that is usually scheduled to fired at the appropriate time after completing transmissio...
PhyMacLowListener(ns3::MacLow *macLow)
Create a PhyMacLowListener for the given MacLow.
Time GetBeaconInterval(void) const
Time m_compressedBlockAckTimeout
Compressed block ACK timeout duration.
void CfPollTimeout(void)
Event handler when CF-POLL timeout occurs.
virtual void TerminateTxop(void)
Update backoff and restart access if needed.
BlockAckType GetBlockAckType(void) const
void NotifyCtsTimeoutResetNow(void)
Notify ChannelAccessManager that CTS timer should be reset.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
Ptr< WifiPsdu > m_currentPacket
Current packet transmitted/to be transmitted.
virtual ~PhyMacLowListener()
void ResetPhy(void)
Remove WifiPhy associated with this MacLow.
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
void DisableAck(void)
Do not wait for Ack after data transmission.
std::pair< BlockAckAgreement, std::list< BufferedPacket > > AgreementValue
agreement value typedef
Time GetSlotTime(void) const
Return slot duration of this MacLow.
WifiTxVector GetCtsTxVectorForRts(Mac48Address to, WifiMode rtsTxMode) const
Return a TXVECTOR for the CTS frame given the destination and the mode of the RTS used by the sender...
void SetBufferSize(uint16_t bufferSize)
Set buffer size.
a unique identifier for an interface.
void SetRxCallback(Callback< void, Ptr< Packet >, const WifiMacHeader *> callback)
bool IsHigherDataRate(WifiMode mode) const
bool NeedCtsToSelf(void) const
Check if CTS-to-self mechanism should be used for the current packet.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
uint8_t GetTid(void) const
Return the Traffic ID (TID).
bool IsStateRx(void) const
Time m_rifs
Reduced Interframe Space (RIFS) duration.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Introspection did not find any typical Config paths.
bool StoreMpduIfNeeded(Ptr< Packet > packet, WifiMacHeader hdr)
Ptr< MpduAggregator > m_mpduAggregator
A-MPDU aggregator.
Ptr< WifiPhy > m_phy
Pointer to WifiPhy (actually send/receives frames)
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
void AddHeader(const Header &header)
Add header to this packet.
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
Set up WifiRemoteStationManager associated with this MacLow.
void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Set Compressed Block ACK timeout of this MacLow.
Implements the IEEE 802.11 MAC trailer.
Ptr< WifiPhy > GetPhy(void) const
class PhyMacLowListener * m_phyMacLowListener
Listener needed to monitor when a channel switching occurs.
ChannelAccessManagers m_channelAccessManagers
List of ChannelAccessManager.
void SendRtsForPacket(void)
Send RTS to begin RTS-CTS-DATA-ACK transaction.
BlockAckType
The different block ACK policies.
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Time GetGuardInterval(void) const
Time GetTxopLimit(void) const
Return the TXOP limit.