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