A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "ns3/traced-value.h"
29 #include "wifi-mode.h"
30 #include "wifi-mac-header.h"
32 #include "qos-utils.h"
33 #include "dcf.h"
34 #include "ctrl-headers.h"
35 #include "block-ack-manager.h"
36 #include <map>
37 #include <list>
38 
40 
41 namespace ns3 {
42 
43 class DcfState;
44 class DcfManager;
45 class MacLow;
46 class MacTxMiddle;
47 class WifiMac;
48 class WifiMacParameters;
49 class WifiMacQueue;
50 class RandomStream;
51 class QosBlockedDestinations;
52 class MsduAggregator;
53 class MpduAggregator;
54 class MgtAddBaResponseHeader;
55 class BlockAckManager;
56 class MgtDelBaHeader;
57 
62 {
63  STA,
64  AP,
71 };
72 
73 
86 class EdcaTxopN : public Dcf
87 {
88 public:
89  // Allow test cases to access private members
90  friend class ::AmpduAggregationTest;
91 
102 
103  std::map<Mac48Address, bool> m_aMpduEnabled;
104 
105  static TypeId GetTypeId (void);
106  EdcaTxopN ();
107  virtual ~EdcaTxopN ();
108  void DoDispose ();
109 
115  void SetLow (Ptr<MacLow> low);
116  void SetTxMiddle (MacTxMiddle *txMiddle);
122  void SetManager (DcfManager *manager);
127  void SetTxOkCallback (TxOk callback);
132  void SetTxFailedCallback (TxFailed callback);
144  void SetTypeOfStation (enum TypeOfStation type);
150  enum TypeOfStation GetTypeOfStation (void) const;
157 
158  virtual void SetMinCw (uint32_t minCw);
159  virtual void SetMaxCw (uint32_t maxCw);
160  virtual void SetAifsn (uint32_t aifsn);
161  virtual uint32_t GetMinCw (void) const;
162  virtual uint32_t GetMaxCw (void) const;
163  virtual uint32_t GetAifsn (void) const;
164 
170  Ptr<MacLow> Low (void);
171 
174 
183  bool GetBaAgreementExists (Mac48Address address, uint8_t tid);
191  uint32_t GetNOutstandingPacketsInBa (Mac48Address address, uint8_t tid);
199  uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
207  void CompleteAmpduTransfer (Mac48Address recipient, uint8_t tid);
208 
209  /* dcf notifications forwarded here */
216  bool NeedsAccess (void) const;
220  void NotifyAccessGranted (void);
224  void NotifyInternalCollision (void);
228  void NotifyCollision (void);
232  void NotifyChannelSwitching (void);
236  void NotifySleep (void);
240  void NotifyWakeUp (void);
241 
242  /* Event handlers */
249  void GotCts (double snr, WifiMode txMode);
253  void MissedCts (void);
260  void GotAck (double snr, WifiMode txMode);
270  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
274  void MissedBlockAck (uint32_t nMpdus);
275  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
276  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
280  void MissedAck (void);
285  void StartNext (void);
289  void Cancel (void);
294  void EndTxNoAck (void);
298  void RestartAccessIfNeeded (void);
302  void StartAccessIfNeeded (void);
309  bool NeedRtsRetransmission (void);
316  bool NeedDataRetransmission (void);
323  bool NeedBarRetransmission (void);
330  bool NeedFragmentation (void) const;
336  uint32_t GetNextFragmentSize (void);
342  uint32_t GetFragmentSize (void);
348  uint32_t GetFragmentOffset (void);
355  bool IsLastFragment (void) const;
361  void NextFragment (void);
370 
376  void SetAccessCategory (enum AcIndex ac);
377 
385  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
386 
389 
397  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
398 
402  void CompleteConfig (void);
403 
410  void SetBlockAckThreshold (uint8_t threshold);
416  uint8_t GetBlockAckThreshold (void) const;
417 
418  void SetBlockAckInactivityTimeout (uint16_t timeout);
419  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
420  void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp);
421  bool GetAmpduExist (Mac48Address dest);
422  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
423 
431  uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr);
443  void RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
444  /*
445  * Peek in retransmit queue and get the next packet without removing it from the queue
446  */
447  Ptr<const Packet> PeekNextRetransmitPacket (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp);
453  void BaTxOk (const WifiMacHeader &hdr);
459  void BaTxFailed (const WifiMacHeader &hdr);
460 
469  int64_t AssignStreams (int64_t stream);
470 
471 
472 private:
473  void DoInitialize ();
488  EdcaTxopN &operator = (const EdcaTxopN &);
489  EdcaTxopN (const EdcaTxopN &);
490 
497  bool SetupBlockAckIfNeeded ();
508  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
509  uint16_t timeout, bool immediateBAck);
516  void SendBlockAckRequest (const struct Bar &bar);
521  void CompleteTx (void);
526  void VerifyBlockAck (void);
530  uint8_t GetCurrentTid ();
531 
533  class Dcf;
534  class TransmissionListener;
536  friend class Dcf;
537  friend class TransmissionListener;
550 
551  /* current packet could be a simple MSDU or, if an aggregator for this queue is
552  present, could be an A-MSDU.
553  */
555 
562  /*
563  * Represents the minimum number of packets for use of block ack.
564  */
572 };
573 
574 } //namespace ns3
575 
576 #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:392
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:545
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:554
void DoInitialize()
Initialize() implementation.
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:542
void NotifyWakeUp(void)
When wake up operation occurs, restart channel access.
Definition: edca-txop-n.cc:803
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:568
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:640
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:364
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:349
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:820
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
uint8_t m_blockAckThreshold
Definition: edca-txop-n.h:565
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:356
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:556
void NotifySleep(void)
When sleep operation occurs, re-insert pending packet into front of the queue.
Definition: edca-txop-n.cc:792
Ptr< MsduAggregator > m_msduAggregator
Definition: edca-txop-n.h:557
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:342
BlockAckManager * m_baManager
Definition: edca-txop-n.h:561
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
struct Bar m_currentBar
Definition: edca-txop-n.h:569
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: edca-txop-n.cc:420
void MissedBlockAck(uint32_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:933
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
Ptr< MpduAggregator > m_mpduAggregator
Definition: edca-txop-n.h:558
DcfManager * m_manager
Definition: edca-txop-n.h:539
void MissedAck(void)
Event handler when an ACK is missed.
Definition: edca-txop-n.cc:868
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:371
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:441
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:434
Ptr< WifiRemoteStationManager > m_stationManager
Definition: edca-txop-n.h:548
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:86
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: edca-txop-n.cc:477
RandomStream * m_rng
Definition: edca-txop-n.h:547
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:471
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:633
std::map< Mac48Address, bool > m_aMpduEnabled
Definition: edca-txop-n.h:103
TracedValue< uint32_t > m_cwTrace
Definition: edca-txop-n.h:571
TracedValue< uint32_t > m_backoffTrace
Definition: edca-txop-n.h:570
virtual void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: edca-txop-n.cc:385
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:465
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
bool GetBaAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:310
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
MacTxMiddle * m_txMiddle
Definition: edca-txop-n.h:544
Callback< void, const WifiMacHeader & > TxOk
typedef for a callback to invoke when a packet transmission was completed successfully.
Definition: edca-txop-n.h:96
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: edca-txop-n.cc:721
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:459
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:784
uint8_t GetCurrentTid()
Get Traffic ID of the current packet.
Definition: edca-txop-n.cc:656
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:280
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:322
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:549
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:567
virtual uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: edca-txop-n.cc:406
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
Ptr< MsduAggregator > GetMsduAggregator(void) const
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:101
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:334
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:810
uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:454
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:566
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.
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:560
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:328
Ptr< MacLow > m_low
Definition: edca-txop-n.h:543
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:427
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: edca-txop-n.cc:649
void DoDispose()
Destructor implementation.
Definition: edca-txop-n.cc:286
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:413
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:540
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
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:61
Manages all block ack agreements for an originator station.
uint32_t GetNOutstandingPacketsInBa(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:316
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:448
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:546
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:399
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:559
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:378