A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-acknowledgment.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
10
11#include "wifi-utils.h"
12
13#include "ns3/mac48-address.h"
14
15namespace ns3
16{
17
18/*
19 * WifiAcknowledgment
20 */
21
26
30
33{
34 auto it = m_ackPolicy.find({receiver, tid});
35 NS_ASSERT(it != m_ackPolicy.end());
36 return it->second;
37}
38
39void
41 uint8_t tid,
43{
44 NS_ABORT_MSG_IF(!CheckQosAckPolicy(receiver, tid, ackPolicy), "QoS Ack policy not admitted");
45 m_ackPolicy[{receiver, tid}] = ackPolicy;
46}
47
48/*
49 * WifiNoAck
50 */
51
57
58std::unique_ptr<WifiAcknowledgment>
60{
61 return std::make_unique<WifiNoAck>(*this);
62}
63
64bool
66 uint8_t tid,
67 WifiMacHeader::QosAckPolicy ackPolicy) const
68{
69 return ackPolicy == WifiMacHeader::NO_ACK || ackPolicy == WifiMacHeader::BLOCK_ACK;
70}
71
72void
73WifiNoAck::Print(std::ostream& os) const
74{
75 os << "NONE";
76}
77
78/*
79 * WifiNormalAck
80 */
81
86
87std::unique_ptr<WifiAcknowledgment>
89{
90 return std::make_unique<WifiNormalAck>(*this);
91}
92
93bool
95 uint8_t tid,
96 WifiMacHeader::QosAckPolicy ackPolicy) const
97{
98 return ackPolicy == WifiMacHeader::NORMAL_ACK;
99}
100
101void
102WifiNormalAck::Print(std::ostream& os) const
103{
104 os << "NORMAL_ACK";
105}
106
107/*
108 * WifiBlockAck
109 */
110
115
116std::unique_ptr<WifiAcknowledgment>
118{
119 return std::make_unique<WifiBlockAck>(*this);
120}
121
122bool
124 uint8_t tid,
125 WifiMacHeader::QosAckPolicy ackPolicy) const
126{
127 return ackPolicy == WifiMacHeader::NORMAL_ACK;
128}
129
130void
131WifiBlockAck::Print(std::ostream& os) const
132{
133 os << "BLOCK_ACK";
134}
135
136/*
137 * WifiBarBlockAck
138 */
139
144
145std::unique_ptr<WifiAcknowledgment>
147{
148 return std::make_unique<WifiBarBlockAck>(*this);
149}
150
151bool
153 uint8_t tid,
154 WifiMacHeader::QosAckPolicy ackPolicy) const
155{
156 return ackPolicy == WifiMacHeader::BLOCK_ACK;
157}
158
159void
160WifiBarBlockAck::Print(std::ostream& os) const
161{
162 os << "BAR_BLOCK_ACK";
163}
164
165/*
166 * WifiDlMuBarBaSequence
167 */
168
173
174std::unique_ptr<WifiAcknowledgment>
176{
177 return std::make_unique<WifiDlMuBarBaSequence>(*this);
178}
179
180bool
182 uint8_t tid,
183 WifiMacHeader::QosAckPolicy ackPolicy) const
184{
185 if (ackPolicy == WifiMacHeader::NORMAL_ACK)
186 {
187 // The given receiver must be the only one to send an immediate reply
188 if (stationsReplyingWithNormalAck.size() == 1 &&
189 stationsReplyingWithNormalAck.begin()->first == receiver)
190 {
191 return true;
192 }
193
194 if (stationsReplyingWithBlockAck.size() == 1 &&
195 stationsReplyingWithBlockAck.begin()->first == receiver)
196 {
197 return true;
198 }
199
200 return false;
201 }
202
203 return ackPolicy == WifiMacHeader::BLOCK_ACK;
204}
205
206void
207WifiDlMuBarBaSequence::Print(std::ostream& os) const
208{
209 os << "DL_MU_BAR_BA_SEQUENCE [";
210 for (const auto& sta : stationsReplyingWithNormalAck)
211 {
212 os << " (ACK) " << sta.first;
213 }
214 for (const auto& sta : stationsReplyingWithBlockAck)
215 {
216 os << " (BA) " << sta.first;
217 }
218 for (const auto& sta : stationsSendBlockAckReqTo)
219 {
220 os << " (BAR+BA) " << sta.first;
221 }
222 os << "]";
223}
224
225/*
226 * WifiDlMuTfMuBar
227 */
228
230 : WifiAcknowledgment(DL_MU_TF_MU_BAR),
231 ulLength(0)
232{
233}
234
235std::unique_ptr<WifiAcknowledgment>
237{
238 return std::make_unique<WifiDlMuTfMuBar>(*this);
239}
240
241bool
243 uint8_t tid,
244 WifiMacHeader::QosAckPolicy ackPolicy) const
245{
246 // the only admitted ack policy is Block Ack because stations need to wait for a MU-BAR
247 return ackPolicy == WifiMacHeader::BLOCK_ACK;
248}
249
250void
251WifiDlMuTfMuBar::Print(std::ostream& os) const
252{
253 os << "DL_MU_TF_MU_BAR [";
254 for (const auto& sta : stationsReplyingWithBlockAck)
255 {
256 os << " (BA) " << sta.first;
257 }
258 os << "]";
259}
260
261/*
262 * WifiDlMuAggregateTf
263 */
264
266 : WifiAcknowledgment(DL_MU_AGGREGATE_TF),
267 ulLength(0)
268{
269}
270
271std::unique_ptr<WifiAcknowledgment>
273{
274 return std::make_unique<WifiDlMuAggregateTf>(*this);
275}
276
277bool
279 uint8_t tid,
280 WifiMacHeader::QosAckPolicy ackPolicy) const
281{
282 // the only admitted ack policy is No explicit acknowledgment or TB PPDU Ack policy
283 return ackPolicy == WifiMacHeader::NO_EXPLICIT_ACK;
284}
285
286void
287WifiDlMuAggregateTf::Print(std::ostream& os) const
288{
289 os << "DL_MU_AGGREGATE_TF [";
290 for (const auto& sta : stationsReplyingWithBlockAck)
291 {
292 os << " (BA) " << sta.first;
293 }
294 os << "]";
295}
296
297/*
298 * WifiUlMuMultiStaBa
299 */
300
302 : WifiAcknowledgment(UL_MU_MULTI_STA_BA),
303 baType(BlockAckType::MULTI_STA)
304{
305}
306
307std::unique_ptr<WifiAcknowledgment>
309{
310 return std::make_unique<WifiUlMuMultiStaBa>(*this);
311}
312
313bool
315 uint8_t tid,
316 WifiMacHeader::QosAckPolicy ackPolicy) const
317{
318 // a Basic Trigger Frame has no QoS ack policy
319 return true;
320}
321
322void
323WifiUlMuMultiStaBa::Print(std::ostream& os) const
324{
325 os << "UL_MU_MULTI_STA_BA [";
326 for (const auto& sta : stationsReceivingMultiStaBa)
327 {
328 os << "(" << sta.first.first << "," << +sta.first.second << ") ";
329 }
330 os << "]";
331}
332
333/*
334 * WifiAckAfterTbPpdu
335 */
336
341
342std::unique_ptr<WifiAcknowledgment>
344{
345 return std::make_unique<WifiAckAfterTbPpdu>(*this);
346}
347
348bool
350 uint8_t tid,
351 WifiMacHeader::QosAckPolicy ackPolicy) const
352{
353 return ackPolicy == WifiMacHeader::NORMAL_ACK;
354}
355
356void
357WifiAckAfterTbPpdu::Print(std::ostream& os) const
358{
359 os << "ACK_AFTER_TB_PPDU";
360}
361
362std::ostream&
363operator<<(std::ostream& os, const WifiAcknowledgment* acknowledgment)
364{
365 acknowledgment->Print(os);
366 return os;
367}
368
369} // namespace ns3
an EUI-48 address
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:55
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
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:148
The different BlockAck variants.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiAcknowledgment > Copy() 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 ...
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.
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 ...
std::optional< Time > acknowledgmentTime
time required by the acknowledgment method
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiAcknowledgment > Copy() 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::unique_ptr< WifiAcknowledgment > Copy() 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 ...
std::unique_ptr< WifiAcknowledgment > Copy() 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 ...
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() const override
Clone this object.
std::map< Mac48Address, AckInfo > stationsReplyingWithNormalAck
Set of stations replying with an Ack frame (no more than one)
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.
std::unique_ptr< WifiAcknowledgment > Copy() const override
Clone this object.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiAcknowledgment > Copy() 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.
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.
std::unique_ptr< WifiAcknowledgment > Copy() const override
Clone this object.
std::unique_ptr< WifiAcknowledgment > Copy() 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 ...