24 #include "ns3/simulator.h" 47 #undef NS_LOG_APPEND_CONTEXT 48 #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] " 53 #define PSDU_DURATION_SAFEGUARD 400 117 : m_msduAggregator (0),
118 m_mpduAggregator (0),
119 m_normalAckTimeoutEvent (),
120 m_blockAckTimeoutEvent (),
121 m_ctsTimeoutEvent (),
126 m_endTxNoAckEvent (),
130 m_lastNavDuration (
Seconds (0)),
133 m_cfpForeshortening (
Seconds (0)),
135 m_phyMacLowListener (0),
136 m_ctsToSelfSupported (false),
153 .SetGroupName (
"Wifi")
154 .AddConstructor<
MacLow> ()
204 bool oneRunning =
false;
474 if (hdr.IsQosData () && !hdr.GetAddr1 ().IsGroup ()
475 && !hdr.IsMoreFragments () && hdr.GetFragmentNumber () == 0)
478 uint8_t tid = hdr.GetQosTid ();
491 bool isPeeked = (tmp != 0 && tmp->GetPacket () == mpdu->GetPacket ());
522 std::vector<Ptr<WifiMacQueueItem>> mpduList;
528 if (mpduList.size () > 1)
532 NS_LOG_DEBUG (
"tx unicast A-MPDU containing " << mpduList.size () <<
" MPDUs");
541 NS_LOG_DEBUG (
"tx unicast S-MPDU with sequence number " << hdr.GetSequenceNumber ());
587 uint32_t ampduSize,
Time ppduDurationLimit)
589 NS_ASSERT (mpdu != 0 && mpdu->GetHeader ().IsQosData ());
592 mpdu->GetHeader ().GetQosTid (), txVector,
593 ampduSize, ppduDurationLimit);
600 NS_LOG_FUNCTION (
this << mpduSize << receiver << +tid << txVector << ampduSize << ppduDurationLimit);
609 uint32_t maxAmpduSize = 0;
612 maxAmpduSize =
GetMpduAggregator ()->GetMaxAmpduSize (receiver, tid, modulation);
616 NS_ASSERT (maxAmpduSize || ampduSize == 0);
618 uint32_t ppduPayloadSize = mpduSize;
623 ppduPayloadSize =
GetMpduAggregator ()->GetSizeIfAggregated (mpduSize, ampduSize);
626 if (maxAmpduSize > 0 && ppduPayloadSize > maxAmpduSize)
628 NS_LOG_DEBUG (
"the frame does not meet the constraint on max A-MPDU size");
640 NS_LOG_DEBUG (
"the frame does not meet the constraint on max PPDU duration");
652 <<
" us (txVector: " << txVector <<
")");
653 if (psduDuration.
IsZero ())
718 NS_LOG_DEBUG (
"switching channel. Cancelling MAC pending events");
734 NS_LOG_DEBUG (
"Device in sleep mode. Cancelling MAC pending events");
749 NS_LOG_DEBUG (
"Device is switched off. Cancelling MAC pending events");
810 else if (hdr.
IsCts ()
827 rxSnr, txVector.
GetMode (), tag.Get ());
836 else if (hdr.
IsAck ()
850 rxSnr, txVector.
GetMode (), tag.Get (),
916 if ((*it).second.first.IsImmediateBlockAck ())
934 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
942 else if (hdr.
IsCtl ())
994 if (hdr.
IsQosAck () && !ampduSubframe)
1051 mpdu = Create<WifiMacQueueItem> (packet, hdr);
1053 if (hdr.
IsMgt () && ampduSubframe)
1055 NS_FATAL_ERROR (
"Received management packet as part of an A-MPDU");
1086 NS_FATAL_ERROR (
"Received group addressed packet as part of an A-MPDU");
1099 mpdu = Create<WifiMacQueueItem> (packet, hdr);
1294 NS_LOG_DEBUG (
"MacLow::GetControlAnswerMode returning " << mode);
1372 NS_LOG_DEBUG (
"MacLow::GetControlAnswerMode returning " << mode);
1440 uint32_t fragmentSize)
const 1445 if (fragmentSize > 0)
1467 txTime +=
GetCtsDuration (item->GetHeader ().GetAddr1 (), rtsTxVector);
1511 if (hdr.
IsRts () && navUpdated)
1524 Time navCounterResetCtsMissedDelay =
1541 (*i)->NotifyNavResetNow (duration);
1552 (*i)->NotifyNavStartNow (duration);
1556 if (newNavEnd > oldNavEnd)
1570 (*i)->NotifyAckTimeoutStartNow (duration);
1579 (*i)->NotifyAckTimeoutResetNow ();
1588 (*i)->NotifyCtsTimeoutStartNow (duration);
1597 (*i)->NotifyCtsTimeoutResetNow ();
1610 ", to=" << hdr.GetAddr1 () <<
1611 ", size=" << psdu->
GetSize () <<
1612 ", mode=" << txVector.
GetMode () <<
1614 ", duration=" << hdr.GetDuration () <<
1615 ", seq=0x" << std::hex << hdr.GetSequenceControl () << std::dec);
1658 if (mpdu->GetHeader ().IsQosData ())
1661 edcaIt->second->CompleteMpduTx (mpdu);
1675 busy = (*i)->IsBusy ();
1770 ForwardDown (Create<const WifiPsdu> (Create<Packet> (), rts), rtsTxVector);
1939 ForwardDown (Create<const WifiPsdu> (Create<Packet> (), cts), ctsTxVector);
1960 cts.SetDsNotFrom ();
1962 cts.SetNoMoreFragments ();
1964 cts.SetAddr1 (source);
1968 cts.SetDuration (duration);
1977 ForwardDown (Create<const WifiPsdu> (packet, cts), ctsTxVector);
1999 duration -= txDuration;
2002 duration =
std::max (duration, newDuration);
2075 ForwardDown (Create<const WifiPsdu> (packet, ack), ackTxVector);
2103 uint16_t delta = (seqNumber - (*it).second.first.GetWinEnd () + 4096) % 4096;
2105 uint16_t bufferSize = (*it).second.first.GetBufferSize ();
2106 uint16_t startingSeq = (seqNumber - bufferSize + 1 + 4096) % 4096;
2107 (*it).second.first.SetStartingSequence (startingSeq);
2127 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
2131 for (; i != (*it).second.second.end ()
2135 (*it).second.second.insert (i, mpdu);
2140 (*j).second.UpdateWithMpdu (&hdr);
2148 uint16_t startingSeq)
2151 uint8_t tid = respHdr->
GetTid ();
2166 std::list<Ptr<WifiMacQueueItem>> buffer (0);
2184 m_edca[ac], originator, tid,
false);
2210 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
2214 if (last != (*it).second.second.end ())
2216 guard = (*(*it).second.second.begin ())->GetHeader ().GetSequenceControl ();
2219 for (; i != (*it).second.second.end ()
2222 if (guard == (*i)->GetHeader ().GetSequenceControl ())
2224 if (!(*i)->GetHeader ().IsMoreFragments ())
2234 while (i != (*it).second.second.end () && guard == (*i)->GetHeader ().GetSequenceControl ())
2238 if (i != (*it).second.second.end ())
2240 guard = (*i)->GetHeader ().GetSequenceControl ();
2252 while (i != (*it).second.second.end () && guard == (*i)->GetHeader ().GetSequenceControl ())
2256 if (i != (*it).second.second.end ())
2258 guard = (*i)->GetHeader ().GetSequenceControl ();
2263 (*it).second.second.erase ((*it).second.second.begin (), i);
2273 uint16_t guard = (*it).second.first.GetStartingSequenceControl ();
2276 for (; i != (*it).second.second.end () && guard == (*i)->GetHeader ().GetSequenceControl (); i++)
2278 if (!(*i)->GetHeader ().IsMoreFragments ())
2280 while (lastComplete != i)
2288 guard = (*i)->GetHeader ().IsMoreFragments () ? (guard + 1) : ((guard + 16) & 0xfff0);
2290 (*it).second.first.SetStartingSequenceControl (guard);
2293 (*it).second.second.erase ((*it).second.second.begin (), lastComplete);
2299 Time duration,
WifiMode blockAckReqTxMode,
double rxSnr)
2342 ForwardDown (Create<const WifiPsdu> (packet, hdr), blockAckReqTxVector);
2353 uint16_t seqNumber = 0;
2356 seqNumber = (*i).second.GetWinStart ();
2358 bool immediate =
true;
2360 blockAck.SetStartingSequence (seqNumber);
2361 blockAck.SetTidInfo (tid);
2362 immediate = (*it).second.first.IsImmediateBlockAck ();
2363 if ((*it).second.first.GetBufferSize () > 64)
2371 NS_LOG_DEBUG (
"Got Implicit block Ack Req with seq " << seqNumber);
2372 (*i).second.FillBlockAckBitmap (&blockAck);
2386 Time duration,
WifiMode blockAckReqTxMode,
double rxSnr)
2391 bool immediate =
false;
2400 immediate = (*it).second.first.IsImmediateBlockAck ();
2415 (*i).second.FillBlockAckBitmap (&blockAck);
2440 NS_LOG_DEBUG (
"there's not a valid block ack agreement with " << originator);
2462 agreement.
GetTid (),
false);
2469 m_edca.insert (std::make_pair (ac, edca));
2476 bool normalAck =
false;
2481 if (ampduSubframe && !statusPerMpdu.empty ())
2486 ampduSubframe =
true;
2487 auto n = psdu->begin ();
2488 auto status = statusPerMpdu.begin ();
2489 NS_ABORT_MSG_IF (psdu->GetNMpdus () != statusPerMpdu.size (),
"Should have one receive status per MPDU");
2492 if (firsthdr.GetAddr1 () ==
m_self)
2495 for (;
n != psdu->end (); ++
n, ++status)
2497 firsthdr = (*n)->GetHeader ();
2498 NS_ABORT_MSG_IF (firsthdr.GetAddr1 () !=
m_self,
"All MPDUs of A-MPDU should have the same destination address");
2501 if (psdu->IsSingle ())
2505 ampduSubframe =
false;
2511 firsthdr.GetQosTid (),
2512 firsthdr.GetAddr2 (),
2513 firsthdr.GetDuration (),
2517 if (firsthdr.IsAck () || firsthdr.IsBlockAck () || firsthdr.IsBlockAckReq ())
2519 ReceiveOk ((*
n), rxSnr, txVector, ampduSubframe);
2521 else if (firsthdr.IsData () || firsthdr.IsQosData ())
2523 NS_LOG_DEBUG (
"Deaggregate packet from " << firsthdr.GetAddr2 () <<
" with sequence=" << firsthdr.GetSequenceNumber ());
2524 if (psdu->IsSingle ())
2526 ReceiveOk ((*
n), rxSnr, txVector, ampduSubframe);
2528 if (firsthdr.IsQosAck ())
2539 if (!psdu->IsSingle ())
2544 if (firsthdr.IsBlockAckReq ())
2546 NS_FATAL_ERROR (
"Sending a BlockAckReq with QosPolicy equal to Normal Ack");
2548 uint8_t tid = firsthdr.GetQosTid ();
2554 NS_LOG_DEBUG (
"rx A-MPDU/sendImmediateBlockAck from=" << firsthdr.GetAddr2 ());
2559 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
2571 ReceiveOk ((*psdu->begin ()), rxSnr, txVector, ampduSubframe);
2581 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.
void ScheduleBar(Ptr< const WifiMacQueueItem > bar, bool skipIfNoDataQueued=false)
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
bool IsStateOff(void) const
Ptr< const WifiMacQueueItem > PeekNextFrame(uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast())
Peek the next frame to transmit to the given receiver and of the given TID from the block ack manager...
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
bool IsSingle(void) const
Return true if the PSDU is an S-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 BlockAckRequest or a packet with Ack Policy equals to Block Ack are received...
EventId m_blockAckTimeoutEvent
BlockAck timeout event.
Time CalculateOverallTxTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters ¶ms, uint32_t fragmentSize=0) const
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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 BlockAckRequest has been received.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
bool ReceiveMpdu(Ptr< WifiMacQueueItem > mpdu)
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
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.
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)
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
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< QosTxop > GetEdca(uint8_t tid) const
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
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 NotifySwitchingStart(Time duration)
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...
void ReceiveError(Ptr< WifiPsdu > psdu)
U * PeekPointer(const Ptr< U > &p)
void Init(uint16_t winStart, uint16_t winSize)
Initialization function.
Time GetResponseDuration(const MacLowTransmissionParameters ¶ms, WifiTxVector dataTxVector, Mac48Address receiver) const
Return the time required to transmit the response frames (Ack or BAR+BA following the policy configur...
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.
void NotifyOffNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
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.
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...
Ptr< WifiAckPolicySelector > GetAckPolicySelector(void) const
Return the ack policy selector.
#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
Exactly equivalent to t > 0.
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.
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr, WifiTxVector dataTxVector, uint32_t packetSize)
Should be invoked whenever we receive the ACK associated to a data packet we just sent...
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.
Callback< R, Ts... > MakeNullCallback(void)
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.
std::list< Ptr< WifiMacQueueItem > >::iterator BufferedPacketI
buffered packet iterator typedef
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, double dataSnr, WifiTxVector dataTxVector)
Event handler when a BlockAck is received.
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.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
BlockAckCaches m_bAckCaches
block ack caches
uint32_t GetNextPacketSize(void) const
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode...
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.
WifiTxVector GetDataTxVector(const WifiMacHeader &header)
uint8_t GetNMcs(void) const
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
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 PHY 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...
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.
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)
bool IsZero(void) const
Exactly equivalent to t == 0.
Time m_lastBeacon
The time when the last beacon frame transmission started.
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)
void DeaggregateAmpduAndReceive(Ptr< WifiPsdu > aggregatedPacket, double rxSnr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
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.
void SetAmpduExist(Mac48Address dest, bool enableAmpdu)
Set indication whether A-MPDU is used to transmit data to a peer station.
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
void ReportRxOk(Mac48Address address, double rxSnr, WifiMode txMode)
virtual bool IsCfPeriod(void) const
This function indicates whether Simulator::Now is in the CF period.
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.
bool StoreMpduIfNeeded(Ptr< WifiMacQueueItem > mpdu)
Ptr< WifiRemoteStationManager > m_stationManager
Pointer to WifiRemoteStationManager (rate control)
void SetMac(const Ptr< WifiMac > mac)
Set up WifiMac associated with this MacLow.
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected without a context.
void SendDataAfterCts(Time duration)
Send Data after receiving CTS.
void RegisterEdcaForAc(AcIndex ac, Ptr< QosTxop > edca)
Agreements m_bAckAgreements
block ack agreements
void RegisterChannelAccessManager(Ptr< ChannelAccessManager > channelAccessManager)
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
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.
void RxStartIndication(WifiTxVector txVector, Time psduDuration)
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.
BlockAckType GetBlockAckRequestType(void) const
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...
void SetStartingSequence(uint16_t seq)
Set starting sequence number.
void BlockAckTimeout(void)
Event handler when BlockAck timeout occurs.
void NotifyCtsTimeoutStartNow(Time duration)
Notify ChannelAccessManager that CTS timer should be started for the given duration.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
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 SetAggregation(bool aggregation)
Sets if PSDU contains A-MPDU.
void SetBssid(Mac48Address ad)
Set the Basic Service Set Identification.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
EventId m_waitIfsEvent
Wait for IFS event.
void EnableAck(void)
Wait ACKTimeout for an Ack.
virtual void MissedBlockAck(uint8_t nMpdus)
Event handler when a BlockAck 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.
bool MustSendBlockAckRequest(void) const
#define PSDU_DURATION_SAFEGUARD
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)
Time m_cfpForeshortening
The delay the current CF period should be foreshortened.
void NotifyTxStart(Time duration, double txPowerDbm)
std::pair< BlockAckAgreement, std::list< Ptr< WifiMacQueueItem > > > AgreementValue
agreement value typedef
void SendBlockAckResponse(const CtrlBAckResponseHeader *blockAck, Mac48Address originator, bool immediate, Time duration, WifiMode blockAckReqTxMode, double rxSnr)
This method creates BlockAck 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 GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
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.
uint32_t GetBlockAckRequestSize(BlockAckType type)
Return the total BlockAckRequest size (including FCS trailer).
Ptr< MsduAggregator > GetMsduAggregator(void) const
Returns the aggregator used to construct A-MSDU subframes.
Time GetBlockAckRequestDuration(WifiTxVector blockAckReqTxVector, BlockAckType type) const
Return the time required to transmit the BlockAckRequest to the specified address given the TXVECTOR ...
void UpdateCurrentPacket(Ptr< WifiMacQueueItem > mpdu)
Update the current packet this QosTxop is trying to transmit.
bool GetCtsToSelfSupported(void) const
Return whether CTS-to-self capability is supported.
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).
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
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.
Ptr< WifiMacQueueItem > DequeuePeekedFrame(Ptr< const WifiMacQueueItem > peekedItem, WifiTxVector txVector, bool aggregate=true, uint32_t ampduSize=0, Time ppduDurationLimit=Time::Min())
Dequeue the frame that has been previously peeked by calling PeekNextFrame.
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
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 DoDispose(void)
Destructor implementation.
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 BlockAck frame given the destination and the mode of the Data used by the s...
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...
void ReceiveOk(Ptr< WifiMacQueueItem > mpdu, double rxSnr, WifiTxVector txVector, bool ampduSubframe)
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 BlockAck frame given the destination and the mode of the Data used by the s...
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
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.
virtual void GotAck(void)
Event handler when an Ack is received.
bool IsPositive(void) const
Exactly equivalent to t >= 0.
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 BlockAck size (including FCS trailer).
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const WifiMacQueueItem > PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
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().
Time GetSlot(void) const
Return the slot duration for this PHY.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
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 BlockAck to the specified address given the TXVECTOR of the ...
WifiTxVector GetRtsTxVector(Mac48Address address)
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 NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
void Send(Ptr< const WifiPsdu > psdu, WifiTxVector txVector)
void SetImmediateBlockAck(void)
Set block ack policy to immediate Ack.
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
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 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.
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...
void SetRxCallback(Callback< void, Ptr< WifiMacQueueItem >> callback)
PhyMacLowListener(ns3::MacLow *macLow)
Create a PhyMacLowListener for the given MacLow.
Time GetBeaconInterval(void) const
static Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
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.
void DisableAck(void)
Do not wait for Ack after data transmission.
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.
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.
uint8_t GetTid(void) const
Return the Traffic ID (TID).
bool IsStateRx(void) const
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Introspection did not find any typical Config paths.
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.
bool IsNegative(void) const
Exactly equivalent to t <= 0.
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.
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
static Time CalculatePhyPreambleAndHeaderDuration(WifiTxVector txVector)
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Time GetTxopLimit(void) const
Return the TXOP limit.