A Discrete-Event Network Simulator
API
edca-txop-n.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 #ifndef EDCA_TXOP_N_H
23 #define EDCA_TXOP_N_H
24 
25 #include "ns3/object.h"
26 #include "ns3/mac48-address.h"
27 #include "ns3/packet.h"
28 #include "wifi-mode.h"
29 #include "wifi-mac-header.h"
31 #include "qos-utils.h"
32 #include "dcf.h"
33 #include "ctrl-headers.h"
34 #include "block-ack-manager.h"
35 #include <map>
36 #include <list>
37 
39 
40 namespace ns3 {
41 
42 class DcfState;
43 class DcfManager;
44 class MacLow;
45 class MacTxMiddle;
46 class WifiMac;
47 class WifiMacParameters;
48 class WifiMacQueue;
49 class RandomStream;
50 class QosBlockedDestinations;
51 class MsduAggregator;
52 class MpduAggregator;
53 class MgtAddBaResponseHeader;
54 class BlockAckManager;
55 class MgtDelBaHeader;
56 
61 {
62  STA,
63  AP,
70 };
71 
72 
85 class EdcaTxopN : public Dcf
86 {
87 public:
88  // Allow test cases to access private members
89  friend class ::AmpduAggregationTest;
90 
101 
102  std::map<Mac48Address, bool> m_aMpduEnabled;
103 
104  static TypeId GetTypeId (void);
105  EdcaTxopN ();
106  virtual ~EdcaTxopN ();
107  void DoDispose ();
108 
114  void SetLow (Ptr<MacLow> low);
115  void SetTxMiddle (MacTxMiddle *txMiddle);
121  void SetManager (DcfManager *manager);
126  void SetTxOkCallback (TxOk callback);
131  void SetTxFailedCallback (TxFailed callback);
143  void SetTypeOfStation (enum TypeOfStation type);
149  enum TypeOfStation GetTypeOfStation (void) const;
156 
157  virtual void SetMinCw (uint32_t minCw);
158  virtual void SetMaxCw (uint32_t maxCw);
159  virtual void SetAifsn (uint32_t aifsn);
160  virtual uint32_t GetMinCw (void) const;
161  virtual uint32_t GetMaxCw (void) const;
162  virtual uint32_t GetAifsn (void) const;
163 
169  Ptr<MacLow> Low (void);
170 
173 
182  bool GetBaAgreementExists (Mac48Address address, uint8_t tid);
190  uint32_t GetNOutstandingPacketsInBa (Mac48Address address, uint8_t tid);
198  uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
206  void CompleteAmpduTransfer (Mac48Address recipient, uint8_t tid);
207 
208  /* dcf notifications forwarded here */
215  bool NeedsAccess (void) const;
219  void NotifyAccessGranted (void);
223  void NotifyInternalCollision (void);
227  void NotifyCollision (void);
231  void NotifyChannelSwitching (void);
235  void NotifySleep (void);
239  void NotifyWakeUp (void);
240 
241  /* Event handlers */
248  void GotCts (double snr, WifiMode txMode);
252  void MissedCts (void);
259  void GotAck (double snr, WifiMode txMode);
269  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
273  void MissedBlockAck (uint32_t nMpdus);
274  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
275  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
279  void MissedAck (void);
284  void StartNext (void);
288  void Cancel (void);
293  void EndTxNoAck (void);
297  void RestartAccessIfNeeded (void);
301  void StartAccessIfNeeded (void);
308  bool NeedRtsRetransmission (void);
315  bool NeedDataRetransmission (void);
322  bool NeedBarRetransmission (void);
329  bool NeedFragmentation (void) const;
335  uint32_t GetNextFragmentSize (void);
341  uint32_t GetFragmentSize (void);
347  uint32_t GetFragmentOffset (void);
354  bool IsLastFragment (void) const;
360  void NextFragment (void);
369 
375  void SetAccessCategory (enum AcIndex ac);
376 
384  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
385 
388 
396  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
397 
401  void CompleteConfig (void);
402 
409  void SetBlockAckThreshold (uint8_t threshold);
415  uint8_t GetBlockAckThreshold (void) const;
416 
417  void SetBlockAckInactivityTimeout (uint16_t timeout);
418  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
419  void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
420  bool GetAmpduExist (Mac48Address dest);
421  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
422 
430  uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr);
442  void RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
443  /*
444  * Peek in retransmit queue and get the next packet without removing it from the queue
445  */
446  Ptr<const Packet> PeekNextRetransmitPacket (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
452  void BaTxOk (const WifiMacHeader &hdr);
458  void BaTxFailed (const WifiMacHeader &hdr);
459 
468  int64_t AssignStreams (int64_t stream);
469 
470 
471 private:
472  void DoInitialize ();
487  EdcaTxopN &operator = (const EdcaTxopN &);
488  EdcaTxopN (const EdcaTxopN &);
489 
496  bool SetupBlockAckIfNeeded ();
507  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
508  uint16_t timeout, bool immediateBAck);
515  void SendBlockAckRequest (const struct Bar &bar);
520  void CompleteTx (void);
525  void VerifyBlockAck (void);
526 
528  class Dcf;
529  class TransmissionListener;
531  friend class Dcf;
532  friend class TransmissionListener;
545 
546  /* current packet could be a simple MSDU or, if an aggregator for this queue is
547  present, could be an A-MSDU.
548  */
550 
557  /*
558  * Represents the minimum number of packets for use of block ack.
559  */
565 };
566 
567 } //namespace ns3
568 
569 #endif /* EDCA_TXOP_N_H */
Keep track of destination address - TID pairs that are waiting for a block ACK response.
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: edca-txop-n.cc:384
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:540
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:549
void DoInitialize()
Initialize() implementation.
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:537
void NotifyWakeUp(void)
When wake up operation occurs, restart channel access.
Definition: edca-txop-n.cc:740
void SetBlockAckInactivityTimeout(uint16_t timeout)
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
uint16_t m_blockAckInactivityTimeout
Definition: edca-txop-n.h:563
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack.
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: edca-txop-n.cc:632
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:356
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed.
void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:341
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:757
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
uint8_t m_blockAckThreshold
Definition: edca-txop-n.h:560
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:348
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:551
void NotifySleep(void)
When sleep operation occurs, re-insert pending packet into front of the queue.
Definition: edca-txop-n.cc:729
Ptr< MsduAggregator > m_msduAggregator
Definition: edca-txop-n.h:552
ns3::Time timeout
BlockAckType
Enumeration for different block ACK policies.
Definition: ctrl-headers.h:31
Block Ack Request.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
void NextFragment(void)
Continue to the next fragment.
void SetTxOkCallback(TxOk callback)
Definition: edca-txop-n.cc:334
BlockAckManager * m_baManager
Definition: edca-txop-n.h:556
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: edca-txop-n.cc:997
struct Bar m_currentBar
Definition: edca-txop-n.h:564
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: edca-txop-n.cc:412
void MissedBlockAck(uint32_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:873
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
Ptr< MpduAggregator > m_mpduAggregator
Definition: edca-txop-n.h:553
DcfManager * m_manager
Definition: edca-txop-n.h:534
void MissedAck(void)
Event handler when an ACK is missed.
Definition: edca-txop-n.cc:803
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:363
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:433
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:426
Ptr< WifiRemoteStationManager > m_stationManager
Definition: edca-txop-n.h:543
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:85
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: edca-txop-n.cc:469
RandomStream * m_rng
Definition: edca-txop-n.h:542
void RemoveRetransmitPacket(uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
Remove a packet after you peek in the retransmit queue and get it.
Definition: edca-txop-n.cc:463
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:625
std::map< Mac48Address, bool > m_aMpduEnabled
Definition: edca-txop-n.h:102
virtual void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: edca-txop-n.cc:377
void SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck)
Sends an ADDBA Request to establish a block ack agreement with sta addressed by recipient for tid tid...
Ptr< const Packet > PeekNextRetransmitPacket(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Definition: edca-txop-n.cc:457
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
bool GetBaAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:302
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
MacTxMiddle * m_txMiddle
Definition: edca-txop-n.h:539
Callback< void, const WifiMacHeader & > TxOk
typedef for a callback to invoke when a packet transmission was completed successfully.
Definition: edca-txop-n.h:95
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: edca-txop-n.cc:647
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:262
A simple wrapper around RngStream to make testing of the code easier.
Definition: random-stream.h:34
bool GetAmpduExist(Mac48Address dest)
uint16_t PeekNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i...
Definition: edca-txop-n.cc:451
Headers for Block ack response.
Definition: ctrl-headers.h:186
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: edca-txop-n.cc:721
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
virtual ~EdcaTxopN()
Definition: edca-txop-n.cc:272
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:314
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:544
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:562
virtual uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: edca-txop-n.cc:398
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Ptr< MpduAggregator > GetMpduAggregator(void) const
Definition: edca-txop-n.cc:967
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: edca-txop-n.cc:961
void SetAccessCategory(enum AcIndex ac)
Set the access category of this EDCAF.
Callback< void, const WifiMacHeader & > TxFailed
typedef for a callback to invoke when a packet transmission was failed.
Definition: edca-txop-n.h:100
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
void SetMpduAggregator(Ptr< MpduAggregator > aggr)
bool SetupBlockAckIfNeeded()
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBA Request frame is sent t...
void StartNext(void)
Start transmission for the next fragment.
an EUI-48 address
Definition: mac48-address.h:43
void SetAmpduExist(Mac48Address dest, bool enableAmpdu)
void Cancel(void)
Cancel the transmission.
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
void SetManager(DcfManager *manager)
Set DcfManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:326
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:747
uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:446
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
EdcaTxopN & operator=(const EdcaTxopN &)
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
enum BlockAckType m_blockAckType
Definition: edca-txop-n.h:561
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:232
void BaTxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
void CompleteConfig(void)
Complete block ACK configuration.
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: edca-txop-n.cc:973
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:758
QosBlockedDestinations * m_qosBlockedDestinations
Definition: edca-txop-n.h:555
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:879
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:320
Ptr< MacLow > m_low
Definition: edca-txop-n.h:538
uint8_t GetBlockAckThreshold(void) const
Return the current threshold for block ACK mechanism.
void CompleteTx(void)
For now is typically invoked to complete transmission of a packets sent with ack policy Block Ack: th...
void SetTxMiddle(MacTxMiddle *txMiddle)
Definition: edca-txop-n.cc:419
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: edca-txop-n.cc:640
void DoDispose()
Destructor implementation.
Definition: edca-txop-n.cc:278
bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
virtual uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: edca-txop-n.cc:405
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:535
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:985
tuple address
Definition: first.py:37
void SendBlockAckRequest(const struct Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
TypeOfStation
Enumeration for type of station.
Definition: edca-txop-n.h:60
Manages all block ack agreements for an originator station.
uint32_t GetNOutstandingPacketsInBa(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:308
a unique identifier for an interface.
Definition: type-id.h:58
bool NeedsAccess(void) const
Check if the EDCAF requires access.
Definition: edca-txop-n.cc:440
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:36
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
AggregationCapableTransmissionListener * m_blockAckListener
Definition: edca-txop-n.h:541
Implements the IEEE 802.11 MAC header.
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
virtual void SetAifsn(uint32_t aifsn)
Definition: edca-txop-n.cc:391
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:554
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set addresses in a-msdu subframe.
Ptr< WifiMacQueue > GetEdcaQueue() const
Return the packet queue associated with this EdcaTxopN.
Definition: edca-txop-n.cc:370