|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/abort.h"
28 #undef NS_LOG_APPEND_CONTEXT
29 #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] "
40 static TypeId tid =
TypeId (
"ns3::QosFrameExchangeManager")
42 .AddConstructor<QosFrameExchangeManager> ()
43 .SetGroupName (
"Wifi")
44 .AddAttribute (
"PifsRecovery",
45 "Perform a PIFS recovery as a response to transmission failure "
50 .AddAttribute (
"SetQueueSize",
51 "Whether to set the Queue Size subfield of the QoS Control field "
52 "of QoS data frames sent by non-AP stations",
61 : m_initialFrame (false)
107 m_phy->
Send (Create<WifiPsdu> (Create<Packet> (), cfEnd), cfEndTxVector);
278 txParams.
m_txVector =
m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (mpdu->GetHeader ());
290 "We should not get an A-MSDU here");
311 Time availableTime)
const
323 std::unique_ptr<WifiProtection> protection;
325 bool protectionSwapped =
false;
331 protectionTime = protection->protectionTime;
335 protectionSwapped =
true;
347 std::unique_ptr<WifiAcknowledgment> acknowledgment;
348 acknowledgment =
GetAckManager ()->TryAddMpdu (mpdu, txParams);
349 bool acknowledgmentSwapped =
false;
355 acknowledgmentTime = acknowledgment->acknowledgmentTime;
359 acknowledgmentSwapped =
true;
362 NS_LOG_DEBUG (
"acknowledgment time=" << acknowledgmentTime);
367 ppduDurationLimit = availableTime - protectionTime - acknowledgmentTime;
374 if (protectionSwapped)
378 if (acknowledgmentSwapped)
395 Time ppduDurationLimit)
const
403 txParams, ppduDurationLimit);
409 Time ppduDurationLimit)
const
411 NS_LOG_FUNCTION (
this << ppduPayloadSize << receiver << &txParams << ppduDurationLimit);
415 NS_LOG_DEBUG (
"ppduDurationLimit is null or negative, time limit is trivially exceeded");
434 NS_LOG_DEBUG (
"the frame does not meet the constraint on max PPDU duration or PPDU duration limit");
446 NS_LOG_FUNCTION (
this << header << size << &txParams << fragmentedPacket);
495 Time txDuration,
Time response)
const
551 NS_LOG_DEBUG (
"Schedule another transmission in a SIFS");
581 NS_LOG_DEBUG (
"TX of the initial frame of a TXOP failed: terminate TXOP");
588 "Cannot transmit more than one frame if TXOP Limit is zero");
597 NS_LOG_DEBUG (
"TX of a non-initial frame of a TXOP failed: perform PIFS recovery");
606 NS_LOG_DEBUG (
"TX of a non-initial frame of a TXOP failed: invoke backoff");
607 m_edca->Txop::NotifyChannelReleased ();
666 double rxSnr = rxSignalInfo.
snr;
689 this, hdr, txVector.
GetMode (), rxSnr);
704 this, hdr, txVector, rxSnr);
virtual void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const
Calculate the time required to acknowledge a frame according to the given acknowledgment method.
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool m_setQosQueueSize
whether to set the Queue Size subfield of the QoS Control field of QoS data frames
WifiTxTimer m_txTimer
the timer set upon frame transmission
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
virtual void ReceiveMpdu(Ptr< WifiMacQueueItem > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu)
This method handles the reception of an MPDU (possibly included in an A-MPDU)
Ptr< WifiPhy > m_phy
the PHY layer on this station
void ForwardMpduDown(Ptr< WifiMacQueueItem > mpdu, WifiTxVector &txVector) override
Forward an MPDU down to the PHY layer.
AttributeValue implementation for Boolean.
uint32_t GetRtsSize(void)
Return the total RTS size (including FCS trailer).
Mac48Address GetAddr1(void) const
Get the Receiver Address (RA), which is common to all the MPDUs.
virtual Time GetRtsDurationId(const WifiTxVector &rtsTxVector, Time txDuration, Time response) const
Compute how to set the Duration/ID field of an RTS frame to send to protect a frame transmitted with ...
void SendNormalAck(const WifiMacHeader &hdr, const WifiTxVector &dataTxVector, double dataSnr)
Send Normal Ack.
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions.
bool IsNegative(void) const
Exactly equivalent to t <= 0.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
bool m_initialFrame
true if transmitting the initial frame of a TXOP
void TransmissionFailed(void) override
Take necessary actions upon a transmission failure.
bool IsRunning(void) const
Return true if the timer is running.
virtual bool IsWithinSizeAndTimeLimits(uint32_t ppduPayloadSize, Mac48Address receiver, const WifiTxParameters &txParams, Time ppduDurationLimit) const
Check whether the transmission time of the frame being built (as described by the given TX parameters...
virtual void CalculateProtectionTime(WifiProtection *protection) const
Calculate the time required to protect a frame according to the given protection method.
void TransmissionSucceeded(void) override
Take necessary actions upon a transmission success.
Time GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
virtual void NavResetTimeout(void)
Reset the NAV upon expiration of the NAV reset timer.
void ReceiveMpdu(Ptr< WifiMacQueueItem > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu) override
This method handles the reception of an MPDU (possibly included in an A-MPDU)
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
virtual ~QosFrameExchangeManager()
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
virtual bool StartFrameExchange(Ptr< QosTxop > edca, Time availableTime, bool initialFrame)
Start a frame exchange (including protection frames and acknowledgment frames as needed) that fits wi...
bool StartTransmission(Ptr< Txop > edca) override
Request the FrameExchangeManager to start a frame exchange sequence.
Ptr< const WifiMacQueueItem > PeekNextMpdu(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...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Mac48Address m_self
the MAC address of this device
virtual Time GetCtsToSelfDurationId(const WifiTxVector &ctsTxVector, Time txDuration, Time response) const
Compute how to set the Duration/ID field of a CTS-to-self frame to send to protect a frame transmitte...
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
Time GetTxopLimit(void) const
Return the TXOP limit.
U * PeekPointer(const Ptr< U > &p)
void NotifyChannelAccessed(Time txopDuration) override
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
std::unique_ptr< WifiProtection > m_protection
protection method
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 DoDispose() override
Destructor implementation.
Ptr< WifiMacQueueItem > GetFirstFragmentIfNeeded(Ptr< WifiMacQueueItem > mpdu)
Fragment the given MPDU if needed.
Ptr< WifiProtectionManager > GetProtectionManager(void) const
Get the Protection Manager used by this node.
void CancelPifsRecovery(void)
Cancel the PIFS recovery event and have the EDCAF attempting PIFS recovery release the channel.
virtual void TransmissionSucceeded(void)
Take necessary actions upon a transmission success.
static Mac48Address GetBroadcast(void)
std::list< Ptr< WifiMacQueueItem > >::const_iterator ConstIterator
Const iterator typedef.
QosFrameExchangeManager handles the frame exchange sequences for QoS stations.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
WifiModulationClass GetModulationClass(void) const
Get the modulation class specified by this TXVECTOR.
Mac48Address m_txopHolder
MAC address of the TXOP holder.
bool m_pifsRecovery
true if performing a PIFS recovery after failure
Ptr< QosTxop > m_edca
the EDCAF that gained channel access
void PreProcessFrame(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) override
Perform actions that are possibly needed when receiving any frame, independently of whether the frame...
Time GetRtsDurationId(const WifiTxVector &rtsTxVector, Time txDuration, Time response) const override
Compute how to set the Duration/ID field of an RTS frame to send to protect a frame transmitted with ...
bool IsZero(void) const
Exactly equivalent to t == 0.
virtual Time GetTxDuration(uint32_t ppduPayloadSize, Mac48Address receiver, const WifiTxParameters &txParams) const
Get the updated TX duration of the frame associated with the given TX parameters if the size of the P...
Ptr< MacRxMiddle > m_rxMiddle
the MAC RX Middle on this station
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
WifiPreamble GetPreambleType(void) const
Time GetFrameDurationId(const WifiMacHeader &header, uint32_t size, const WifiTxParameters &txParams, Ptr< Packet > fragmentedPacket) const override
Compute how to set the Duration/ID field of a frame being transmitted with the given TX parameters.
Simulation virtual time values and global simulation resolution.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
virtual bool IsQosTxop() const
Check for QoS TXOP.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual Time GetFrameDurationId(const WifiMacHeader &header, uint32_t size, const WifiTxParameters &txParams, Ptr< Packet > fragmentedPacket) const
Compute how to set the Duration/ID field of a frame being transmitted with the given TX parameters.
Time m_navEnd
NAV expiration time.
Ptr< WifiAckManager > GetAckManager(void) const
Get the Acknowledgment Manager used by this node.
void PifsRecovery(void)
Perform a PIFS recovery as a response to transmission failure within a TXOP.
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
virtual void SetTxopHolder(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Set the TXOP holder, if needed, based on the received frame.
virtual bool StartTransmission(Ptr< Txop > dcf)
Request the FrameExchangeManager to start a frame exchange sequence.
virtual bool IsWithinLimitsIfAddMpdu(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams, Time ppduDurationLimit) const
Check whether the given MPDU can be added to the frame being built (as described by the given TX para...
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
EventId m_pifsRecoveryEvent
event associated with an attempt of PIFS recovery
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
void UpdateTxDuration(Mac48Address receiver, WifiTxParameters &txParams) const
Update the TX duration field of the given TX parameters after that the PSDU addressed to the given re...
Mac48Address GetAddr2(void) const
Get the Transmitter Address (TA), which is common to all the MPDUs.
double snr
SNR in linear scale.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
Ptr< WifiMacQueueItem > GetNextMpdu(Ptr< const WifiMacQueueItem > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame, WifiMacQueueItem::ConstIterator &queueIt)
Prepare the frame to transmit starting from the MPDU that has been previously peeked by calling PeekN...
RxSignalInfo structure containing info on the received signal.
Time Seconds(double value)
Construct a Time in the indicated unit.
void NotifyChannelReleased(void) override
Called by the FrameExchangeManager to notify the completion of the transmissions.
static TypeId GetTypeId(void)
Get the type ID.
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
void SendMpduWithProtection(Ptr< WifiMacQueueItem > mpdu, WifiTxParameters &txParams)
Send an MPDU with the given TX parameters (with the specified protection).
Ptr< RegularWifiMac > m_mac
the MAC layer on this station
QosFrameExchangeManager()
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
virtual void TransmissionFailed(void)
Take necessary actions upon a transmission failure.
virtual void ForwardMpduDown(Ptr< WifiMacQueueItem > mpdu, WifiTxVector &txVector)
Forward an MPDU down to the PHY layer.
Ptr< Txop > m_edcaBackingOff
channel access function that invoked backoff during TXOP
void DoDispose() override
Destructor implementation.
bool TryAddMpdu(Ptr< const WifiMacQueueItem > mpdu, WifiTxParameters &txParams, Time availableTime) const
Recompute the protection and acknowledgment methods to use if the given MPDU is added to the frame be...
void SendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiMode rtsTxMode, double rtsSnr)
Send CTS after receiving RTS.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
virtual bool SendCfEndIfNeeded(void)
Send a CF-End frame to indicate the completion of the TXOP, provided that the remaining duration is l...
void AddMpdu(Ptr< const WifiMacQueueItem > mpdu)
Record that an MPDU is being added to the current frame.
bool IsFragment(void) const
Return true if this item contains an MSDU fragment, false otherwise.
uint32_t GetSize(void) const
Return the size of the packet stored by this item, including header size and trailer size.
Time GetCtsToSelfDurationId(const WifiTxVector &ctsTxVector, Time txDuration, Time response) const override
Compute how to set the Duration/ID field of a CTS-to-self frame to send to protect a frame transmitte...
uint32_t GetCtsSize(void)
Return the total CTS size (including FCS trailer).
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
virtual void PreProcessFrame(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Perform actions that are possibly needed when receiving any frame, independently of whether the frame...
void Cancel(void)
Cancel the timer.
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument.
virtual bool IsTxopStarted(void) const
Return true if a TXOP has started.
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.
Ptr< Txop > m_dcf
the DCF/EDCAF that gained channel access
virtual Time GetRemainingTxop(void) const
Return the remaining duration in the current TXOP.