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