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