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 
25 namespace 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 
49 void
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 
67 std::unique_ptr<WifiAcknowledgment>
68 WifiNoAck::Copy (void) const
69 {
70  return std::unique_ptr<WifiAcknowledgment> (new WifiNoAck (*this));
71 }
72 
73 bool
75 {
76  if (ackPolicy == WifiMacHeader::NO_ACK || ackPolicy == WifiMacHeader::BLOCK_ACK)
77  {
78  return true;
79  }
80  return false;
81 }
82 
83 void
84 WifiNoAck::Print (std::ostream &os) const
85 {
86  os << "NONE";
87 }
88 
89 
90 /*
91  * WifiNormalAck
92  */
93 
95  : WifiAcknowledgment (NORMAL_ACK)
96 {
97 }
98 
99 std::unique_ptr<WifiAcknowledgment>
101 {
102  return std::unique_ptr<WifiAcknowledgment> (new WifiNormalAck (*this));
103 }
104 
105 bool
107 {
108  if (ackPolicy == WifiMacHeader::NORMAL_ACK)
109  {
110  return true;
111  }
112  return false;
113 }
114 
115 void
116 WifiNormalAck::Print (std::ostream &os) const
117 {
118  os << "NORMAL_ACK";
119 }
120 
121 /*
122  * WifiBlockAck
123  */
124 
126  : WifiAcknowledgment (BLOCK_ACK)
127 {
128 }
129 
130 std::unique_ptr<WifiAcknowledgment>
131 WifiBlockAck::Copy (void) const
132 {
133  return std::unique_ptr<WifiAcknowledgment> (new WifiBlockAck (*this));
134 }
135 
136 bool
138 {
139  if (ackPolicy == WifiMacHeader::NORMAL_ACK)
140  {
141  return true;
142  }
143  return false;
144 }
145 
146 void
147 WifiBlockAck::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 
162 std::unique_ptr<WifiAcknowledgment>
164 {
165  return std::unique_ptr<WifiAcknowledgment> (new WifiBarBlockAck (*this));
166 }
167 
168 bool
170 {
171  if (ackPolicy == WifiMacHeader::BLOCK_ACK)
172  {
173  return true;
174  }
175  return false;
176 }
177 
178 void
179 WifiBarBlockAck::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 
194 std::unique_ptr<WifiAcknowledgment>
196 {
197  return std::unique_ptr<WifiAcknowledgment> (new WifiDlMuBarBaSequence (*this));
198 }
199 
200 bool
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 
230 void
231 WifiDlMuBarBaSequence::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 
260 std::unique_ptr<WifiAcknowledgment>
262 {
263  return std::unique_ptr<WifiAcknowledgment> (new WifiDlMuTfMuBar (*this));
264 }
265 
266 bool
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 
279 void
280 WifiDlMuTfMuBar::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 
301 std::unique_ptr<WifiAcknowledgment>
303 {
304  return std::unique_ptr<WifiAcknowledgment> (new WifiDlMuAggregateTf (*this));
305 }
306 
307 bool
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 
320 void
321 WifiDlMuAggregateTf::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 {
339 }
340 
341 std::unique_ptr<WifiAcknowledgment>
343 {
344  return std::unique_ptr<WifiAcknowledgment> (new WifiUlMuMultiStaBa (*this));
345 }
346 
347 bool
349  WifiMacHeader::QosAckPolicy ackPolicy) const
350 {
351  // a Basic Trigger Frame has no QoS ack policy
352  return true;
353 }
354 
355 void
356 WifiUlMuMultiStaBa::Print (std::ostream &os) const
357 {
358  os << "UL_MU_MULTI_STA_BA [";
359  for (const auto& sta : stationsReceivingMultiStaBa)
360  {
361  os << "(" << sta.first.first << "," << +sta.first.second << ") ";
362  }
363  os << "]";
364 }
365 
366 
367 /*
368  * WifiAckAfterTbPpdu
369  */
370 
372  : WifiAcknowledgment (ACK_AFTER_TB_PPDU)
373 {
374 }
375 
376 std::unique_ptr<WifiAcknowledgment>
378 {
379  return std::unique_ptr<WifiAcknowledgment> (new WifiAckAfterTbPpdu (*this));
380 }
381 
382 bool
384  WifiMacHeader::QosAckPolicy ackPolicy) const
385 {
386  if (ackPolicy == WifiMacHeader::NORMAL_ACK)
387  {
388  return true;
389  }
390 
391  return false;
392 }
393 
394 void
395 WifiAckAfterTbPpdu::Print (std::ostream &os) const
396 {
397  os << "ACK_AFTER_TB_PPDU";
398 }
399 
400 
401 std::ostream & operator << (std::ostream &os, const WifiAcknowledgment* acknowledgment)
402 {
403  acknowledgment->Print (os);
404  return os;
405 }
406 
407 } //namespace ns3
ns3::WifiUlMuMultiStaBa::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:342
ns3::WifiUlMuMultiStaBa
WifiUlMuMultiStaBa specifies that a Basic Trigger Frame is being sent to solicit TB PPDUs that will b...
Definition: wifi-acknowledgment.h:306
ns3::WifiAcknowledgment::acknowledgmentTime
Time acknowledgmentTime
time required by the acknowledgment method
Definition: wifi-acknowledgment.h:104
ns3::WifiNoAck::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:84
NS_ASSERT
#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
ns3::WifiNormalAck::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:100
ns3::WifiBlockAck::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:147
ns3::WifiBarBlockAck::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:179
ns3::WifiAcknowledgment::CheckQosAckPolicy
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 ...
ns3::WifiDlMuAggregateTf::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:308
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiNoAck::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:74
ns3::WifiBlockAck
WifiBlockAck specifies that acknowledgment via Block Ack is required.
Definition: wifi-acknowledgment.h:162
ns3::WifiDlMuBarBaSequence::stationsSendBlockAckReqTo
std::map< Mac48Address, BlockAckReqInfo > stationsSendBlockAckReqTo
Set of stations receiving a BlockAckReq frame and replying with a BlockAck frame.
Definition: wifi-acknowledgment.h:234
ns3::WifiMacHeader::BLOCK_ACK
@ BLOCK_ACK
Definition: wifi-mac-header.h:95
ns3::WifiBarBlockAck::WifiBarBlockAck
WifiBarBlockAck()
Definition: wifi-acknowledgment.cc:157
ns3::WifiUlMuMultiStaBa::WifiUlMuMultiStaBa
WifiUlMuMultiStaBa()
Definition: wifi-acknowledgment.cc:336
ns3::WifiDlMuTfMuBar::stationsReplyingWithBlockAck
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
Definition: wifi-acknowledgment.h:262
ns3::WifiMacHeader::NO_ACK
@ NO_ACK
Definition: wifi-mac-header.h:93
wifi-acknowledgment.h
ns3::WifiAcknowledgment::WifiAcknowledgment
WifiAcknowledgment(Method m)
Constructor.
Definition: wifi-acknowledgment.cc:31
ns3::WifiUlMuMultiStaBa::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:356
ns3::WifiDlMuBarBaSequence::stationsReplyingWithBlockAck
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame (no more than one)
Definition: wifi-acknowledgment.h:232
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::WifiDlMuAggregateTf
WifiDlMuAggregateTf specifies that a DL MU PPDU made of PSDUs including each a MU-BAR Trigger Frame i...
Definition: wifi-acknowledgment.h:277
ns3::WifiAckAfterTbPpdu
WifiAckAfterTbPpdu is used when a station prepares a TB PPDU to send in response to a Basic Trigger F...
Definition: wifi-acknowledgment.h:331
ns3::WifiDlMuTfMuBar::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:280
ns3::Min
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:218
ns3::WifiDlMuBarBaSequence::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:195
ns3::WifiDlMuBarBaSequence::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:231
ns3::WifiAcknowledgment::~WifiAcknowledgment
virtual ~WifiAcknowledgment()
Definition: wifi-acknowledgment.cc:37
ns3::WifiDlMuTfMuBar::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:261
ns3::WifiBarBlockAck
WifiBarBlockAck specifies that a BlockAckReq is sent to solicit a Block Ack response.
Definition: wifi-acknowledgment.h:180
ns3::WifiAckAfterTbPpdu::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:395
ns3::WifiAckAfterTbPpdu::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:377
ns3::WifiMacHeader::QosAckPolicy
QosAckPolicy
Ack policy for QoS frames.
Definition: wifi-mac-header.h:91
ns3::WifiDlMuTfMuBar::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:267
ns3::WifiDlMuTfMuBar
WifiDlMuTfMuBar specifies that a DL MU PPDU is followed after a SIFS duration by a MU-BAR Trigger Fra...
Definition: wifi-acknowledgment.h:246
ns3::WifiNormalAck
WifiNormalAck specifies that acknowledgment via Normal Ack is required.
Definition: wifi-acknowledgment.h:145
ns3::WifiMacHeader::NORMAL_ACK
@ NORMAL_ACK
Definition: wifi-mac-header.h:92
ns3::WifiBlockAck::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:131
ns3::WifiDlMuAggregateTf::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:321
ns3::WifiBarBlockAck::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:163
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::WifiNoAck::WifiNoAck
WifiNoAck()
Definition: wifi-acknowledgment.cc:61
NS_ABORT_MSG_IF
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
ns3::WifiBarBlockAck::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:169
ns3::WifiDlMuAggregateTf::stationsReplyingWithBlockAck
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
Definition: wifi-acknowledgment.h:294
ns3::WifiNoAck::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:68
ns3::WifiDlMuBarBaSequence
WifiDlMuBarBaSequence specifies that a DL MU PPDU is acknowledged through a sequence of BlockAckReq a...
Definition: wifi-acknowledgment.h:202
ns3::WifiDlMuTfMuBar::WifiDlMuTfMuBar
WifiDlMuTfMuBar()
Definition: wifi-acknowledgment.cc:254
ns3::WifiDlMuAggregateTf::WifiDlMuAggregateTf
WifiDlMuAggregateTf()
Definition: wifi-acknowledgment.cc:295
ns3::WifiAckAfterTbPpdu::WifiAckAfterTbPpdu
WifiAckAfterTbPpdu()
Definition: wifi-acknowledgment.cc:371
ns3::WifiBlockAck::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:137
ns3::WifiNormalAck::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:106
ns3::WifiAcknowledgment::SetQosAckPolicy
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...
Definition: wifi-acknowledgment.cc:50
ns3::WifiAckAfterTbPpdu::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:383
ns3::WifiMacHeader::NO_EXPLICIT_ACK
@ NO_EXPLICIT_ACK
Definition: wifi-mac-header.h:94
wifi-utils.h
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::WifiAcknowledgment
WifiAcknowledgment is an abstract base struct.
Definition: wifi-acknowledgment.h:45
ns3::WifiNoAck
WifiNoAck specifies that no acknowledgment is required.
Definition: wifi-acknowledgment.h:130
ns3::WifiAcknowledgment::Print
virtual void Print(std::ostream &os) const =0
Print the object contents.
ns3::WifiDlMuBarBaSequence::stationsReplyingWithNormalAck
std::map< Mac48Address, AckInfo > stationsReplyingWithNormalAck
Set of stations replying with an Ack frame (no more than one)
Definition: wifi-acknowledgment.h:230
ns3::WifiUlMuMultiStaBa::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:348
ns3::WifiAcknowledgment::Method
Method
Available acknowledgment methods.
Definition: wifi-acknowledgment.h:51
ns3::WifiDlMuAggregateTf::Copy
std::unique_ptr< WifiAcknowledgment > Copy(void) const override
Clone this object.
Definition: wifi-acknowledgment.cc:302
ns3::WifiNormalAck::WifiNormalAck
WifiNormalAck()
Definition: wifi-acknowledgment.cc:94
ns3::WifiUlMuMultiStaBa::stationsReceivingMultiStaBa
std::map< std::pair< Mac48Address, uint8_t >, std::size_t > stationsReceivingMultiStaBa
Map (originator, tid) pairs to the their index in baType.
Definition: wifi-acknowledgment.h:314
ns3::WifiAcknowledgment::m_ackPolicy
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.
Definition: wifi-acknowledgment.h:120
ns3::WifiAcknowledgment::GetQosAckPolicy
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...
Definition: wifi-acknowledgment.cc:42
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ns3::WifiDlMuBarBaSequence::CheckQosAckPolicy
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 ...
Definition: wifi-acknowledgment.cc:201
ns3::WifiNormalAck::Print
void Print(std::ostream &os) const override
Print the object contents.
Definition: wifi-acknowledgment.cc:116
ns3::WifiBlockAck::WifiBlockAck
WifiBlockAck()
Definition: wifi-acknowledgment.cc:125
ns3::WifiDlMuBarBaSequence::WifiDlMuBarBaSequence
WifiDlMuBarBaSequence()
Definition: wifi-acknowledgment.cc:189