A Discrete-Event Network Simulator
API
mac-low.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005, 2006 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Mirko Banchi <mk.banchi@gmail.com>
21  */
22 #ifndef MAC_LOW_H
23 #define MAC_LOW_H
24 
25 #include <vector>
26 #include <stdint.h>
27 #include <ostream>
28 #include <map>
29 
30 #include "wifi-mac-header.h"
31 #include "wifi-mode.h"
32 #include "wifi-preamble.h"
34 #include "ctrl-headers.h"
35 #include "mgt-headers.h"
36 #include "block-ack-agreement.h"
37 #include "ns3/mac48-address.h"
38 #include "ns3/callback.h"
39 #include "ns3/event-id.h"
40 #include "ns3/packet.h"
41 #include "ns3/nstime.h"
42 #include "qos-utils.h"
43 #include "block-ack-cache.h"
44 #include "wifi-tx-vector.h"
45 #include "mpdu-aggregator.h"
46 
47 namespace ns3 {
48 
49 class WifiPhy;
50 class WifiMac;
51 class EdcaTxopN;
52 class WifiMacQueue;
53 
59 {
60 public:
62  virtual ~MacLowTransmissionListener ();
63 
71  virtual void GotCts (double snr, WifiMode txMode) = 0;
76  virtual void MissedCts (void) = 0;
86  virtual void GotAck (double snr, WifiMode txMode) = 0;
91  virtual void MissedAck (void) = 0;
105  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address source, WifiMode txMode);
115  virtual void MissedBlockAck (void);
122  virtual void StartNext (void) = 0;
129  virtual void Cancel (void) = 0;
135  virtual void EndTxNoAck (void) = 0;
136 
137 };
138 
139 
149 {
150 public:
152  virtual ~MacLowDcfListener ();
158  virtual void NavStart (Time duration) = 0;
164  virtual void NavReset (Time duration) = 0;
170  virtual void AckTimeoutStart (Time duration) = 0;
174  virtual void AckTimeoutReset () = 0;
180  virtual void CtsTimeoutStart (Time duration) = 0;
184  virtual void CtsTimeoutReset () = 0;
185 };
186 
192 {
193 public:
195  virtual ~MacLowBlockAckEventListener ();
208  virtual void BlockAckInactivityTimeout (Mac48Address originator, uint8_t tid) = 0;
212  virtual Ptr<WifiMacQueue> GetQueue (void) = 0;
220  virtual void CompleteTransfer (Mac48Address address, uint8_t tid);
221  virtual void SetAmpdu (bool ampdu);
227  virtual void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
234  virtual uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr);
241  virtual uint16_t PeekNextSequenceNumberfor (WifiMacHeader *hdr);
242  /*
243  * Peek in retransmit queue and get the next packet without removing it from the queue
244  */
245  virtual Ptr<const Packet> PeekNextPacketInBaQueue (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
249  virtual void RemoveFromBaQueue (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
258  virtual bool GetBlockAckAgreementExists (Mac48Address address, uint8_t tid) = 0;
266  virtual uint32_t GetNOutstandingPackets (Mac48Address recipient, uint8_t tid);
274  virtual uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
275 };
276 
286 {
287 public:
289 
295  void EnableAck (void);
309  void EnableFastAck (void);
316  void EnableSuperFastAck (void);
320  void EnableBasicBlockAck (void);
324  void EnableCompressedBlockAck (void);
328  void EnableMultiTidBlockAck (void);
335  void EnableRts (void);
345  void EnableNextData (uint32_t size);
353  void EnableOverrideDurationId (Time durationId);
358  void DisableAck (void);
362  void DisableRts (void);
366  void DisableNextData (void);
372  void DisableOverrideDurationId (void);
380  bool MustWaitAck (void) const;
387  bool MustWaitNormalAck (void) const;
394  bool MustWaitFastAck (void) const;
401  bool MustWaitSuperFastAck (void) const;
407  bool MustWaitBasicBlockAck (void) const;
413  bool MustWaitCompressedBlockAck (void) const;
419  bool MustWaitMultiTidBlockAck (void) const;
424  bool MustSendRts (void) const;
429  bool HasDurationId (void) const;
433  Time GetDurationId (void) const;
437  bool HasNextPacket (void) const;
441  uint32_t GetNextPacketSize (void) const;
442 
443 private:
444 
445  friend std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
446  uint32_t m_nextSize;
447  enum
448  {
456  } m_waitAck;
457  bool m_sendRts;
459 };
460 
468 std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
469 
470 
475 class MacLow : public Object
476 {
477 public:
482 
483  MacLow ();
484  virtual ~MacLow ();
485 
491  void SetPhy (Ptr<WifiPhy> phy);
492  /*
493  * \return current attached PHY device
494  */
495  Ptr<WifiPhy> GetPhy (void) const;
501  void ResetPhy (void);
513  void SetMpduAggregator (Ptr<MpduAggregator> aggregator);
519  void SetAddress (Mac48Address ad);
525  void SetAckTimeout (Time ackTimeout);
531  void SetBasicBlockAckTimeout (Time blockAckTimeout);
537  void SetCompressedBlockAckTimeout (Time blockAckTimeout);
543  void SetCtsToSelfSupported (bool enable);
549  void SetCtsTimeout (Time ctsTimeout);
555  void SetSifs (Time sifs);
561  void SetRifs (Time rifs);
567  void SetSlotTime (Time slotTime);
573  void SetPifs (Time pifs);
579  void SetBssid (Mac48Address ad);
583  void SetPromisc (void);
589  bool GetCtsToSelfSupported () const;
595  Mac48Address GetAddress (void) const;
601  Time GetAckTimeout (void) const;
607  Time GetBasicBlockAckTimeout () const;
619  Time GetCtsTimeout (void) const;
625  Time GetSifs (void) const;
631  Time GetSlotTime (void) const;
637  Time GetPifs (void) const;
643  Time GetRifs (void) const;
649  Mac48Address GetBssid (void) const;
656  bool IsPromisc (void) const;
657 
664  void SetRxCallback (Callback<void,Ptr<Packet>,const WifiMacHeader *> callback);
669  void RegisterDcfListener (MacLowDcfListener *listener);
670 
681  const WifiMacHeader* hdr,
682  const MacLowTransmissionParameters& parameters) const;
683 
693  virtual void StartTransmission (Ptr<const Packet> packet,
694  const WifiMacHeader* hdr,
695  MacLowTransmissionParameters parameters,
696  MacLowTransmissionListener *listener);
697 
708  void ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamble preamble, bool ampduSubframe);
716  void ReceiveError (Ptr<const Packet> packet, double rxSnr);
724  void NotifySwitchingStartNow (Time duration);
730  void NotifySleepNow (void);
746  void CreateBlockAckAgreement (const MgtAddBaResponseHeader *respHdr,
747  Mac48Address originator,
748  uint16_t startingSeq);
757  void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid);
784  void DeaggregateAmpduAndReceive (Ptr<Packet> aggregatedPacket, double rxSnr, WifiMode txMode, WifiPreamble preamble);
795  bool StopAggregation (Ptr<const Packet> peekedPacket, WifiMacHeader peekedHdr, Ptr<Packet> aggregatedPacket, uint16_t size) const;
801  void FlushAggregateQueue (void);
802 
803 protected:
813  virtual WifiTxVector GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
814 private:
819  void CancelAllEvents (void);
825  uint32_t GetAckSize (void) const;
832  uint32_t GetBlockAckSize (enum BlockAckType type) const;
838  uint32_t GetRtsSize (void) const;
844  uint32_t GetCtsSize (void) const;
853  uint32_t GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
862  void ForwardDown (Ptr<const Packet> packet, const WifiMacHeader *hdr,
863  WifiTxVector txVector, WifiPreamble preamble);
872  void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType);
882  WifiTxVector GetRtsTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
893  WifiTxVector GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const;
904  WifiTxVector GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
915  WifiTxVector GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
954  Time GetCtsDuration (WifiTxVector ctsTxVector) const;
963  Time GetCtsDuration (Mac48Address to, WifiTxVector rtsTxVector) const;
970  Time GetAckDuration (WifiTxVector ackTxVector) const;
979  Time GetAckDuration (Mac48Address to, WifiTxVector dataTxVector) const;
989  Time GetBlockAckDuration (Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const;
996  bool NeedCtsToSelf (void);
997 
999  const WifiMacHeader* hdr,
1000  const MacLowTransmissionParameters &params) const;
1001  void NotifyNav (Ptr<const Packet> packet,const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble);
1007  void DoNavResetNow (Time duration);
1014  bool DoNavStartNow (Time duration);
1021  bool IsNavZero (void) const;
1029  void NotifyAckTimeoutStartNow (Time duration);
1034  void NotifyAckTimeoutResetNow ();
1042  void NotifyCtsTimeoutStartNow (Time duration);
1047  void NotifyCtsTimeoutResetNow ();
1054  void NavCounterResetCtsMissed (Time rtsEndRxTime);
1055  /* Event handlers */
1059  void NormalAckTimeout (void);
1063  void FastAckTimeout (void);
1067  void SuperFastAckTimeout (void);
1071  void FastAckFailedTimeout (void);
1075  void BlockAckTimeout (void);
1079  void CtsTimeout (void);
1083  void SendCtsToSelf (void);
1092  void SendCtsAfterRts (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr);
1101  void SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr);
1109  void SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode);
1114  void WaitSifsAfterEndTx (void);
1118  void EndTxNoAck (void);
1122  void SendRtsForPacket (void);
1127  void SendDataPacket (void);
1134  void StartDataTxTimers (WifiTxVector dataTxVector);
1135 
1136  virtual void DoDispose (void);
1137 
1144  uint8_t GetTid(Ptr<const Packet> packet, const WifiMacHeader hdr) const;
1153  void RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address originator, uint8_t tid);
1166  void RxCompleteBufferedPacketsUntilFirstLost (Mac48Address originator, uint8_t tid);
1173  bool IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize);
1179  bool ReceiveMpdu (Ptr<Packet> packet, WifiMacHeader hdr);
1186  bool StoreMpduIfNeeded (Ptr<Packet> packet, WifiMacHeader hdr);
1197  Time duration, WifiMode blockAckReqTxMode);
1202  void SendBlockAckAfterAmpdu (uint8_t tid, Mac48Address originator,
1203  Time duration, WifiMode blockAckReqTxMode);
1213  void SendBlockAckResponse (const CtrlBAckResponseHeader* blockAck, Mac48Address originator, bool immediate,
1214  Time duration, WifiMode blockAckReqTxMode);
1224 
1244  bool IsAmpdu (Ptr<const Packet> packet, const WifiMacHeader hdr);
1245 
1248  MacLowRxCallback m_rxCallback;
1249 
1252  typedef std::vector<MacLowDcfListener *>::const_iterator DcfListenersCI;
1256  typedef std::vector<MacLowDcfListener *> DcfListeners;
1257  DcfListeners m_dcfListeners;
1258 
1272 
1274 
1289 
1292 
1293  bool m_promisc;
1294  bool m_ampdu;
1295 
1297 
1298  /*
1299  * BlockAck data structures.
1300  */
1301  typedef std::pair<Ptr<Packet>, WifiMacHeader> BufferedPacket;
1302  typedef std::list<BufferedPacket>::iterator BufferedPacketI;
1303 
1304  typedef std::pair<Mac48Address, uint8_t> AgreementKey;
1305  typedef std::pair<BlockAckAgreement, std::list<BufferedPacket> > AgreementValue;
1306 
1307  typedef std::map<AgreementKey, AgreementValue> Agreements;
1308  typedef std::map<AgreementKey, AgreementValue>::iterator AgreementsI;
1309 
1310  typedef std::map<AgreementKey, BlockAckCache> BlockAckCaches;
1311  typedef std::map<AgreementKey, BlockAckCache>::iterator BlockAckCachesI;
1312 
1313  Agreements m_bAckAgreements;
1314  BlockAckCaches m_bAckCaches;
1315 
1316  typedef std::map<AcIndex, MacLowBlockAckEventListener*> QueueListeners;
1317  QueueListeners m_edcaListeners;
1319  uint8_t m_sentMpdus;
1323 };
1324 
1325 } // namespace ns3
1326 
1327 #endif /* MAC_LOW_H */
bool MustSendRts(void) const
Definition: mac-low.cc:226
Time GetPifs(void) const
Return PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:623
uint32_t GetAckSize(void) const
Return the total ACK size (including FCS trailer).
Definition: mac-low.cc:1131
virtual ~MacLowDcfListener()
Definition: mac-low.cc:67
void SetPifs(Time pifs)
Set PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:563
Time m_ctsTimeout
CTS timeout duration.
Definition: mac-low.h:1284
virtual uint32_t GetNOutstandingPackets(Mac48Address recipient, uint8_t tid)
Definition: mac-low.cc:108
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
EventId m_navCounterResetCtsMissed
Event to reset NAV when CTS is not received.
Definition: mac-low.h:1270
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Ptr< WifiPhy > GetPhy(void) const
Definition: mac-low.cc:499
void ResetBlockAckInactivityTimerIfNeeded(BlockAckAgreement &agreement)
Every time that a block ack request or a packet with ack policy equals to block ack are received...
Definition: mac-low.cc:2485
enum ns3::MacLowTransmissionParameters::@89 m_waitAck
virtual void CtsTimeoutReset()=0
Notify that CTS timeout has resetted.
EventId m_blockAckTimeoutEvent
Block ACK timeout event.
Definition: mac-low.h:1263
Time GetBlockAckDuration(Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const
Return the time required to transmit the Block ACK to the specified address given the TXVECTOR of the...
Definition: mac-low.cc:1182
Callback template class.
Definition: callback.h:978
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
virtual ~MacLowTransmissionListener()
Definition: mac-low.cc:53
Time GetAckDuration(WifiTxVector ackTxVector) const
Return the time required to transmit the ACK (including preamble and FCS).
Definition: mac-low.cc:1172
virtual void GotAck(double snr, WifiMode txMode)=0
void SetPromisc(void)
Enable promiscuous mode.
Definition: mac-low.cc:578
EventId m_waitSifsEvent
Wait for SIFS event.
Definition: mac-low.h:1268
void SendDataAfterCts(Mac48Address source, Time duration, WifiMode txMode)
Send DATA after receiving CTS.
Definition: mac-low.cc:1970
void DoNavResetNow(Time duration)
Reset NAV with the given duration.
Definition: mac-low.cc:1404
bool IsPromisc(void) const
Check if MacLow is operating in promiscuous mode.
Definition: mac-low.cc:633
bool m_receivedAtLeastOneMpdu
Flag whether an MPDU has already been successfully received while receiving an A-MPDU.
Definition: mac-low.h:1322
void EnableBasicBlockAck(void)
Wait BASICBLOCKACKTimeout for a Basic Block Ack Response frame.
Definition: mac-low.cc:151
EventId m_fastAckTimeoutEvent
Fast ACK timeout event.
Definition: mac-low.h:1260
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: mac-low.h:1287
void ReceiveOk(Ptr< Packet > packet, double rxSnr, WifiMode txMode, WifiPreamble preamble, bool ampduSubframe)
Definition: mac-low.cc:811
void FastAckFailedTimeout(void)
Event handler when fast ACK timeout occurs (busy).
Definition: mac-low.cc:2058
bool DoNavStartNow(Time duration)
Start NAV with the given duration.
Definition: mac-low.cc:1414
Mac48Address GetBssid(void) const
Return the Basic Service Set Identification.
Definition: mac-low.cc:628
void SetSifs(Time sifs)
Set Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:553
virtual void MissedAck(void)=0
ns3::MacLow did not receive an expected ACK within AckTimeout.
std::pair< Mac48Address, uint8_t > AgreementKey
Definition: mac-low.h:1304
WifiTxVector GetCtsToSelfTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the CTS-to-self frame.
Definition: mac-low.cc:1236
void SetupPhyMacLowListener(Ptr< WifiPhy > phy)
Set up WifiPhy listener for this MacLow.
Definition: mac-low.cc:372
virtual void BlockAckInactivityTimeout(Mac48Address originator, uint8_t tid)=0
Typically is called in order to notify EdcaTxopN that a block ack inactivity timeout occurs for the b...
friend std::ostream & operator<<(std::ostream &os, const MacLowTransmissionParameters &params)
Serialize MacLowTransmissionParameters to ostream in a human-readable form.
Definition: mac-low.cc:253
bool StopAggregation(Ptr< const Packet > peekedPacket, WifiMacHeader peekedHdr, Ptr< Packet > aggregatedPacket, uint16_t size) const
Definition: mac-low.cc:2588
void NotifySleepNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
Definition: mac-low.cc:796
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr) const
Definition: mac-low.cc:1110
bool HasDurationId(void) const
Definition: mac-low.cc:231
DcfListeners m_dcfListeners
List of MacLowDcfListener (pass events to Dcf)
Definition: mac-low.h:1257
uint8_t m_sentMpdus
Number of transmitted MPDUs in an A-MPDU that have not been acknowledged yet.
Definition: mac-low.h:1319
bool m_ampdu
Flag if the current transmission involves an A-MPDU.
Definition: mac-low.h:1294
virtual void CtsTimeoutStart(Time duration)=0
Notify that CTS timeout has started for a given duration.
void SetRxCallback(Callback< void, Ptr< Packet >, const WifiMacHeader * > callback)
Definition: mac-low.cc:639
Time GetCompressedBlockAckTimeout() const
Return Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:598
Mac48Address m_bssid
BSSID address (Mac48Address)
Definition: mac-low.h:1280
BlockAckType
Enumeration for different block ACK policies.
Definition: ctrl-headers.h:30
Ptr< Packet > AggregateToAmpdu(Ptr< const Packet > packet, const WifiMacHeader hdr)
Definition: mac-low.cc:2611
EventId m_sendCtsEvent
Event to send CTS.
Definition: mac-low.h:1265
MacLowRxCallback m_rxCallback
Callback to pass packet up.
Definition: mac-low.h:1248
Time GetCtsTimeout(void) const
Return CTS timeout of this MacLow.
Definition: mac-low.cc:603
EventId m_superFastAckTimeoutEvent
Super fast ACK timeout event.
Definition: mac-low.h:1261
EventId m_sendAckEvent
Event to send ACK.
Definition: mac-low.h:1266
listen to events coming from ns3::MacLow.
Definition: mac-low.h:58
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:93
void SendBlockAckAfterAmpdu(uint8_t tid, Mac48Address originator, Time duration, WifiMode blockAckReqTxMode)
Invoked after an A-MPDU has been received.
Definition: mac-low.cc:2400
Time GetCtsDuration(WifiTxVector ctsTxVector) const
Return the time required to transmit the CTS (including preamble and FCS).
Definition: mac-low.cc:1207
bool MustWaitFastAck(void) const
Definition: mac-low.cc:201
virtual void CompleteTransfer(Mac48Address address, uint8_t tid)
Definition: mac-low.cc:81
control how a packet is transmitted.
Definition: mac-low.h:285
void WaitSifsAfterEndTx(void)
Event handler that is usually scheduled to fired at the appropriate time after completing transmissio...
Definition: mac-low.cc:2044
std::vector< MacLowDcfListener * >::const_iterator DcfListenersCI
typedef for an iterator for a list of MacLowDcfListener.
Definition: mac-low.h:1252
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self capability.
Definition: mac-low.cc:538
void NormalAckTimeout(void)
Event handler when normal ACK timeout occurs.
Definition: mac-low.cc:1551
void SetBasicBlockAckTimeout(Time blockAckTimeout)
Set Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:528
BlockAckCaches m_bAckCaches
Definition: mac-low.h:1314
virtual uint16_t PeekNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i...
Definition: mac-low.cc:94
virtual void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
This function stores an MPDU (part of an A-MPDU) in blockackagreement (i.e.
Definition: mac-low.cc:85
void RemovePhyMacLowListener(Ptr< WifiPhy > phy)
Remove current WifiPhy listener for this MacLow.
Definition: mac-low.cc:379
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address source, WifiMode txMode)
Definition: mac-low.cc:57
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:29
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2225
Time m_lastNavDuration
The duration of the latest NAV.
Definition: mac-low.h:1291
std::pair< Ptr< Packet >, WifiMacHeader > BufferedPacket
Definition: mac-low.h:1301
bool m_ctsToSelfSupported
Flag whether CTS-to-self is supported.
Definition: mac-low.h:1318
void SendCtsToSelf(void)
Send CTS for a CTS-to-self mechanism.
Definition: mac-low.cc:1846
void SendAckAfterData(Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr)
Send ACK after receiving DATA.
Definition: mac-low.cc:2068
void CreateBlockAckAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq)
Definition: mac-low.cc:2183
Ptr< WifiMacQueue > m_aggregateQueue
Queue used for MPDU aggregation.
Definition: mac-low.h:1320
WifiMode m_currentMode
mode used for the current packet transmission
Definition: mac-low.h:1321
uint32_t GetBlockAckSize(enum BlockAckType type) const
Return the total Block ACK size (including FCS trailer).
Definition: mac-low.cc:1138
Listener for PHY events.
Definition: mac-low.cc:292
void CtsTimeout(void)
Event handler when CTS timeout occurs.
Definition: mac-low.cc:1532
virtual void StartNext(void)=0
Invoked when ns3::MacLow wants to start a new transmission as configured by MacLowTransmissionParamet...
void EndTxNoAck(void)
A transmission that does not require an ACK has completed.
Definition: mac-low.cc:2050
std::map< AgreementKey, BlockAckCache >::iterator BlockAckCachesI
Definition: mac-low.h:1311
std::map< AcIndex, MacLowBlockAckEventListener * > QueueListeners
Definition: mac-low.h:1316
std::vector< MacLowDcfListener * > DcfListeners
typedef for a list of MacLowDcfListener.
Definition: mac-low.h:1256
virtual void EndTxNoAck(void)=0
Invoked upon the end of the transmission of a frame that does not require an ACK (e.g., broadcast and multicast frames).
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...
Definition: mac-low.cc:1262
virtual void SetAmpdu(bool ampdu)
Definition: mac-low.cc:78
void SetAckTimeout(Time ackTimeout)
Set ACK timeout of this MacLow.
Definition: mac-low.cc:523
virtual Ptr< WifiMacQueue > GetQueue(void)=0
Returns the EDCA queue to check if there are packets that can be aggregated with a Block Ack...
virtual void GotCts(double snr, WifiMode txMode)=0
void SendBlockAckResponse(const CtrlBAckResponseHeader *blockAck, Mac48Address originator, bool immediate, Time duration, WifiMode blockAckReqTxMode)
This method creates block ack frame with header equals to blockAck and start its transmission.
Definition: mac-low.cc:2335
Time GetRifs(void) const
Return Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:613
virtual bool GetBlockAckAgreementExists(Mac48Address address, uint8_t tid)=0
void NavCounterResetCtsMissed(Time rtsEndRxTime)
Reset NAV after CTS was missed when the NAV was setted with RTS.
Definition: mac-low.cc:1395
Ptr< WifiRemoteStationManager > m_stationManager
Pointer to WifiRemoteStationManager (rate control)
Definition: mac-low.h:1247
bool MustWaitMultiTidBlockAck(void) const
Definition: mac-low.cc:221
Headers for Block ack response.
Definition: ctrl-headers.h:183
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:583
uint32_t GetNextPacketSize(void) const
Definition: mac-low.cc:247
Agreements m_bAckAgreements
Definition: mac-low.h:1313
bool HasNextPacket(void) const
Definition: mac-low.cc:242
WifiTxVector GetAckTxVectorForData(Mac48Address to, WifiMode dataTxMode) const
Return a TXVECTOR for the Block ACK frame given the destination and the mode of the DATA used by the ...
Definition: mac-low.cc:1278
virtual void RemoveFromBaQueue(uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
Remove a packet after you peek in the retransmit queue and get it.
Definition: mac-low.cc:104
void RegisterDcfListener(MacLowDcfListener *listener)
Definition: mac-low.cc:644
void NotifySwitchingStartNow(Time duration)
Definition: mac-low.cc:780
Time m_slotTime
Slot duration.
Definition: mac-low.h:1286
bool m_promisc
Flag if the device is operating in promiscuous mode.
Definition: mac-low.h:1293
void CancelAllEvents(void)
Cancel all scheduled events.
Definition: mac-low.cc:419
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener)
Definition: mac-low.cc:667
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
std::list< BufferedPacket >::iterator BufferedPacketI
Definition: mac-low.h:1302
void BlockAckTimeout(void)
Event handler when block ACK timeout occurs.
Definition: mac-low.cc:1583
void NotifyCtsTimeoutStartNow(Time duration)
Notify DcfManager (via DcfListener) that CTS timer should be started for the given duration...
Definition: mac-low.cc:1447
void SendBlockAckAfterBlockAckRequest(const CtrlBAckRequestHeader reqHdr, Mac48Address originator, Time duration, WifiMode blockAckReqTxMode)
Invoked after that a block ack request has been received.
Definition: mac-low.cc:2422
std::map< AgreementKey, BlockAckCache > BlockAckCaches
Definition: mac-low.h:1310
virtual uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: mac-low.cc:113
virtual void NavStart(Time duration)=0
Norify that NAV has started for the given duration.
void EnableCompressedBlockAck(void)
Wait COMPRESSEDBLOCKACKTimeout for a Compressed Block Ack Response frame.
Definition: mac-low.cc:156
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SuperFastAckTimeout(void)
Event handler when super fast ACK timeout occurs.
Definition: mac-low.cc:1596
void SetBssid(Mac48Address ad)
Set the Basic Service Set Identification.
Definition: mac-low.cc:573
listen for block ack events.
Definition: mac-low.h:191
uint32_t GetRtsSize(void) const
Return the total RTS size (including FCS trailer).
Definition: mac-low.cc:1159
void EnableAck(void)
Wait ACKTimeout for an ACK.
Definition: mac-low.cc:171
Time CalculateTransmissionTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &parameters) const
Definition: mac-low.cc:1330
virtual uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: mac-low.cc:89
EventId m_normalAckTimeoutEvent
Normal ACK timeout event.
Definition: mac-low.h:1259
void StartDataTxTimers(WifiTxVector dataTxVector)
Start a DATA timer by scheduling appropriate ACK timeout.
Definition: mac-low.cc:1695
void NotifyCtsTimeoutResetNow()
Notify DcfManager (via DcfListener) that CTS timer should be resetted.
Definition: mac-low.cc:1455
bool MustWaitBasicBlockAck(void) const
Definition: mac-low.cc:211
bool MustWaitCompressedBlockAck(void) const
Definition: mac-low.cc:216
bool NeedCtsToSelf(void)
Check if CTS-to-self mechanism should be used for the current packet.
Definition: mac-low.cc:734
an EUI-48 address
Definition: mac48-address.h:43
virtual ~MacLowBlockAckEventListener()
Definition: mac-low.cc:74
virtual void Cancel(void)=0
Invoked if this transmission was canceled one way or another.
Callback< void, Ptr< Packet >, const WifiMacHeader * > MacLowRxCallback
typedef for a callback for MacLowRx
Definition: mac-low.h:481
Time m_ackTimeout
ACK timeout duration.
Definition: mac-low.h:1281
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
Definition: mac-low.cc:2106
virtual void AckTimeoutStart(Time duration)=0
Notify that ACK timeout has started for a given duration.
listen to NAV eventsThis class is typically connected to an instance of ns3::Dcf and calls to its met...
Definition: mac-low.h:148
void FastAckTimeout(void)
Event handler when fast ACK timeout occurs (idle).
Definition: mac-low.cc:1566
void DisableRts(void)
Do not send rts and wait for cts before sending data.
Definition: mac-low.cc:186
void EnableMultiTidBlockAck(void)
NOT IMPLEMENTED FOR NOW.
Definition: mac-low.cc:161
EventId m_ctsTimeoutEvent
CTS timeout event.
Definition: mac-low.h:1264
void RxCompleteBufferedPacketsWithSmallerSequence(uint16_t seq, Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2241
void SetPhy(Ptr< WifiPhy > phy)
Set up WifiPhy associated with this MacLow.
Definition: mac-low.cc:491
Time m_basicBlockAckTimeout
Basic block ACK timeout duration.
Definition: mac-low.h:1282
Time GetDurationId(void) const
Definition: mac-low.cc:236
virtual void MissedBlockAck(void)
ns3::MacLow did not receive an expected BLOCK_ACK within BlockAckTimeout.
Definition: mac-low.cc:61
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition: mac-low.h:1285
void ReceiveError(Ptr< const Packet > packet, double rxSnr)
Definition: mac-low.cc:740
Time GetSlotTime(void) const
Return slot duration of this MacLow.
Definition: mac-low.cc:618
Time m_lastNavStart
The time when the latest NAV started.
Definition: mac-low.h:1290
WifiTxVector GetRtsTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the RTS frame given the destination.
Definition: mac-low.cc:1242
std::map< AgreementKey, AgreementValue > Agreements
Definition: mac-low.h:1307
virtual WifiTxVector GetDataTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the DATA frame given the destination.
Definition: mac-low.cc:1248
handle RTS/CTS/DATA/ACK transactions.
Definition: mac-low.h:475
virtual void MissedCts(void)=0
ns3::MacLow did not receive an expected CTS within CtsTimeout.
EventId m_sendDataEvent
Event to send DATA.
Definition: mac-low.h:1267
bool ReceiveMpdu(Ptr< Packet > packet, WifiMacHeader hdr)
This method updates the reorder buffer and the scoreboard when an MPDU is received in an HT station a...
Definition: mac-low.cc:2112
MacLowTransmissionParameters m_txParams
Transmission parameters of the current packet.
Definition: mac-low.h:1277
void SetRifs(Time rifs)
Set Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:568
virtual void DoDispose(void)
Destructor implementation.
Definition: mac-low.cc:390
void NotifyAckTimeoutResetNow()
Notify DcfManager (via DcfListener) that ACK timer should be resetted.
Definition: mac-low.cc:1439
bool MustWaitSuperFastAck(void) const
Definition: mac-low.cc:206
Time CalculateOverallTxTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &params) const
Definition: mac-low.cc:1285
QueueListeners m_edcaListeners
Definition: mac-low.h:1317
WifiTxVector GetBlockAckTxVector(Mac48Address to, WifiMode dataTxMode) const
Return a TXVECTOR for the Block ACK frame given the destination and the mode of the DATA used by the ...
Definition: mac-low.cc:1267
Mac48Address m_self
Address of this MacLow (Mac48Address)
Definition: mac-low.h:1279
Maintains information for a block ack agreement.
An identifier for simulation events.
Definition: event-id.h:53
EventId m_fastAckFailedTimeoutEvent
Fast ACK failed timeout event.
Definition: mac-low.h:1262
bool IsNavZero(void) const
Check if NAV is zero.
Definition: mac-low.cc:1834
void EnableRts(void)
Send a RTS, and wait CTSTimeout for a CTS.
Definition: mac-low.cc:181
void NotifyAckTimeoutStartNow(Time duration)
Notify DcfManager (via DcfListener) that ACK timer should be started for the given duration...
Definition: mac-low.cc:1431
virtual void NavReset(Time duration)=0
Notify that NAV has resetted.
void SetSlotTime(Time slotTime)
Set slot duration of this MacLow.
Definition: mac-low.cc:558
Ptr< Packet > m_currentPacket
Current packet transmitted/to be transmitted.
Definition: mac-low.h:1275
Time GetSifs(void) const
Return Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:608
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:582
void SendCtsAfterRts(Mac48Address source, Time duration, WifiMode txMode, double rtsSnr)
Send CTS after receiving RTS.
Definition: mac-low.cc:1933
std::map< AgreementKey, AgreementValue >::iterator AgreementsI
Definition: mac-low.h:1308
EventId m_endTxNoAckEvent
Event for finishing transmission that does not require ACK.
Definition: mac-low.h:1269
void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType)
Forward the packet down to WifiPhy for transmission.
Definition: mac-low.cc:1525
void EnableOverrideDurationId(Time durationId)
Definition: mac-low.cc:136
bool GetCtsToSelfSupported() const
Return whether CTS-to-self capability is supported.
Definition: mac-low.cc:543
void SetCtsTimeout(Time ctsTimeout)
Set CTS timeout of this MacLow.
Definition: mac-low.cc:548
void EnableNextData(uint32_t size)
Definition: mac-low.cc:126
void DeaggregateAmpduAndReceive(Ptr< Packet > aggregatedPacket, double rxSnr, WifiMode txMode, WifiPreamble preamble)
Definition: mac-low.cc:2517
void DisableOverrideDurationId(void)
Do not force the duration/id field of the packet: its value is automatically calculated by the MacLow...
Definition: mac-low.cc:141
Time GetAckTimeout(void) const
Return ACK timeout of this MacLow.
Definition: mac-low.cc:588
EventId m_waitRifsEvent
Wait for RIFS event.
Definition: mac-low.h:1271
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
Definition: mac-low.cc:131
void SendDataPacket(void)
Send DATA packet, which can be DATA-ACK or RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:1767
uint32_t GetCtsSize(void) const
Return the total CTS size (including FCS trailer).
Definition: mac-low.cc:1217
WifiMacHeader m_currentHdr
Header of the current packet.
Definition: mac-low.h:1276
void SetAddress(Mac48Address ad)
Set MAC address of this MacLow.
Definition: mac-low.cc:518
A base class which provides memory management and object aggregation.
Definition: object.h:87
tuple address
Definition: first.py:37
void ForwardDown(Ptr< const Packet > packet, const WifiMacHeader *hdr, WifiTxVector txVector, WifiPreamble preamble)
Forward the packet down to WifiPhy for transmission.
Definition: mac-low.cc:1464
Time m_compressedBlockAckTimeout
Compressed block ACK timeout duration.
Definition: mac-low.h:1283
bool MustWaitAck(void) const
Definition: mac-low.cc:191
virtual Ptr< const Packet > PeekNextPacketInBaQueue(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Definition: mac-low.cc:99
Headers for Block ack request.
Definition: ctrl-headers.h:49
bool IsAmpdu(Ptr< const Packet > packet, const WifiMacHeader hdr)
Checks if the given packet will be aggregated to an A-MPDU or not.
Definition: mac-low.cc:650
void FlushAggregateQueue(void)
This function is called to flush the aggregate queue, which is used for A-MPDU.
Definition: mac-low.cc:2810
virtual void AckTimeoutReset()=0
Notify that ACK timeout has resetted.
void RegisterBlockAckListenerForAc(enum AcIndex ac, MacLowBlockAckEventListener *listener)
Definition: mac-low.cc:2505
void ResetPhy(void)
Remove WifiPhy associated with this MacLow.
Definition: mac-low.cc:504
void DisableAck(void)
Do not wait for Ack after data transmission.
Definition: mac-low.cc:176
std::pair< BlockAckAgreement, std::list< BufferedPacket > > AgreementValue
Definition: mac-low.h:1305
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...
Definition: mac-low.cc:1273
Time GetBasicBlockAckTimeout() const
Return Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:593
void NotifyNav(Ptr< const Packet > packet, const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble)
Definition: mac-low.cc:1353
Time m_rifs
Reduced Interframe Space (RIFS) duration.
Definition: mac-low.h:1288
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:35
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...
Definition: mac-low.cc:1257
bool StoreMpduIfNeeded(Ptr< Packet > packet, WifiMacHeader hdr)
This method checks if exists a valid established block ack agreement.
Definition: mac-low.cc:2153
bool MustWaitNormalAck(void) const
Definition: mac-low.cc:196
virtual ~MacLow()
Definition: mac-low.cc:366
Ptr< MpduAggregator > m_mpduAggregator
Definition: mac-low.h:1273
Ptr< WifiPhy > m_phy
Pointer to WifiPhy (actually send/receives frames)
Definition: mac-low.h:1246
Implements the IEEE 802.11 MAC header.
void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Set Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:533
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
Set up WifiRemoteStationManager associated with this MacLow.
Definition: mac-low.cc:512
class PhyMacLowListener * m_phyMacLowListener
Listener needed to monitor when a channel switching occurs.
Definition: mac-low.h:1296
void SetMpduAggregator(Ptr< MpduAggregator > aggregator)
Set up MpduAggregator associated with this MacLow.
Definition: mac-low.cc:2511
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return the total size of the packet after WifiMacHeader and FCS trailer have been added...
Definition: mac-low.cc:1224
MacLowTransmissionListener * m_listener
Transmission listener for the current packet.
Definition: mac-low.h:1278
void SendRtsForPacket(void)
Send RTS to begin RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:1615
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2304