A Discrete-Event Network Simulator
API
wifi-acknowledgment.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Stefano Avallone <stavallo@unina.it>
19 */
20
21#include "wifi-acknowledgment.h"
22#include "wifi-utils.h"
23#include "ns3/mac48-address.h"
24
25namespace ns3 {
26
27/*
28 * WifiAcknowledgment
29 */
30
32 : method (m),
33 acknowledgmentTime (Time::Min ()) // uninitialized
34{
35}
36
38{
39}
40
43{
44 auto it = m_ackPolicy.find ({receiver, tid});
45 NS_ASSERT (it != m_ackPolicy.end ());
46 return it->second;
47}
48
49void
52{
53 NS_ABORT_MSG_IF (!CheckQosAckPolicy (receiver, tid, ackPolicy), "QoS Ack policy not admitted");
54 m_ackPolicy[{receiver, tid}] = ackPolicy;
55}
56
57/*
58 * WifiNoAck
59 */
60
62 : WifiAcknowledgment (NONE)
63{
65}
66
67std::unique_ptr<WifiAcknowledgment>
68WifiNoAck::Copy (void) const
69{
70 return std::unique_ptr<WifiAcknowledgment> (new WifiNoAck (*this));
71}
72
73bool
75{
76 if (ackPolicy == WifiMacHeader::NO_ACK || ackPolicy == WifiMacHeader::BLOCK_ACK)
77 {
78 return true;
79 }
80 return false;
81}
82
83void
84WifiNoAck::Print (std::ostream &os) const
85{
86 os << "NONE";
87}
88
89
90/*
91 * WifiNormalAck
92 */
93
95 : WifiAcknowledgment (NORMAL_ACK)
96{
97}
98
99std::unique_ptr<WifiAcknowledgment>
101{
102 return std::unique_ptr<WifiAcknowledgment> (new WifiNormalAck (*this));
103}
104
105bool
107{
108 if (ackPolicy == WifiMacHeader::NORMAL_ACK)
109 {
110 return true;
111 }
112 return false;
113}
114
115void
116WifiNormalAck::Print (std::ostream &os) const
117{
118 os << "NORMAL_ACK";
119}
120
121/*
122 * WifiBlockAck
123 */
124
126 : WifiAcknowledgment (BLOCK_ACK)
127{
128}
129
130std::unique_ptr<WifiAcknowledgment>
132{
133 return std::unique_ptr<WifiAcknowledgment> (new WifiBlockAck (*this));
134}
135
136bool
138{
139 if (ackPolicy == WifiMacHeader::NORMAL_ACK)
140 {
141 return true;
142 }
143 return false;
144}
145
146void
147WifiBlockAck::Print (std::ostream &os) const
148{
149 os << "BLOCK_ACK";
150}
151
152
153/*
154 * WifiBarBlockAck
155 */
156
158 : WifiAcknowledgment (BAR_BLOCK_ACK)
159{
160}
161
162std::unique_ptr<WifiAcknowledgment>
164{
165 return std::unique_ptr<WifiAcknowledgment> (new WifiBarBlockAck (*this));
166}
167
168bool
170{
171 if (ackPolicy == WifiMacHeader::BLOCK_ACK)
172 {
173 return true;
174 }
175 return false;
176}
177
178void
179WifiBarBlockAck::Print (std::ostream &os) const
180{
181 os << "BAR_BLOCK_ACK";
182}
183
184
185/*
186 * WifiDlMuBarBaSequence
187 */
188
190 : WifiAcknowledgment (DL_MU_BAR_BA_SEQUENCE)
191{
192}
193
194std::unique_ptr<WifiAcknowledgment>
196{
197 return std::unique_ptr<WifiAcknowledgment> (new WifiDlMuBarBaSequence (*this));
198}
199
200bool
202 WifiMacHeader::QosAckPolicy ackPolicy) const
203{
204 if (ackPolicy == WifiMacHeader::NORMAL_ACK)
205 {
206 // The given receiver must be the only one to send an immediate reply
207 if (stationsReplyingWithNormalAck.size () == 1
208 && stationsReplyingWithNormalAck.begin ()->first == receiver)
209 {
210 return true;
211 }
212
213 if (stationsReplyingWithBlockAck.size () == 1
214 && stationsReplyingWithBlockAck.begin ()->first == receiver)
215 {
216 return true;
217 }
218
219 return false;
220 }
221
222 if (ackPolicy == WifiMacHeader::BLOCK_ACK)
223 {
224 return true;
225 }
226
227 return false;
228}
229
230void
231WifiDlMuBarBaSequence::Print (std::ostream &os) const
232{
233 os << "DL_MU_BAR_BA_SEQUENCE [";
234 for (const auto& sta : stationsReplyingWithNormalAck)
235 {
236 os << " (ACK) " << sta.first;
237 }
238 for (const auto& sta : stationsReplyingWithBlockAck)
239 {
240 os << " (BA) " << sta.first;
241 }
242 for (const auto& sta : stationsSendBlockAckReqTo)
243 {
244 os << " (BAR+BA) " << sta.first;
245 }
246 os << "]";
247}
248
249
250/*
251 * WifiDlMuTfMuBar
252 */
253
255 : WifiAcknowledgment (DL_MU_TF_MU_BAR),
256 ulLength (0)
257{
258}
259
260std::unique_ptr<WifiAcknowledgment>
262{
263 return std::unique_ptr<WifiAcknowledgment> (new WifiDlMuTfMuBar (*this));
264}
265
266bool
268 WifiMacHeader::QosAckPolicy ackPolicy) const
269{
270 // the only admitted ack policy is Block Ack because stations need to wait for a MU-BAR
271 if (ackPolicy == WifiMacHeader::BLOCK_ACK)
272 {
273 return true;
274 }
275
276 return false;
277}
278
279void
280WifiDlMuTfMuBar::Print (std::ostream &os) const
281{
282 os << "DL_MU_TF_MU_BAR [";
283 for (const auto& sta : stationsReplyingWithBlockAck)
284 {
285 os << " (BA) " << sta.first;
286 }
287 os << "]";
288}
289
290
291/*
292 * WifiDlMuAggregateTf
293 */
294
296 : WifiAcknowledgment (DL_MU_AGGREGATE_TF),
297 ulLength (0)
298{
299}
300
301std::unique_ptr<WifiAcknowledgment>
303{
304 return std::unique_ptr<WifiAcknowledgment> (new WifiDlMuAggregateTf (*this));
305}
306
307bool
309 WifiMacHeader::QosAckPolicy ackPolicy) const
310{
311 // the only admitted ack policy is No explicit acknowledgment or TB PPDU Ack policy
312 if (ackPolicy == WifiMacHeader::NO_EXPLICIT_ACK)
313 {
314 return true;
315 }
316
317 return false;
318}
319
320void
321WifiDlMuAggregateTf::Print (std::ostream &os) const
322{
323 os << "DL_MU_AGGREGATE_TF [";
324 for (const auto& sta : stationsReplyingWithBlockAck)
325 {
326 os << " (BA) " << sta.first;
327 }
328 os << "]";
329}
330
331
332/*
333 * WifiUlMuMultiStaBa
334 */
335
337 : WifiAcknowledgment (UL_MU_MULTI_STA_BA),
338 baType (BlockAckType::MULTI_STA)
339{
340}
341
342std::unique_ptr<WifiAcknowledgment>
344{
345 return std::unique_ptr<WifiAcknowledgment> (new WifiUlMuMultiStaBa (*this));
346}
347
348bool
350 WifiMacHeader::QosAckPolicy ackPolicy) const
351{
352 // a Basic Trigger Frame has no QoS ack policy
353 return true;
354}
355
356void
357WifiUlMuMultiStaBa::Print (std::ostream &os) const
358{
359 os << "UL_MU_MULTI_STA_BA [";
360 for (const auto& sta : stationsReceivingMultiStaBa)
361 {
362 os << "(" << sta.first.first << "," << +sta.first.second << ") ";
363 }
364 os << "]";
365}
366
367
368/*
369 * WifiAckAfterTbPpdu
370 */
371
373 : WifiAcknowledgment (ACK_AFTER_TB_PPDU)
374{
375}
376
377std::unique_ptr<WifiAcknowledgment>
379{
380 return std::unique_ptr<WifiAcknowledgment> (new WifiAckAfterTbPpdu (*this));
381}
382
383bool
385 WifiMacHeader::QosAckPolicy ackPolicy) const
386{
387 if (ackPolicy == WifiMacHeader::NORMAL_ACK)
388 {
389 return true;
390 }
391
392 return false;
393}
394
395void
396WifiAckAfterTbPpdu::Print (std::ostream &os) const
397{
398 os << "ACK_AFTER_TB_PPDU";
399}
400
401
402std::ostream & operator << (std::ostream &os, const WifiAcknowledgment* acknowledgment)
403{
404 acknowledgment->Print (os);
405 return os;
406}
407
408} //namespace ns3
an EUI-48 address
Definition: mac48-address.h:44
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
QosAckPolicy
Ack policy for QoS frames.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:218
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:139
The different BlockAck variants.
WifiAckAfterTbPpdu is used when a station prepares a TB PPDU to send in response to a Basic Trigger F...
void Print(std::ostream &os) const override
Print the object contents.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
WifiAcknowledgment is an abstract base struct.
WifiAcknowledgment(Method m)
Constructor.
std::map< std::pair< Mac48Address, uint8_t >, WifiMacHeader::QosAckPolicy > m_ackPolicy
Qos Ack Policy to set for MPDUs addressed to a given receiver and having a given TID.
Time acknowledgmentTime
time required by the acknowledgment method
void SetQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy)
Set the QoS Ack policy to use for the MPDUs addressed to the given receiver and belonging to the give...
WifiMacHeader::QosAckPolicy GetQosAckPolicy(Mac48Address receiver, uint8_t tid) const
Get the QoS Ack policy to use for the MPDUs addressed to the given receiver and belonging to the give...
virtual void Print(std::ostream &os) const =0
Print the object contents.
Method
Available acknowledgment methods.
virtual bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const =0
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
WifiBarBlockAck specifies that a BlockAckReq is sent to solicit a Block Ack response.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
WifiBlockAck specifies that acknowledgment via Block Ack is required.
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
void Print(std::ostream &os) const override
Print the object contents.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
WifiDlMuAggregateTf specifies that a DL MU PPDU made of PSDUs including each a MU-BAR Trigger Frame i...
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
void Print(std::ostream &os) const override
Print the object contents.
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
WifiDlMuBarBaSequence specifies that a DL MU PPDU is acknowledged through a sequence of BlockAckReq a...
void Print(std::ostream &os) const override
Print the object contents.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
std::map< Mac48Address, BlockAckReqInfo > stationsSendBlockAckReqTo
Set of stations receiving a BlockAckReq frame and replying with a BlockAck frame.
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame (no more than one)
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
std::map< Mac48Address, AckInfo > stationsReplyingWithNormalAck
Set of stations replying with an Ack frame (no more than one)
WifiDlMuTfMuBar specifies that a DL MU PPDU is followed after a SIFS duration by a MU-BAR Trigger Fra...
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
void Print(std::ostream &os) const override
Print the object contents.
WifiNoAck specifies that no acknowledgment is required.
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
void Print(std::ostream &os) const override
Print the object contents.
WifiNormalAck specifies that acknowledgment via Normal Ack is required.
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
void Print(std::ostream &os) const override
Print the object contents.
WifiUlMuMultiStaBa specifies that a Basic Trigger Frame is being sent to solicit TB PPDUs that will b...
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
std::map< std::pair< Mac48Address, uint8_t >, std::size_t > stationsReceivingMultiStaBa
Map (originator, tid) pairs to the their index in baType.
void Print(std::ostream &os) const override
Print the object contents.
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const override
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...