A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
gcr-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 DERONNE SOFTWARE ENGINEERING
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#include "gcr-manager.h"
10
11#include "ap-wifi-mac.h"
12#include "wifi-mpdu.h"
13
14#include "ns3/enum.h"
15#include "ns3/log.h"
16#include "ns3/uinteger.h"
17
18#include <algorithm>
19
20namespace ns3
21{
22
23NS_LOG_COMPONENT_DEFINE("GcrManager");
24
26
27TypeId
29{
30 static TypeId tid =
31 TypeId("ns3::GcrManager")
33 .SetGroupName("Wifi")
34 .AddAttribute("RetransmissionPolicy",
35 "The retransmission policy to use for group addresses.",
37 TypeId::ATTR_CONSTRUCT, // prevent setting after construction
42 "NO_RETRY",
44 "GCR_UR",
46 "GCR_BA"))
47 .AddAttribute(
48 "GcrProtectionMode",
49 "Protection mode used for groupcast frames when needed: "
50 "Rts-Cts or Cts-To-Self",
54 "Rts-Cts",
56 "Cts-To-Self"))
57 .AddAttribute("UnsolicitedRetryLimit",
58 "The maximum number of transmission attempts of a frame delivered using "
59 "the GCR unsolicited retry retransmission policy.",
63 .AddAttribute("GcrConcealmentAddress",
64 "The GCR concealment address.",
65 Mac48AddressValue(Mac48Address("01:0F:AC:47:43:52")),
69 return tid;
70}
71
73 : m_unsolicitedRetryCounter{0}
74{
75 NS_LOG_FUNCTION(this);
76}
77
82
83void
85{
86 NS_LOG_FUNCTION(this);
87 m_apMac = nullptr;
89}
90
91void
93{
94 NS_LOG_FUNCTION(this << mac);
95 NS_ASSERT(mac);
96 m_apMac = mac;
97
98 NS_ABORT_MSG_IF(m_apMac->GetTypeOfStation() != AP || !m_apMac->GetQosSupported(),
99 "GcrManager can only be installed on QoS APs");
100}
101
107
110{
111 NS_ASSERT_MSG(header.IsQosData() && IsGroupcast(header.GetAddr1()),
112 "GCR service is only for QoS groupcast data frames");
113
114 // 11.21.16.3.4 GCR operation:
115 // A STA providing GCR service may switch between the DMS,
116 // GCR block ack, or GCR unsolicited retry retransmission policies
117
118 // This is a retry, use configured retransmission policy
119 if (header.IsRetry())
120 {
122 }
123
124 // This is not a retry but all STAs are GCR-capable, use configured retransmission policy
125 if (m_nonGcrStas.empty())
126 {
128 }
129
130 // not a retry and GCR-incapable STA(s) present, transmit using No-Ack/No-Retry
132}
133
134void
136{
137 NS_LOG_FUNCTION(this << address);
138 NS_ASSERT_MSG(address.IsGroup(), "The concealment address should be a group address");
139 m_gcrConcealmentAddress = address;
140}
141
142const Mac48Address&
147
148bool
150{
151 NS_ASSERT_MSG(header.IsQosData() && IsGroupcast(header.GetAddr1()),
152 "GCR service is only for QoS groupcast data frames");
154 "GCR service is not enabled");
155 NS_ASSERT_MSG(!m_staMembers.empty(), "GCR service should not be used");
156
157 // Only GCR capable STAs, hence concealment is always used
158 if (m_nonGcrStas.empty())
159 {
160 return true;
161 }
162 // If A-MSDU is used, that means previous transmission was already concealed
163 if (header.IsQosAmsdu())
164 {
165 return true;
166 }
167 // Otherwise, use concealment except for the first transmission (hence when it is a retry)
168 return header.IsRetry();
169}
170
171bool
173{
174 NS_LOG_FUNCTION(this << *mpdu);
175 NS_ASSERT_MSG(mpdu->GetHeader().IsQosData() && IsGroupcast(mpdu->GetHeader().GetAddr1()),
176 "GCR service is only for QoS groupcast data frames");
178 "GCR service is not enabled");
179 NS_ASSERT_MSG(!m_staMembers.empty(), "GCR service should not be used");
181 {
182 return !mpdu->GetHeader().IsRetry() && !m_nonGcrStas.empty();
183 }
184 if (!m_mpdu || !mpdu->GetHeader().IsRetry())
185 {
187 m_mpdu = mpdu;
188 NS_LOG_DEBUG("First groupcast transmission using No-Ack/No-Retry");
189 }
190 else
191 {
193 NS_LOG_DEBUG("GCR solicited retry counter increased to " << +m_unsolicitedRetryCounter);
194 }
196 {
197 NS_LOG_DEBUG("Last groupcast transmission retry done");
198 m_mpdu = nullptr;
200 return false;
201 }
202 return true;
203}
204
205void
206GcrManager::NotifyStaAssociated(const Mac48Address& staAddress, bool gcrCapable)
207{
209 {
210 // GCR is not used and we do not support run-time change of the retransmission policy
211 return;
212 }
213 NS_LOG_FUNCTION(this << staAddress << gcrCapable);
214 if (gcrCapable)
215 {
216 NS_ASSERT(m_staMembers.count(staAddress) == 0);
217 m_staMembers.insert(staAddress);
218 }
219 else
220 {
221 NS_ASSERT(m_nonGcrStas.count(staAddress) == 0);
222 m_nonGcrStas.insert(staAddress);
223 }
224}
225
226void
228{
230 {
231 // GCR is not used and we do not support run-time change of the retransmission policy
232 return;
233 }
234 NS_LOG_FUNCTION(this << staAddress);
235 m_nonGcrStas.erase(staAddress);
236 m_staMembers.erase(staAddress);
237}
238
241{
242 // TODO: we currently assume all STAs belong to all group addresses
243 // as long as group membership action frame is not implemented
244 return m_staMembers;
245}
246
247void
249 const std::set<Mac48Address>& groupAddressList)
250{
251 NS_LOG_FUNCTION(this << staAddress << groupAddressList.size());
252 // TODO: group membership is not implemented yet, current implementation assumes GCR STAs are
253 // members of all groups
254}
255
256} // namespace ns3
Hold variables of type enum.
Definition enum.h:52
Mac48Address m_gcrConcealmentAddress
GCR concealment address.
const GcrMembers & GetMemberStasForGroupAddress(const Mac48Address &groupAddress) const
Get the list of MAC addresses of member STAs for a given group address.
NonGcrStas m_nonGcrStas
the list of non-GCR capable STAs
void SetGcrConcealmentAddress(const Mac48Address &address)
Set the GCR concealment address.
void NotifyStaAssociated(const Mac48Address &staAddress, bool isGcrCapable)
This function notifies a STA is associated.
GcrMembers m_staMembers
the list of STA members (assume currently each member is part of all group)
void DoDispose() override
Destructor implementation.
Ptr< ApWifiMac > m_apMac
the MAC of the AP
static TypeId GetTypeId()
Get the type ID.
Ptr< WifiMpdu > m_mpdu
current MPDU being retransmitted
uint8_t m_unsolicitedRetryCounter
the unsolicited retry counter
void NotifyGroupMembershipChanged(const Mac48Address &staAddress, const std::set< Mac48Address > &groupAddressList)
This function adds a STA as a member of zero or more group addresses.
GroupAddressRetransmissionPolicy m_retransmissionPolicy
retransmission policy
void NotifyStaDeassociated(const Mac48Address &staAddress)
This function deletes a STA as a member of any group addresses.
std::unordered_set< Mac48Address, WifiAddressHash > GcrMembers
MAC addresses of member STAs of a GCR group.
const Mac48Address & GetGcrConcealmentAddress() const
Get the GCR concealment address.
uint8_t m_gcrUnsolicitedRetryLimit
GCR Unsolicited Retry Limit.
GroupAddressRetransmissionPolicy GetRetransmissionPolicyFor(const WifiMacHeader &header) const
Get the retransmission policy to use to transmit a given group addressed packet.
GroupcastProtectionMode m_gcrProtectionMode
Protection mode for groupcast frames.
~GcrManager() override
bool UseConcealment(const WifiMacHeader &header) const
Indicate whether a group addressed packet should be transmitted to the GCR concealment address.
bool KeepGroupcastQueued(Ptr< WifiMpdu > mpdu)
This function indicates whether a groupcast MPDU should be kept for next retransmission.
GroupAddressRetransmissionPolicy GetRetransmissionPolicy() const
Get the configured retransmission policy.
void SetWifiMac(Ptr< ApWifiMac > mac)
Set the wifi MAC.
an EUI-48 address
AttributeValue implementation for Mac48Address.
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:49
@ ATTR_GET
The attribute can be read.
Definition type-id.h:54
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
Definition type-id.h:56
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
Implements the IEEE 802.11 MAC header.
bool IsQosAmsdu() const
Check if IsQosData() is true and the A-MSDU present bit is set in the QoS control field.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
bool IsRetry() const
Return if the Retry bit is set.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
#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_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition enum.h:221
Ptr< const AttributeAccessor > MakeMac48AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeMac48AddressChecker()
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
@ AP
Definition wifi-mac.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition enum.h:179
bool IsGroupcast(const Mac48Address &adr)
Check whether a MAC destination address corresponds to a groupcast transmission.
@ CTS_TO_SELF
Definition gcr-manager.h:40
@ RTS_CTS
Definition gcr-manager.h:39
GroupAddressRetransmissionPolicy
The possible values for group address retransmission policy.
Definition gcr-manager.h:30