A Discrete-Event Network Simulator
API
wifi-ack-manager.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 "ns3/log.h"
22 #include "wifi-ack-manager.h"
23 #include "wifi-psdu.h"
24 #include "wifi-mac.h"
25 
26 
27 namespace ns3 {
28 
29 NS_LOG_COMPONENT_DEFINE ("WifiAckManager");
30 
31 NS_OBJECT_ENSURE_REGISTERED (WifiAckManager);
32 
33 TypeId
35 {
36  static TypeId tid = TypeId ("ns3::WifiAckManager")
37  .SetParent<Object> ()
38  .SetGroupName ("Wifi")
39  ;
40  return tid;
41 }
42 
44 {
46 }
47 
48 void
50 {
51  NS_LOG_FUNCTION (this);
52  m_mac = 0;
54 }
55 
56 void
58 {
59  NS_LOG_FUNCTION (this << mac);
60  m_mac = mac;
61 }
62 
63 void
65 {
66  NS_LOG_FUNCTION (*item << acknowledgment);
67 
68  WifiMacHeader& hdr = item->GetHeader ();
69  if (!hdr.IsQosData ())
70  {
71  return;
72  }
73  NS_ASSERT (acknowledgment != nullptr);
74 
75  hdr.SetQosAckPolicy (acknowledgment->GetQosAckPolicy (hdr.GetAddr1 (), hdr.GetQosTid ()));
76 }
77 
78 void
80 {
81  NS_LOG_FUNCTION (*psdu << acknowledgment);
82 
83  if (psdu->GetNMpdus () == 1)
84  {
85  SetQosAckPolicy (*psdu->begin (), acknowledgment);
86  return;
87  }
88 
89  NS_ASSERT (acknowledgment != nullptr);
90 
91  for (const auto& tid : psdu->GetTids ())
92  {
93  psdu->SetAckPolicyForTid (tid, acknowledgment->GetQosAckPolicy (psdu->GetAddr1 (), tid));
94  }
95 }
96 
97 } //namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:88
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< WifiMac > m_mac
MAC which is using this Acknowledgment Manager.
void DoDispose(void) override
Destructor implementation.
static void SetQosAckPolicy(Ptr< WifiMacQueueItem > item, const WifiAcknowledgment *acknowledgment)
Set the QoS Ack policy for the given MPDU, which must be a QoS data frame.
static TypeId GetTypeId(void)
Get the type ID.
void SetWifiMac(Ptr< WifiMac > mac)
Set the MAC which is using this Acknowledgment Manager.
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
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:214
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
Definition: wifi-psdu.cc:325
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:319
Mac48Address GetAddr1(void) const
Get the Receiver Address (RA), which is common to all the MPDUs.
Definition: wifi-psdu.cc:111
std::set< uint8_t > GetTids(void) const
Get the set of TIDs of the QoS Data frames included in the PSDU.
Definition: wifi-psdu.cc:166
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mac
Definition: third.py:99
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...