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 bool
69 {
70  if (ackPolicy == WifiMacHeader::NO_ACK || ackPolicy == WifiMacHeader::BLOCK_ACK)
71  {
72  return true;
73  }
74  return false;
75 }
76 
77 void
78 WifiNoAck::Print (std::ostream &os) const
79 {
80  os << "NONE";
81 }
82 
83 
84 /*
85  * WifiNormalAck
86  */
87 
89  : WifiAcknowledgment (NORMAL_ACK)
90 {
91 }
92 
93 bool
95 {
96  if (ackPolicy == WifiMacHeader::NORMAL_ACK)
97  {
98  return true;
99  }
100  return false;
101 }
102 
103 void
104 WifiNormalAck::Print (std::ostream &os) const
105 {
106  os << "NORMAL_ACK";
107 }
108 
109 /*
110  * WifiBlockAck
111  */
112 
114  : WifiAcknowledgment (BLOCK_ACK)
115 {
116 }
117 
118 bool
120 {
121  if (ackPolicy == WifiMacHeader::NORMAL_ACK)
122  {
123  return true;
124  }
125  return false;
126 }
127 
128 void
129 WifiBlockAck::Print (std::ostream &os) const
130 {
131  os << "BLOCK_ACK";
132 }
133 
134 
135 /*
136  * WifiBarBlockAck
137  */
138 
140  : WifiAcknowledgment (BAR_BLOCK_ACK)
141 {
142 }
143 
144 bool
146 {
147  if (ackPolicy == WifiMacHeader::BLOCK_ACK)
148  {
149  return true;
150  }
151  return false;
152 }
153 
154 void
155 WifiBarBlockAck::Print (std::ostream &os) const
156 {
157  os << "BAR_BLOCK_ACK";
158 }
159 
160 
161 /*
162  * WifiDlMuBarBaSequence
163  */
164 
166  : WifiAcknowledgment (DL_MU_BAR_BA_SEQUENCE)
167 {
168 }
169 
170 bool
172  WifiMacHeader::QosAckPolicy ackPolicy) const
173 {
174  if (ackPolicy == WifiMacHeader::NORMAL_ACK)
175  {
176  // The given receiver must be the only one to send an immediate reply
177  if (stationsReplyingWithNormalAck.size () == 1
178  && stationsReplyingWithNormalAck.begin ()->first == receiver)
179  {
180  return true;
181  }
182 
183  if (stationsReplyingWithBlockAck.size () == 1
184  && stationsReplyingWithBlockAck.begin ()->first == receiver)
185  {
186  return true;
187  }
188 
189  return false;
190  }
191 
192  if (ackPolicy == WifiMacHeader::BLOCK_ACK)
193  {
194  return true;
195  }
196 
197  return false;
198 }
199 
200 void
201 WifiDlMuBarBaSequence::Print (std::ostream &os) const
202 {
203  os << "DL_MU_BAR_BA_SEQUENCE [";
204  for (const auto& sta : stationsReplyingWithNormalAck)
205  {
206  os << " (ACK) " << sta.first;
207  }
208  for (const auto& sta : stationsReplyingWithBlockAck)
209  {
210  os << " (BA) " << sta.first;
211  }
212  for (const auto& sta : stationsSendBlockAckReqTo)
213  {
214  os << " (BAR+BA) " << sta.first;
215  }
216  os << "]";
217 }
218 
219 
220 /*
221  * WifiDlMuTfMuBar
222  */
223 
225  : WifiAcknowledgment (DL_MU_TF_MU_BAR),
226  ulLength (0)
227 {
228 }
229 
230 bool
232  WifiMacHeader::QosAckPolicy ackPolicy) const
233 {
234  // the only admitted ack policy is Block Ack because stations need to wait for a MU-BAR
235  if (ackPolicy == WifiMacHeader::BLOCK_ACK)
236  {
237  return true;
238  }
239 
240  return false;
241 }
242 
243 void
244 WifiDlMuTfMuBar::Print (std::ostream &os) const
245 {
246  os << "DL_MU_TF_MU_BAR [";
247  for (const auto& sta : stationsReplyingWithBlockAck)
248  {
249  os << " (BA) " << sta.first;
250  }
251  os << "]";
252 }
253 
254 
255 /*
256  * WifiDlMuAggregateTf
257  */
258 
260  : WifiAcknowledgment (DL_MU_AGGREGATE_TF),
261  ulLength (0)
262 {
263 }
264 
265 bool
267  WifiMacHeader::QosAckPolicy ackPolicy) const
268 {
269  // the only admitted ack policy is No explicit acknowledgment or TB PPDU Ack policy
270  if (ackPolicy == WifiMacHeader::NO_EXPLICIT_ACK)
271  {
272  return true;
273  }
274 
275  return false;
276 }
277 
278 void
279 WifiDlMuAggregateTf::Print (std::ostream &os) const
280 {
281  os << "DL_MU_AGGREGATE_TF [";
282  for (const auto& sta : stationsReplyingWithBlockAck)
283  {
284  os << " (BA) " << sta.first;
285  }
286  os << "]";
287 }
288 
289 
290 std::ostream & operator << (std::ostream &os, const WifiAcknowledgment* acknowledgment)
291 {
292  acknowledgment->Print (os);
293  return os;
294 }
295 
296 } //namespace ns3
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
WifiAcknowledgment(Method m)
Constructor.
virtual void Print(std::ostream &os) const =0
Print the object contents.
Time acknowledgmentTime
time required by the acknowledgment method
WifiAcknowledgment is an abstract base struct.
void Print(std::ostream &os) const override
Print the object contents.
#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
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
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 Print(std::ostream &os) const
Print the object contents.
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 ...
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 ...
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...
void Print(std::ostream &os) const override
Print the object contents.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:218
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations receiving a BlockAckReq frame and replying with a BlockAck frame. ...
Method
Available acknowledgment methods.
void Print(std::ostream &os) const
Print the object contents.
void Print(std::ostream &os) const override
Print the object contents.
void Print(std::ostream &os) const override
Print the object contents.
void Print(std::ostream &os) const override
Print the object contents.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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 ...
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 ...
an EUI-48 address
Definition: mac48-address.h:43
QosAckPolicy
Ack policy for QoS frames.
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 ...
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 ...
bool CheckQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy) const
Check whether the given QoS Ack policy can be used for the MPDUs addressed to the given receiver and ...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
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...
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
std::map< Mac48Address, BlockAckReqInfo > stationsSendBlockAckReqTo
std::map< Mac48Address, AckInfo > stationsReplyingWithNormalAck
Set of stations replying with a BlockAck frame (no more than one)