|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/abort.h"
29 #undef NS_LOG_APPEND_CONTEXT
30 #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] "
35 #define PSDU_DURATION_SAFEGUARD 400
48 .AddConstructor<FrameExchangeManager> ()
49 .SetGroupName (
"Wifi")
57 m_moreFragments (false)
235 <<
" (txVector: " << txVector <<
")");
238 "The TX timer and the NAV reset event cannot be both running");
275 if (queue->IsEmpty ())
326 else if (
m_mac->GetWifiRemoteStationManager ()->NeedFragmentation (mpdu))
338 m_mac->GetTxopQueue (ac)->PushFront (item);
427 NS_ABORT_MSG (
"Unable to handle the selected acknowledgment method ("
446 m_phy->
Send (Create<WifiPsdu> (mpdu,
false), txVector);
454 if (mpdu->IsQueued ())
456 m_mac->GetTxopQueue (mpdu->GetQueueAc ())->DequeueIfQueued (mpdu);
527 NS_LOG_FUNCTION (
this << header << size << &txParams << fragmentedPacket);
538 uint32_t nextFragmentSize =
std::min (fragmentedPacket->
GetSize () - nextFragmentOffset,
556 ctsTxVector =
m_mac->GetWifiRemoteStationManager ()->GetCtsTxVector (
m_self, rtsTxVector.
GetMode ());
646 Time txDuration,
Time response)
const
749 NS_LOG_DEBUG (
"Schedule transmission of next fragment in a SIFS");
774 m_mac->GetWifiRemoteStationManager ()->ReportDataFailed (mpdu);
776 if (!
m_mac->GetWifiRemoteStationManager ()->NeedRetransmission (mpdu))
782 m_mac->GetWifiRemoteStationManager ()->ReportFinalDataFailed (mpdu);
810 if (!
m_mac->GetWifiRemoteStationManager ()->NeedRetransmission (
m_mpdu))
862 m_mac->GetWifiRemoteStationManager ()->ReportDataFailed (mpdu);
864 if (!mpdu->GetHeader ().GetAddr1 ().IsGroup ()
865 && !
m_mac->GetWifiRemoteStationManager ()->NeedRetransmission (mpdu))
868 m_mac->GetWifiRemoteStationManager ()->ReportFinalDataFailed (mpdu);
880 txop->Txop::NotifyChannelReleased ();
886 NS_LOG_DEBUG (
"Switching channel. Cancelling MAC pending events");
887 m_mac->GetWifiRemoteStationManager ()->Reset ();
894 NS_LOG_DEBUG (
"Device in sleep mode. Cancelling MAC pending events");
901 NS_LOG_DEBUG (
"Device is switched off. Cancelling MAC pending events");
909 NS_LOG_FUNCTION (
this << psdu << rxSignalInfo << txVector << perMpduStatus.size ()
910 << std::all_of (perMpduStatus.begin(), perMpduStatus.end(), [](
bool v) { return v; }));
912 if (!perMpduStatus.empty ())
934 NS_ASSERT (perMpduStatus.empty () || (perMpduStatus.size () == 1 && perMpduStatus[0]));
939 rxSignalInfo, txVector);
941 ReceiveMpdu (*(psdu->
begin ()), rxSignalInfo, txVector, perMpduStatus.empty ());
1026 NS_LOG_FUNCTION (
this << *mpdu << rxSignalInfo << txVector << inAmpdu);
1031 double rxSnr = rxSignalInfo.
snr;
1048 this, hdr, txVector.
GetMode (), rxSnr);
1066 m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxSignalInfo, txVector);
1084 else if (hdr.
IsMgt ())
1086 NS_ABORT_MSG_IF (inAmpdu,
"Received management frame as part of an A-MPDU");
1095 mpdu = Create<WifiMacQueueItem> (packet, hdr);
1102 this, hdr, txVector, rxSnr);
1113 this, hdr, txVector, rxSnr);
1133 m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxInfo, ackTxVector);
1134 m_mac->GetWifiRemoteStationManager ()->ReportDataOk (mpdu, rxInfo.
snr, ackTxVector.
GetMode (),
1173 const WifiTxVector& txVector,
const std::vector<bool>& perMpduStatus)
1175 NS_ASSERT_MSG (
false,
"A non-QoS station should not receive an A-MPDU");
virtual void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const
Calculate the time required to acknowledge a frame according to the given acknowledgment method.
a unique identifier for an interface.
virtual void RetransmitMpduAfterMissedAck(Ptr< WifiMacQueueItem > mpdu) const
Retransmit an MPDU that was not acknowledged.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual void SetChannelAccessManager(const Ptr< ChannelAccessManager > channelAccessManager)
Set the channel access manager to use.
Time acknowledgmentTime
time required by the acknowledgment method
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,...
Ptr< const Packet > GetPacket(void) const
Get the packet stored in this item.
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
virtual void NotifyInternalCollision(Ptr< Txop > txop)
Notify that an internal collision has occurred for the given Txop.
bool m_moreFragments
true if a fragment has to be sent after a SIFS
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 void ResetPhy(void)
Remove WifiPhy associated with this FrameExchangeManager.
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.
Time GetDuration(void) const
Get the duration from the Duration/ID field, which is common to all the MPDUs.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions.
virtual void SetMacTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set the MAC TX Middle to use.
Time GetSlot(void) const
Return the slot duration for this PHY.
Time m_txDuration
TX duration of the frame.
WifiRtsCtsProtection specifies that RTS/CTS protection method is used.
const Method method
protection method
const PsduInfoMap & GetPsduInfoMap(void) const
Get a const reference to the map containing information about PSDUs.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
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.
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
bool IsNull(void) const
Check for null implementation.
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected without a context.
bool IsRunning(void) const
Return true if the timer is running.
virtual void CalculateProtectionTime(WifiProtection *protection) const
Calculate the time required to protect a frame according to the given protection method.
Ptr< WifiProtectionManager > m_protectionManager
Protection manager.
@ WIFI_MAC_DROP_REACHED_RETRY_LIMIT
void SendCtsToSelf(const WifiTxParameters &txParams)
Send CTS for a CTS-to-self mechanism.
virtual void NavResetTimeout(void)
Reset the NAV upon expiration of the NAV reset timer.
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
virtual void UpdateNav(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Update the NAV, if needed, based on the Duration/ID of the given psdu.
uint32_t GetSize(Mac48Address receiver) const
Get the size in bytes of the (A-)MPDU addressed to the given receiver.
AcIndex GetQueueAc(void) const
Get the AC of the queue this item is stored into.
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Ptr< WifiMacQueueItem > GetNextFragment(void)
Get the next fragment of the current MSDU.
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...
WifiTxVector ctsTxVector
CTS TXVECTOR.
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
virtual void CtsTimeout(Ptr< WifiMacQueueItem > rts, const WifiTxVector &txVector)
Called when the CTS timeout expires.
void NotifyOffNow(void)
This method is typically invoked by the PhyListener to notify the MAC layer that the device has been ...
uint32_t GetPacketSize(void) const
Return the size in bytes of the packet or control header or management header stored by this item.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
void SetReceiveOkCallback(RxOkCallback callback)
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...
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
virtual void SetMacRxMiddle(const Ptr< MacRxMiddle > rxMiddle)
Set the MAC RX Middle to use.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void NotifySleepNow(void)
This method is typically invoked by the PhyListener to notify the MAC layer that the device has been ...
AckedMpdu m_ackedMpduCallback
the acknowledged MPDU callback
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
virtual void NotifyChannelAccessed(Time txopDuration=Seconds(0))
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
WifiTxVector ackTxVector
Ack TXVECTOR.
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
std::unique_ptr< WifiProtection > m_protection
protection method
Callback< R, Ts... > MakeNullCallback(void)
void DoSendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiTxVector &ctsTxVector, double rtsSnr)
Send CTS after receiving RTS.
void SetAckedMpduCallback(AckedMpdu callback)
Set the callback to invoke when an MPDU is successfully acked.
virtual void NotifyPacketDiscarded(Ptr< const WifiMacQueueItem > mpdu)
Pass the given MPDU, discarded because of the max retry limit was reached, to the MPDU dropped callba...
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.
uint32_t GetAckSize(void)
Return the total Ack size (including FCS trailer).
void SendRts(const WifiTxParameters &txParams)
Send RTS to begin RTS-CTS-Data-Ack transaction.
Smart pointer class similar to boost::intrusive_ptr.
virtual void TransmissionSucceeded(void)
Take necessary actions upon a transmission success.
void Receive(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > perMpduStatus)
This method is intended to be called by the PHY layer every time an MPDU is received and also when th...
WifiTxVector ctsTxVector
CTS TXVECTOR.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
WifiTxParameters m_txParams
the TX parameters for the current frame
represent a single transmission mode
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
bool IsPromisc(void) const
Check if the device is operating in promiscuous mode.
virtual void SetWifiMac(const Ptr< RegularWifiMac > mac)
Set the MAC layer to use.
A base class which provides memory management and object aggregation.
void Reschedule(const Time &delay)
Reschedule the timer to time out the given amount of time from the moment this function is called.
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Set the callback to invoke when an MPDU is dropped.
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...
virtual void SetAddress(Mac48Address address)
Set the MAC address.
Time protectionTime
time required by the protection method
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< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
WifiNormalAck specifies that acknowledgment via Normal Ack is required.
void Clear(void)
Reset the TX parameters.
WifiTxVector rtsTxVector
RTS TXVECTOR.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Ptr< WifiMacQueueItem > m_mpdu
the MPDU being transmitted
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
Set the PHY layer to use.
Simulation virtual time values and global simulation resolution.
void SetPromisc(void)
Enable promiscuous mode.
#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...
WifiProtection is an abstract base struct.
virtual void Reset(void)
Reset this frame exchange manager.
void Set(double snr)
Set the SNR to the given value.
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.
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
Introspection did not find any typical Config paths.
virtual void DequeueMpdu(Ptr< const WifiMacQueueItem > mpdu)
Dequeue the given MPDU from the queue in which it is stored.
virtual bool StartTransmission(Ptr< Txop > dcf)
Request the FrameExchangeManager to start a frame exchange sequence.
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...
static void SetQosAckPolicy(Ptr< WifiMacQueueItem > item, const WifiAcknowledgment *acknowledgment)
Set the QoS Ack policy for the given MPDU, which must be a QoS data frame.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
EventId m_navResetEvent
the event to reset the NAV after an RTS
void NotifySwitchingStartNow(Time duration)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
Ptr< WifiAckManager > m_ackManager
Acknowledgment manager.
bool IsStrictlyNegative(void) const
Exactly equivalent to t < 0.
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...
bool IsQueued(void) const
Return true if this item is stored in some queue, false otherwise.
Ptr< MacTxMiddle > m_txMiddle
the MAC TX Middle on this station
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.
Time GetTimeStamp(void) const
Get the timestamp included in this item.
RxSignalInfo structure containing info on the received signal.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool m_promisc
Flag if the device is operating in promiscuous mode.
WifiAcknowledgment is an abstract base struct.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
virtual void NotifyReceivedNormalAck(Ptr< WifiMacQueueItem > mpdu)
Notify other components that an MPDU was acknowledged.
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
Mac48Address m_bssid
BSSID address (Mac48Address)
double Get(void) const
Return the SNR value.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
#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.
void DoDispose() override
Destructor implementation.
Reason GetReason(void) const
Get the reason why the timer was started.
void RxStartIndication(WifiTxVector txVector, Time psduDuration)
virtual void RetransmitMpduAfterMissedCts(Ptr< WifiMacQueueItem > mpdu) const
Retransmit an MPDU that was not sent because a CTS was not received.
void SendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiMode rtsTxMode, double rtsSnr)
Send CTS after receiving RTS.
void AddMpdu(Ptr< const WifiMacQueueItem > mpdu)
Record that an MPDU is being added to the current frame.
virtual ~FrameExchangeManager()
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
bool IsFragment(void) const
Return true if this item contains an MSDU fragment, false otherwise.
const WifiTxTimer & GetWifiTxTimer(void) const
Get a const reference to the WifiTxTimer object.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
virtual void EndReceiveAmpdu(Ptr< const WifiPsdu > psdu, const RxSignalInfo &rxSignalInfo, const WifiTxVector &txVector, const std::vector< bool > &perMpduStatus)
This method is called when the reception of an A-MPDU including multiple MPDUs is completed.
virtual void ReceivedNormalAck(Ptr< WifiMacQueueItem > mpdu, const WifiTxVector &txVector, const WifiTxVector &ackTxVector, const RxSignalInfo &rxInfo, double snr)
Perform the actions needed when a Normal Ack is received.
uint32_t GetSize(void) const
Return the size of the packet stored by this item, including header size and trailer size.
const Method method
acknowledgment method
virtual void SetBssid(Mac48Address bssid)
Set the Basic Service Set Identification.
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 Set(Reason reason, const Time &delay, MEM mem_ptr, OBJ obj, Args... args)
This method is called when a frame soliciting a response is transmitted.
void SendMpdu(void)
Send the current MPDU, which can be acknowledged by a Normal Ack.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Packet > m_fragmentedPacket
the MSDU being fragmented
virtual void DoDispose(void)
Destructor implementation.
void Cancel(void)
Cancel the timer.
This class is used to handle the timer that a station starts when transmitting a frame that solicits ...
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.
WifiCtsToSelfProtection specifies that CTS-to-self protection method is used.
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.
void NormalAckTimeout(Ptr< WifiMacQueueItem > mpdu, const WifiTxVector &txVector)
Called when the Ack timeout expires.
Ptr< Txop > m_dcf
the DCF/EDCAF that gained channel access
#define PSDU_DURATION_SAFEGUARD
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.