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-phy.h"
33 #include "wifi-preamble.h"
35 #include "ctrl-headers.h"
36 #include "mgt-headers.h"
37 #include "block-ack-agreement.h"
38 #include "ns3/mac48-address.h"
39 #include "ns3/callback.h"
40 #include "ns3/event-id.h"
41 #include "ns3/packet.h"
42 #include "ns3/nstime.h"
43 #include "qos-utils.h"
44 #include "block-ack-cache.h"
45 #include "wifi-tx-vector.h"
46 #include "mpdu-aggregator.h"
47 #include "msdu-aggregator.h"
48 
51 
52 namespace ns3 {
53 
54 class WifiPhy;
55 class WifiMac;
56 class EdcaTxopN;
57 class WifiMacQueue;
58 
64 {
65 public:
67  virtual ~MacLowTransmissionListener ();
68 
76  virtual void GotCts (double snr, WifiMode txMode) = 0;
81  virtual void MissedCts (void) = 0;
91  virtual void GotAck (double snr, WifiMode txMode) = 0;
96  virtual void MissedAck (void) = 0;
112  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address source, double rxSnr, WifiMode txMode, double dataSnr);
124  virtual void MissedBlockAck (uint32_t nMpdus);
131  virtual void StartNextFragment (void) = 0;
137  virtual void StartNext (void) = 0;
144  virtual void Cancel (void) = 0;
150  virtual void EndTxNoAck (void) = 0;
151 };
152 
153 
163 {
164 public:
166  virtual ~MacLowDcfListener ();
172  virtual void NavStart (Time duration) = 0;
178  virtual void NavReset (Time duration) = 0;
184  virtual void AckTimeoutStart (Time duration) = 0;
188  virtual void AckTimeoutReset () = 0;
194  virtual void CtsTimeoutStart (Time duration) = 0;
198  virtual void CtsTimeoutReset () = 0;
199 };
200 
206 {
207 public:
222  virtual void BlockAckInactivityTimeout (Mac48Address originator, uint8_t tid) = 0;
226  virtual Ptr<WifiMacQueue> GetQueue (void) = 0;
234  virtual void CompleteTransfer (Mac48Address address, uint8_t tid);
235  virtual void SetAmpdu (Mac48Address dest, bool enableAmpdu);
241  virtual void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
248  virtual uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr);
255  virtual uint16_t PeekNextSequenceNumberfor (WifiMacHeader *hdr);
256  /*
257  * Peek in retransmit queue and get the next packet without removing it from the queue
258  */
259  virtual Ptr<const Packet> PeekNextPacketInBaQueue (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
263  virtual void RemoveFromBaQueue (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
272  virtual bool GetBlockAckAgreementExists (Mac48Address address, uint8_t tid) = 0;
280  virtual uint32_t GetNOutstandingPackets (Mac48Address recipient, uint8_t tid);
288  virtual uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
291  virtual Ptr<MsduAggregator> GetMsduAggregator (void) const;
294  virtual Ptr<MpduAggregator> GetMpduAggregator (void) const;
301 };
302 
312 {
313 public:
315 
321  void EnableAck (void);
335  void EnableFastAck (void);
342  void EnableSuperFastAck (void);
346  void EnableBasicBlockAck (void);
350  void EnableCompressedBlockAck (void);
354  void EnableMultiTidBlockAck (void);
361  void EnableRts (void);
371  void EnableNextData (uint32_t size);
379  void EnableOverrideDurationId (Time durationId);
384  void DisableAck (void);
388  void DisableRts (void);
392  void DisableNextData (void);
398  void DisableOverrideDurationId (void);
406  bool MustWaitAck (void) const;
413  bool MustWaitNormalAck (void) const;
420  bool MustWaitFastAck (void) const;
427  bool MustWaitSuperFastAck (void) const;
433  bool MustWaitBasicBlockAck (void) const;
439  bool MustWaitCompressedBlockAck (void) const;
445  bool MustWaitMultiTidBlockAck (void) const;
450  bool MustSendRts (void) const;
455  bool HasDurationId (void) const;
459  Time GetDurationId (void) const;
463  bool HasNextPacket (void) const;
467  uint32_t GetNextPacketSize (void) const;
468 
469 private:
470  friend std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
471  uint32_t m_nextSize;
472  enum
473  {
481  } m_waitAck;
482  bool m_sendRts;
484 };
485 
493 std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
494 
495 
500 class MacLow : public Object
501 {
502 public:
503  // Allow test cases to access private members
504  friend class ::TwoLevelAggregationTest;
505  friend class ::AmpduAggregationTest;
510 
511  MacLow ();
512  virtual ~MacLow ();
513 
518  static TypeId GetTypeId (void);
519 
525  void SetPhy (Ptr<WifiPhy> phy);
526  /*
527  * \return current attached PHY device
528  */
529  Ptr<WifiPhy> GetPhy (void) const;
535  void ResetPhy (void);
547  void SetAddress (Mac48Address ad);
553  void SetAckTimeout (Time ackTimeout);
559  void SetBasicBlockAckTimeout (Time blockAckTimeout);
565  void SetCompressedBlockAckTimeout (Time blockAckTimeout);
571  void SetCtsToSelfSupported (bool enable);
577  void SetCtsTimeout (Time ctsTimeout);
583  void SetSifs (Time sifs);
589  void SetRifs (Time rifs);
595  void SetSlotTime (Time slotTime);
601  void SetPifs (Time pifs);
607  void SetBssid (Mac48Address ad);
611  void SetPromisc (void);
617  bool GetCtsToSelfSupported () const;
623  Mac48Address GetAddress (void) const;
629  Time GetAckTimeout (void) const;
635  Time GetBasicBlockAckTimeout () const;
647  Time GetCtsTimeout (void) const;
653  Time GetSifs (void) const;
659  Time GetSlotTime (void) const;
665  Time GetPifs (void) const;
671  Time GetRifs (void) const;
677  Mac48Address GetBssid (void) const;
684  bool IsPromisc (void) const;
685 
692  void SetRxCallback (Callback<void,Ptr<Packet>,const WifiMacHeader *> callback);
697  void RegisterDcfListener (MacLowDcfListener *listener);
698 
709  const WifiMacHeader* hdr,
710  const MacLowTransmissionParameters& parameters) const;
711 
713  const WifiMacHeader* hdr,
714  const MacLowTransmissionParameters &params) const;
715 
725  virtual void StartTransmission (Ptr<const Packet> packet,
726  const WifiMacHeader* hdr,
727  MacLowTransmissionParameters parameters,
728  MacLowTransmissionListener *listener);
729 
740  void ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiTxVector txVector, WifiPreamble preamble, bool ampduSubframe);
749  void ReceiveError (Ptr<Packet> packet, double rxSnr);
757  void NotifySwitchingStartNow (Time duration);
763  void NotifySleepNow (void);
779  void CreateBlockAckAgreement (const MgtAddBaResponseHeader *respHdr,
780  Mac48Address originator,
781  uint16_t startingSeq);
790  void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid);
817  void DeaggregateAmpduAndReceive (Ptr<Packet> aggregatedPacket, double rxSnr, WifiTxVector txVector, WifiPreamble preamble);
828  bool StopMpduAggregation (Ptr<const Packet> peekedPacket, WifiMacHeader peekedHdr, Ptr<Packet> aggregatedPacket, uint16_t size) const;
834  void FlushAggregateQueue (void);
835 
845  virtual WifiTxVector GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
846 
847 private:
852  void CancelAllEvents (void);
858  uint32_t GetAckSize (void) const;
865  uint32_t GetBlockAckSize (enum BlockAckType type) const;
871  uint32_t GetRtsSize (void) const;
877  uint32_t GetCtsSize (void) const;
886  uint32_t GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
895  void ForwardDown (Ptr<const Packet> packet, const WifiMacHeader *hdr,
896  WifiTxVector txVector, WifiPreamble preamble);
906  void SendMpdu (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype);
916  WifiTxVector GetRtsTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
927  WifiTxVector GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const;
938  WifiTxVector GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
949  WifiTxVector GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
988  Time GetCtsDuration (WifiTxVector ctsTxVector) const;
997  Time GetCtsDuration (Mac48Address to, WifiTxVector rtsTxVector) const;
1004  Time GetAckDuration (WifiTxVector ackTxVector) const;
1013  Time GetAckDuration (Mac48Address to, WifiTxVector dataTxVector) const;
1023  Time GetBlockAckDuration (Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const;
1030  bool NeedRts (void);
1037  bool NeedCtsToSelf (void);
1038 
1039  void NotifyNav (Ptr<const Packet> packet,const WifiMacHeader &hdr, WifiPreamble preamble);
1045  void DoNavResetNow (Time duration);
1052  bool DoNavStartNow (Time duration);
1059  bool IsNavZero (void) const;
1067  void NotifyAckTimeoutStartNow (Time duration);
1072  void NotifyAckTimeoutResetNow ();
1080  void NotifyCtsTimeoutStartNow (Time duration);
1085  void NotifyCtsTimeoutResetNow ();
1092  void NavCounterResetCtsMissed (Time rtsEndRxTime);
1093  /* Event handlers */
1097  void NormalAckTimeout (void);
1101  void FastAckTimeout (void);
1105  void SuperFastAckTimeout (void);
1109  void FastAckFailedTimeout (void);
1113  void BlockAckTimeout (void);
1117  void CtsTimeout (void);
1121  void SendCtsToSelf (void);
1130  void SendCtsAfterRts (Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr);
1139  void SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr);
1146  void SendDataAfterCts (Mac48Address source, Time duration);
1147 
1152  void WaitSifsAfterEndTxFragment (void);
1153  void WaitSifsAfterEndTx (void);
1154 
1158  void EndTxNoAck (void);
1162  void SendRtsForPacket (void);
1167  void SendDataPacket (void);
1174  void StartDataTxTimers (WifiTxVector dataTxVector);
1175 
1176  virtual void DoDispose (void);
1177 
1184  uint8_t GetTid (Ptr<const Packet> packet, const WifiMacHeader hdr) const;
1193  void RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address originator, uint8_t tid);
1206  void RxCompleteBufferedPacketsUntilFirstLost (Mac48Address originator, uint8_t tid);
1213  bool IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize);
1219  bool ReceiveMpdu (Ptr<Packet> packet, WifiMacHeader hdr);
1226  bool StoreMpduIfNeeded (Ptr<Packet> packet, WifiMacHeader hdr);
1238  Time duration, WifiMode blockAckReqTxMode, double rxSnr);
1243  void SendBlockAckAfterAmpdu (uint8_t tid, Mac48Address originator,
1244  Time duration, WifiTxVector blockAckReqTxVector, double rxSnr);
1255  void SendBlockAckResponse (const CtrlBAckResponseHeader* blockAck, Mac48Address originator, bool immediate,
1256  Time duration, WifiMode blockAckReqTxMode, double rxSnr);
1266 
1286  bool IsAmpdu (Ptr<const Packet> packet, const WifiMacHeader hdr);
1291  void InsertInTxQueue (Ptr<const Packet> packet, const WifiMacHeader &hdr, Time tStamp);
1303  Ptr<Packet> PerformMsduAggregation (Ptr<const Packet> packet, WifiMacHeader *hdr, Time *tstamp, Ptr<Packet> currentAmpduPacket, uint16_t blockAckSize);
1304 
1307  MacLowRxCallback m_rxCallback;
1308 
1312  typedef struct
1313  {
1317  } Item;
1318 
1322  typedef std::vector<MacLowDcfListener *>::const_iterator DcfListenersCI;
1326  typedef std::vector<MacLowDcfListener *> DcfListeners;
1327  DcfListeners m_dcfListeners;
1328 
1342 
1358 
1361 
1362  bool m_promisc;
1363  bool m_ampdu;
1364 
1366 
1367  /*
1368  * BlockAck data structures.
1369  */
1370  typedef std::pair<Ptr<Packet>, WifiMacHeader> BufferedPacket;
1371  typedef std::list<BufferedPacket>::iterator BufferedPacketI;
1372 
1373  typedef std::pair<Mac48Address, uint8_t> AgreementKey;
1374  typedef std::pair<BlockAckAgreement, std::list<BufferedPacket> > AgreementValue;
1375 
1376  typedef std::map<AgreementKey, AgreementValue> Agreements;
1377  typedef std::map<AgreementKey, AgreementValue>::iterator AgreementsI;
1378 
1379  typedef std::map<AgreementKey, BlockAckCache> BlockAckCaches;
1380  typedef std::map<AgreementKey, BlockAckCache>::iterator BlockAckCachesI;
1381 
1382  Agreements m_bAckAgreements;
1383  BlockAckCaches m_bAckCaches;
1384 
1385  typedef std::map<AcIndex, MacLowAggregationCapableTransmissionListener*> QueueListeners;
1386  QueueListeners m_edcaListeners;
1388  uint8_t m_sentMpdus;
1391  std::vector<Item> m_txPackets;
1392  uint32_t m_nTxMpdus;
1393 };
1394 
1395 } //namespace ns3
1396 
1397 #endif /* MAC_LOW_H */
bool MustSendRts(void) const
Definition: mac-low.cc:244
Time GetPifs(void) const
Return PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:675
uint32_t GetAckSize(void) const
Return the total ACK size (including FCS trailer).
Definition: mac-low.cc:1237
virtual ~MacLowDcfListener()
Definition: mac-low.cc:66
void SetPifs(Time pifs)
Set PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:603
Time m_ctsTimeout
CTS timeout duration.
Definition: mac-low.h:1353
virtual void SetAmpdu(Mac48Address dest, bool enableAmpdu)
Definition: mac-low.cc:76
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
EventId m_navCounterResetCtsMissed
Event to reset NAV when CTS is not received.
Definition: mac-low.h:1340
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Ptr< WifiPhy > GetPhy(void) const
Definition: mac-low.cc:528
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:2796
virtual void CtsTimeoutReset()=0
Notify that CTS timeout has resetted.
EventId m_blockAckTimeoutEvent
Block ACK timeout event.
Definition: mac-low.h:1333
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:1298
Callback template class.
Definition: callback.h:1176
virtual Ptr< WifiMacQueue > GetQueue(void)=0
Returns the EDCA queue to check if there are packets that can be aggregated with a Block Ack...
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:51
Time GetAckDuration(WifiTxVector ackTxVector) const
Return the time required to transmit the ACK (including preamble and FCS).
Definition: mac-low.cc:1282
void SendBlockAckAfterBlockAckRequest(const CtrlBAckRequestHeader reqHdr, Mac48Address originator, Time duration, WifiMode blockAckReqTxMode, double rxSnr)
Invoked after that a block ack request has been received.
Definition: mac-low.cc:2733
virtual void GotAck(double snr, WifiMode txMode)=0
virtual Ptr< const Packet > PeekNextPacketInBaQueue(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Definition: mac-low.cc:97
void SetPromisc(void)
Enable promiscuous mode.
Definition: mac-low.cc:621
EventId m_waitSifsEvent
Wait for SIFS event.
Definition: mac-low.h:1338
void DoNavResetNow(Time duration)
Reset NAV with the given duration.
Definition: mac-low.cc:1564
virtual Mac48Address GetDestAddressForAggregation(const WifiMacHeader &hdr)
Definition: mac-low.cc:131
bool IsPromisc(void) const
Check if MacLow is operating in promiscuous mode.
Definition: mac-low.cc:687
virtual bool GetBlockAckAgreementExists(Mac48Address address, uint8_t tid)=0
void EnableBasicBlockAck(void)
Wait BASICBLOCKACKTimeout for a Basic Block Ack Response frame.
Definition: mac-low.cc:169
EventId m_fastAckTimeoutEvent
Fast ACK timeout event.
Definition: mac-low.h:1330
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: mac-low.h:1356
void FastAckFailedTimeout(void)
Event handler when fast ACK timeout occurs (busy).
Definition: mac-low.cc:2351
bool DoNavStartNow(Time duration)
Start NAV with the given duration.
Definition: mac-low.cc:1575
Mac48Address GetBssid(void) const
Return the Basic Service Set Identification.
Definition: mac-low.cc:681
void SetSifs(Time sifs)
Set Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:591
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:1373
WifiTxVector GetCtsToSelfTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the CTS-to-self frame.
Definition: mac-low.cc:1368
void RegisterBlockAckListenerForAc(enum AcIndex ac, MacLowAggregationCapableTransmissionListener *listener)
Definition: mac-low.cc:2813
void SetupPhyMacLowListener(Ptr< WifiPhy > phy)
Set up WifiPhy listener for this MacLow.
Definition: mac-low.cc:401
virtual void MissedBlockAck(uint32_t nMpdus)
Definition: mac-low.cc:59
friend std::ostream & operator<<(std::ostream &os, const MacLowTransmissionParameters &params)
Serialize MacLowTransmissionParameters to ostream in a human-readable form.
Definition: mac-low.cc:271
void NotifySleepNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
Definition: mac-low.cc:875
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr) const
Definition: mac-low.cc:1214
bool HasDurationId(void) const
Definition: mac-low.cc:249
DcfListeners m_dcfListeners
List of MacLowDcfListener (pass events to Dcf)
Definition: mac-low.h:1327
uint8_t m_sentMpdus
Number of transmitted MPDUs in an A-MPDU that have not been acknowledged yet.
Definition: mac-low.h:1388
bool m_ampdu
Flag if the current transmission involves an A-MPDU.
Definition: mac-low.h:1363
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:693
void DeaggregateAmpduAndReceive(Ptr< Packet > aggregatedPacket, double rxSnr, WifiTxVector txVector, WifiPreamble preamble)
Definition: mac-low.cc:2819
Time GetCompressedBlockAckTimeout() const
Return Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:645
Mac48Address m_bssid
BSSID address (Mac48Address)
Definition: mac-low.h:1349
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...
BlockAckType
Enumeration for different block ACK policies.
Definition: ctrl-headers.h:31
Ptr< Packet > AggregateToAmpdu(Ptr< const Packet > packet, const WifiMacHeader hdr)
Definition: mac-low.cc:2962
EventId m_sendCtsEvent
Event to send CTS.
Definition: mac-low.h:1335
MacLowRxCallback m_rxCallback
Callback to pass packet up.
Definition: mac-low.h:1307
Time GetCtsTimeout(void) const
Return CTS timeout of this MacLow.
Definition: mac-low.cc:651
EventId m_superFastAckTimeoutEvent
Super fast ACK timeout event.
Definition: mac-low.h:1331
EventId m_sendAckEvent
Event to send ACK.
Definition: mac-low.h:1336
listen to events coming from ns3::MacLow.
Definition: mac-low.h:63
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
virtual void StartNextFragment(void)=0
Invoked when ns3::MacLow wants to start a new transmission as configured by MacLowTransmissionParamet...
Time GetCtsDuration(WifiTxVector ctsTxVector) const
Return the time required to transmit the CTS (including preamble and FCS).
Definition: mac-low.cc:1328
bool MustWaitFastAck(void) const
Definition: mac-low.cc:219
Ptr< Packet > PerformMsduAggregation(Ptr< const Packet > packet, WifiMacHeader *hdr, Time *tstamp, Ptr< Packet > currentAmpduPacket, uint16_t blockAckSize)
Perform MSDU aggregation for a given MPDU in an A-MPDU.
Definition: mac-low.cc:3284
control how a packet is transmitted.
Definition: mac-low.h:311
void WaitSifsAfterEndTx(void)
Definition: mac-low.cc:2337
std::vector< MacLowDcfListener * >::const_iterator DcfListenersCI
typedef for an iterator for a list of MacLowDcfListener.
Definition: mac-low.h:1322
virtual void CompleteTransfer(Mac48Address address, uint8_t tid)
Definition: mac-low.cc:79
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self capability.
Definition: mac-low.cc:573
void NormalAckTimeout(void)
Event handler when normal ACK timeout occurs.
Definition: mac-low.cc:1762
void SetBasicBlockAckTimeout(Time blockAckTimeout)
Set Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:561
BlockAckCaches m_bAckCaches
Definition: mac-low.h:1383
void InsertInTxQueue(Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tStamp)
Insert in a temporary queue.
Definition: mac-low.cc:3272
virtual uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: mac-low.cc:111
void RemovePhyMacLowListener(Ptr< WifiPhy > phy)
Remove current WifiPhy listener for this MacLow.
Definition: mac-low.cc:408
std::map< AcIndex, MacLowAggregationCapableTransmissionListener * > QueueListeners
Definition: mac-low.h:1385
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
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:102
WifiTxVector m_currentTxVector
TXVECTOR used for the current packet transmission.
Definition: mac-low.h:1390
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2526
Time m_lastNavDuration
The duration of the latest NAV.
Definition: mac-low.h:1360
enum ns3::MacLowTransmissionParameters::@84 m_waitAck
std::pair< Ptr< Packet >, WifiMacHeader > BufferedPacket
Definition: mac-low.h:1370
bool m_ctsToSelfSupported
Flag whether CTS-to-self is supported.
Definition: mac-low.h:1387
void SendCtsToSelf(void)
Send CTS for a CTS-to-self mechanism.
Definition: mac-low.cc:2093
tuple phy
Definition: third.py:86
void SendAckAfterData(Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr)
Send ACK after receiving DATA.
Definition: mac-low.cc:2361
virtual Mac48Address GetSrcAddressForAggregation(const WifiMacHeader &hdr)
Definition: mac-low.cc:126
void CreateBlockAckAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq)
Definition: mac-low.cc:2484
Ptr< WifiMacQueue > m_aggregateQueue
Queue used for MPDU aggregation.
Definition: mac-low.h:1389
void NotifyNav(Ptr< const Packet > packet, const WifiMacHeader &hdr, WifiPreamble preamble)
Definition: mac-low.cc:1513
uint32_t GetBlockAckSize(enum BlockAckType type) const
Return the total Block ACK size (including FCS trailer).
Definition: mac-low.cc:1245
Listener for PHY events.
Definition: mac-low.cc:310
void CtsTimeout(void)
Event handler when CTS timeout occurs.
Definition: mac-low.cc:1742
virtual void StartNext(void)=0
Invoked when ns3::MacLow wants to continue the TXOP.
void EndTxNoAck(void)
A transmission that does not require an ACK has completed.
Definition: mac-low.cc:2343
void SendBlockAckAfterAmpdu(uint8_t tid, Mac48Address originator, Time duration, WifiTxVector blockAckReqTxVector, double rxSnr)
Invoked after an A-MPDU has been received.
Definition: mac-low.cc:2711
std::map< AgreementKey, BlockAckCache >::iterator BlockAckCachesI
Definition: mac-low.h:1380
std::vector< MacLowDcfListener * > DcfListeners
typedef for a list of MacLowDcfListener.
Definition: mac-low.h:1326
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:1394
void SetAckTimeout(Time ackTimeout)
Set ACK timeout of this MacLow.
Definition: mac-low.cc:555
static TypeId GetTypeId(void)
Register this type.
Definition: mac-low.cc:390
virtual uint32_t GetNOutstandingPackets(Mac48Address recipient, uint8_t tid)
Definition: mac-low.cc:106
virtual void GotCts(double snr, WifiMode txMode)=0
void SendDataAfterCts(Mac48Address source, Time duration)
Send DATA after receiving CTS.
Definition: mac-low.cc:2231
Time GetRifs(void) const
Return Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:663
void NavCounterResetCtsMissed(Time rtsEndRxTime)
Reset NAV after CTS was missed when the NAV was setted with RTS.
Definition: mac-low.cc:1555
Ptr< WifiRemoteStationManager > m_stationManager
Pointer to WifiRemoteStationManager (rate control)
Definition: mac-low.h:1306
bool MustWaitMultiTidBlockAck(void) const
Definition: mac-low.cc:239
Headers for Block ack response.
Definition: ctrl-headers.h:186
bool NeedRts(void)
Check if the current packet should be sent with a RTS protection.
Definition: mac-low.cc:830
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:627
uint32_t GetNextPacketSize(void) const
Definition: mac-low.cc:265
Agreements m_bAckAgreements
Definition: mac-low.h:1382
bool HasNextPacket(void) const
Definition: mac-low.cc:260
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:1412
virtual uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: mac-low.cc:87
void RegisterDcfListener(MacLowDcfListener *listener)
Definition: mac-low.cc:699
void NotifySwitchingStartNow(Time duration)
Definition: mac-low.cc:859
Time m_slotTime
Slot duration.
Definition: mac-low.h:1355
bool m_promisc
Flag if the device is operating in promiscuous mode.
Definition: mac-low.h:1362
WifiMacHeader hdr
Definition: mac-low.h:1315
void CancelAllEvents(void)
Cancel all scheduled events.
Definition: mac-low.cc:447
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener)
Definition: mac-low.cc:724
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:1371
void BlockAckTimeout(void)
Event handler when block ACK timeout occurs.
Definition: mac-low.cc:1797
void NotifyCtsTimeoutStartNow(Time duration)
Notify DcfManager (via DcfListener) that CTS timer should be started for the given duration...
Definition: mac-low.cc:1611
std::map< AgreementKey, BlockAckCache > BlockAckCaches
Definition: mac-low.h:1379
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address source, double rxSnr, WifiMode txMode, double dataSnr)
Definition: mac-low.cc:55
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:174
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:1810
void SetBssid(Mac48Address ad)
Set the Basic Service Set Identification.
Definition: mac-low.cc:615
uint32_t GetRtsSize(void) const
Return the total RTS size (including FCS trailer).
Definition: mac-low.cc:1267
void EnableAck(void)
Wait ACKTimeout for an ACK.
Definition: mac-low.cc:189
Time CalculateTransmissionTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &parameters) const
Definition: mac-low.cc:1477
EventId m_normalAckTimeoutEvent
Normal ACK timeout event.
Definition: mac-low.h:1329
void StartDataTxTimers(WifiTxVector dataTxVector)
Start a DATA timer by scheduling appropriate ACK timeout.
Definition: mac-low.cc:1915
void NotifyCtsTimeoutResetNow()
Notify DcfManager (via DcfListener) that CTS timer should be resetted.
Definition: mac-low.cc:1620
bool MustWaitBasicBlockAck(void) const
Definition: mac-low.cc:229
bool MustWaitCompressedBlockAck(void) const
Definition: mac-low.cc:234
bool NeedCtsToSelf(void)
Check if CTS-to-self mechanism should be used for the current packet.
Definition: mac-low.cc:838
an EUI-48 address
Definition: mac48-address.h:43
Ptr< const Packet > packet
Definition: mac-low.h:1314
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:509
void SendBlockAckResponse(const CtrlBAckResponseHeader *blockAck, Mac48Address originator, bool immediate, Time duration, WifiMode blockAckReqTxMode, double rxSnr)
This method creates block ack frame with header equals to blockAck and start its transmission.
Definition: mac-low.cc:2634
Time m_ackTimeout
ACK timeout duration.
Definition: mac-low.h:1350
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
Definition: mac-low.cc:2404
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:162
void FastAckTimeout(void)
Event handler when fast ACK timeout occurs (idle).
Definition: mac-low.cc:1779
void DisableRts(void)
Do not send rts and wait for cts before sending data.
Definition: mac-low.cc:204
void EnableMultiTidBlockAck(void)
NOT IMPLEMENTED FOR NOW.
Definition: mac-low.cc:179
EventId m_ctsTimeoutEvent
CTS timeout event.
Definition: mac-low.h:1334
void RxCompleteBufferedPacketsWithSmallerSequence(uint16_t seq, Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2542
void SendCtsAfterRts(Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr)
Send CTS after receiving RTS.
Definition: mac-low.cc:2188
void SetPhy(Ptr< WifiPhy > phy)
Set up WifiPhy associated with this MacLow.
Definition: mac-low.cc:519
Time m_basicBlockAckTimeout
Basic block ACK timeout duration.
Definition: mac-low.h:1351
void SendMpdu(Ptr< const Packet > packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype)
Forward the MPDU down to WifiPhy for transmission.
Definition: mac-low.cc:1735
Time GetDurationId(void) const
Definition: mac-low.cc:254
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:83
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition: mac-low.h:1354
Time GetSlotTime(void) const
Return slot duration of this MacLow.
Definition: mac-low.cc:669
WifiMacHeader m_lastReceivedHdr
Header of the last received packet.
Definition: mac-low.h:1345
Time m_lastNavStart
The time when the latest NAV started.
Definition: mac-low.h:1359
void ReceiveError(Ptr< Packet > packet, double rxSnr)
Definition: mac-low.cc:845
WifiTxVector GetRtsTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the RTS frame given the destination.
Definition: mac-low.cc:1374
std::map< AgreementKey, AgreementValue > Agreements
Definition: mac-low.h:1376
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:1381
handle RTS/CTS/DATA/ACK transactions.
Definition: mac-low.h:500
virtual void MissedCts(void)=0
ns3::MacLow did not receive an expected CTS within CtsTimeout.
std::vector< Item > m_txPackets
Contain temporary items to be sent with the next A-MPDU transmission, once RTS/CTS exchange has succe...
Definition: mac-low.h:1391
EventId m_sendDataEvent
Event to send DATA.
Definition: mac-low.h:1337
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:2410
MacLowTransmissionParameters m_txParams
Transmission parameters of the current packet.
Definition: mac-low.h:1346
void SetRifs(Time rifs)
Set Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:609
virtual void DoDispose(void)
Destructor implementation.
Definition: mac-low.cc:419
void NotifyAckTimeoutResetNow()
Notify DcfManager (via DcfListener) that ACK timer should be resetted.
Definition: mac-low.cc:1602
bool MustWaitSuperFastAck(void) const
Definition: mac-low.cc:224
Time CalculateOverallTxTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &params) const
Definition: mac-low.cc:1418
QueueListeners m_edcaListeners
Definition: mac-low.h:1386
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:1400
Mac48Address m_self
Address of this MacLow (Mac48Address)
Definition: mac-low.h:1348
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:1332
bool IsNavZero(void) const
Check if NAV is zero.
Definition: mac-low.cc:2080
void EnableRts(void)
Send a RTS, and wait CTSTimeout for a CTS.
Definition: mac-low.cc:199
void NotifyAckTimeoutStartNow(Time duration)
Notify DcfManager (via DcfListener) that ACK timer should be started for the given duration...
Definition: mac-low.cc:1593
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:597
Ptr< Packet > m_currentPacket
Current packet transmitted/to be transmitted.
Definition: mac-low.h:1343
Time GetSifs(void) const
Return Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:657
bool StopMpduAggregation(Ptr< const Packet > peekedPacket, WifiMacHeader peekedHdr, Ptr< Packet > aggregatedPacket, uint16_t size) const
Definition: mac-low.cc:2908
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:799
std::map< AgreementKey, AgreementValue >::iterator AgreementsI
Definition: mac-low.h:1377
EventId m_endTxNoAckEvent
Event for finishing transmission that does not require ACK.
Definition: mac-low.h:1339
void EnableOverrideDurationId(Time durationId)
Definition: mac-low.cc:154
uint32_t m_nTxMpdus
Holds the number of transmitted MPDUs in the last A-MPDU transmission.
Definition: mac-low.h:1392
bool GetCtsToSelfSupported() const
Return whether CTS-to-self capability is supported.
Definition: mac-low.cc:579
void ReceiveOk(Ptr< Packet > packet, double rxSnr, WifiTxVector txVector, WifiPreamble preamble, bool ampduSubframe)
Definition: mac-low.cc:890
void SetCtsTimeout(Time ctsTimeout)
Set CTS timeout of this MacLow.
Definition: mac-low.cc:585
void EnableNextData(uint32_t size)
Definition: mac-low.cc:144
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:159
Time GetAckTimeout(void) const
Return ACK timeout of this MacLow.
Definition: mac-low.cc:633
virtual Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: mac-low.cc:116
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:92
EventId m_waitRifsEvent
Wait for RIFS event.
Definition: mac-low.h:1341
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
Definition: mac-low.cc:149
void SendDataPacket(void)
Send DATA packet, which can be DATA-ACK or RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:2001
uint32_t GetCtsSize(void) const
Return the total CTS size (including FCS trailer).
Definition: mac-low.cc:1344
WifiMacHeader m_currentHdr
Header of the current transmitted packet.
Definition: mac-low.h:1344
void SetAddress(Mac48Address ad)
Set MAC address of this MacLow.
Definition: mac-low.cc:549
void WaitSifsAfterEndTxFragment(void)
Event handler that is usually scheduled to fired at the appropriate time after completing transmissio...
Definition: mac-low.cc:2331
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:1629
Time m_compressedBlockAckTimeout
Compressed block ACK timeout duration.
Definition: mac-low.h:1352
bool MustWaitAck(void) const
Definition: mac-low.cc:209
Headers for Block ack request.
Definition: ctrl-headers.h:50
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:705
void FlushAggregateQueue(void)
This function is called to flush the aggregate queue, which is used for A-MPDU.
Definition: mac-low.cc:3261
virtual void AckTimeoutReset()=0
Notify that ACK timeout has resetted.
void ResetPhy(void)
Remove WifiPhy associated with this MacLow.
Definition: mac-low.cc:534
void DisableAck(void)
Do not wait for Ack after data transmission.
Definition: mac-low.cc:194
std::pair< BlockAckAgreement, std::list< BufferedPacket > > AgreementValue
Definition: mac-low.h:1374
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:1406
Time GetBasicBlockAckTimeout() const
Return Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:639
a unique identifier for an interface.
Definition: type-id.h:58
Time m_rifs
Reduced Interframe Space (RIFS) duration.
Definition: mac-low.h:1357
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:36
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:1388
bool StoreMpduIfNeeded(Ptr< Packet > packet, WifiMacHeader hdr)
This method checks if exists a valid established block ack agreement.
Definition: mac-low.cc:2455
bool MustWaitNormalAck(void) const
Definition: mac-low.cc:214
virtual ~MacLow()
Definition: mac-low.cc:383
A struct for packet, Wifi header, and timestamp.
Definition: mac-low.h:1312
Ptr< WifiPhy > m_phy
Pointer to WifiPhy (actually send/receives frames)
Definition: mac-low.h:1305
Implements the IEEE 802.11 MAC header.
void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Set Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:567
virtual Ptr< MpduAggregator > GetMpduAggregator(void) const
Definition: mac-low.cc:121
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
Set up WifiRemoteStationManager associated with this MacLow.
Definition: mac-low.cc:543
class PhyMacLowListener * m_phyMacLowListener
Listener needed to monitor when a channel switching occurs.
Definition: mac-low.h:1365
mpduType
This enumeration defines the type of an MPDU.
Definition: wifi-phy.h:56
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:1352
MacLowTransmissionListener * m_listener
Transmission listener for the current packet.
Definition: mac-low.h:1347
void SendRtsForPacket(void)
Send RTS to begin RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:1829
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2605