1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2020 Orange Labs 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 * Authors: Rediet <getachew.redieteab@orange.com> 19 * Sébastien Deronne <sebastien.deronne@gmail.com> (for logic ported from wifi-phy) 20 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr> (for logic ported from wifi-phy) 21 */ 22 23 #ifndef ERP_OFDM_PHY_H 24 #define ERP_OFDM_PHY_H 25 26 #include "ofdm-phy.h" 27 28 /** 29 * \file 30 * \ingroup wifi 31 * Declaration of ns3::ErpOfdmPhy class. 32 */ 33 34 namespace ns3 { 35 36 /** 37 * \brief PHY entity for ERP-OFDM (11g) 38 * \ingroup wifi 39 * 40 * ERP-OFDM PHY is based on OFDM PHY. 41 * ERP-DSSS/CCK mode is not supported. 42 * 43 * Refer to IEEE 802.11-2016, clause 18. 44 */ 45 class ErpOfdmPhy : public OfdmPhy 46 { 47 public: 48 /** 49 * Constructor for ERP-OFDM PHY 50 */ 51 ErpOfdmPhy (); 52 /** 53 * Destructor for ERP-OFDM PHY 54 */ 55 virtual ~ErpOfdmPhy (); 56 57 Ptr<WifiPpdu> BuildPpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time ppduDuration) override; 58 uint32_t GetMaxPsduSize (void) const override; 59 60 /** 61 * Initialize all ERP-OFDM modes. 62 */ 63 static void InitializeModes (void); 64 /** 65 * Return a WifiMode for ERP-OFDM 66 * corresponding to the provided rate. 67 * 68 * \param rate the rate in bps 69 * \return a WifiMode for ERP-OFDM 70 */ 71 static WifiMode GetErpOfdmRate (uint64_t rate); 72 73 /** 74 * Return a WifiMode for ERP-OFDM at 6 Mbps. 75 * 76 * \return a WifiMode for ERP-OFDM at 6 Mbps 77 */ 78 static WifiMode GetErpOfdmRate6Mbps (void); 79 /** 80 * Return a WifiMode for ERP-OFDM at 9 Mbps. 81 * 82 * \return a WifiMode for ERP-OFDM at 9 Mbps 83 */ 84 static WifiMode GetErpOfdmRate9Mbps (void); 85 /** 86 * Return a WifiMode for ERP-OFDM at 12 Mbps. 87 * 88 * \return a WifiMode for ERP-OFDM at 12 Mbps 89 */ 90 static WifiMode GetErpOfdmRate12Mbps (void); 91 /** 92 * Return a WifiMode for ERP-OFDM at 18 Mbps. 93 * 94 * \return a WifiMode for ERP-OFDM at 18 Mbps 95 */ 96 static WifiMode GetErpOfdmRate18Mbps (void); 97 /** 98 * Return a WifiMode for ERP-OFDM at 24 Mbps. 99 * 100 * \return a WifiMode for ERP-OFDM at 24 Mbps 101 */ 102 static WifiMode GetErpOfdmRate24Mbps (void); 103 /** 104 * Return a WifiMode for ERP-OFDM at 36 Mbps. 105 * 106 * \return a WifiMode for ERP-OFDM at 36 Mbps 107 */ 108 static WifiMode GetErpOfdmRate36Mbps (void); 109 /** 110 * Return a WifiMode for ERP-OFDM at 48 Mbps. 111 * 112 * \return a WifiMode for ERP-OFDM at 48 Mbps 113 */ 114 static WifiMode GetErpOfdmRate48Mbps (void); 115 /** 116 * Return a WifiMode for ERP-OFDM at 54 Mbps. 117 * 118 * \return a WifiMode for ERP-OFDM at 54 Mbps 119 */ 120 static WifiMode GetErpOfdmRate54Mbps (void); 121 122 /** 123 * Return the WifiCodeRate from the ERP-OFDM mode's unique name using 124 * ModulationLookupTable. This is mainly used as a callback for 125 * WifiMode operation. 126 * 127 * \param name the unique name of the ERP-OFDM mode 128 * \return WifiCodeRate corresponding to the unique name 129 */ 130 static WifiCodeRate GetCodeRate (const std::string& name); 131 /** 132 * Return the constellation size from the ERP-OFDM mode's unique name using 133 * ModulationLookupTable. This is mainly used as a callback for 134 * WifiMode operation. 135 * 136 * \param name the unique name of the ERP-OFDM mode 137 * \return constellation size corresponding to the unique name 138 */ 139 static uint16_t GetConstellationSize (const std::string& name); 140 /** 141 * Return the PHY rate from the ERP-OFDM mode's unique name and 142 * the supplied parameters. This function calls OfdmPhy::CalculatePhyRate 143 * and is mainly used as a callback for WifiMode operation. 144 * 145 * \param name the unique name of the ERP-OFDM mode 146 * \param channelWidth the considered channel width in MHz 147 * \param guardInterval the considered guard interval duration in nanoseconds 148 * \param nss the considered number of streams 149 * 150 * \return the physical bit rate of this signal in bps. 151 */ 152 static uint64_t GetPhyRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss); 153 /** 154 * Return the PHY rate corresponding to 155 * the supplied TXVECTOR. 156 * This function is mainly used as a callback 157 * for WifiMode operation. 158 * 159 * \param txVector the TXVECTOR used for the transmission 160 * \param staId the station ID (only here to have a common signature for all callbacks) 161 * \return the physical bit rate of this signal in bps. 162 */ 163 static uint64_t GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t staId); 164 /** 165 * Return the data rate corresponding to 166 * the supplied TXVECTOR. 167 * This function is mainly used as a callback 168 * for WifiMode operation. 169 * 170 * \param txVector the TXVECTOR used for the transmission 171 * \param staId the station ID (only here to have a common signature for all callbacks) 172 * \return the data bit rate in bps. 173 */ 174 static uint64_t GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t staId); 175 /** 176 * Return the data rate from the ERP-OFDM mode's unique name and 177 * the supplied parameters. This function calls OfdmPhy::CalculateDataRate 178 * and is mainly used as a callback for WifiMode operation. 179 * 180 * \param name the unique name of the ERP-OFDM mode 181 * \param channelWidth the considered channel width in MHz 182 * \param guardInterval the considered guard interval duration in nanoseconds 183 * \param nss the considered number of streams 184 * 185 * \return the data bit rate of this signal in bps. 186 */ 187 static uint64_t GetDataRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss); 188 /** 189 * Check whether the combination of <WifiMode, channel width, NSS> is allowed. 190 * This function is used as a callback for WifiMode operation, and always 191 * returns true since there is no limitation for any mode in ErpOfdmPhy. 192 * 193 * \param channelWidth the considered channel width in MHz 194 * \param nss the considered number of streams 195 * \returns true. 196 */ 197 static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss); 198 199 private: 200 WifiMode GetHeaderMode (const WifiTxVector& txVector) const override; 201 Time GetPreambleDuration (const WifiTxVector& txVector) const override; 202 Time GetHeaderDuration (const WifiTxVector& txVector) const override; 203 204 /** 205 * Create an ERP-OFDM mode from a unique name, the unique name 206 * must already be contained inside ModulationLookupTable. 207 * This method binds all the callbacks used by WifiMode. 208 * 209 * \param uniqueName the unique name of the WifiMode 210 * \param isMandatory whether the WifiMode is mandatory 211 * \return the ERP-OFDM WifiMode 212 */ 213 static WifiMode CreateErpOfdmMode (std::string uniqueName, bool isMandatory); 214 215 static const ModulationLookupTable m_erpOfdmModulationLookupTable; //!< lookup table to retrieve code rate and constellation size corresponding to a unique name of modulation 216 }; //class ErpOfdmPhy 217 218 } //namespace ns3 219 220 #endif /* ERP_OFDM_PHY_H */ 221