1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation; 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * 18 * Author: Stefano Avallone <stavallo@unina.it> 19 */ 20 21 #ifndef WIFI_TX_PARAMETERS_H 22 #define WIFI_TX_PARAMETERS_H 23 24 #include "wifi-tx-vector.h" 25 #include "wifi-mac-header.h" 26 #include "ns3/nstime.h" 27 #include <map> 28 #include <set> 29 #include <memory> 30 31 namespace ns3 { 32 33 class WifiMacQueueItem; 34 struct WifiProtection; 35 struct WifiAcknowledgment; 36 37 /** 38 * \ingroup wifi 39 * 40 * This class stores the TX parameters (TX vector, protection mechanism, 41 * acknowledgment mechanism, TX duration, ...) for a frame of different types 42 * (MPDU, A-MPDU, multi-TID A-MPDU, MU PPDU, ...). 43 */ 44 class WifiTxParameters 45 { 46 public: 47 WifiTxParameters (); 48 /** 49 * Copy constructor. 50 * 51 * \param txParams the WifiTxParameters to copy 52 */ 53 WifiTxParameters (const WifiTxParameters& txParams); 54 55 /** 56 * Copy assignment operator. 57 * \param txParams the TX parameters to assign to this object 58 * \return the reference to this object 59 */ 60 WifiTxParameters& operator= (const WifiTxParameters& txParams); 61 62 WifiTxVector m_txVector; //!< TXVECTOR of the frame being prepared 63 std::unique_ptr<WifiProtection> m_protection; //!< protection method 64 std::unique_ptr<WifiAcknowledgment> m_acknowledgment; //!< acknowledgment method 65 Time m_txDuration {Time::Min ()}; //!< TX duration of the frame 66 67 /** 68 * Reset the TX parameters. 69 */ 70 void Clear (void); 71 72 /** 73 * Record that an MPDU is being added to the current frame. If an MPDU addressed 74 * to the same receiver already exists in the frame, A-MPDU aggregation is considered. 75 * 76 * \param mpdu the MPDU being added 77 */ 78 void AddMpdu (Ptr<const WifiMacQueueItem> mpdu); 79 80 /** 81 * Record that an MSDU is being aggregated to the last MPDU added to the frame 82 * that hase the same receiver. 83 * 84 * \param msdu the MSDU being aggregated 85 */ 86 void AggregateMsdu (Ptr<const WifiMacQueueItem> msdu); 87 88 /** 89 * Get the size in bytes of the frame in case the given MPDU is added. 90 * 91 * \param mpdu the given MPDU 92 * \return the size in bytes of the frame in case the given MPDU is added 93 */ 94 uint32_t GetSizeIfAddMpdu (Ptr<const WifiMacQueueItem> mpdu) const; 95 96 /** 97 * Get the size in bytes of the frame in case the given MSDU is aggregated. 98 * 99 * \param msdu the given MSDU 100 * \return a pair (size in bytes of the current A-MSDU, size in bytes of the frame) 101 in case the given MSDU is aggregated 102 */ 103 std::pair<uint32_t, uint32_t> GetSizeIfAggregateMsdu (Ptr<const WifiMacQueueItem> msdu) const; 104 105 /** 106 * Get the size in bytes of the (A-)MPDU addressed to the given receiver. 107 * 108 * \param receiver the MAC address of the given receiver 109 * \return the size in bytes of the (A-)MPDU addressed to the given receiver 110 */ 111 uint32_t GetSize (Mac48Address receiver) const; 112 113 /// information about the frame being prepared for a specific receiver 114 struct PsduInfo 115 { 116 WifiMacHeader header; //!< MAC header of the last MPDU added 117 uint32_t amsduSize; //!< the size in bytes of the MSDU or A-MSDU 118 //!< included in the last MPDU added 119 uint32_t ampduSize; //!< the size in bytes of the A-MPDU if multiple 120 //!< MPDUs have been added, and zero otherwise 121 std::map<uint8_t, std::set<uint16_t>> seqNumbers; //!< set of the sequence numbers of the MPDUs added 122 //!< for each TID 123 }; 124 125 /** 126 * Get a pointer to the information about the PSDU addressed to the given 127 * receiver, if present, and a null pointer otherwise. 128 * 129 * \param receiver the MAC address of the receiver 130 * \return a pointer to an entry in the PSDU information map or a null pointer 131 */ 132 const PsduInfo* GetPsduInfo (Mac48Address receiver) const; 133 134 /// Map containing information about the PSDUs addressed to every receiver 135 typedef std::map<Mac48Address, PsduInfo> PsduInfoMap; 136 137 /** 138 * Get a const reference to the map containing information about PSDUs. 139 * 140 * \return a const reference to the map containing information about PSDUs 141 */ 142 const PsduInfoMap& GetPsduInfoMap (void) const; 143 144 /** 145 * \brief Print the object contents. 146 * \param os output stream in which the data should be printed. 147 */ 148 void Print (std::ostream &os) const; 149 150 private: 151 PsduInfoMap m_info; //!< information about the frame being prepared. Handles 152 //!< multi-TID A-MPDUs, MU PPDUs, etc. 153 }; 154 155 /** 156 * \brief Stream insertion operator. 157 * 158 * \param os the output stream 159 * \param txParams the TX parameters 160 * \returns a reference to the stream 161 */ 162 std::ostream& operator<< (std::ostream& os, const WifiTxParameters* txParams); 163 164 } //namespace ns3 165 166 #endif /* WIFI_TX_PARAMETERS_H */ 167