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;
540 if (hdr.IsQosData () && !hdr.GetAddr1 ().IsBroadcast ()
541 && !hdr.IsMoreFragments () && hdr.GetFragmentNumber () == 0)
544 uint8_t tid = hdr.GetQosTid ();
557 bool isPeeked = (tmp != 0 && tmp->GetPacket () == mpdu->GetPacket ());
588 std::vector<Ptr<WifiMacQueueItem>> mpduList;
594 if (mpduList.size () > 1)
598 NS_LOG_DEBUG (
"tx unicast A-MPDU containing " << mpduList.size () <<
" MPDUs");
607 NS_LOG_DEBUG (
"tx unicast S-MPDU with sequence number " << hdr.GetSequenceNumber ());
653 uint32_t ampduSize,
Time ppduDurationLimit)
655 NS_ASSERT (mpdu != 0 && mpdu->GetHeader ().IsQosData ());
658 mpdu->GetHeader ().GetQosTid (), txVector,
659 ampduSize, ppduDurationLimit);
666 NS_LOG_FUNCTION (
this << mpduSize << receiver << +tid << txVector << ampduSize << ppduDurationLimit);
675 uint32_t maxAmpduSize = 0;
678 maxAmpduSize =
GetMpduAggregator ()->GetMaxAmpduSize (receiver, tid, modulation);
682 NS_ASSERT (maxAmpduSize || ampduSize == 0);
684 uint32_t ppduPayloadSize = mpduSize;
689 ppduPayloadSize =
GetMpduAggregator ()->GetSizeIfAggregated (mpduSize, ampduSize);
692 if (maxAmpduSize > 0 && ppduPayloadSize > maxAmpduSize)
694 NS_LOG_DEBUG (
"the frame does not meet the constraint on max A-MPDU size");
706 NS_LOG_DEBUG (
"the frame does not meet the constraint on max PPDU duration");
718 <<
" us (txVector: " << txVector <<
")");
779 NS_LOG_DEBUG (
"switching channel. Cancelling MAC pending events");
795 NS_LOG_DEBUG (
"Device in sleep mode. Cancelling MAC pending events");
810 NS_LOG_DEBUG (
"Device is switched off. Cancelling MAC pending events");
871 else if (hdr.
IsCts ()
888 rxSnr, txVector.
GetMode (), tag.Get ());
897 else if (hdr.
IsAck ()
911 rxSnr, txVector.
GetMode (), tag.Get (),
996 if ((*it).second.first.IsImmediateBlockAck ())
1014 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
1022 else if (hdr.
IsCtl ())
1074 if (hdr.
IsQosAck () && !ampduSubframe)
1131 mpdu = Create<WifiMacQueueItem> (packet, hdr);
1133 if (hdr.
IsMgt () && ampduSubframe)
1135 NS_FATAL_ERROR (
"Received management packet as part of an A-MPDU");
1166 NS_FATAL_ERROR (
"Received group addressed packet as part of an A-MPDU");
1179 mpdu = Create<WifiMacQueueItem> (packet, hdr);
1374 NS_LOG_DEBUG (
"MacLow::GetControlAnswerMode returning " << mode);
1452 NS_LOG_DEBUG (
"MacLow::GetControlAnswerMode returning " << mode);
1520 uint32_t fragmentSize)
const 1525 if (fragmentSize > 0)
1547 txTime +=
GetCtsDuration (item->GetHeader ().GetAddr1 (), rtsTxVector);
1591 if (hdr.
IsRts () && navUpdated)
1604 Time navCounterResetCtsMissedDelay =
1621 (*i)->NotifyNavResetNow (duration);
1632 (*i)->NotifyNavStartNow (duration);
1636 if (newNavEnd > oldNavEnd)
1650 (*i)->NotifyAckTimeoutStartNow (duration);
1659 (*i)->NotifyAckTimeoutResetNow ();
1668 (*i)->NotifyCtsTimeoutStartNow (duration);
1677 (*i)->NotifyCtsTimeoutResetNow ();
1690 ", to=" << hdr.GetAddr1 () <<
1691 ", size=" << psdu->GetSize () <<
1692 ", mode=" << txVector.
GetMode () <<
1694 ", duration=" << hdr.GetDuration () <<
1695 ", seq=0x" << std::hex << hdr.GetSequenceControl () << std::dec);
1721 if (psdu->IsSingle ())
1726 else if (psdu->IsAggregate ())
1738 if (mpdu->GetHeader ().IsQosData ())
1741 edcaIt->second->CompleteMpduTx (mpdu);
1755 busy = (*i)->IsBusy ();
1850 ForwardDown (Create<const WifiPsdu> (Create<Packet> (), rts), rtsTxVector);
1886 Time delay = txDuration;
1900 Time delay = txDuration;
2042 ForwardDown (Create<const WifiPsdu> (Create<Packet> (), cts), ctsTxVector);
2063 cts.SetDsNotFrom ();
2065 cts.SetNoMoreFragments ();
2067 cts.SetAddr1 (source);
2071 cts.SetDuration (duration);
2080 ForwardDown (Create<const WifiPsdu> (packet, cts), ctsTxVector);
2109 duration -= txDuration;
2112 duration =
std::max (duration, newDuration);
2185 ForwardDown (Create<const WifiPsdu> (packet, ack), ackTxVector);
2213 uint16_t delta = (seqNumber - (*it).second.first.GetWinEnd () + 4096) % 4096;
2215 uint16_t bufferSize = (*it).second.first.GetBufferSize ();
2216 uint16_t startingSeq = (seqNumber - bufferSize + 1 + 4096) % 4096;
2217 (*it).second.first.SetStartingSequence (startingSeq);
2237 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
2241 for (; i != (*it).second.second.end ()
2245 (*it).second.second.insert (i, mpdu);
2250 (*j).second.UpdateWithMpdu (&hdr);
2258 uint16_t startingSeq)
2261 uint8_t tid = respHdr->
GetTid ();
2276 std::list<Ptr<WifiMacQueueItem>> buffer (0);
2294 m_edca[ac], originator, tid,
false);
2320 uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
2324 if (last != (*it).second.second.end ())
2326 guard = (*(*it).second.second.begin ())->GetHeader ().GetSequenceControl ();
2329 for (; i != (*it).second.second.end ()
2332 if (guard == (*i)->GetHeader ().GetSequenceControl ())
2334 if (!(*i)->GetHeader ().IsMoreFragments ())
2344 while (i != (*it).second.second.end () && guard == (*i)->GetHeader ().GetSequenceControl ())
2348 if (i != (*it).second.second.end ())
2350 guard = (*i)->GetHeader ().GetSequenceControl ();
2362 while (i != (*it).second.second.end () && guard == (*i)->GetHeader ().GetSequenceControl ())
2366 if (i != (*it).second.second.end ())
2368 guard = (*i)->GetHeader ().GetSequenceControl ();
2373 (*it).second.second.erase ((*it).second.second.begin (), i);
2383 uint16_t guard = (*it).second.first.GetStartingSequenceControl ();
2386 for (; i != (*it).second.second.end () && guard == (*i)->GetHeader ().GetSequenceControl (); i++)
2388 if (!(*i)->GetHeader ().IsMoreFragments ())
2390 while (lastComplete != i)
2398 guard = (*i)->GetHeader ().IsMoreFragments () ? (guard + 1) : ((guard + 16) & 0xfff0);
2400 (*it).second.first.SetStartingSequenceControl (guard);
2403 (*it).second.second.erase ((*it).second.second.begin (), lastComplete);
2409 Time duration,
WifiMode blockAckReqTxMode,
double rxSnr)
2452 ForwardDown (Create<const WifiPsdu> (packet, hdr), blockAckReqTxVector);
2463 uint16_t seqNumber = 0;
2466 seqNumber = (*i).second.GetWinStart ();
2468 bool immediate =
true;
2470 blockAck.SetStartingSequence (seqNumber);
2471 blockAck.SetTidInfo (tid);
2472 immediate = (*it).second.first.IsImmediateBlockAck ();
2473 if ((*it).second.first.GetBufferSize () > 64)
2481 NS_LOG_DEBUG (
"Got Implicit block Ack Req with seq " << seqNumber);
2482 (*i).second.FillBlockAckBitmap (&blockAck);
2496 Time duration,
WifiMode blockAckReqTxMode,
double rxSnr)
2501 bool immediate =
false;
2510 immediate = (*it).second.first.IsImmediateBlockAck ();
2525 (*i).second.FillBlockAckBitmap (&blockAck);
2550 NS_LOG_DEBUG (
"there's not a valid block ack agreement with " << originator);
2572 agreement.
GetTid (),
false);
2579 m_edca.insert (std::make_pair (ac, edca));
2586 bool normalAck =
false;
2587 bool ampduSubframe =
false;
2591 ampduSubframe =
true;
2592 auto n = psdu->begin ();
2593 auto status = statusPerMpdu.begin ();
2594 NS_ABORT_MSG_IF (psdu->GetNMpdus () != statusPerMpdu.size (),
"Should have one receive status per MPDU");
2597 NS_LOG_DEBUG (
"duration/id=" << firsthdr.GetDuration ());
2598 NotifyNav ((*n)->GetPacket (), firsthdr);
2600 if (firsthdr.GetAddr1 () ==
m_self)
2603 for (;
n != psdu->end (); ++
n, ++status)
2605 firsthdr = (*n)->GetHeader ();
2606 NS_ABORT_MSG_IF (firsthdr.GetAddr1 () !=
m_self,
"All MPDUs of A-MPDU should have the same destination address");
2609 if (psdu->IsSingle ())
2613 ampduSubframe =
false;
2619 firsthdr.GetQosTid (),
2620 firsthdr.GetAddr2 (),
2621 firsthdr.GetDuration (),
2625 if (firsthdr.IsAck () || firsthdr.IsBlockAck () || firsthdr.IsBlockAckReq ())
2627 ReceiveOk ((*
n), rxSnr, txVector, ampduSubframe);
2629 else if (firsthdr.IsData () || firsthdr.IsQosData ())
2631 NS_LOG_DEBUG (
"Deaggregate packet from " << firsthdr.GetAddr2 () <<
" with sequence=" << firsthdr.GetSequenceNumber ());
2632 ReceiveOk ((*
n), rxSnr, txVector, ampduSubframe);
2633 if (firsthdr.IsQosAck ())
2644 if (!psdu->IsSingle ())
2649 if (firsthdr.IsBlockAckReq ())
2651 NS_FATAL_ERROR (
"Sending a BlockAckReq with QosPolicy equal to Normal Ack");
2653 uint8_t tid = firsthdr.GetQosTid ();
2659 NS_LOG_DEBUG (
"rx A-MPDU/sendImmediateBlockAck from=" << firsthdr.GetAddr2 ());
2664 NS_LOG_DEBUG (
"There's not a valid agreement for this block ack request.");
2676 ReceiveOk ((*psdu->begin ()), rxSnr, txVector, ampduSubframe);
2686 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 ScheduleBar(Ptr< const WifiMacQueueItem > bar, bool skipIfNoDataQueued=false)
void SetPifs(Time pifs)
Set PCF Interframe Space (PIFS) of this MacLow.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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 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 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)
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
static Time Min()
Minimum representable 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.
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< QosTxop > GetEdca(uint8_t tid) const
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)
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
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...
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.
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.
void SetBasicBlockAckTimeout(Time blockAckTimeout)
Set Basic BlockAck 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.
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...
static 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 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)
Time m_lastBeacon
The time when the last beacon frame transmission started.
Time GetCompressedBlockAckTimeout(void) const
Return Compressed BlockAck 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)
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.
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.
bool StoreMpduIfNeeded(Ptr< WifiMacQueueItem > mpdu)
WifiMode GetMode(void) const
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
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.
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 refer to IEEE 802.11n Table 20-28 for explanation and range.
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.
Time GetAckTimeout(void) const
Return Ack timeout of this MacLow.
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.
Time GetBasicBlockAckTimeout(void) const
Return Basic BlockAck 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 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 m_ackTimeout
Ack timeout duration.
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 ...
Time m_basicBlockAckTimeout
Basic BlockAck timeout duration.
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.
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.
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 SetRifs(Time rifs)
Set Reduced Interframe Space (RIFS) of this MacLow.
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...
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 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().
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.
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
Time m_compressedBlockAckTimeout
Compressed BlockAck 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.
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
Time m_rifs
Reduced Interframe Space (RIFS) duration.
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
void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Set Compressed BlockAck 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.
static Time CalculatePhyPreambleAndHeaderDuration(WifiTxVector txVector)
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Time GetGuardInterval(void) const
Time GetTxopLimit(void) const
Return the TXOP limit.