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