author | Andrey Mazo <mazo@iitp.ru> |
Fri, 23 Apr 2010 15:09:31 +0400 | |
changeset 6273 | 8d70de29d514 |
parent 6080 | 41ee42654550 |
child 6294 | 6cefb3c0696a |
permissions | -rw-r--r-- |
4408 | 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.h" |
|
31 |
#include "wifi-mac-header.h" |
|
32 |
#include "qos-utils.h" |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
33 |
#include "dcf.h" |
5963
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
34 |
#include "ctrl-headers.h" |
4408 | 35 |
|
36 |
#include <map> |
|
37 |
#include <list> |
|
38 |
||
39 |
namespace ns3 { |
|
40 |
||
41 |
class DcfState; |
|
42 |
class DcfManager; |
|
43 |
class MacLow; |
|
44 |
class MacTxMiddle; |
|
45 |
class WifiMacParameters; |
|
46 |
class WifiMacQueue; |
|
47 |
class RandomStream; |
|
5963
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
48 |
class QosBlockedDestinations; |
4408 | 49 |
class MsduAggregator; |
5953
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5952
diff
changeset
|
50 |
class MgtAddBaResponseHeader; |
5963
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
51 |
class BlockAckManager; |
5965
4e64e751be07
add support to block ack tear down in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5964
diff
changeset
|
52 |
class MgtDelBaHeader; |
5953
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5952
diff
changeset
|
53 |
|
4408 | 54 |
|
55 |
/* This queue contains packets for a particular access class. |
|
56 |
* possibles access classes are: |
|
57 |
* |
|
58 |
* -AC_VO : voice, tid = 6,7 ^ |
|
59 |
* -AC_VI : video, tid = 4,5 | |
|
60 |
* -AC_BE : best-effort, tid = 0,3 | priority |
|
61 |
* -AC_BK : background, tid = 1,2 | |
|
62 |
* |
|
63 |
* For more details see section 9.1.3.1 in 802.11 standard. |
|
64 |
*/ |
|
65 |
enum TypeOfStation |
|
66 |
{ |
|
67 |
STA, |
|
68 |
AP, |
|
69 |
ADHOC_STA |
|
70 |
}; |
|
71 |
||
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
72 |
class EdcaTxopN : public Dcf |
4408 | 73 |
{ |
74 |
public: |
|
75 |
||
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5192
diff
changeset
|
76 |
typedef Callback <void, const WifiMacHeader&> TxOk; |
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5192
diff
changeset
|
77 |
typedef Callback <void, const WifiMacHeader&> TxFailed; |
4408 | 78 |
|
79 |
static TypeId GetTypeId (void); |
|
80 |
EdcaTxopN (); |
|
81 |
virtual ~EdcaTxopN (); |
|
82 |
void DoDispose (); |
|
83 |
||
84 |
void SetLow (Ptr<MacLow> low); |
|
85 |
void SetTxMiddle (MacTxMiddle *txMiddle); |
|
86 |
void SetManager (DcfManager *manager); |
|
87 |
void SetTxOkCallback (TxOk callback); |
|
88 |
void SetTxFailedCallback (TxFailed callback); |
|
89 |
void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager); |
|
90 |
void SetTypeOfStation (enum TypeOfStation type); |
|
91 |
enum TypeOfStation GetTypeOfStation (void) const; |
|
92 |
||
93 |
void SetMaxQueueSize (uint32_t size); |
|
94 |
void SetMaxQueueDelay (Time delay); |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
95 |
virtual void SetMinCw (uint32_t minCw); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
96 |
virtual void SetMaxCw (uint32_t maxCw); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
97 |
virtual void SetAifsn (uint32_t aifsn); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
98 |
virtual uint32_t GetMinCw (void) const; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
99 |
virtual uint32_t GetMaxCw (void) const; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4421
diff
changeset
|
100 |
virtual uint32_t GetAifsn (void) const; |
4408 | 101 |
|
102 |
Ptr<MacLow> Low (void); |
|
103 |
Ptr<MsduAggregator> GetMsduAggregator (void) const; |
|
104 |
||
105 |
/* dcf notifications forwarded here */ |
|
106 |
bool NeedsAccess (void) const; |
|
107 |
void NotifyAccessGranted (void); |
|
108 |
void NotifyInternalCollision (void); |
|
109 |
void NotifyCollision (void); |
|
5192 | 110 |
/** |
111 |
* When a channel switching occurs, enqueued packets are removed. |
|
112 |
*/ |
|
5189 | 113 |
void NotifyChannelSwitching (void); |
4408 | 114 |
|
115 |
/*event handlers*/ |
|
116 |
void GotCts (double snr, WifiMode txMode); |
|
117 |
void MissedCts (void); |
|
118 |
void GotAck (double snr, WifiMode txMode); |
|
5955
10fbe045901e
add support for block ack in MacLowTransmissionListener
Mirko Banchi <mk.banchi@gmail.com>
parents:
5953
diff
changeset
|
119 |
void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient); |
5958 | 120 |
void MissedBlockAck (void); |
5953
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5952
diff
changeset
|
121 |
void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient); |
5965
4e64e751be07
add support to block ack tear down in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5964
diff
changeset
|
122 |
void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient); |
4408 | 123 |
void MissedAck (void); |
124 |
void StartNext (void); |
|
125 |
void Cancel (void); |
|
126 |
||
127 |
void RestartAccessIfNeeded (void); |
|
128 |
void StartAccessIfNeeded (void); |
|
129 |
bool NeedRts (void); |
|
130 |
bool NeedRtsRetransmission (void); |
|
131 |
bool NeedDataRetransmission (void); |
|
132 |
bool NeedFragmentation (void) const; |
|
133 |
uint32_t GetNextFragmentSize (void); |
|
134 |
uint32_t GetFragmentSize (void); |
|
135 |
uint32_t GetFragmentOffset (void); |
|
136 |
bool IsLastFragment (void) const; |
|
137 |
void NextFragment (void); |
|
138 |
Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr); |
|
139 |
||
5964
8a59a619c30e
add support to block ack tear down in MacLow
Mirko Banchi <mk.banchi@gmail.com>
parents:
5963
diff
changeset
|
140 |
void SetAccessClass (enum AccessClass ac); |
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5192
diff
changeset
|
141 |
void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr); |
4408 | 142 |
void SetMsduAggregator (Ptr<MsduAggregator> aggr); |
5952
0588b01cd77e
WifiMacQueue now supports head pushing
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
143 |
void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr); |
5963
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
144 |
void CompleteConfig (void); |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
145 |
void SetBlockAckThreshold (uint8_t threshold); |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
146 |
uint8_t GetBlockAckThreshold (void) const; |
5964
8a59a619c30e
add support to block ack tear down in MacLow
Mirko Banchi <mk.banchi@gmail.com>
parents:
5963
diff
changeset
|
147 |
void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator); |
4408 | 148 |
|
149 |
private: |
|
6080 | 150 |
void DoStart (); |
4408 | 151 |
/** |
152 |
* This functions are used only to correctly set addresses in a-msdu subframe. |
|
153 |
* If aggregating sta is a STA (in an infrastructured network): |
|
154 |
* SA = Address2 |
|
155 |
* DA = Address3 |
|
156 |
* If aggregating sta is an AP |
|
157 |
* SA = Address3 |
|
158 |
* DA = Address1 |
|
159 |
*/ |
|
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5192
diff
changeset
|
160 |
Mac48Address MapSrcAddressForAggregation (const WifiMacHeader &hdr); |
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5192
diff
changeset
|
161 |
Mac48Address MapDestAddressForAggregation (const WifiMacHeader &hdr); |
4421
0608881b163f
help python bindings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
162 |
EdcaTxopN &operator = (const EdcaTxopN &); |
0608881b163f
help python bindings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
163 |
EdcaTxopN (const EdcaTxopN &); |
5963
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
164 |
|
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
165 |
/* If number of packets in the queue reaches m_blockAckThreshold value, an ADDBARequest frame |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
166 |
* is sent to destination in order to setup a block ack. |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
167 |
*/ |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
168 |
bool SetupBlockAckIfNeeded (); |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
169 |
/* Sends an ADDBARequest to establish a block ack agreement with sta |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
170 |
* addressed by <i>recipient</i> for tid <i>tid</i>. |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
171 |
*/ |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
172 |
void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq, |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
173 |
uint16_t timeout, bool immediateBAck); |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
174 |
/* After that all packets, for which a block ack agreement was established, have been |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
175 |
* transmitted, we have to send a block ack request. |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
176 |
*/ |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
177 |
void SendBlockAckRequest (const struct Bar &bar); |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
178 |
/* For now is typically invoked to complete transmission of a packets sent with ack policy |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
179 |
* Block Ack: the packet is buffered and dcf is reset. |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
180 |
*/ |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
181 |
void CompleteTx (void); |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
182 |
/* Verifies if dequeued packet has to be transmitted with ack policy Block Ack. This happens |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
183 |
* if an established block ack agreement exists with the receiver. |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
184 |
*/ |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
185 |
void VerifyBlockAck (void); |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
186 |
|
5964
8a59a619c30e
add support to block ack tear down in MacLow
Mirko Banchi <mk.banchi@gmail.com>
parents:
5963
diff
changeset
|
187 |
AccessClass m_ac; |
4408 | 188 |
class Dcf; |
189 |
class TransmissionListener; |
|
5964
8a59a619c30e
add support to block ack tear down in MacLow
Mirko Banchi <mk.banchi@gmail.com>
parents:
5963
diff
changeset
|
190 |
class BlockAckEventListener; |
4408 | 191 |
friend class Dcf; |
192 |
friend class TransmissionListener; |
|
193 |
Dcf *m_dcf; |
|
194 |
DcfManager *m_manager; |
|
195 |
Ptr<WifiMacQueue> m_queue; |
|
196 |
TxOk m_txOkCallback; |
|
197 |
TxFailed m_txFailedCallback; |
|
198 |
Ptr<MacLow> m_low; |
|
199 |
MacTxMiddle *m_txMiddle; |
|
200 |
TransmissionListener *m_transmissionListener; |
|
5964
8a59a619c30e
add support to block ack tear down in MacLow
Mirko Banchi <mk.banchi@gmail.com>
parents:
5963
diff
changeset
|
201 |
BlockAckEventListener *m_blockAckListener; |
4408 | 202 |
RandomStream *m_rng; |
203 |
Ptr<WifiRemoteStationManager> m_stationManager; |
|
204 |
uint8_t m_fragmentNumber; |
|
205 |
||
206 |
/* current packet could be a simple MSDU or, if an aggregator for this queue is |
|
207 |
present, could be an A-MSDU. |
|
208 |
*/ |
|
209 |
Ptr<const Packet> m_currentPacket; |
|
210 |
||
211 |
WifiMacHeader m_currentHdr; |
|
212 |
Ptr<MsduAggregator> m_aggregator; |
|
213 |
TypeOfStation m_typeOfStation; |
|
5963
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
214 |
QosBlockedDestinations *m_qosBlockedDestinations; |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
215 |
BlockAckManager *m_baManager; |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
216 |
/* |
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
6080
diff
changeset
|
217 |
* Represents the minimum number of packets for use of block ack. |
5963
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
218 |
*/ |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
219 |
uint8_t m_blockAckThreshold; |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
220 |
enum BlockAckType m_blockAckType; |
5f82c5a7068e
add support to block ack in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5958
diff
changeset
|
221 |
Time m_currentPacketTimestamp; |
5965
4e64e751be07
add support to block ack tear down in EdcaTxopN
Mirko Banchi <mk.banchi@gmail.com>
parents:
5964
diff
changeset
|
222 |
uint16_t m_blockAckInactivityTimeout; |
4408 | 223 |
}; |
224 |
||
225 |
} //namespace ns3 |
|
226 |
||
227 |
#endif /* EDCA_TXOP_N_H */ |