A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mpdu-aggregator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013
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: Ghada Badawy <gbadawy@gmail.com>
18 */
19
20#ifndef MPDU_AGGREGATOR_H
21#define MPDU_AGGREGATOR_H
22
23#include "qos-utils.h"
24#include "wifi-mode.h"
25
26#include "ns3/nstime.h"
27#include "ns3/object.h"
28
29#include <vector>
30
31namespace ns3
32{
33
34class AmpduSubframeHeader;
35class WifiTxVector;
36class QosTxop;
37class Packet;
38class WifiMac;
39class WifiMpdu;
40class WifiTxParameters;
41class HtFrameExchangeManager;
42
43/**
44 * \brief Aggregator used to construct A-MPDUs
45 * \ingroup wifi
46 */
47class MpduAggregator : public Object
48{
49 public:
50 /**
51 * EDCA queues typedef
52 */
53 typedef std::map<AcIndex, Ptr<QosTxop>> EdcaQueues;
54
55 /**
56 * \brief Get the type ID.
57 * \return the object TypeId
58 */
59 static TypeId GetTypeId();
60
61 MpduAggregator() = default;
62 ~MpduAggregator() override = default;
63
64 /**
65 * Aggregate an MPDU to an A-MPDU.
66 *
67 * \param mpdu the MPDU.
68 * \param ampdu the A-MPDU.
69 * \param isSingle whether it is a single MPDU.
70 */
71 static void Aggregate(Ptr<const WifiMpdu> mpdu, Ptr<Packet> ampdu, bool isSingle);
72
73 /**
74 * Set the ID of the link this MPDU aggregator is associated with.
75 *
76 * \param linkId the ID of the link this MPDU aggregator is associated with
77 */
78 void SetLinkId(uint8_t linkId);
79
80 /**
81 * Compute the size of the A-MPDU resulting from the aggregation of an MPDU of
82 * size <i>mpduSize</i> and an A-MPDU of size <i>ampduSize</i>.
83 *
84 * \param mpduSize the MPDU size in bytes.
85 * \param ampduSize the A-MPDU size in bytes.
86 * \return the size of the resulting A-MPDU in bytes.
87 */
88 static uint32_t GetSizeIfAggregated(uint32_t mpduSize, uint32_t ampduSize);
89
90 /**
91 * Determine the maximum size for an A-MPDU of the given TID that can be sent
92 * to the given receiver when using the given modulation class.
93 *
94 * \param recipient the receiver station address.
95 * \param tid the TID.
96 * \param modulation the modulation class.
97 * \return the maximum A-MPDU size in bytes.
98 */
100 uint8_t tid,
101 WifiModulationClass modulation) const;
102
103 /**
104 * Attempt to aggregate other MPDUs to the given MPDU, while meeting the
105 * following constraints:
106 *
107 * - the size of the resulting A-MPDU does not exceed the maximum A-MPDU size
108 * as determined for the modulation class indicated by the given TxVector
109 *
110 * - the time to transmit the resulting PPDU, according to the given TxVector,
111 * does not exceed the maximum PPDU duration allowed by the corresponding
112 * modulation class (if any)
113 *
114 * - the time to transmit the resulting PPDU and to carry out protection and
115 * acknowledgment, as specified by the given TX parameters, does not exceed the
116 * given available time (if distinct from Time::Min ())
117 *
118 * For now, only non-broadcast QoS Data frames can be aggregated (do not pass
119 * other types of frames to this method). MPDUs to aggregate are looked for
120 * among those with the same TID and receiver as the given MPDU.
121 *
122 * The resulting A-MPDU is returned as a vector of the constituent MPDUs
123 * (including the given MPDU), which are not actually aggregated (call the
124 * Aggregate method afterwards to get the actual A-MPDU). If aggregation was
125 * not possible (aggregation is disabled, there is no Block Ack agreement
126 * established with the receiver, or another MPDU to aggregate was not found),
127 * the returned vector is empty.
128 *
129 * \param mpdu the given MPDU.
130 * \param txParams the TX parameters used to transmit the frame
131 * \param availableTime the time available for the frame exchange
132 * \return the resulting A-MPDU, if aggregation is possible.
133 */
134 std::vector<Ptr<WifiMpdu>> GetNextAmpdu(Ptr<WifiMpdu> mpdu,
135 WifiTxParameters& txParams,
136 Time availableTime) const;
137
138 /**
139 * Set the MAC layer to use.
140 *
141 * \param mac the MAC layer to use
142 */
143 void SetWifiMac(const Ptr<WifiMac> mac);
144
145 /**
146 * \param ampduSize the size of the A-MPDU that needs to be padded in bytes
147 * \return the size of the padding that must be added to the end of an A-MPDU in bytes
148 *
149 * Calculates how much padding must be added to the end of an A-MPDU of the given size
150 * (once another MPDU is aggregated).
151 * Each A-MPDU subframe is padded so that its length is multiple of 4 octets.
152 */
153 static uint8_t CalculatePadding(uint32_t ampduSize);
154
155 /**
156 * Get the A-MPDU subframe header corresponding to the MPDU size and
157 * whether the MPDU is a single MPDU.
158 *
159 * \param mpduSize size of the MPDU in bytes.
160 * \param isSingle true if S-MPDU.
161 * \return the A-MPDU subframe header
162 */
163 static AmpduSubframeHeader GetAmpduSubframeHeader(uint16_t mpduSize, bool isSingle);
164
165 protected:
166 void DoDispose() override;
167
168 private:
169 Ptr<WifiMac> m_mac; //!< the MAC of this station
170 Ptr<HtFrameExchangeManager> m_htFem; //!< the HT Frame Exchange Manager of this station
171 uint8_t m_linkId{0}; //!< ID of the link this object is connected to
172};
173
174} // namespace ns3
175
176#endif /* MPDU_AGGREGATOR_H */
Headers for A-MPDU subframes.
an EUI-48 address
Definition: mac48-address.h:46
Aggregator used to construct A-MPDUs.
static uint8_t CalculatePadding(uint32_t ampduSize)
~MpduAggregator() override=default
MpduAggregator()=default
void DoDispose() override
Destructor implementation.
static void Aggregate(Ptr< const WifiMpdu > mpdu, Ptr< Packet > ampdu, bool isSingle)
Aggregate an MPDU to an A-MPDU.
Ptr< WifiMac > m_mac
the MAC of this station
Ptr< HtFrameExchangeManager > m_htFem
the HT Frame Exchange Manager of this station
std::map< AcIndex, Ptr< QosTxop > > EdcaQueues
EDCA queues typedef.
uint32_t GetMaxAmpduSize(Mac48Address recipient, uint8_t tid, WifiModulationClass modulation) const
Determine the maximum size for an A-MPDU of the given TID that can be sent to the given receiver when...
static AmpduSubframeHeader GetAmpduSubframeHeader(uint16_t mpduSize, bool isSingle)
Get the A-MPDU subframe header corresponding to the MPDU size and whether the MPDU is a single MPDU.
static TypeId GetTypeId()
Get the type ID.
void SetWifiMac(const Ptr< WifiMac > mac)
Set the MAC layer to use.
static uint32_t GetSizeIfAggregated(uint32_t mpduSize, uint32_t ampduSize)
Compute the size of the A-MPDU resulting from the aggregation of an MPDU of size mpduSize and an A-MP...
std::vector< Ptr< WifiMpdu > > GetNextAmpdu(Ptr< WifiMpdu > mpdu, WifiTxParameters &txParams, Time availableTime) const
Attempt to aggregate other MPDUs to the given MPDU, while meeting the following constraints:
void SetLinkId(uint8_t linkId)
Set the ID of the link this MPDU aggregator is associated with.
uint8_t m_linkId
ID of the link this object is connected to.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
Every class exported by the ns3 library is enclosed in the ns3 namespace.