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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: 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 
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 
37 #include <map>
38 #include <list>
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 MgtAddBaResponseHeader;
53 class BlockAckManager;
54 class MgtDelBaHeader;
55 
57 {
58  STA,
59  AP,
65 };
66 
67 
80 class EdcaTxopN : public Dcf
81 {
82 public:
85 
86  static TypeId GetTypeId (void);
87  EdcaTxopN ();
88  virtual ~EdcaTxopN ();
89  void DoDispose ();
90 
91  void SetLow (Ptr<MacLow> low);
92  void SetTxMiddle (MacTxMiddle *txMiddle);
93  void SetManager (DcfManager *manager);
94  void SetTxOkCallback (TxOk callback);
95  void SetTxFailedCallback (TxFailed callback);
97  void SetTypeOfStation (enum TypeOfStation type);
98  enum TypeOfStation GetTypeOfStation (void) const;
99 
100  Ptr<WifiMacQueue > GetQueue () const;
101  virtual void SetMinCw (uint32_t minCw);
102  virtual void SetMaxCw (uint32_t maxCw);
103  virtual void SetAifsn (uint32_t aifsn);
104  virtual uint32_t GetMinCw (void) const;
105  virtual uint32_t GetMaxCw (void) const;
106  virtual uint32_t GetAifsn (void) const;
107 
108  Ptr<MacLow> Low (void);
110 
111  /* dcf notifications forwarded here */
112  bool NeedsAccess (void) const;
113  void NotifyAccessGranted (void);
114  void NotifyInternalCollision (void);
115  void NotifyCollision (void);
119  void NotifyChannelSwitching (void);
120 
121  /*event handlers*/
122  void GotCts (double snr, WifiMode txMode);
123  void MissedCts (void);
124  void GotAck (double snr, WifiMode txMode);
125  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient);
126  void MissedBlockAck (void);
127  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
128  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
129  void MissedAck (void);
130  void StartNext (void);
131  void Cancel (void);
132  void EndTxNoAck (void);
133 
134  void RestartAccessIfNeeded (void);
135  void StartAccessIfNeeded (void);
136  bool NeedRts (void);
137  bool NeedRtsRetransmission (void);
138  bool NeedDataRetransmission (void);
139  bool NeedFragmentation (void) const;
140  uint32_t GetNextFragmentSize (void);
141  uint32_t GetFragmentSize (void);
142  uint32_t GetFragmentOffset (void);
143  bool IsLastFragment (void) const;
144  void NextFragment (void);
146 
147  void SetAccessCategory (enum AcIndex ac);
148  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
150  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
151  void CompleteConfig (void);
152  void SetBlockAckThreshold (uint8_t threshold);
153  uint8_t GetBlockAckThreshold (void) const;
154  void SetBlockAckInactivityTimeout (uint16_t timeout);
155  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
156 
165  int64_t AssignStreams (int64_t stream);
166 
167 private:
168  void DoInitialize ();
180  EdcaTxopN &operator = (const EdcaTxopN &);
181  EdcaTxopN (const EdcaTxopN &);
182 
183  /* If number of packets in the queue reaches m_blockAckThreshold value, an ADDBARequest frame
184  * is sent to destination in order to setup a block ack.
185  */
186  bool SetupBlockAckIfNeeded ();
187  /* Sends an ADDBARequest to establish a block ack agreement with sta
188  * addressed by <i>recipient</i> for tid <i>tid</i>.
189  */
190  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
191  uint16_t timeout, bool immediateBAck);
192  /* After that all packets, for which a block ack agreement was established, have been
193  * transmitted, we have to send a block ack request.
194  */
195  void SendBlockAckRequest (const struct Bar &bar);
196  /* For now is typically invoked to complete transmission of a packets sent with ack policy
197  * Block Ack: the packet is buffered and dcf is reset.
198  */
199  void CompleteTx (void);
200  /* Verifies if dequeued packet has to be transmitted with ack policy Block Ack. This happens
201  * if an established block ack agreement exists with the receiver.
202  */
203  void VerifyBlockAck (void);
204 
206  class Dcf;
207  class TransmissionListener;
209  friend class Dcf;
210  friend class TransmissionListener;
223 
224  /* current packet could be a simple MSDU or, if an aggregator for this queue is
225  present, could be an A-MSDU.
226  */
228 
234  /*
235  * Represents the minimum number of packets for use of block ack.
236  */
242 };
243 
244 } // namespace ns3
245 
246 #endif /* EDCA_TXOP_N_H */
virtual void SetMaxCw(uint32_t maxCw)
Definition: edca-txop-n.cc:276
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:218
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:227
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:215
void SetBlockAckInactivityTimeout(uint16_t timeout)
uint32_t GetFragmentSize(void)
Definition: edca-txop-n.cc:769
uint16_t m_blockAckInactivityTimeout
Definition: edca-txop-n.h:240
void VerifyBlockAck(void)
Definition: edca-txop-n.cc:923
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient)
Definition: edca-txop-n.cc:911
void NotifyCollision(void)
Definition: edca-txop-n.cc:511
void SetTypeOfStation(enum TypeOfStation type)
Definition: edca-txop-n.cc:248
bool NeedDataRetransmission(void)
Definition: edca-txop-n.cc:704
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:235
void GotAck(double snr, WifiMode txMode)
Definition: edca-txop-n.cc:571
uint8_t m_blockAckThreshold
Definition: edca-txop-n.h:237
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Definition: edca-txop-n.cc:242
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:229
ns3::Time timeout
BlockAckType
Definition: ctrl-headers.h:27
Block Ack Request.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
void NextFragment(void)
Definition: edca-txop-n.cc:712
void SetTxOkCallback(TxOk callback)
Definition: edca-txop-n.cc:228
BlockAckManager * m_baManager
Definition: edca-txop-n.h:233
bool NeedRtsRetransmission(void)
Definition: edca-txop-n.cc:696
struct Bar m_currentBar
Definition: edca-txop-n.h:241
virtual uint32_t GetAifsn(void) const
Definition: edca-txop-n.cc:304
DcfManager * m_manager
Definition: edca-txop-n.h:212
void MissedAck(void)
Definition: edca-txop-n.cc:617
enum TypeOfStation GetTypeOfStation(void) const
Definition: edca-txop-n.cc:255
void SetLow(Ptr< MacLow > low)
Definition: edca-txop-n.cc:325
Ptr< MacLow > Low(void)
Definition: edca-txop-n.cc:318
Ptr< WifiRemoteStationManager > m_stationManager
Definition: edca-txop-n.h:221
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Definition: edca-txop-n.cc:903
void NotifyAccessGranted(void)
Definition: edca-txop-n.cc:339
RandomStream * m_rng
Definition: edca-txop-n.h:220
void NotifyInternalCollision(void)
Definition: edca-txop-n.cc:504
virtual void SetMinCw(uint32_t minCw)
Definition: edca-txop-n.cc:269
void SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck)
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
void SetBlockAckThreshold(uint8_t threshold)
MacTxMiddle * m_txMiddle
Definition: edca-txop-n.h:217
Callback< void, const WifiMacHeader & > TxOk
Definition: edca-txop-n.h:83
void MissedCts(void)
Definition: edca-txop-n.cc:526
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:173
Headers for Block ack response.
Definition: ctrl-headers.h:102
void NotifyChannelSwitching(void)
Definition: edca-txop-n.cc:551
int64_t AssignStreams(int64_t stream)
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Definition: edca-txop-n.cc:802
virtual ~EdcaTxopN()
Definition: edca-txop-n.cc:191
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:222
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:239
virtual uint32_t GetMinCw(void) const
Definition: edca-txop-n.cc:290
void MissedBlockAck(void)
Definition: edca-txop-n.cc:644
void EndTxNoAck(void)
Definition: edca-txop-n.cc:750
bool NeedFragmentation(void) const
Definition: edca-txop-n.cc:761
Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: edca-txop-n.cc:658
void SetAccessCategory(enum AcIndex ac)
Definition: edca-txop-n.cc:823
Callback< void, const WifiMacHeader & > TxFailed
Definition: edca-txop-n.h:84
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:846
bool SetupBlockAckIfNeeded()
Definition: edca-txop-n.cc:956
void StartNext(void)
Definition: edca-txop-n.cc:719
an EUI-48 address
Definition: mac48-address.h:41
void Cancel(void)
Definition: edca-txop-n.cc:743
void SetManager(DcfManager *manager)
Definition: edca-txop-n.cc:220
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:559
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
Definition: edca-txop-n.cc:862
EdcaTxopN & operator=(const EdcaTxopN &)
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:869
enum BlockAckType m_blockAckType
Definition: edca-txop-n.h:238
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:144
BlockAckEventListener * m_blockAckListener
Definition: edca-txop-n.h:219
uint32_t GetNextFragmentSize(void)
Definition: edca-txop-n.cc:777
void CompleteConfig(void)
void RestartAccessIfNeeded(void)
Definition: edca-txop-n.cc:664
QosBlockedDestinations * m_qosBlockedDestinations
Definition: edca-txop-n.h:232
Ptr< MacLow > m_low
Definition: edca-txop-n.h:216
uint8_t GetBlockAckThreshold(void) const
void CompleteTx(void)
Definition: edca-txop-n.cc:940
void SetTxMiddle(MacTxMiddle *txMiddle)
Definition: edca-txop-n.cc:311
void GotCts(double snr, WifiMode txMode)
Definition: edca-txop-n.cc:519
bool IsLastFragment(void) const
Definition: edca-txop-n.cc:794
virtual uint32_t GetMaxCw(void) const
Definition: edca-txop-n.cc:297
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:213
void StartAccessIfNeeded(void)
Definition: edca-txop-n.cc:676
bool NeedRts(void)
Definition: edca-txop-n.cc:688
void SendBlockAckRequest(const struct Bar &bar)
Definition: edca-txop-n.cc:975
TypeOfStation
Definition: edca-txop-n.h:56
Ptr< MsduAggregator > m_aggregator
Definition: edca-txop-n.h:230
Manages all block ack agreements for an originator station.
Ptr< WifiMacQueue > GetQueue() const
Definition: edca-txop-n.cc:262
a unique identifier for an interface.
Definition: type-id.h:49
bool NeedsAccess(void) const
Definition: edca-txop-n.cc:332
AcIndex
Definition: qos-utils.h:35
uint32_t GetFragmentOffset(void)
Definition: edca-txop-n.cc:785
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
Definition: edca-txop-n.cc:881
virtual void SetAifsn(uint32_t aifsn)
Definition: edca-txop-n.cc:283
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:231
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:830