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
27namespace ns3 {
28
29NS_LOG_COMPONENT_DEFINE ("WifiAckManager");
30
31NS_OBJECT_ENSURE_REGISTERED (WifiAckManager);
32
33TypeId
35{
36 static TypeId tid = TypeId ("ns3::WifiAckManager")
37 .SetParent<Object> ()
38 .SetGroupName ("Wifi")
39 ;
40 return tid;
41}
42
44 : m_linkId (0)
45{
46 NS_LOG_FUNCTION (this);
47}
48
50{
52}
53
54void
56{
57 NS_LOG_FUNCTION (this);
58 m_mac = 0;
60}
61
62void
64{
65 NS_LOG_FUNCTION (this << mac);
66 m_mac = mac;
67}
68
69void
71{
72 NS_LOG_FUNCTION (this << +linkId);
73 m_linkId = linkId;
74}
75
76void
78{
79 NS_LOG_FUNCTION (*item << acknowledgment);
80
81 WifiMacHeader& hdr = item->GetHeader ();
82 if (!hdr.IsQosData ())
83 {
84 return;
85 }
86 NS_ASSERT (acknowledgment != nullptr);
87
88 hdr.SetQosAckPolicy (acknowledgment->GetQosAckPolicy (hdr.GetAddr1 (), hdr.GetQosTid ()));
89}
90
91void
93{
94 NS_LOG_FUNCTION (*psdu << acknowledgment);
95
96 if (psdu->GetNMpdus () == 1)
97 {
98 SetQosAckPolicy (*psdu->begin (), acknowledgment);
99 return;
100 }
101
102 NS_ASSERT (acknowledgment != nullptr);
103
104 for (const auto& tid : psdu->GetTids ())
105 {
106 psdu->SetAckPolicyForTid (tid, acknowledgment->GetQosAckPolicy (psdu->GetAddr1 (), tid));
107 }
108}
109
110} //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
uint8_t m_linkId
ID of the link this Acknowledgment Manager is operating on.
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 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.
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:87
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...