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 "regular-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
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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::WifiPsdu::GetAddr1
Mac48Address GetAddr1(void) const
Get the Receiver Address (RA), which is common to all the MPDUs.
Definition: wifi-psdu.cc:111
regular-wifi-mac.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiAckManager::DoDispose
void DoDispose(void) override
Destructor implementation.
Definition: wifi-ack-manager.cc:49
ns3::WifiMacHeader::GetAddr1
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
Definition: wifi-mac-header.cc:424
third.mac
mac
Definition: third.py:99
ns3::WifiMacQueueItem::GetHeader
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
Definition: wifi-mac-queue-item.cc:65
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
wifi-psdu.h
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition: wifi-mac-header.h:85
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::WifiMacHeader::SetQosAckPolicy
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
Definition: wifi-mac-header.cc:367
wifi-ack-manager.h
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::WifiAckManager::SetWifiMac
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Acknowledgment Manager.
Definition: wifi-ack-manager.cc:57
ns3::WifiPsdu::GetNMpdus
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:319
ns3::WifiMacHeader::IsQosData
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
Definition: wifi-mac-header.cc:565
ns3::WifiPsdu::GetTids
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
ns3::WifiAckManager::~WifiAckManager
virtual ~WifiAckManager()
Definition: wifi-ack-manager.cc:43
ns3::WifiPsdu::SetAckPolicyForTid
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
ns3::WifiAckManager::SetQosAckPolicy
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.
Definition: wifi-ack-manager.cc:64
ns3::WifiMacHeader::GetQosTid
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
Definition: wifi-mac-header.cc:862
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log-macros-enabled.h:209
ns3::WifiAcknowledgment
WifiAcknowledgment is an abstract base struct.
Definition: wifi-acknowledgment.h:45
ns3::WifiAckManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-ack-manager.cc:34
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::WifiAckManager::m_mac
Ptr< RegularWifiMac > m_mac
MAC which is using this Acknowledgment Manager.
Definition: wifi-ack-manager.h:104
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::WifiPsdu::begin
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
Definition: wifi-psdu.cc:325
ns3::Object::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346