A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
msdu-aggregator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 MIRKO BANCHI
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: Mirko Banchi <mk.banchi@gmail.com>
18 */
19
20#ifndef MSDU_AGGREGATOR_H
21#define MSDU_AGGREGATOR_H
22
23#include "qos-utils.h"
24#include "wifi-mode.h"
25#include "wifi-mpdu.h"
26
27#include "ns3/nstime.h"
28#include "ns3/object.h"
29
30#include <map>
31
32namespace ns3
33{
34
35class Packet;
36class QosTxop;
37class WifiTxVector;
38class WifiMac;
39class HtFrameExchangeManager;
40class WifiTxParameters;
41
42/**
43 * \brief Aggregator used to construct A-MSDUs
44 * \ingroup wifi
45 */
46class MsduAggregator : public Object
47{
48 public:
49 /// EDCA queues typedef
50 typedef std::map<AcIndex, Ptr<QosTxop>> EdcaQueues;
51
52 /**
53 * \brief Get the type ID.
54 * \return the object TypeId
55 */
56 static TypeId GetTypeId();
57
58 MsduAggregator() = default;
59 ~MsduAggregator() override = default;
60
61 /**
62 * Set the ID of the link this MSDU aggregator is associated with.
63 *
64 * \param linkId the ID of the link this MSDU aggregator is associated with
65 */
66 void SetLinkId(uint8_t linkId);
67
68 /**
69 * Compute the size of the A-MSDU resulting from the aggregation of an MSDU of
70 * size <i>msduSize</i> and an A-MSDU of size <i>amsduSize</i>.
71 * Note that only the basic A-MSDU subframe format (section 9.3.2.2.2 of IEEE
72 * 802.11-2016) is supported.
73 *
74 * \param msduSize the MSDU size in bytes.
75 * \param amsduSize the A-MSDU size in bytes.
76 * \return the size of the resulting A-MSDU in bytes.
77 */
78 static uint16_t GetSizeIfAggregated(uint16_t msduSize, uint16_t amsduSize);
79
80 /**
81 * Attempt to aggregate other MSDUs to the given A-MSDU while meeting the
82 * following constraints:
83 *
84 * - the A-MSDU size does not exceed the maximum A-MSDU size as determined for
85 * the modulation class indicated by the given TxVector
86 *
87 * - the size of the A-MPDU resulting from the aggregation of the MPDU in which
88 * the A-MSDU will be embedded and the current A-MPDU (as specified by the given
89 * TX parameters) does not exceed the maximum A-MPDU size as determined for
90 * the modulation class indicated by the given TxVector
91 *
92 * - the time to transmit the resulting PPDU, according to the given TxVector,
93 * does not exceed the maximum PPDU duration allowed by the corresponding
94 * modulation class (if any)
95 *
96 * - the time to transmit the resulting PPDU and to carry out protection and
97 * acknowledgment, as specified by the given TX parameters, does not exceed the
98 * given available time (if distinct from Time::Min ())
99 *
100 * If aggregation succeeds (it was possible to aggregate at least an MSDU to the
101 * given MSDU), all the aggregated MSDUs are dequeued and an MPDU containing the
102 * A-MSDU is enqueued in the queue (replacing the given MPDU) and returned.
103 * Otherwise, no MSDU is dequeued from the EDCA queue and a null pointer is returned.
104 *
105 * \param peekedItem the MSDU which we attempt to aggregate other MSDUs to
106 * \param txParams the TX parameters for the current frame
107 * \param availableTime the time available for the frame exchange
108 * \return the resulting A-MSDU, if aggregation is possible, a null pointer otherwise.
109 */
111 WifiTxParameters& txParams,
112 Time availableTime) const;
113
114 /**
115 * Determine the maximum size for an A-MSDU of the given TID that can be sent
116 * to the given receiver when using the given modulation class.
117 *
118 * \param recipient the receiver station address.
119 * \param tid the TID.
120 * \param modulation the modulation class.
121 * \return the maximum A-MSDU size in bytes.
122 */
123 uint16_t GetMaxAmsduSize(Mac48Address recipient,
124 uint8_t tid,
125 WifiModulationClass modulation) const;
126
127 /**
128 *
129 * \param aggregatedPacket the aggregated packet.
130 * \returns DeaggregatedMsdus.
131 */
132 static WifiMpdu::DeaggregatedMsdus Deaggregate(Ptr<Packet> aggregatedPacket);
133
134 /**
135 * Set the MAC layer to use.
136 *
137 * \param mac the MAC layer to use
138 */
139 void SetWifiMac(const Ptr<WifiMac> mac);
140
141 /**
142 * Calculate how much padding must be added to the end of an A-MSDU of the
143 * given size if a new MSDU is added.
144 * Each A-MSDU subframe is padded so that its length is multiple of 4 octets.
145 *
146 * \param amsduSize the size of the A-MSDU
147 *
148 * \return the number of octets required for padding
149 */
150 static uint8_t CalculatePadding(uint16_t amsduSize);
151
152 protected:
153 void DoDispose() override;
154
155 private:
156 Ptr<WifiMac> m_mac; //!< the MAC of this station
157 Ptr<HtFrameExchangeManager> m_htFem; //!< the HT Frame Exchange Manager of this station
158 uint8_t m_linkId{0}; //!< ID of the link this object is connected to
159};
160
161} // namespace ns3
162
163#endif /* MSDU_AGGREGATOR_H */
an EUI-48 address
Definition: mac48-address.h:46
Aggregator used to construct A-MSDUs.
static TypeId GetTypeId()
Get the type ID.
uint16_t GetMaxAmsduSize(Mac48Address recipient, uint8_t tid, WifiModulationClass modulation) const
Determine the maximum size for an A-MSDU of the given TID that can be sent to the given receiver when...
MsduAggregator()=default
std::map< AcIndex, Ptr< QosTxop > > EdcaQueues
EDCA queues typedef.
void DoDispose() override
Destructor implementation.
Ptr< WifiMac > m_mac
the MAC of this station
uint8_t m_linkId
ID of the link this object is connected to.
static WifiMpdu::DeaggregatedMsdus Deaggregate(Ptr< Packet > aggregatedPacket)
Ptr< HtFrameExchangeManager > m_htFem
the HT Frame Exchange Manager of this station
static uint16_t GetSizeIfAggregated(uint16_t msduSize, uint16_t amsduSize)
Compute the size of the A-MSDU resulting from the aggregation of an MSDU of size msduSize and an A-MS...
Ptr< WifiMpdu > GetNextAmsdu(Ptr< WifiMpdu > peekedItem, WifiTxParameters &txParams, Time availableTime) const
Attempt to aggregate other MSDUs to the given A-MSDU while meeting the following constraints:
void SetWifiMac(const Ptr< WifiMac > mac)
Set the MAC layer to use.
static uint8_t CalculatePadding(uint16_t amsduSize)
Calculate how much padding must be added to the end of an A-MSDU of the given size if a new MSDU is a...
~MsduAggregator() override=default
void SetLinkId(uint8_t linkId)
Set the ID of the link this MSDU aggregator is associated with.
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
std::list< std::pair< Ptr< const Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
DeaggregatedMsdus typedef.
Definition: wifi-mpdu.h:142
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.