A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-tx-parameters.h
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#ifndef WIFI_TX_PARAMETERS_H
21#define WIFI_TX_PARAMETERS_H
22
23#include "wifi-mac-header.h"
24#include "wifi-tx-vector.h"
25
26#include "ns3/nstime.h"
27
28#include <map>
29#include <memory>
30#include <optional>
31#include <set>
32
33namespace ns3
34{
35
36class WifiMpdu;
37struct WifiProtection;
38struct WifiAcknowledgment;
39
40/**
41 * \ingroup wifi
42 *
43 * This class stores the TX parameters (TX vector, protection mechanism,
44 * acknowledgment mechanism, TX duration, ...) for a frame of different types
45 * (MPDU, A-MPDU, multi-TID A-MPDU, MU PPDU, ...).
46 */
48{
49 public:
51 /**
52 * Copy constructor.
53 *
54 * \param txParams the WifiTxParameters to copy
55 */
56 WifiTxParameters(const WifiTxParameters& txParams);
57
58 /**
59 * Copy assignment operator.
60 * \param txParams the TX parameters to assign to this object
61 * \return the reference to this object
62 */
64
65 /**
66 * Move constructor. Must define it manually because copy constructor is explicit.
67 * \param txParams the WifiTxParameters to copy
68 */
69 WifiTxParameters(WifiTxParameters&& txParams) = default;
70
71 /**
72 * Move assignment operator. Must define it manually because copy assignment
73 * operator is explicit.
74 * \param txParams the TX parameters to assign to this object
75 * \return the reference to this object
76 */
78
79 WifiTxVector m_txVector; //!< TXVECTOR of the frame being prepared
80 std::unique_ptr<WifiProtection> m_protection; //!< protection method
81 std::unique_ptr<WifiAcknowledgment> m_acknowledgment; //!< acknowledgment method
82 std::optional<Time> m_txDuration; //!< TX duration of the frame
83
84 /**
85 * Reset the TX parameters.
86 */
87 void Clear();
88
89 /**
90 * Record that an MPDU is being added to the current frame. If an MPDU addressed
91 * to the same receiver already exists in the frame, A-MPDU aggregation is considered.
92 * Store information needed to "undo" the addition of the MPDU by calling UndoAddMpdu().
93 *
94 * \param mpdu the MPDU being added
95 */
97
98 /**
99 * Undo the addition of the last MPDU added by calling AddMpdu().
100 */
101 void UndoAddMpdu();
102
103 /**
104 * Check if the last added MPDU is the first MPDU for the given receiver.
105 * Call this method only after adding an MPDU for the given receiver.
106 *
107 * \param receiver the MAC address of the given receiver
108 * \return whether the last added MPDU is the first MPDU for the given receiver
109 */
110 bool LastAddedIsFirstMpdu(Mac48Address receiver) const;
111
112 /**
113 * Record that an MSDU is being aggregated to the last MPDU added to the frame
114 * that hase the same receiver.
115 *
116 * \param msdu the MSDU being aggregated
117 */
119
120 /**
121 * Get the size in bytes of the frame in case the given MPDU is added.
122 *
123 * \param mpdu the given MPDU
124 * \return the size in bytes of the frame in case the given MPDU is added
125 */
127
128 /**
129 * Get the size in bytes of the frame in case the given MSDU is aggregated.
130 *
131 * \param msdu the given MSDU
132 * \return size in bytes of the frame in case the given MSDU is aggregated
133 */
135
136 /**
137 * Get the size in bytes of the (A-)MPDU addressed to the given receiver.
138 *
139 * \param receiver the MAC address of the given receiver
140 * \return the size in bytes of the (A-)MPDU addressed to the given receiver
141 */
142 uint32_t GetSize(Mac48Address receiver) const;
143
144 /// information about the frame being prepared for a specific receiver
145 struct PsduInfo
146 {
147 WifiMacHeader header; //!< MAC header of the last MPDU added
148 uint32_t amsduSize; //!< the size in bytes of the MSDU or A-MSDU
149 //!< included in the last MPDU added
150 uint32_t ampduSize; //!< the size in bytes of the A-MPDU if multiple
151 //!< MPDUs have been added, and zero otherwise
152 std::map<uint8_t, std::set<uint16_t>> seqNumbers; //!< set of the sequence numbers of the
153 //!< MPDUs added for each TID
154 };
155
156 /**
157 * Get a pointer to the information about the PSDU addressed to the given
158 * receiver, if present, and a null pointer otherwise.
159 *
160 * \param receiver the MAC address of the receiver
161 * \return a pointer to an entry in the PSDU information map or a null pointer
162 */
163 const PsduInfo* GetPsduInfo(Mac48Address receiver) const;
164
165 /// Map containing information about the PSDUs addressed to every receiver
166 typedef std::map<Mac48Address, PsduInfo> PsduInfoMap;
167
168 /**
169 * Get a const reference to the map containing information about PSDUs.
170 *
171 * \return a const reference to the map containing information about PSDUs
172 */
173 const PsduInfoMap& GetPsduInfoMap() const;
174
175 /**
176 * \brief Print the object contents.
177 * \param os output stream in which the data should be printed.
178 */
179 void Print(std::ostream& os) const;
180
181 private:
182 PsduInfoMap m_info; //!< information about the frame being prepared. Handles
183 //!< multi-TID A-MPDUs, MU PPDUs, etc.
184 PsduInfo m_undoInfo{}; //!< information needed to undo the addition of an MPDU
185 std::optional<PsduInfoMap::iterator>
186 m_lastInfoIt; //!< iterator pointing to the entry in the m_info map
187 //!< that was created/modified by the last added MPDU
188};
189
190/**
191 * \brief Stream insertion operator.
192 *
193 * \param os the output stream
194 * \param txParams the TX parameters
195 * \returns a reference to the stream
196 */
197std::ostream& operator<<(std::ostream& os, const WifiTxParameters* txParams);
198
199} // namespace ns3
200
201#endif /* WIFI_TX_PARAMETERS_H */
an EUI-48 address
Definition: mac48-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Implements the IEEE 802.11 MAC header.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
uint32_t GetSizeIfAddMpdu(Ptr< const WifiMpdu > mpdu) const
Get the size in bytes of the frame in case the given MPDU is added.
std::optional< Time > m_txDuration
TX duration of the frame.
const PsduInfoMap & GetPsduInfoMap() const
Get a const reference to the map containing information about PSDUs.
PsduInfo m_undoInfo
information needed to undo the addition of an MPDU
WifiTxParameters & operator=(WifiTxParameters &&txParams)=default
Move assignment operator.
std::unique_ptr< WifiProtection > m_protection
protection method
WifiTxParameters & operator=(const WifiTxParameters &txParams)
Copy assignment operator.
uint32_t GetSizeIfAggregateMsdu(Ptr< const WifiMpdu > msdu) const
Get the size in bytes of the frame in case the given MSDU is aggregated.
uint32_t GetSize(Mac48Address receiver) const
Get the size in bytes of the (A-)MPDU addressed to the given receiver.
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
const PsduInfo * GetPsduInfo(Mac48Address receiver) const
Get a pointer to the information about the PSDU addressed to the given receiver, if present,...
void UndoAddMpdu()
Undo the addition of the last MPDU added by calling AddMpdu().
WifiTxParameters(WifiTxParameters &&txParams)=default
Move constructor.
bool LastAddedIsFirstMpdu(Mac48Address receiver) const
Check if the last added MPDU is the first MPDU for the given receiver.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
PsduInfoMap m_info
information about the frame being prepared.
void AggregateMsdu(Ptr< const WifiMpdu > msdu)
Record that an MSDU is being aggregated to the last MPDU added to the frame that hase the same receiv...
void Print(std::ostream &os) const
Print the object contents.
void AddMpdu(Ptr< const WifiMpdu > mpdu)
Record that an MPDU is being added to the current frame.
void Clear()
Reset the TX parameters.
std::map< Mac48Address, PsduInfo > PsduInfoMap
Map containing information about the PSDUs addressed to every receiver.
std::optional< PsduInfoMap::iterator > m_lastInfoIt
iterator pointing to the entry in the m_info map that was created/modified by the last added MPDU
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
information about the frame being prepared for a specific receiver
std::map< uint8_t, std::set< uint16_t > > seqNumbers
set of the sequence numbers of the MPDUs added for each TID
uint32_t ampduSize
the size in bytes of the A-MPDU if multiple MPDUs have been added, and zero otherwise
WifiMacHeader header
MAC header of the last MPDU added.
uint32_t amsduSize
the size in bytes of the MSDU or A-MSDU included in the last MPDU added