A Discrete-Event Network Simulator
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Stefano Avallone <stavallo@unina.it>
19 */
24#include "ns3/object.h"
25#include "qos-txop.h"
26#include "wifi-tx-vector.h"
27#include "wifi-psdu.h"
28#include "wifi-mac.h"
29#include "mac-rx-middle.h"
30#include "mac-tx-middle.h"
31#include "wifi-phy.h"
32#include "wifi-tx-timer.h"
33#include "wifi-tx-parameters.h"
34// Needed to compile wave bindings
35#include "ns3/wifi-protection-manager.h"
36#include "ns3/wifi-ack-manager.h"
39namespace ns3 {
41struct RxSignalInfo;
42struct WifiProtection;
43struct WifiAcknowledgment;
58 static TypeId GetTypeId (void);
60 virtual ~FrameExchangeManager ();
79 virtual bool StartTransmission (Ptr<Txop> dcf, uint16_t allowedWidth);
92 void Receive (Ptr<const WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
93 WifiTxVector txVector, std::vector<bool> perMpduStatus);
100 void SetLinkId (uint8_t linkId);
106 virtual void SetWifiMac (const Ptr<WifiMac> mac);
112 virtual void SetMacTxMiddle (const Ptr<MacTxMiddle> txMiddle);
118 virtual void SetMacRxMiddle (const Ptr<MacRxMiddle> rxMiddle);
124 virtual void SetChannelAccessManager (const Ptr<ChannelAccessManager> channelAccessManager);
130 virtual void SetWifiPhy (const Ptr<WifiPhy> phy);
134 virtual void ResetPhy (void);
140 virtual void SetProtectionManager (Ptr<WifiProtectionManager> protectionManager);
146 virtual void SetAckManager (Ptr<WifiAckManager> ackManager);
152 virtual void SetAddress (Mac48Address address);
158 Mac48Address GetAddress (void) const;
164 virtual void SetBssid (Mac48Address bssid);
170 Mac48Address GetBssid (void) const;
176 virtual void SetDroppedMpduCallback (DroppedMpdu callback);
182 void SetAckedMpduCallback (AckedMpdu callback);
186 void SetPromisc (void);
193 bool IsPromisc (void) const;
200 const WifiTxTimer& GetWifiTxTimer (void) const;
216 virtual void CalculateProtectionTime (WifiProtection* protection) const;
232 virtual void CalculateAcknowledgmentTime (WifiAcknowledgment* acknowledgment) const;
239 virtual void NotifyInternalCollision (Ptr<Txop> txop);
248 virtual void NotifySwitchingStartNow (Time duration);
255 void NotifySleepNow (void);
262 void NotifyOffNow (void);
265 void DoDispose () override;
299 virtual void UpdateNav (Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
304 virtual void NavResetTimeout (void);
314 virtual void ReceiveMpdu (Ptr<const WifiMpdu> mpdu, RxSignalInfo rxSignalInfo,
315 const WifiTxVector& txVector, bool inAmpdu);
326 virtual void EndReceiveAmpdu (Ptr<const WifiPsdu> psdu, const RxSignalInfo& rxSignalInfo,
327 const WifiTxVector& txVector, const std::vector<bool>& perMpduStatus);
338 virtual void ReceivedNormalAck (Ptr<WifiMpdu> mpdu, const WifiTxVector& txVector,
339 const WifiTxVector& ackTxVector, const RxSignalInfo& rxInfo, double snr);
346 virtual void NotifyReceivedNormalAck (Ptr<WifiMpdu> mpdu);
353 virtual void RetransmitMpduAfterMissedAck (Ptr<WifiMpdu> mpdu) const;
361 virtual void ReleaseSequenceNumber (Ptr<WifiMpdu> mpdu) const;
369 virtual void NotifyPacketDiscarded (Ptr<const WifiMpdu> mpdu);
379 virtual void PreProcessFrame (Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
391 virtual Time GetTxDuration (uint32_t ppduPayloadSize, Mac48Address receiver,
392 const WifiTxParameters& txParams) const;
401 void UpdateTxDuration (Mac48Address receiver, WifiTxParameters& txParams) const;
412 virtual uint32_t GetPsduSize (Ptr<const WifiMpdu> mpdu, const WifiTxVector& txVector) const;
425 uint8_t m_linkId;
426 uint16_t m_allowedWidth;
437 virtual void ForwardMpduDown (Ptr<WifiMpdu> mpdu, WifiTxVector& txVector);
444 virtual void DequeueMpdu (Ptr<const WifiMpdu> mpdu);
457 virtual Time GetFrameDurationId (const WifiMacHeader& header, uint32_t size,
458 const WifiTxParameters& txParams,
459 Ptr<Packet> fragmentedPacket) const;
470 virtual Time GetRtsDurationId (const WifiTxVector& rtsTxVector, Time txDuration, Time response) const;
477 void SendRts (const WifiTxParameters& txParams);
486 void SendCtsAfterRts (const WifiMacHeader& rtsHdr, WifiMode rtsTxMode, double rtsSnr);
495 void DoSendCtsAfterRts (const WifiMacHeader& rtsHdr, WifiTxVector& ctsTxVector, double rtsSnr);
506 virtual Time GetCtsToSelfDurationId (const WifiTxVector& ctsTxVector, Time txDuration,
507 Time response) const;
514 void SendCtsToSelf (const WifiTxParameters& txParams);
523 void SendNormalAck (const WifiMacHeader& hdr, const WifiTxVector& dataTxVector, double dataSnr);
537 virtual void TransmissionSucceeded (void);
543 virtual void TransmissionFailed (void);
551 virtual void NormalAckTimeout (Ptr<WifiMpdu> mpdu, const WifiTxVector& txVector);
559 virtual void CtsTimeout (Ptr<WifiMpdu> rts, const WifiTxVector& txVector);
566 void DoCtsTimeout (Ptr<WifiPsdu> psdu);
579 void RxStartIndication (WifiTxVector txVector, Time psduDuration);
584 void SendMpdu (void);
589 virtual void Reset (void);
599} //namespace ns3
Callback template class.
Definition: callback.h:422
An identifier for simulation events.
Definition: event-id.h:54
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
Mac48Address GetBssid(void) const
Get the Basic Service Set Identification.
void SetPromisc(void)
Enable promiscuous mode.
void DoCtsTimeout(Ptr< WifiPsdu > psdu)
Take required actions when the CTS timer fired after sending an RTS to protect the given PSDU expires...
Ptr< WifiMpdu > m_mpdu
the MPDU being transmitted
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
void NotifyOffNow(void)
This method is typically invoked by the PhyListener to notify the MAC layer that the device has been ...
virtual void NotifyInternalCollision(Ptr< Txop > txop)
Notify that an internal collision has occurred for the given Txop.
uint8_t m_linkId
the ID of the link this object is associated with
Ptr< WifiMac > m_mac
the MAC layer on this station
Callback< void, WifiMacDropReason, Ptr< const WifiMpdu > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the MAC layer to use.
virtual void TransmissionSucceeded(void)
Take necessary actions upon a transmission success.
const WifiTxTimer & GetWifiTxTimer(void) const
Get a const reference to the WifiTxTimer object.
virtual void UpdateNav(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Update the NAV, if needed, based on the Duration/ID of the given psdu.
void SendMpduWithProtection(Ptr< WifiMpdu > mpdu, WifiTxParameters &txParams)
Send an MPDU with the given TX parameters (with the specified protection).
Ptr< WifiAckManager > m_ackManager
Acknowledgment manager.
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...
virtual void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const
Calculate the time required to acknowledge a frame according to the given acknowledgment method.
Ptr< MacTxMiddle > m_txMiddle
the MAC TX Middle on this station
void SendNormalAck(const WifiMacHeader &hdr, const WifiTxVector &dataTxVector, double dataSnr)
Send Normal Ack.
Ptr< Packet > m_fragmentedPacket
the MSDU being fragmented
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Set the callback to invoke when an MPDU is dropped.
Callback< void, Ptr< const WifiMpdu > > AckedMpdu
typedef for a callback to invoke when an MPDU is successfully acknowledged.
static TypeId GetTypeId(void)
Get the type ID.
Mac48Address m_self
the MAC address of this device
uint16_t m_allowedWidth
the allowed width in MHz for the current transmission
virtual void NotifyPacketDiscarded(Ptr< const WifiMpdu > mpdu)
Pass the given MPDU, discarded because of the max retry limit was reached, to the MPDU dropped callba...
WifiTxTimer m_txTimer
the timer set upon frame transmission
void SendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiMode rtsTxMode, double rtsSnr)
Send CTS after receiving RTS.
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 ...
virtual void RetransmitMpduAfterMissedAck(Ptr< WifiMpdu > mpdu) const
Retransmit an MPDU that was not acknowledged.
Ptr< WifiProtectionManager > m_protectionManager
Protection manager.
virtual void ForwardMpduDown(Ptr< WifiMpdu > mpdu, WifiTxVector &txVector)
Forward an MPDU down to the PHY layer.
void SetLinkId(uint8_t linkId)
Set the ID of the link this Frame Exchange Manager is associated with.
void SendRts(const WifiTxParameters &txParams)
Send RTS to begin RTS-CTS-Data-Ack transaction.
virtual void NotifyReceivedNormalAck(Ptr< WifiMpdu > mpdu)
Notify other components that an MPDU was acknowledged.
virtual void NormalAckTimeout(Ptr< WifiMpdu > mpdu, const WifiTxVector &txVector)
Called when the Ack timeout expires.
virtual void NotifySwitchingStartNow(Time duration)
Ptr< WifiProtectionManager > GetProtectionManager(void) const
Get the Protection Manager used by this node.
virtual void SetBssid(Mac48Address bssid)
Set the Basic Service Set Identification.
void SendCtsToSelf(const WifiTxParameters &txParams)
Send CTS for a CTS-to-self mechanism.
virtual void CtsTimeout(Ptr< WifiMpdu > rts, const WifiTxVector &txVector)
Called when the CTS timeout expires.
virtual void CalculateProtectionTime(WifiProtection *protection) const
Calculate the time required to protect a frame according to the given protection method.
virtual void SetAddress(Mac48Address address)
Set the MAC address.
virtual void DequeueMpdu(Ptr< const WifiMpdu > mpdu)
Dequeue the given MPDU from the queue in which it is stored.
Ptr< WifiMpdu > GetNextFragment(void)
Get the next fragment of the current MSDU.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
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.
Ptr< MacRxMiddle > m_rxMiddle
the MAC RX Middle on this station
Ptr< Txop > m_dcf
the DCF/EDCAF that gained channel access
Ptr< WifiPhy > m_phy
the PHY layer on this station
Ptr< WifiMpdu > GetFirstFragmentIfNeeded(Ptr< WifiMpdu > mpdu)
Fragment the given MPDU if needed.
virtual void TransmissionFailed(void)
Take necessary actions upon a transmission failure.
Ptr< WifiAckManager > GetAckManager(void) const
Get the Acknowledgment Manager used by this node.
void SetAckedMpduCallback(AckedMpdu callback)
Set the callback to invoke when an MPDU is successfully acked.
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...
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.
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...
void DoSendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiTxVector &ctsTxVector, double rtsSnr)
Send CTS after receiving RTS.
Mac48Address GetAddress(void) const
Get the MAC address.
void SendMpdu(void)
Send the current MPDU, which can be acknowledged by a Normal Ack.
void NotifySleepNow(void)
This method is typically invoked by the PhyListener to notify the MAC layer that the device has been ...
void Receive(Ptr< const 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...
Mac48Address m_bssid
BSSID address (Mac48Address)
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
Set the PHY layer to use.
AckedMpdu m_ackedMpduCallback
the acknowledged MPDU callback
virtual void ReleaseSequenceNumber(Ptr< WifiMpdu > mpdu) const
Make the sequence number of the given MPDU available again if the MPDU has never been transmitted.
virtual uint32_t GetPsduSize(Ptr< const WifiMpdu > mpdu, const WifiTxVector &txVector) const
Get the size in bytes of the given MPDU, which is to be transmitted with the given TXVECTOR.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
virtual void ReceivedNormalAck(Ptr< WifiMpdu > mpdu, const WifiTxVector &txVector, const WifiTxVector &ackTxVector, const RxSignalInfo &rxInfo, double snr)
Perform the actions needed when a Normal Ack is received.
bool m_promisc
Flag if the device is operating in promiscuous mode.
virtual void ReceiveMpdu(Ptr< const WifiMpdu > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu)
This method handles the reception of an MPDU (possibly included in an A-MPDU)
virtual void SetChannelAccessManager(const Ptr< ChannelAccessManager > channelAccessManager)
Set the channel access manager to use.
bool m_moreFragments
true if a fragment has to be sent after a SIFS
Time m_navEnd
NAV expiration time.
virtual void NavResetTimeout(void)
Reset the NAV upon expiration of the NAV reset timer.
virtual void SetMacTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set the MAC TX Middle to use.
virtual void SetMacRxMiddle(const Ptr< MacRxMiddle > rxMiddle)
Set the MAC RX Middle to use.
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
bool IsPromisc(void) const
Check if the device is operating in promiscuous mode.
virtual void Reset(void)
Reset this frame exchange manager.
void DoDispose() override
Destructor implementation.
WifiTxParameters m_txParams
the TX parameters for the current frame
virtual bool StartTransmission(Ptr< Txop > dcf, uint16_t allowedWidth)
Request the FrameExchangeManager to start a frame exchange sequence.
void RxStartIndication(WifiTxVector txVector, Time psduDuration)
EventId m_navResetEvent
the event to reset the NAV after an RTS
virtual void ResetPhy(void)
Remove WifiPhy associated with this FrameExchangeManager.
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...
an EUI-48 address
Definition: mac48-address.h:44
A base class which provides memory management and object aggregation.
Definition: object.h:88
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
a unique identifier for an interface.
Definition: type-id.h:59
Implements the IEEE 802.11 MAC header.
represent a single transmission mode
Definition: wifi-mode.h:48
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
This class is used to handle the timer that a station starts when transmitting a frame that solicits ...
Definition: wifi-tx-timer.h:48
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: third.py:87
Definition: third.py:84
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:69
WifiAcknowledgment is an abstract base struct.
WifiProtection is an abstract base struct.