A Discrete-Event Network Simulator
API
wifi-ack-manager.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Stefano Avallone <stavallo@unina.it>
18  */
19 
20 #include "wifi-ack-manager.h"
21 
22 #include "wifi-mac.h"
23 #include "wifi-psdu.h"
24 
25 #include "ns3/log.h"
26 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE("WifiAckManager");
31 
32 NS_OBJECT_ENSURE_REGISTERED(WifiAckManager);
33 
34 TypeId
36 {
37  static TypeId tid = TypeId("ns3::WifiAckManager").SetParent<Object>().SetGroupName("Wifi");
38  return tid;
39 }
40 
42  : m_linkId(0)
43 {
44  NS_LOG_FUNCTION(this);
45 }
46 
48 {
50 }
51 
52 void
54 {
55  NS_LOG_FUNCTION(this);
56  m_mac = nullptr;
58 }
59 
60 void
62 {
63  NS_LOG_FUNCTION(this << mac);
64  m_mac = mac;
65 }
66 
69 {
71 }
72 
73 void
75 {
76  NS_LOG_FUNCTION(this << +linkId);
77  m_linkId = linkId;
78 }
79 
80 void
82 {
83  NS_LOG_FUNCTION(*item << acknowledgment);
84 
85  WifiMacHeader& hdr = item->GetHeader();
86  if (!hdr.IsQosData())
87  {
88  return;
89  }
90  NS_ASSERT(acknowledgment);
91 
92  hdr.SetQosAckPolicy(acknowledgment->GetQosAckPolicy(hdr.GetAddr1(), hdr.GetQosTid()));
93 }
94 
95 void
97 {
98  NS_LOG_FUNCTION(*psdu << acknowledgment);
99 
100  if (psdu->GetNMpdus() == 1)
101  {
102  SetQosAckPolicy(*psdu->begin(), acknowledgment);
103  return;
104  }
105 
106  NS_ASSERT(acknowledgment);
107 
108  for (const auto& tid : psdu->GetTids())
109  {
110  psdu->SetAckPolicyForTid(tid, acknowledgment->GetQosAckPolicy(psdu->GetAddr1(), tid));
111  }
112 }
113 
114 } // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:89
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:352
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
uint8_t m_linkId
ID of the link this Acknowledgment Manager is operating on.
static void SetQosAckPolicy(Ptr< WifiMpdu > item, const WifiAcknowledgment *acknowledgment)
Set the QoS Ack policy for the given MPDU, which must be a QoS data frame.
Ptr< WifiMac > m_mac
MAC which is using this Acknowledgment Manager.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager() const
void DoDispose() override
Destructor implementation.
void SetLinkId(uint8_t linkId)
Set the ID of the link this Acknowledgment Manager is associated with.
void SetWifiMac(Ptr< WifiMac > mac)
Set the MAC which is using this Acknowledgment Manager.
static TypeId GetTypeId()
Get the type ID.
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
Definition: wifi-mac.cc:906
std::set< uint8_t > GetTids() const
Get the set of TIDs of the QoS Data frames included in the PSDU.
Definition: wifi-psdu.cc:178
void SetAckPolicyForTid(uint8_t tid, WifiMacHeader::QosAckPolicy policy)
Set the QoS Ack Policy of the QoS Data frames included in the PSDU that have the given TID to the giv...
Definition: wifi-psdu.cc:226
std::vector< Ptr< WifiMpdu > >::const_iterator begin() const
Return a const iterator to the first MPDU.
Definition: wifi-psdu.cc:333
Mac48Address GetAddr1() const
Get the Receiver Address (RA), which is common to all the MPDUs.
Definition: wifi-psdu.cc:113
std::size_t GetNMpdus() const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:327
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#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:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mac
Definition: third.py:92
WifiAcknowledgment is an abstract base struct.
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...