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 #include "msdu-aggregator.h"
47 
49 
50 namespace ns3 {
51 
52 class WifiPhy;
53 class WifiMac;
54 class EdcaTxopN;
55 class WifiMacQueue;
56 
62 {
63 public:
65  virtual ~MacLowTransmissionListener ();
66 
74  virtual void GotCts (double snr, WifiMode txMode) = 0;
79  virtual void MissedCts (void) = 0;
89  virtual void GotAck (double snr, WifiMode txMode) = 0;
94  virtual void MissedAck (void) = 0;
108  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address source, WifiMode txMode);
118  virtual void MissedBlockAck (void);
125  virtual void StartNext (void) = 0;
132  virtual void Cancel (void) = 0;
138  virtual void EndTxNoAck (void) = 0;
139 };
140 
141 
151 {
152 public:
154  virtual ~MacLowDcfListener ();
160  virtual void NavStart (Time duration) = 0;
166  virtual void NavReset (Time duration) = 0;
172  virtual void AckTimeoutStart (Time duration) = 0;
176  virtual void AckTimeoutReset () = 0;
182  virtual void CtsTimeoutStart (Time duration) = 0;
186  virtual void CtsTimeoutReset () = 0;
187 };
188 
194 {
195 public:
210  virtual void BlockAckInactivityTimeout (Mac48Address originator, uint8_t tid) = 0;
214  virtual Ptr<WifiMacQueue> GetQueue (void) = 0;
222  virtual void CompleteTransfer (Mac48Address address, uint8_t tid);
223  virtual void SetAmpdu (bool ampdu);
229  virtual void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
236  virtual uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr);
243  virtual uint16_t PeekNextSequenceNumberfor (WifiMacHeader *hdr);
244  /*
245  * Peek in retransmit queue and get the next packet without removing it from the queue
246  */
247  virtual Ptr<const Packet> PeekNextPacketInBaQueue (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
251  virtual void RemoveFromBaQueue (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
260  virtual bool GetBlockAckAgreementExists (Mac48Address address, uint8_t tid) = 0;
268  virtual uint32_t GetNOutstandingPackets (Mac48Address recipient, uint8_t tid);
276  virtual uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
279  virtual Ptr<MsduAggregator> GetMsduAggregator (void) const;
286 };
287 
297 {
298 public:
300 
306  void EnableAck (void);
320  void EnableFastAck (void);
327  void EnableSuperFastAck (void);
331  void EnableBasicBlockAck (void);
335  void EnableCompressedBlockAck (void);
339  void EnableMultiTidBlockAck (void);
346  void EnableRts (void);
356  void EnableNextData (uint32_t size);
364  void EnableOverrideDurationId (Time durationId);
369  void DisableAck (void);
373  void DisableRts (void);
377  void DisableNextData (void);
383  void DisableOverrideDurationId (void);
391  bool MustWaitAck (void) const;
398  bool MustWaitNormalAck (void) const;
405  bool MustWaitFastAck (void) const;
412  bool MustWaitSuperFastAck (void) const;
418  bool MustWaitBasicBlockAck (void) const;
424  bool MustWaitCompressedBlockAck (void) const;
430  bool MustWaitMultiTidBlockAck (void) const;
435  bool MustSendRts (void) const;
440  bool HasDurationId (void) const;
444  Time GetDurationId (void) const;
448  bool HasNextPacket (void) const;
452  uint32_t GetNextPacketSize (void) const;
453 
454 private:
455 
456  friend std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
457  uint32_t m_nextSize;
458  enum
459  {
467  } m_waitAck;
468  bool m_sendRts;
470 };
471 
479 std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
480 
481 
486 class MacLow : public Object
487 {
488 public:
489  // Allow test cases to access private members
490  friend class ::TwoLevelAggregationTest;
495 
496  MacLow ();
497  virtual ~MacLow ();
498 
504  void SetPhy (Ptr<WifiPhy> phy);
505  /*
506  * \return current attached PHY device
507  */
508  Ptr<WifiPhy> GetPhy (void) const;
514  void ResetPhy (void);
526  void SetMpduAggregator (Ptr<MpduAggregator> aggregator);
532  void SetAddress (Mac48Address ad);
538  void SetAckTimeout (Time ackTimeout);
544  void SetBasicBlockAckTimeout (Time blockAckTimeout);
550  void SetCompressedBlockAckTimeout (Time blockAckTimeout);
556  void SetCtsToSelfSupported (bool enable);
562  void SetCtsTimeout (Time ctsTimeout);
568  void SetSifs (Time sifs);
574  void SetRifs (Time rifs);
580  void SetSlotTime (Time slotTime);
586  void SetPifs (Time pifs);
592  void SetBssid (Mac48Address ad);
596  void SetPromisc (void);
602  bool GetCtsToSelfSupported () const;
608  Mac48Address GetAddress (void) const;
614  Time GetAckTimeout (void) const;
620  Time GetBasicBlockAckTimeout () const;
632  Time GetCtsTimeout (void) const;
638  Time GetSifs (void) const;
644  Time GetSlotTime (void) const;
650  Time GetPifs (void) const;
656  Time GetRifs (void) const;
662  Mac48Address GetBssid (void) const;
669  bool IsPromisc (void) const;
670 
677  void SetRxCallback (Callback<void,Ptr<Packet>,const WifiMacHeader *> callback);
682  void RegisterDcfListener (MacLowDcfListener *listener);
683 
694  const WifiMacHeader* hdr,
695  const MacLowTransmissionParameters& parameters) const;
696 
706  virtual void StartTransmission (Ptr<const Packet> packet,
707  const WifiMacHeader* hdr,
708  MacLowTransmissionParameters parameters,
709  MacLowTransmissionListener *listener);
710 
721  void ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiTxVector txVector, WifiPreamble preamble, bool ampduSubframe);
729  void ReceiveError (Ptr<const Packet> packet, double rxSnr);
737  void NotifySwitchingStartNow (Time duration);
743  void NotifySleepNow (void);
759  void CreateBlockAckAgreement (const MgtAddBaResponseHeader *respHdr,
760  Mac48Address originator,
761  uint16_t startingSeq);
770  void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid);
797  void DeaggregateAmpduAndReceive (Ptr<Packet> aggregatedPacket, double rxSnr, WifiTxVector txVector, WifiPreamble preamble);
808  bool StopMpduAggregation (Ptr<const Packet> peekedPacket, WifiMacHeader peekedHdr, Ptr<Packet> aggregatedPacket, uint16_t size) const;
814  void FlushAggregateQueue (void);
815 
816 protected:
826  virtual WifiTxVector GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
827 private:
832  void CancelAllEvents (void);
838  uint32_t GetAckSize (void) const;
845  uint32_t GetBlockAckSize (enum BlockAckType type) const;
851  uint32_t GetRtsSize (void) const;
857  uint32_t GetCtsSize (void) const;
866  uint32_t GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
875  void ForwardDown (Ptr<const Packet> packet, const WifiMacHeader *hdr,
876  WifiTxVector txVector, WifiPreamble preamble);
885  void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType);
895  WifiTxVector GetRtsTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
906  WifiTxVector GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const;
917  WifiTxVector GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
928  WifiTxVector GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
967  Time GetCtsDuration (WifiTxVector ctsTxVector) const;
976  Time GetCtsDuration (Mac48Address to, WifiTxVector rtsTxVector) const;
983  Time GetAckDuration (WifiTxVector ackTxVector) const;
992  Time GetAckDuration (Mac48Address to, WifiTxVector dataTxVector) const;
1002  Time GetBlockAckDuration (Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const;
1009  bool NeedCtsToSelf (void);
1010 
1012  const WifiMacHeader* hdr,
1013  const MacLowTransmissionParameters &params) const;
1014  void NotifyNav (Ptr<const Packet> packet,const WifiMacHeader &hdr, WifiPreamble preamble);
1020  void DoNavResetNow (Time duration);
1027  bool DoNavStartNow (Time duration);
1034  bool IsNavZero (void) const;
1042  void NotifyAckTimeoutStartNow (Time duration);
1047  void NotifyAckTimeoutResetNow ();
1055  void NotifyCtsTimeoutStartNow (Time duration);
1060  void NotifyCtsTimeoutResetNow ();
1067  void NavCounterResetCtsMissed (Time rtsEndRxTime);
1068  /* Event handlers */
1072  void NormalAckTimeout (void);
1076  void FastAckTimeout (void);
1080  void SuperFastAckTimeout (void);
1084  void FastAckFailedTimeout (void);
1088  void BlockAckTimeout (void);
1092  void CtsTimeout (void);
1096  void SendCtsToSelf (void);
1105  void SendCtsAfterRts (Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr);
1114  void SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr);
1121  void SendDataAfterCts (Mac48Address source, Time duration);
1126  void WaitSifsAfterEndTx (void);
1130  void EndTxNoAck (void);
1134  void SendRtsForPacket (void);
1139  void SendDataPacket (void);
1146  void StartDataTxTimers (WifiTxVector dataTxVector);
1147 
1148  virtual void DoDispose (void);
1149 
1156  uint8_t GetTid(Ptr<const Packet> packet, const WifiMacHeader hdr) const;
1165  void RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address originator, uint8_t tid);
1178  void RxCompleteBufferedPacketsUntilFirstLost (Mac48Address originator, uint8_t tid);
1185  bool IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize);
1191  bool ReceiveMpdu (Ptr<Packet> packet, WifiMacHeader hdr);
1198  bool StoreMpduIfNeeded (Ptr<Packet> packet, WifiMacHeader hdr);
1209  Time duration, WifiMode blockAckReqTxMode);
1214  void SendBlockAckAfterAmpdu (uint8_t tid, Mac48Address originator,
1215  Time duration, WifiTxVector blockAckReqTxVector);
1225  void SendBlockAckResponse (const CtrlBAckResponseHeader* blockAck, Mac48Address originator, bool immediate,
1226  Time duration, WifiMode blockAckReqTxMode);
1236 
1256  bool IsAmpdu (Ptr<const Packet> packet, const WifiMacHeader hdr);
1261  void InsertInTxQueue (Ptr<const Packet> packet, const WifiMacHeader &hdr, Time tStamp);
1273  Ptr<Packet> PerformMsduAggregation(Ptr<const Packet> packet, WifiMacHeader *hdr, Time *tstamp, Ptr<Packet> currentAmpduPacket, uint16_t blockAckSize);
1274 
1275 
1278  MacLowRxCallback m_rxCallback;
1279 
1283  typedef struct
1284  {
1288  } Item;
1289 
1293  typedef std::vector<MacLowDcfListener *>::const_iterator DcfListenersCI;
1297  typedef std::vector<MacLowDcfListener *> DcfListeners;
1298  DcfListeners m_dcfListeners;
1299 
1313 
1315 
1330 
1333 
1334  bool m_promisc;
1335  bool m_ampdu;
1336 
1338 
1339  /*
1340  * BlockAck data structures.
1341  */
1342  typedef std::pair<Ptr<Packet>, WifiMacHeader> BufferedPacket;
1343  typedef std::list<BufferedPacket>::iterator BufferedPacketI;
1344 
1345  typedef std::pair<Mac48Address, uint8_t> AgreementKey;
1346  typedef std::pair<BlockAckAgreement, std::list<BufferedPacket> > AgreementValue;
1347 
1348  typedef std::map<AgreementKey, AgreementValue> Agreements;
1349  typedef std::map<AgreementKey, AgreementValue>::iterator AgreementsI;
1350 
1351  typedef std::map<AgreementKey, BlockAckCache> BlockAckCaches;
1352  typedef std::map<AgreementKey, BlockAckCache>::iterator BlockAckCachesI;
1353 
1354  Agreements m_bAckAgreements;
1355  BlockAckCaches m_bAckCaches;
1356 
1357  typedef std::map<AcIndex, MacLowAggregationCapableTransmissionListener*> QueueListeners;
1358  QueueListeners m_edcaListeners;
1360  uint8_t m_sentMpdus;
1364  std::vector<Item> m_txPackets;
1365 };
1366 
1367 } // namespace ns3
1368 
1369 #endif /* MAC_LOW_H */
bool MustSendRts(void) const
Definition: mac-low.cc:242
Time GetPifs(void) const
Return PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:639
uint32_t GetAckSize(void) const
Return the total ACK size (including FCS trailer).
Definition: mac-low.cc:1148
virtual ~MacLowDcfListener()
Definition: mac-low.cc:68
void SetPifs(Time pifs)
Set PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:579
Time m_ctsTimeout
CTS timeout duration.
Definition: mac-low.h:1325
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:1311
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Ptr< WifiPhy > GetPhy(void) const
Definition: mac-low.cc:515
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:2487
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:1304
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:1195
Callback template class.
Definition: callback.h:984
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:53
Time GetAckDuration(WifiTxVector ackTxVector) const
Return the time required to transmit the ACK (including preamble and FCS).
Definition: mac-low.cc:1189
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:100
void SetPromisc(void)
Enable promiscuous mode.
Definition: mac-low.cc:594
EventId m_waitSifsEvent
Wait for SIFS event.
Definition: mac-low.h:1309
void DoNavResetNow(Time duration)
Reset NAV with the given duration.
Definition: mac-low.cc:1403
virtual Mac48Address GetDestAddressForAggregation(const WifiMacHeader &hdr)
Definition: mac-low.cc:129
bool IsPromisc(void) const
Check if MacLow is operating in promiscuous mode.
Definition: mac-low.cc:649
bool m_receivedAtLeastOneMpdu
Flag whether an MPDU has already been successfully received while receiving an A-MPDU.
Definition: mac-low.h:1363
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:167
EventId m_fastAckTimeoutEvent
Fast ACK timeout event.
Definition: mac-low.h:1301
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: mac-low.h:1328
void FastAckFailedTimeout(void)
Event handler when fast ACK timeout occurs (busy).
Definition: mac-low.cc:2065
bool DoNavStartNow(Time duration)
Start NAV with the given duration.
Definition: mac-low.cc:1413
Mac48Address GetBssid(void) const
Return the Basic Service Set Identification.
Definition: mac-low.cc:644
void SetSifs(Time sifs)
Set Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:569
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:1345
WifiTxVector GetCtsToSelfTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the CTS-to-self frame.
Definition: mac-low.cc:1241
void RegisterBlockAckListenerForAc(enum AcIndex ac, MacLowAggregationCapableTransmissionListener *listener)
Definition: mac-low.cc:2507
void SetupPhyMacLowListener(Ptr< WifiPhy > phy)
Set up WifiPhy listener for this MacLow.
Definition: mac-low.cc:388
friend std::ostream & operator<<(std::ostream &os, const MacLowTransmissionParameters &params)
Serialize MacLowTransmissionParameters to ostream in a human-readable form.
Definition: mac-low.cc:269
void NotifySleepNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
Definition: mac-low.cc:812
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr) const
Definition: mac-low.cc:1127
bool HasDurationId(void) const
Definition: mac-low.cc:247
DcfListeners m_dcfListeners
List of MacLowDcfListener (pass events to Dcf)
Definition: mac-low.h:1298
uint8_t m_sentMpdus
Number of transmitted MPDUs in an A-MPDU that have not been acknowledged yet.
Definition: mac-low.h:1360
bool m_ampdu
Flag if the current transmission involves an A-MPDU.
Definition: mac-low.h:1335
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:655
void DeaggregateAmpduAndReceive(Ptr< Packet > aggregatedPacket, double rxSnr, WifiTxVector txVector, WifiPreamble preamble)
Definition: mac-low.cc:2519
Time GetCompressedBlockAckTimeout() const
Return Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:614
Mac48Address m_bssid
BSSID address (Mac48Address)
Definition: mac-low.h:1321
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:30
Ptr< Packet > AggregateToAmpdu(Ptr< const Packet > packet, const WifiMacHeader hdr)
Definition: mac-low.cc:2613
EventId m_sendCtsEvent
Event to send CTS.
Definition: mac-low.h:1306
MacLowRxCallback m_rxCallback
Callback to pass packet up.
Definition: mac-low.h:1278
Time GetCtsTimeout(void) const
Return CTS timeout of this MacLow.
Definition: mac-low.cc:619
EventId m_superFastAckTimeoutEvent
Super fast ACK timeout event.
Definition: mac-low.h:1302
EventId m_sendAckEvent
Event to send ACK.
Definition: mac-low.h:1307
listen to events coming from ns3::MacLow.
Definition: mac-low.h:61
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:93
Time GetCtsDuration(WifiTxVector ctsTxVector) const
Return the time required to transmit the CTS (including preamble and FCS).
Definition: mac-low.cc:1216
bool MustWaitFastAck(void) const
Definition: mac-low.cc:217
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:2868
control how a packet is transmitted.
Definition: mac-low.h:296
void WaitSifsAfterEndTx(void)
Event handler that is usually scheduled to fired at the appropriate time after completing transmissio...
Definition: mac-low.cc:2051
std::vector< MacLowDcfListener * >::const_iterator DcfListenersCI
typedef for an iterator for a list of MacLowDcfListener.
Definition: mac-low.h:1293
virtual void CompleteTransfer(Mac48Address address, uint8_t tid)
Definition: mac-low.cc:82
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self capability.
Definition: mac-low.cc:554
void NormalAckTimeout(void)
Event handler when normal ACK timeout occurs.
Definition: mac-low.cc:1550
void SetBasicBlockAckTimeout(Time blockAckTimeout)
Set Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:544
BlockAckCaches m_bAckCaches
Definition: mac-low.h:1355
void InsertInTxQueue(Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tStamp)
Insert in a temporary queue.
Definition: mac-low.cc:2856
virtual uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: mac-low.cc:114
void RemovePhyMacLowListener(Ptr< WifiPhy > phy)
Remove current WifiPhy listener for this MacLow.
Definition: mac-low.cc:395
std::map< AcIndex, MacLowAggregationCapableTransmissionListener * > QueueListeners
Definition: mac-low.h:1357
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
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:105
WifiTxVector m_currentTxVector
TXVECTOR used for the current packet transmission.
Definition: mac-low.h:1362
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2227
Time m_lastNavDuration
The duration of the latest NAV.
Definition: mac-low.h:1332
std::pair< Ptr< Packet >, WifiMacHeader > BufferedPacket
Definition: mac-low.h:1342
bool m_ctsToSelfSupported
Flag whether CTS-to-self is supported.
Definition: mac-low.h:1359
void SendCtsToSelf(void)
Send CTS for a CTS-to-self mechanism.
Definition: mac-low.cc:1845
void SendAckAfterData(Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr)
Send ACK after receiving DATA.
Definition: mac-low.cc:2075
virtual Mac48Address GetSrcAddressForAggregation(const WifiMacHeader &hdr)
Definition: mac-low.cc:124
void CreateBlockAckAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq)
Definition: mac-low.cc:2185
Ptr< WifiMacQueue > m_aggregateQueue
Queue used for MPDU aggregation.
Definition: mac-low.h:1361
void NotifyNav(Ptr< const Packet > packet, const WifiMacHeader &hdr, WifiPreamble preamble)
Definition: mac-low.cc:1352
uint32_t GetBlockAckSize(enum BlockAckType type) const
Return the total Block ACK size (including FCS trailer).
Definition: mac-low.cc:1155
Listener for PHY events.
Definition: mac-low.cc:308
void CtsTimeout(void)
Event handler when CTS timeout occurs.
Definition: mac-low.cc:1531
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:2057
std::map< AgreementKey, BlockAckCache >::iterator BlockAckCachesI
Definition: mac-low.h:1352
std::vector< MacLowDcfListener * > DcfListeners
typedef for a list of MacLowDcfListener.
Definition: mac-low.h:1297
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:1267
void SetAckTimeout(Time ackTimeout)
Set ACK timeout of this MacLow.
Definition: mac-low.cc:539
virtual uint32_t GetNOutstandingPackets(Mac48Address recipient, uint8_t tid)
Definition: mac-low.cc:109
virtual void GotCts(double snr, WifiMode txMode)=0
void SendDataAfterCts(Mac48Address source, Time duration)
Send DATA after receiving CTS.
Definition: mac-low.cc:1964
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:2337
Time GetRifs(void) const
Return Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:629
void NavCounterResetCtsMissed(Time rtsEndRxTime)
Reset NAV after CTS was missed when the NAV was setted with RTS.
Definition: mac-low.cc:1394
Ptr< WifiRemoteStationManager > m_stationManager
Pointer to WifiRemoteStationManager (rate control)
Definition: mac-low.h:1277
bool MustWaitMultiTidBlockAck(void) const
Definition: mac-low.cc:237
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:599
uint32_t GetNextPacketSize(void) const
Definition: mac-low.cc:263
Agreements m_bAckAgreements
Definition: mac-low.h:1354
bool HasNextPacket(void) const
Definition: mac-low.cc:258
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:1283
void SendBlockAckAfterAmpdu(uint8_t tid, Mac48Address originator, Time duration, WifiTxVector blockAckReqTxVector)
Invoked after an A-MPDU has been received.
Definition: mac-low.cc:2402
virtual uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: mac-low.cc:90
void RegisterDcfListener(MacLowDcfListener *listener)
Definition: mac-low.cc:660
void NotifySwitchingStartNow(Time duration)
Definition: mac-low.cc:796
Time m_slotTime
Slot duration.
Definition: mac-low.h:1327
bool m_promisc
Flag if the device is operating in promiscuous mode.
Definition: mac-low.h:1334
WifiMacHeader hdr
Definition: mac-low.h:1286
void CancelAllEvents(void)
Cancel all scheduled events.
Definition: mac-low.cc:435
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener)
Definition: mac-low.cc:683
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:1343
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:1446
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:2424
std::map< AgreementKey, BlockAckCache > BlockAckCaches
Definition: mac-low.h:1351
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:172
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:1597
void SetBssid(Mac48Address ad)
Set the Basic Service Set Identification.
Definition: mac-low.cc:589
uint32_t GetRtsSize(void) const
Return the total RTS size (including FCS trailer).
Definition: mac-low.cc:1176
void EnableAck(void)
Wait ACKTimeout for an ACK.
Definition: mac-low.cc:187
Time CalculateTransmissionTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &parameters) const
Definition: mac-low.cc:1329
EventId m_normalAckTimeoutEvent
Normal ACK timeout event.
Definition: mac-low.h:1300
void StartDataTxTimers(WifiTxVector dataTxVector)
Start a DATA timer by scheduling appropriate ACK timeout.
Definition: mac-low.cc:1694
void NotifyCtsTimeoutResetNow()
Notify DcfManager (via DcfListener) that CTS timer should be resetted.
Definition: mac-low.cc:1454
bool MustWaitBasicBlockAck(void) const
Definition: mac-low.cc:227
bool MustWaitCompressedBlockAck(void) const
Definition: mac-low.cc:232
bool NeedCtsToSelf(void)
Check if CTS-to-self mechanism should be used for the current packet.
Definition: mac-low.cc:750
an EUI-48 address
Definition: mac48-address.h:43
Ptr< const Packet > packet
Definition: mac-low.h:1285
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:494
Time m_ackTimeout
ACK timeout duration.
Definition: mac-low.h:1322
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
Definition: mac-low.cc:2108
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:150
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:202
void EnableMultiTidBlockAck(void)
NOT IMPLEMENTED FOR NOW.
Definition: mac-low.cc:177
EventId m_ctsTimeoutEvent
CTS timeout event.
Definition: mac-low.h:1305
void RxCompleteBufferedPacketsWithSmallerSequence(uint16_t seq, Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2243
void SendCtsAfterRts(Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr)
Send CTS after receiving RTS.
Definition: mac-low.cc:1931
void SetPhy(Ptr< WifiPhy > phy)
Set up WifiPhy associated with this MacLow.
Definition: mac-low.cc:507
Time m_basicBlockAckTimeout
Basic block ACK timeout duration.
Definition: mac-low.h:1323
Time GetDurationId(void) const
Definition: mac-low.cc:252
virtual void MissedBlockAck(void)
ns3::MacLow did not receive an expected BLOCK_ACK within BlockAckTimeout.
Definition: mac-low.cc:61
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:86
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition: mac-low.h:1326
void ReceiveError(Ptr< const Packet > packet, double rxSnr)
Definition: mac-low.cc:756
Time GetSlotTime(void) const
Return slot duration of this MacLow.
Definition: mac-low.cc:634
Time m_lastNavStart
The time when the latest NAV started.
Definition: mac-low.h:1331
WifiTxVector GetRtsTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the RTS frame given the destination.
Definition: mac-low.cc:1247
std::map< AgreementKey, AgreementValue > Agreements
Definition: mac-low.h:1348
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:1253
handle RTS/CTS/DATA/ACK transactions.
Definition: mac-low.h:486
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:1364
EventId m_sendDataEvent
Event to send DATA.
Definition: mac-low.h:1308
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:2114
MacLowTransmissionParameters m_txParams
Transmission parameters of the current packet.
Definition: mac-low.h:1318
void SetRifs(Time rifs)
Set Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:584
virtual void DoDispose(void)
Destructor implementation.
Definition: mac-low.cc:406
void NotifyAckTimeoutResetNow()
Notify DcfManager (via DcfListener) that ACK timer should be resetted.
Definition: mac-low.cc:1438
bool MustWaitSuperFastAck(void) const
Definition: mac-low.cc:222
Time CalculateOverallTxTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &params) const
Definition: mac-low.cc:1290
QueueListeners m_edcaListeners
Definition: mac-low.h:1358
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:1272
Mac48Address m_self
Address of this MacLow (Mac48Address)
Definition: mac-low.h:1320
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:1303
bool IsNavZero(void) const
Check if NAV is zero.
Definition: mac-low.cc:1833
void EnableRts(void)
Send a RTS, and wait CTSTimeout for a CTS.
Definition: mac-low.cc:197
void NotifyAckTimeoutStartNow(Time duration)
Notify DcfManager (via DcfListener) that ACK timer should be started for the given duration...
Definition: mac-low.cc:1430
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:574
Ptr< Packet > m_currentPacket
Current packet transmitted/to be transmitted.
Definition: mac-low.h:1316
Time GetSifs(void) const
Return Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:624
bool StopMpduAggregation(Ptr< const Packet > peekedPacket, WifiMacHeader peekedHdr, Ptr< Packet > aggregatedPacket, uint16_t size) const
Definition: mac-low.cc:2590
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:572
std::map< AgreementKey, AgreementValue >::iterator AgreementsI
Definition: mac-low.h:1349
EventId m_endTxNoAckEvent
Event for finishing transmission that does not require ACK.
Definition: mac-low.h:1310
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:1524
void EnableOverrideDurationId(Time durationId)
Definition: mac-low.cc:152
bool GetCtsToSelfSupported() const
Return whether CTS-to-self capability is supported.
Definition: mac-low.cc:559
void ReceiveOk(Ptr< Packet > packet, double rxSnr, WifiTxVector txVector, WifiPreamble preamble, bool ampduSubframe)
Definition: mac-low.cc:827
void SetCtsTimeout(Time ctsTimeout)
Set CTS timeout of this MacLow.
Definition: mac-low.cc:564
void EnableNextData(uint32_t size)
Definition: mac-low.cc:142
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:157
Time GetAckTimeout(void) const
Return ACK timeout of this MacLow.
Definition: mac-low.cc:604
virtual Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: mac-low.cc:119
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:95
EventId m_waitRifsEvent
Wait for RIFS event.
Definition: mac-low.h:1312
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
Definition: mac-low.cc:147
void SendDataPacket(void)
Send DATA packet, which can be DATA-ACK or RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:1766
uint32_t GetCtsSize(void) const
Return the total CTS size (including FCS trailer).
Definition: mac-low.cc:1222
WifiMacHeader m_currentHdr
Header of the current packet.
Definition: mac-low.h:1317
void SetAddress(Mac48Address ad)
Set MAC address of this MacLow.
Definition: mac-low.cc:534
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:1463
Time m_compressedBlockAckTimeout
Compressed block ACK timeout duration.
Definition: mac-low.h:1324
bool MustWaitAck(void) const
Definition: mac-low.cc:207
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:666
void FlushAggregateQueue(void)
This function is called to flush the aggregate queue, which is used for A-MPDU.
Definition: mac-low.cc:2848
virtual void AckTimeoutReset()=0
Notify that ACK timeout has resetted.
void ResetPhy(void)
Remove WifiPhy associated with this MacLow.
Definition: mac-low.cc:520
void DisableAck(void)
Do not wait for Ack after data transmission.
Definition: mac-low.cc:192
std::pair< BlockAckAgreement, std::list< BufferedPacket > > AgreementValue
Definition: mac-low.h:1346
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:1278
Time GetBasicBlockAckTimeout() const
Return Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:609
Time m_rifs
Reduced Interframe Space (RIFS) duration.
Definition: mac-low.h:1329
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:1262
bool StoreMpduIfNeeded(Ptr< Packet > packet, WifiMacHeader hdr)
This method checks if exists a valid established block ack agreement.
Definition: mac-low.cc:2155
bool MustWaitNormalAck(void) const
Definition: mac-low.cc:212
virtual ~MacLow()
Definition: mac-low.cc:382
Ptr< MpduAggregator > m_mpduAggregator
Definition: mac-low.h:1314
A struct for packet, Wifi header, and timestamp.
Definition: mac-low.h:1283
Ptr< WifiPhy > m_phy
Pointer to WifiPhy (actually send/receives frames)
Definition: mac-low.h:1276
Implements the IEEE 802.11 MAC header.
void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Set Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:549
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
Set up WifiRemoteStationManager associated with this MacLow.
Definition: mac-low.cc:528
class PhyMacLowListener * m_phyMacLowListener
Listener needed to monitor when a channel switching occurs.
Definition: mac-low.h:1337
void SetMpduAggregator(Ptr< MpduAggregator > aggregator)
Set up MpduAggregator associated with this MacLow.
Definition: mac-low.cc:2513
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:1229
MacLowTransmissionListener * m_listener
Transmission listener for the current packet.
Definition: mac-low.h:1319
void SendRtsForPacket(void)
Send RTS to begin RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:1616
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2306