A Discrete-Event Network Simulator
API
frame-exchange-manager.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
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
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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  */
20 
21 #ifndef FRAME_EXCHANGE_MANAGER_H
22 #define FRAME_EXCHANGE_MANAGER_H
23 
24 #include "ns3/object.h"
25 #include "qos-txop.h"
26 #include "wifi-tx-vector.h"
27 #include "wifi-psdu.h"
28 #include "regular-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 
35 namespace ns3 {
36 
37 class ChannelAccessManager;
38 struct RxSignalInfo;
39 class WifiProtectionManager;
40 struct WifiProtection;
41 class WifiAckManager;
42 struct WifiAcknowledgment;
43 
51 {
52 public:
57  static TypeId GetTypeId (void);
59  virtual ~FrameExchangeManager ();
60 
69 
77  virtual bool StartTransmission (Ptr<Txop> dcf);
78 
90  void Receive (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
91  WifiTxVector txVector, std::vector<bool> perMpduStatus);
92 
98  virtual void SetWifiMac (const Ptr<RegularWifiMac> mac);
104  virtual void SetMacTxMiddle (const Ptr<MacTxMiddle> txMiddle);
110  virtual void SetMacRxMiddle (const Ptr<MacRxMiddle> rxMiddle);
116  virtual void SetChannelAccessManager (const Ptr<ChannelAccessManager> channelAccessManager);
122  virtual void SetWifiPhy (const Ptr<WifiPhy> phy);
126  virtual void ResetPhy (void);
132  virtual void SetProtectionManager (Ptr<WifiProtectionManager> protectionManager);
138  virtual void SetAckManager (Ptr<WifiAckManager> ackManager);
144  virtual void SetAddress (Mac48Address address);
150  virtual void SetBssid (Mac48Address bssid);
156  virtual void SetDroppedMpduCallback (DroppedMpdu callback);
162  void SetAckedMpduCallback (AckedMpdu callback);
166  void SetPromisc (void);
173  bool IsPromisc (void) const;
174 
180  const WifiTxTimer& GetWifiTxTimer (void) const;
181 
188 
196  virtual void CalculateProtectionTime (WifiProtection* protection) const;
197 
203  Ptr<WifiAckManager> GetAckManager (void) const;
204 
212  virtual void CalculateAcknowledgmentTime (WifiAcknowledgment* acknowledgment) const;
213 
221  void NotifySwitchingStartNow (Time duration);
222 
228  void NotifySleepNow (void);
229 
235  void NotifyOffNow (void);
236 
237 protected:
238  virtual void DoDispose ();
239 
250 
260 
267  virtual void UpdateNav (Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
268 
272  virtual void NavResetTimeout (void);
273 
282  virtual void ReceiveMpdu (Ptr<WifiMacQueueItem> mpdu, RxSignalInfo rxSignalInfo,
283  const WifiTxVector& txVector, bool inAmpdu);
284 
294  virtual void EndReceiveAmpdu (Ptr<const WifiPsdu> psdu, const RxSignalInfo& rxSignalInfo,
295  const WifiTxVector& txVector, const std::vector<bool>& perMpduStatus);
296 
306  virtual void ReceivedNormalAck (Ptr<WifiMacQueueItem> mpdu, const WifiTxVector& txVector,
307  const WifiTxVector& ackTxVector, const RxSignalInfo& rxInfo, double snr);
308 
315 
321  virtual void RetransmitMpduAfterMissedAck (Ptr<WifiMacQueueItem> mpdu) const;
322 
328  virtual void RetransmitMpduAfterMissedCts (Ptr<WifiMacQueueItem> mpdu) const;
329 
337 
346  virtual void PreProcessFrame (Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
347 
358  virtual Time GetTxDuration (uint32_t ppduPayloadSize, Mac48Address receiver,
359  const WifiTxParameters& txParams) const;
360 
368  void UpdateTxDuration (Mac48Address receiver, WifiTxParameters& txParams) const;
369 
381  bool m_promisc;
384 
391  virtual void ForwardMpduDown (Ptr<WifiMacQueueItem> mpdu, WifiTxVector& txVector);
392 
398  virtual void DequeueMpdu (Ptr<WifiMacQueueItem> mpdu);
399 
411  virtual Time GetFrameDurationId (const WifiMacHeader& header, uint32_t size,
412  const WifiTxParameters& txParams,
413  Ptr<Packet> fragmentedPacket) const;
414 
424  virtual Time GetRtsDurationId (const WifiTxVector& rtsTxVector, Time txDuration, Time response) const;
425 
431  void SendRts (const WifiTxParameters& txParams);
432 
440  void SendCtsAfterRts (const WifiMacHeader& rtsHdr, WifiMode rtsTxMode, double rtsSnr);
441 
449  void DoSendCtsAfterRts (const WifiMacHeader& rtsHdr, WifiTxVector& ctsTxVector, double rtsSnr);
450 
460  virtual Time GetCtsToSelfDurationId (const WifiTxVector& ctsTxVector, Time txDuration,
461  Time response) const;
462 
468  void SendCtsToSelf (const WifiTxParameters& txParams);
469 
477  void SendNormalAck (const WifiMacHeader& hdr, const WifiTxVector& dataTxVector, double dataSnr);
478 
486 
491  virtual void TransmissionSucceeded (void);
492 
497  virtual void TransmissionFailed (void);
498 
505  void NormalAckTimeout (Ptr<WifiMacQueueItem> mpdu, const WifiTxVector& txVector);
506 
513  virtual void CtsTimeout (Ptr<WifiMacQueueItem> rts, const WifiTxVector& txVector);
514 
515 private:
526  void RxStartIndication (WifiTxVector txVector, Time psduDuration);
527 
531  void SendMpdu (void);
532 
536  virtual void Reset (void);
537 
546 };
547 
548 } //namespace ns3
549 
550 #endif /* FRAME_EXCHANGE_MANAGER_H */
void SetAckedMpduCallback(AckedMpdu callback)
Set the callback to invoke when an MPDU is successfully acked.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
bool m_moreFragments
true if a fragment has to be sent after a SIFS
virtual void DequeueMpdu(Ptr< WifiMacQueueItem > mpdu)
Dequeue the given MPDU from the queue in which it is stored.
void SendCtsToSelf(const WifiTxParameters &txParams)
Send CTS for a CTS-to-self mechanism.
Callback< void, WifiMacDropReason, Ptr< const WifiMacQueueItem > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
WifiTxTimer m_txTimer
the timer set upon frame transmission
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
AckedMpdu m_ackedMpduCallback
the acknowledged MPDU callback
Callback template class.
Definition: callback.h:1278
bool IsPromisc(void) const
Check if the device is operating in promiscuous mode.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SendMpduWithProtection(Ptr< WifiMacQueueItem > mpdu, WifiTxParameters &txParams)
Send an MPDU with the given TX parameters (with the specified protection).
virtual void SetAddress(Mac48Address address)
Set the MAC address.
Ptr< WifiProtectionManager > GetProtectionManager(void) const
Get the Protection Manager used by this node.
Ptr< WifiPhy > m_phy
the PHY layer on this station
Ptr< Packet > m_fragmentedPacket
the MSDU being fragmented
void SetPromisc(void)
Enable promiscuous mode.
WifiAcknowledgment is an abstract base struct.
Ptr< WifiMacQueueItem > m_mpdu
the MPDU being transmitted
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 void ForwardMpduDown(Ptr< WifiMacQueueItem > mpdu, WifiTxVector &txVector)
Forward an MPDU down to the PHY layer.
virtual void CalculateProtectionTime(WifiProtection *protection) const
Calculate the time required to protect a frame according to the given protection method.
bool m_promisc
Flag if the device is operating in promiscuous mode.
void NotifySwitchingStartNow(Time duration)
TypeId m_protectionManagerTypeId
TypeId of the protection manager to install.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
virtual void DoDispose()
Destructor implementation.
virtual void TransmissionFailed(void)
Take necessary actions upon a transmission failure.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:47
virtual void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const
Calculate the time required to acknowledge a frame according to the given acknowledgment method...
virtual void ResetPhy(void)
Remove WifiPhy associated with this MacLow.
virtual void CtsTimeout(Ptr< WifiMacQueueItem > rts, const WifiTxVector &txVector)
Called when the CTS timeout expires.
Ptr< WifiAckManager > GetAckManager(void) const
Get the Acknowledgment Manager used by this node.
Ptr< RegularWifiMac > m_mac
the MAC layer on this station
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
virtual void SetMacRxMiddle(const Ptr< MacRxMiddle > rxMiddle)
Set the MAC RX Middle to use.
phy
Definition: third.py:93
Ptr< WifiMacQueueItem > GetFirstFragmentIfNeeded(Ptr< WifiMacQueueItem > mpdu)
Fragment the given MPDU if needed.
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
TypeId m_acknowledgmentManagerTypeId
TypeId of the acknowledgment manager to install.
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:66
Mac48Address m_bssid
BSSID address (Mac48Address)
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...
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...
virtual void UpdateNav(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Update the NAV, if needed, based on the Duration/ID of the given psdu.
virtual void SetMacTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set the MAC TX Middle to use.
void NotifyOffNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
EventId m_navResetEvent
the event to reset the NAV after an RTS
mac
Definition: third.py:99
virtual void SetChannelAccessManager(const Ptr< ChannelAccessManager > channelAccessManager)
Set the channel access manager to use.
virtual bool StartTransmission(Ptr< Txop > dcf)
Request the FrameExchangeManager to start a frame exchange sequence.
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 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< WifiAckManager > m_ackManager
Acknowledgment manager.
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...
Mac48Address m_self
the MAC address of this device
WifiProtection is an abstract base struct.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SendRts(const WifiTxParameters &txParams)
Send RTS to begin RTS-CTS-Data-Ack transaction.
This class is used to handle the timer that a station starts when transmitting a frame that solicits ...
Definition: wifi-tx-timer.h:47
address
Definition: first.py:44
an EUI-48 address
Definition: mac48-address.h:43
Callback< void, Ptr< const WifiMacQueueItem > > AckedMpdu
typedef for a callback to invoke when an MPDU is successfully acknowledged.
void SendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiMode rtsTxMode, double rtsSnr)
Send CTS after receiving RTS.
virtual void SetWifiMac(const Ptr< RegularWifiMac > mac)
Set the MAC layer to use.
WifiTxParameters m_txParams
the TX parameters for the current frame
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.
static TypeId GetTypeId(void)
Get the type ID.
void SendNormalAck(const WifiMacHeader &hdr, const WifiTxVector &dataTxVector, double dataSnr)
Send Normal Ack.
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
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...
const WifiTxTimer & GetWifiTxTimer(void) const
Get a const reference to the WifiTxTimer object.
Ptr< WifiProtectionManager > m_protectionManager
Protection manager.
void NotifySleepNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
void NormalAckTimeout(Ptr< WifiMacQueueItem > mpdu, const WifiTxVector &txVector)
Called when the Ack timeout expires.
An identifier for simulation events.
Definition: event-id.h:53
virtual void Reset(void)
Reset this frame exchange manager.
virtual void SetBssid(Mac48Address bssid)
Set the Basic Service Set Identification.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism...
Ptr< Txop > m_dcf
the DCF/EDCAF that gained channel access
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...
Time m_navEnd
NAV expiration time.
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)
virtual void RetransmitMpduAfterMissedAck(Ptr< WifiMacQueueItem > mpdu) const
Retransmit an MPDU that was not acknowledged.
virtual void TransmissionSucceeded(void)
Take necessary actions upon a transmission success.
void RxStartIndication(WifiTxVector txVector, Time psduDuration)
void DoSendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiTxVector &ctsTxVector, double rtsSnr)
Send CTS after receiving RTS.
Ptr< WifiMacQueueItem > GetNextFragment(void)
Get the next fragment of the current MSDU.
virtual void NotifyReceivedNormalAck(Ptr< WifiMacQueueItem > mpdu)
Notify other components that an MPDU was acknowledged.
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Set the callback to invoke when an MPDU is dropped.
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...
Ptr< MacRxMiddle > m_rxMiddle
the MAC RX Middle on this station
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
Set the PHY layer to use.
Ptr< MacTxMiddle > m_txMiddle
the MAC TX Middle on this station
a unique identifier for an interface.
Definition: type-id.h:58
void SendMpdu(void)
Send the current MPDU, which can be acknowledged by a Normal Ack.
Implements the IEEE 802.11 MAC header.
virtual void NavResetTimeout(void)
Reset the NAV upon expiration of the NAV reset timer.
virtual void RetransmitMpduAfterMissedCts(Ptr< WifiMacQueueItem > mpdu) const
Retransmit an MPDU that was not sent because a CTS was not received.