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  friend std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
456  uint32_t m_nextSize;
457  enum
458  {
466  } m_waitAck;
467  bool m_sendRts;
469 };
470 
478 std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params);
479 
480 
485 class MacLow : public Object
486 {
487 public:
488  // Allow test cases to access private members
489  friend class ::TwoLevelAggregationTest;
494 
495  MacLow ();
496  virtual ~MacLow ();
497 
502  static TypeId GetTypeId (void);
503 
509  void SetPhy (Ptr<WifiPhy> phy);
510  /*
511  * \return current attached PHY device
512  */
513  Ptr<WifiPhy> GetPhy (void) const;
519  void ResetPhy (void);
531  void SetMpduAggregator (Ptr<MpduAggregator> aggregator);
542  void SetAddress (Mac48Address ad);
548  void SetAckTimeout (Time ackTimeout);
554  void SetBasicBlockAckTimeout (Time blockAckTimeout);
560  void SetCompressedBlockAckTimeout (Time blockAckTimeout);
566  void SetCtsToSelfSupported (bool enable);
572  void SetCtsTimeout (Time ctsTimeout);
578  void SetSifs (Time sifs);
584  void SetRifs (Time rifs);
590  void SetSlotTime (Time slotTime);
596  void SetPifs (Time pifs);
602  void SetBssid (Mac48Address ad);
606  void SetPromisc (void);
612  bool GetCtsToSelfSupported () const;
618  Mac48Address GetAddress (void) const;
624  Time GetAckTimeout (void) const;
630  Time GetBasicBlockAckTimeout () const;
642  Time GetCtsTimeout (void) const;
648  Time GetSifs (void) const;
654  Time GetSlotTime (void) const;
660  Time GetPifs (void) const;
666  Time GetRifs (void) const;
672  Mac48Address GetBssid (void) const;
679  bool IsPromisc (void) const;
680 
687  void SetRxCallback (Callback<void,Ptr<Packet>,const WifiMacHeader *> callback);
692  void RegisterDcfListener (MacLowDcfListener *listener);
693 
704  const WifiMacHeader* hdr,
705  const MacLowTransmissionParameters& parameters) const;
706 
716  virtual void StartTransmission (Ptr<const Packet> packet,
717  const WifiMacHeader* hdr,
718  MacLowTransmissionParameters parameters,
719  MacLowTransmissionListener *listener);
720 
731  void ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiTxVector txVector, WifiPreamble preamble, bool ampduSubframe);
739  void ReceiveError (Ptr<const Packet> packet, double rxSnr);
747  void NotifySwitchingStartNow (Time duration);
753  void NotifySleepNow (void);
769  void CreateBlockAckAgreement (const MgtAddBaResponseHeader *respHdr,
770  Mac48Address originator,
771  uint16_t startingSeq);
780  void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid);
807  void DeaggregateAmpduAndReceive (Ptr<Packet> aggregatedPacket, double rxSnr, WifiTxVector txVector, WifiPreamble preamble);
818  bool StopMpduAggregation (Ptr<const Packet> peekedPacket, WifiMacHeader peekedHdr, Ptr<Packet> aggregatedPacket, uint16_t size) const;
824  void FlushAggregateQueue (void);
825 
826 protected:
836  virtual WifiTxVector GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
837 private:
842  void CancelAllEvents (void);
848  uint32_t GetAckSize (void) const;
855  uint32_t GetBlockAckSize (enum BlockAckType type) const;
861  uint32_t GetRtsSize (void) const;
867  uint32_t GetCtsSize (void) const;
876  uint32_t GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
885  void ForwardDown (Ptr<const Packet> packet, const WifiMacHeader *hdr,
886  WifiTxVector txVector, WifiPreamble preamble);
897  void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, uint32_t mpduReferenceNumber);
907  WifiTxVector GetRtsTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
918  WifiTxVector GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const;
929  WifiTxVector GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
940  WifiTxVector GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const;
979  Time GetCtsDuration (WifiTxVector ctsTxVector) const;
988  Time GetCtsDuration (Mac48Address to, WifiTxVector rtsTxVector) const;
995  Time GetAckDuration (WifiTxVector ackTxVector) const;
1004  Time GetAckDuration (Mac48Address to, WifiTxVector dataTxVector) const;
1014  Time GetBlockAckDuration (Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const;
1021  bool NeedCtsToSelf (void);
1022 
1024  const WifiMacHeader* hdr,
1025  const MacLowTransmissionParameters &params) const;
1026  void NotifyNav (Ptr<const Packet> packet,const WifiMacHeader &hdr, WifiPreamble preamble);
1032  void DoNavResetNow (Time duration);
1039  bool DoNavStartNow (Time duration);
1046  bool IsNavZero (void) const;
1054  void NotifyAckTimeoutStartNow (Time duration);
1059  void NotifyAckTimeoutResetNow ();
1067  void NotifyCtsTimeoutStartNow (Time duration);
1072  void NotifyCtsTimeoutResetNow ();
1079  void NavCounterResetCtsMissed (Time rtsEndRxTime);
1080  /* Event handlers */
1084  void NormalAckTimeout (void);
1088  void FastAckTimeout (void);
1092  void SuperFastAckTimeout (void);
1096  void FastAckFailedTimeout (void);
1100  void BlockAckTimeout (void);
1104  void CtsTimeout (void);
1108  void SendCtsToSelf (void);
1117  void SendCtsAfterRts (Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr);
1126  void SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr);
1133  void SendDataAfterCts (Mac48Address source, Time duration);
1138  void WaitSifsAfterEndTx (void);
1142  void EndTxNoAck (void);
1146  void SendRtsForPacket (void);
1151  void SendDataPacket (void);
1158  void StartDataTxTimers (WifiTxVector dataTxVector);
1159 
1160  virtual void DoDispose (void);
1161 
1168  uint8_t GetTid (Ptr<const Packet> packet, const WifiMacHeader hdr) const;
1177  void RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address originator, uint8_t tid);
1190  void RxCompleteBufferedPacketsUntilFirstLost (Mac48Address originator, uint8_t tid);
1197  bool IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize);
1203  bool ReceiveMpdu (Ptr<Packet> packet, WifiMacHeader hdr);
1210  bool StoreMpduIfNeeded (Ptr<Packet> packet, WifiMacHeader hdr);
1221  Time duration, WifiMode blockAckReqTxMode);
1226  void SendBlockAckAfterAmpdu (uint8_t tid, Mac48Address originator,
1227  Time duration, WifiTxVector blockAckReqTxVector);
1237  void SendBlockAckResponse (const CtrlBAckResponseHeader* blockAck, Mac48Address originator, bool immediate,
1238  Time duration, WifiMode blockAckReqTxMode);
1248 
1268  bool IsAmpdu (Ptr<const Packet> packet, const WifiMacHeader hdr);
1273  void InsertInTxQueue (Ptr<const Packet> packet, const WifiMacHeader &hdr, Time tStamp);
1285  Ptr<Packet> PerformMsduAggregation (Ptr<const Packet> packet, WifiMacHeader *hdr, Time *tstamp, Ptr<Packet> currentAmpduPacket, uint16_t blockAckSize);
1286 
1289  MacLowRxCallback m_rxCallback;
1290 
1294  typedef struct
1295  {
1299  } Item;
1300 
1304  typedef std::vector<MacLowDcfListener *>::const_iterator DcfListenersCI;
1308  typedef std::vector<MacLowDcfListener *> DcfListeners;
1309  DcfListeners m_dcfListeners;
1310 
1324 
1326 
1341 
1344 
1345  bool m_promisc;
1346  bool m_ampdu;
1347 
1349 
1350  /*
1351  * BlockAck data structures.
1352  */
1353  typedef std::pair<Ptr<Packet>, WifiMacHeader> BufferedPacket;
1354  typedef std::list<BufferedPacket>::iterator BufferedPacketI;
1355 
1356  typedef std::pair<Mac48Address, uint8_t> AgreementKey;
1357  typedef std::pair<BlockAckAgreement, std::list<BufferedPacket> > AgreementValue;
1358 
1359  typedef std::map<AgreementKey, AgreementValue> Agreements;
1360  typedef std::map<AgreementKey, AgreementValue>::iterator AgreementsI;
1361 
1362  typedef std::map<AgreementKey, BlockAckCache> BlockAckCaches;
1363  typedef std::map<AgreementKey, BlockAckCache>::iterator BlockAckCachesI;
1364 
1365  Agreements m_bAckAgreements;
1366  BlockAckCaches m_bAckCaches;
1367 
1368  typedef std::map<AcIndex, MacLowAggregationCapableTransmissionListener*> QueueListeners;
1369  QueueListeners m_edcaListeners;
1371  uint8_t m_sentMpdus;
1375  std::vector<Item> m_txPackets;
1377 };
1378 
1379 } //namespace ns3
1380 
1381 #endif /* MAC_LOW_H */
bool MustSendRts(void) const
Definition: mac-low.cc:239
Time GetPifs(void) const
Return PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:673
uint32_t GetAckSize(void) const
Return the total ACK size (including FCS trailer).
Definition: mac-low.cc:1227
virtual ~MacLowDcfListener()
Definition: mac-low.cc:66
void SetPifs(Time pifs)
Set PCF Interframe Space (PIFS) of this MacLow.
Definition: mac-low.cc:601
Time m_ctsTimeout
CTS timeout duration.
Definition: mac-low.h:1336
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:1322
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
uint32_t m_mpduReferenceNumber
A-MPDU reference number to identify all subframes belonging to the same A-MPDU.
Definition: mac-low.h:1376
Ptr< WifiPhy > GetPhy(void) const
Definition: mac-low.cc:526
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:2682
virtual void CtsTimeoutReset()=0
Notify that CTS timeout has resetted.
EventId m_blockAckTimeoutEvent
Block ACK timeout event.
Definition: mac-low.h:1315
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:1279
Callback template class.
Definition: callback.h:1164
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:1272
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:619
EventId m_waitSifsEvent
Wait for SIFS event.
Definition: mac-low.h:1320
void DoNavResetNow(Time duration)
Reset NAV with the given duration.
Definition: mac-low.cc:1523
virtual Mac48Address GetDestAddressForAggregation(const WifiMacHeader &hdr)
Definition: mac-low.cc:126
bool IsPromisc(void) const
Check if MacLow is operating in promiscuous mode.
Definition: mac-low.cc:685
bool m_receivedAtLeastOneMpdu
Flag whether an MPDU has already been successfully received while receiving an A-MPDU.
Definition: mac-low.h:1374
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:164
EventId m_fastAckTimeoutEvent
Fast ACK timeout event.
Definition: mac-low.h:1312
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: mac-low.h:1339
void FastAckFailedTimeout(void)
Event handler when fast ACK timeout occurs (busy).
Definition: mac-low.cc:2254
bool DoNavStartNow(Time duration)
Start NAV with the given duration.
Definition: mac-low.cc:1534
Mac48Address GetBssid(void) const
Return the Basic Service Set Identification.
Definition: mac-low.cc:679
void SetSifs(Time sifs)
Set Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:589
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:1356
WifiTxVector GetCtsToSelfTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the CTS-to-self frame.
Definition: mac-low.cc:1336
void RegisterBlockAckListenerForAc(enum AcIndex ac, MacLowAggregationCapableTransmissionListener *listener)
Definition: mac-low.cc:2699
void SetupPhyMacLowListener(Ptr< WifiPhy > phy)
Set up WifiPhy listener for this MacLow.
Definition: mac-low.cc:398
friend std::ostream & operator<<(std::ostream &os, const MacLowTransmissionParameters &params)
Serialize MacLowTransmissionParameters to ostream in a human-readable form.
Definition: mac-low.cc:266
void NotifySleepNow(void)
This method is typically invoked by the PhyMacLowListener to notify the MAC layer that the device has...
Definition: mac-low.cc:884
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr) const
Definition: mac-low.cc:1204
bool HasDurationId(void) const
Definition: mac-low.cc:244
DcfListeners m_dcfListeners
List of MacLowDcfListener (pass events to Dcf)
Definition: mac-low.h:1309
uint8_t m_sentMpdus
Number of transmitted MPDUs in an A-MPDU that have not been acknowledged yet.
Definition: mac-low.h:1371
bool m_ampdu
Flag if the current transmission involves an A-MPDU.
Definition: mac-low.h:1346
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:691
void DeaggregateAmpduAndReceive(Ptr< Packet > aggregatedPacket, double rxSnr, WifiTxVector txVector, WifiPreamble preamble)
Definition: mac-low.cc:2717
Time GetCompressedBlockAckTimeout() const
Return Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:643
Mac48Address m_bssid
BSSID address (Mac48Address)
Definition: mac-low.h:1332
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:2845
EventId m_sendCtsEvent
Event to send CTS.
Definition: mac-low.h:1317
MacLowRxCallback m_rxCallback
Callback to pass packet up.
Definition: mac-low.h:1289
Time GetCtsTimeout(void) const
Return CTS timeout of this MacLow.
Definition: mac-low.cc:649
EventId m_superFastAckTimeoutEvent
Super fast ACK timeout event.
Definition: mac-low.h:1313
EventId m_sendAckEvent
Event to send ACK.
Definition: mac-low.h:1318
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:97
Time GetCtsDuration(WifiTxVector ctsTxVector) const
Return the time required to transmit the CTS (including preamble and FCS).
Definition: mac-low.cc:1305
bool MustWaitFastAck(void) const
Definition: mac-low.cc:214
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:3153
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:2240
std::vector< MacLowDcfListener * >::const_iterator DcfListenersCI
typedef for an iterator for a list of MacLowDcfListener.
Definition: mac-low.h:1304
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:571
void NormalAckTimeout(void)
Event handler when normal ACK timeout occurs.
Definition: mac-low.cc:1697
void SetBasicBlockAckTimeout(Time blockAckTimeout)
Set Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:559
BlockAckCaches m_bAckCaches
Definition: mac-low.h:1366
void InsertInTxQueue(Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tStamp)
Insert in a temporary queue.
Definition: mac-low.cc:3141
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:405
std::map< AcIndex, MacLowAggregationCapableTransmissionListener * > QueueListeners
Definition: mac-low.h:1368
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address source, WifiMode txMode)
Definition: mac-low.cc:55
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:1373
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2419
Time m_lastNavDuration
The duration of the latest NAV.
Definition: mac-low.h:1343
std::pair< Ptr< Packet >, WifiMacHeader > BufferedPacket
Definition: mac-low.h:1353
bool m_ctsToSelfSupported
Flag whether CTS-to-self is supported.
Definition: mac-low.h:1370
void SendCtsToSelf(void)
Send CTS for a CTS-to-self mechanism.
Definition: mac-low.cc:2019
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:2264
virtual Mac48Address GetSrcAddressForAggregation(const WifiMacHeader &hdr)
Definition: mac-low.cc:121
void CreateBlockAckAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq)
Definition: mac-low.cc:2377
Ptr< WifiMacQueue > m_aggregateQueue
Queue used for MPDU aggregation.
Definition: mac-low.h:1372
void NotifyNav(Ptr< const Packet > packet, const WifiMacHeader &hdr, WifiPreamble preamble)
Definition: mac-low.cc:1472
uint32_t GetBlockAckSize(enum BlockAckType type) const
Return the total Block ACK size (including FCS trailer).
Definition: mac-low.cc:1235
Listener for PHY events.
Definition: mac-low.cc:305
void CtsTimeout(void)
Event handler when CTS timeout occurs.
Definition: mac-low.cc:1677
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:2246
std::map< AgreementKey, BlockAckCache >::iterator BlockAckCachesI
Definition: mac-low.h:1363
std::vector< MacLowDcfListener * > DcfListeners
typedef for a list of MacLowDcfListener.
Definition: mac-low.h:1308
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:1365
void SetAckTimeout(Time ackTimeout)
Set ACK timeout of this MacLow.
Definition: mac-low.cc:553
static TypeId GetTypeId(void)
Register this type.
Definition: mac-low.cc:387
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:2143
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:2527
Time GetRifs(void) const
Return Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:661
void NavCounterResetCtsMissed(Time rtsEndRxTime)
Reset NAV after CTS was missed when the NAV was setted with RTS.
Definition: mac-low.cc:1514
Ptr< WifiRemoteStationManager > m_stationManager
Pointer to WifiRemoteStationManager (rate control)
Definition: mac-low.h:1288
bool MustWaitMultiTidBlockAck(void) const
Definition: mac-low.cc:234
Headers for Block ack response.
Definition: ctrl-headers.h:186
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:625
uint32_t GetNextPacketSize(void) const
Definition: mac-low.cc:260
Agreements m_bAckAgreements
Definition: mac-low.h:1365
bool HasNextPacket(void) const
Definition: mac-low.cc:255
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:1383
void SendBlockAckAfterAmpdu(uint8_t tid, Mac48Address originator, Time duration, WifiTxVector blockAckReqTxVector)
Invoked after an A-MPDU has been received.
Definition: mac-low.cc:2597
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:697
void NotifySwitchingStartNow(Time duration)
Definition: mac-low.cc:868
Time m_slotTime
Slot duration.
Definition: mac-low.h:1338
bool m_promisc
Flag if the device is operating in promiscuous mode.
Definition: mac-low.h:1345
WifiMacHeader hdr
Definition: mac-low.h:1297
void CancelAllEvents(void)
Cancel all scheduled events.
Definition: mac-low.cc:445
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener)
Definition: mac-low.cc:722
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:1354
void BlockAckTimeout(void)
Event handler when block ACK timeout occurs.
Definition: mac-low.cc:1732
void NotifyCtsTimeoutStartNow(Time duration)
Notify DcfManager (via DcfListener) that CTS timer should be started for the given duration...
Definition: mac-low.cc:1570
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:2619
std::map< AgreementKey, BlockAckCache > BlockAckCaches
Definition: mac-low.h:1362
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:169
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:1747
void SetBssid(Mac48Address ad)
Set the Basic Service Set Identification.
Definition: mac-low.cc:613
uint32_t GetRtsSize(void) const
Return the total RTS size (including FCS trailer).
Definition: mac-low.cc:1257
void EnableAck(void)
Wait ACKTimeout for an ACK.
Definition: mac-low.cc:184
Time CalculateTransmissionTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &parameters) const
Definition: mac-low.cc:1440
EventId m_normalAckTimeoutEvent
Normal ACK timeout event.
Definition: mac-low.h:1311
void StartDataTxTimers(WifiTxVector dataTxVector)
Start a DATA timer by scheduling appropriate ACK timeout.
Definition: mac-low.cc:1848
void NotifyCtsTimeoutResetNow()
Notify DcfManager (via DcfListener) that CTS timer should be resetted.
Definition: mac-low.cc:1579
bool MustWaitBasicBlockAck(void) const
Definition: mac-low.cc:224
bool MustWaitCompressedBlockAck(void) const
Definition: mac-low.cc:229
bool NeedCtsToSelf(void)
Check if CTS-to-self mechanism should be used for the current packet.
Definition: mac-low.cc:815
an EUI-48 address
Definition: mac48-address.h:43
Ptr< const Packet > packet
Definition: mac-low.h:1296
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:493
Time m_ackTimeout
ACK timeout duration.
Definition: mac-low.h:1333
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
Definition: mac-low.cc:2297
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:1714
void DisableRts(void)
Do not send rts and wait for cts before sending data.
Definition: mac-low.cc:199
void EnableMultiTidBlockAck(void)
NOT IMPLEMENTED FOR NOW.
Definition: mac-low.cc:174
EventId m_ctsTimeoutEvent
CTS timeout event.
Definition: mac-low.h:1316
void RxCompleteBufferedPacketsWithSmallerSequence(uint16_t seq, Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2435
void SendCtsAfterRts(Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr)
Send CTS after receiving RTS.
Definition: mac-low.cc:2111
void SetPhy(Ptr< WifiPhy > phy)
Set up WifiPhy associated with this MacLow.
Definition: mac-low.cc:517
Time m_basicBlockAckTimeout
Basic block ACK timeout duration.
Definition: mac-low.h:1334
Time GetDurationId(void) const
Definition: mac-low.cc:249
virtual void MissedBlockAck(void)
ns3::MacLow did not receive an expected BLOCK_ACK within BlockAckTimeout.
Definition: mac-low.cc:59
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:1337
enum ns3::MacLowTransmissionParameters::@92 m_waitAck
void ReceiveError(Ptr< const Packet > packet, double rxSnr)
Definition: mac-low.cc:822
Time GetSlotTime(void) const
Return slot duration of this MacLow.
Definition: mac-low.cc:667
Time m_lastNavStart
The time when the latest NAV started.
Definition: mac-low.h:1342
WifiTxVector GetRtsTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the RTS frame given the destination.
Definition: mac-low.cc:1342
std::map< AgreementKey, AgreementValue > Agreements
Definition: mac-low.h:1359
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:1349
handle RTS/CTS/DATA/ACK transactions.
Definition: mac-low.h:485
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:1375
EventId m_sendDataEvent
Event to send DATA.
Definition: mac-low.h:1319
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:2303
MacLowTransmissionParameters m_txParams
Transmission parameters of the current packet.
Definition: mac-low.h:1329
void SetRifs(Time rifs)
Set Reduced Interframe Space (RIFS) of this MacLow.
Definition: mac-low.cc:607
virtual void DoDispose(void)
Destructor implementation.
Definition: mac-low.cc:416
void NotifyAckTimeoutResetNow()
Notify DcfManager (via DcfListener) that ACK timer should be resetted.
Definition: mac-low.cc:1561
bool MustWaitSuperFastAck(void) const
Definition: mac-low.cc:219
Time CalculateOverallTxTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &params) const
Definition: mac-low.cc:1389
QueueListeners m_edcaListeners
Definition: mac-low.h:1369
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:1371
Mac48Address m_self
Address of this MacLow (Mac48Address)
Definition: mac-low.h:1331
Maintains information for a block ack agreement.
An identifier for simulation events.
Definition: event-id.h:53
void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, uint32_t mpduReferenceNumber)
Forward the packet down to WifiPhy for transmission.
Definition: mac-low.cc:1670
EventId m_fastAckFailedTimeoutEvent
Fast ACK failed timeout event.
Definition: mac-low.h:1314
bool IsNavZero(void) const
Check if NAV is zero.
Definition: mac-low.cc:2006
void EnableRts(void)
Send a RTS, and wait CTSTimeout for a CTS.
Definition: mac-low.cc:194
void NotifyAckTimeoutStartNow(Time duration)
Notify DcfManager (via DcfListener) that ACK timer should be started for the given duration...
Definition: mac-low.cc:1552
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:595
Ptr< Packet > m_currentPacket
Current packet transmitted/to be transmitted.
Definition: mac-low.h:1327
Time GetSifs(void) const
Return Short Interframe Space (SIFS) of this MacLow.
Definition: mac-low.cc:655
bool StopMpduAggregation(Ptr< const Packet > peekedPacket, WifiMacHeader peekedHdr, Ptr< Packet > aggregatedPacket, uint16_t size) const
Definition: mac-low.cc:2801
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:670
std::map< AgreementKey, AgreementValue >::iterator AgreementsI
Definition: mac-low.h:1360
EventId m_endTxNoAckEvent
Event for finishing transmission that does not require ACK.
Definition: mac-low.h:1321
void EnableOverrideDurationId(Time durationId)
Definition: mac-low.cc:149
bool GetCtsToSelfSupported() const
Return whether CTS-to-self capability is supported.
Definition: mac-low.cc:577
void ReceiveOk(Ptr< Packet > packet, double rxSnr, WifiTxVector txVector, WifiPreamble preamble, bool ampduSubframe)
Definition: mac-low.cc:899
void SetCtsTimeout(Time ctsTimeout)
Set CTS timeout of this MacLow.
Definition: mac-low.cc:583
void EnableNextData(uint32_t size)
Definition: mac-low.cc:139
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:154
Time GetAckTimeout(void) const
Return ACK timeout of this MacLow.
Definition: mac-low.cc:631
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:1323
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
Definition: mac-low.cc:144
Ptr< MpduAggregator > GetMpduAggregator(void)
Definition: mac-low.cc:2711
void SendDataPacket(void)
Send DATA packet, which can be DATA-ACK or RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:1930
uint32_t GetCtsSize(void) const
Return the total CTS size (including FCS trailer).
Definition: mac-low.cc:1312
WifiMacHeader m_currentHdr
Header of the current packet.
Definition: mac-low.h:1328
void SetAddress(Mac48Address ad)
Set MAC address of this MacLow.
Definition: mac-low.cc:547
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:1588
Time m_compressedBlockAckTimeout
Compressed block ACK timeout duration.
Definition: mac-low.h:1335
bool MustWaitAck(void) const
Definition: mac-low.cc:204
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:703
void FlushAggregateQueue(void)
This function is called to flush the aggregate queue, which is used for A-MPDU.
Definition: mac-low.cc:3130
virtual void AckTimeoutReset()=0
Notify that ACK timeout has resetted.
void ResetPhy(void)
Remove WifiPhy associated with this MacLow.
Definition: mac-low.cc:532
void DisableAck(void)
Do not wait for Ack after data transmission.
Definition: mac-low.cc:189
std::pair< BlockAckAgreement, std::list< BufferedPacket > > AgreementValue
Definition: mac-low.h:1357
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:1377
Time GetBasicBlockAckTimeout() const
Return Basic Block ACK timeout of this MacLow.
Definition: mac-low.cc:637
a unique identifier for an interface.
Definition: type-id.h:58
Time m_rifs
Reduced Interframe Space (RIFS) duration.
Definition: mac-low.h:1340
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:1359
bool StoreMpduIfNeeded(Ptr< Packet > packet, WifiMacHeader hdr)
This method checks if exists a valid established block ack agreement.
Definition: mac-low.cc:2348
bool MustWaitNormalAck(void) const
Definition: mac-low.cc:209
virtual ~MacLow()
Definition: mac-low.cc:380
Ptr< MpduAggregator > m_mpduAggregator
Definition: mac-low.h:1325
A struct for packet, Wifi header, and timestamp.
Definition: mac-low.h:1294
Ptr< WifiPhy > m_phy
Pointer to WifiPhy (actually send/receives frames)
Definition: mac-low.h:1287
Implements the IEEE 802.11 MAC header.
void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Set Compressed Block ACK timeout of this MacLow.
Definition: mac-low.cc:565
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
Set up WifiRemoteStationManager associated with this MacLow.
Definition: mac-low.cc:541
class PhyMacLowListener * m_phyMacLowListener
Listener needed to monitor when a channel switching occurs.
Definition: mac-low.h:1348
void SetMpduAggregator(Ptr< MpduAggregator > aggregator)
Set up MpduAggregator associated with this MacLow.
Definition: mac-low.cc:2705
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:1320
MacLowTransmissionListener * m_listener
Transmission listener for the current packet.
Definition: mac-low.h:1330
void SendRtsForPacket(void)
Send RTS to begin RTS-CTS-DATA-ACK transaction.
Definition: mac-low.cc:1766
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2498