OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2009 Stylianos Papanastasiou, Jens Mittag |
| 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 * Jens Mittag <jens.mittag@kit.edu> |
| 19 * Stylianos Papanastasiou <stylianos@gmail.com> |
| 20 * |
| 21 */ |
| 22 |
| 23 #ifndef PHYSIM_HELPER_H |
| 24 #define PHYSIM_HELPER_H |
| 25 |
| 26 #include "ns3/object.h" |
| 27 #include "ns3/wifi-mode.h" |
| 28 #include <itpp/itcomm.h> |
| 29 |
| 30 namespace ns3 { |
| 31 |
| 32 /** |
| 33 * \brief |
| 34 */ |
| 35 class PhySimHelper : public Object |
| 36 { |
| 37 public: |
| 38 /** |
| 39 * The different modulation types that can be used in OFDM-based IEEE 802.11 c
ommunication. |
| 40 */ |
| 41 enum ModulationType |
| 42 { |
| 43 BPSK, |
| 44 QPSK, |
| 45 QAM16, |
| 46 QAM64 |
| 47 }; |
| 48 |
| 49 static TypeId GetTypeId (void); |
| 50 |
| 51 PhySimHelper (); |
| 52 virtual ~PhySimHelper (); |
| 53 |
| 54 /** |
| 55 * Calculates the energy of the sequence of complex time samples stored within
the given block. |
| 56 * This function is typically used to compute the OFDM symbol signal strength,
e.g. for SINR |
| 57 * calculations. More precisely, it will return normalized sum S:= |x_{i}| |
| 58 * \param block The vector of complex time samples over which to calculate the
average signal strength |
| 59 * \return The normalized/average energy over the whole block of complex
time samples |
| 60 */ |
| 61 static double GetOFDMSymbolSignalStrength (const itpp::cvec block); |
| 62 /** |
| 63 * Calculates the power of complex time sample, which is actually the standard
norm on complex values. |
| 64 */ |
| 65 static double CalcPower (std::complex<double> num); |
| 66 static double DbmToW (double dbm); |
| 67 static double DbToRatio (double db); |
| 68 static double WToDbm (double w); |
| 69 static double RatioToDb (double ratio); |
| 70 static double GetPowerDbm (uint8_t power, uint8_t nTxPower, double txPowerBase
Dbm, double txPowerEndDbm); |
| 71 |
| 72 /** |
| 73 * The window function that is specified in the IEEE 802.11 standard in Sectio
n 17 |
| 74 */ |
| 75 static void WindowFunction (itpp::cvec &input); |
| 76 /** |
| 77 * Converts from an integer representation into a bit vector representation, e
.g. when converting a sequence |
| 78 * of uint8_t values into a sequence of bits (which is necessary when converti
ng the payload of a packet to |
| 79 * the IT++ bit vector format for further processing) |
| 80 * \param input The integer that shall be converted into binary format |
| 81 * \param noBits The number of bits (or the length of the resulting bit vector
) that shall be used |
| 82 * \return The bit vector that represents the integer, which the least s
ignificant bit on the left side |
| 83 */ |
| 84 static itpp::bvec DecToBin (const uint32_t input, const uint32_t noBits); |
| 85 /** |
| 86 * Calculates the parity bit for the signal header |
| 87 * \param headerPart The bit vector that represents the signal header of the p
acket |
| 88 * \return The parity bit |
| 89 */ |
| 90 static itpp::bin CalcEvenParity (const itpp::bvec& headerPart); |
| 91 /** |
| 92 * Performs a plausibility check on the decoded signal header fields, i.e. che
cks whether the parity bit |
| 93 * is correct or not. |
| 94 * \param input The decoded signal header in bit vector presentation |
| 95 * \return Result of the parity check |
| 96 */ |
| 97 static bool CheckSignalField (const itpp::bvec &input); |
| 98 /** |
| 99 * Creates the rate field that is inserted within the signal header, depending
on the to be used WiFi mode |
| 100 * \param mode The to be used WiFi mode |
| 101 * \return The rate field as a bit vector |
| 102 */ |
| 103 static itpp::bvec CreateRateField (const WifiMode mode); |
| 104 /** |
| 105 * Returns whether the given rate field corresponds to a known WiFi mode and i
f yes, stores the instance of this WiFi mode |
| 106 * object in the second parameter. |
| 107 * \param bits The bit vector that represents the rate field |
| 108 * \param mode The WifiMode object in which to save the detected WiFi mode |
| 109 * \return Result of the mode detection. True if the bits corresponded to
a known WiFi mode, false otherwise. |
| 110 */ |
| 111 static bool GetWifiMode (const itpp::bvec &bits, WifiMode &mode); |
| 112 |
| 113 /** |
| 114 * Returns the number of coded bits per OFDM symbol for the given WiFi mode |
| 115 * \param mode The WiFi mode for which the number of bits is requested |
| 116 * \return The number of coded bits per OFDM symbol |
| 117 */ |
| 118 static uint32_t GetNCBPS (const WifiMode mode); |
| 119 /** |
| 120 * Returns the number of data bits per OFDM symbol for the given WiFi mode |
| 121 * \param mode The WiFi mode for which the number of bits is requested |
| 122 * \return The number of data bits per OFDM symbol |
| 123 */ |
| 124 static uint32_t GetNDBPS (const WifiMode mode); |
| 125 /** |
| 126 * Returns the underlying ModulationType that is used by the given WiFi mode.
I.e., it should return |
| 127 * BPSK for the lowest two data rates, QPSK, for the next two higher rates, QA
M16 for the subsequent |
| 128 * two higher rates and QAM64 for the two fastest data rates. |
| 129 * Note: currently it supports only 10 and 20 MHz channels |
| 130 * \param mode The WiFi mode for which to determine the ModulationType |
| 131 * \return The detected modulation type |
| 132 */ |
| 133 static enum ModulationType GetModulationType (const WifiMode mode); |
| 134 |
| 135 // Short and long training symbols reference in IEEE notation (and their conju
gates) |
| 136 static const itpp::cvec m_refShortSymbolCompleteIEEE; |
| 137 static const itpp::cvec m_refLongSymbolCompleteIEEE; |
| 138 static const itpp::cvec m_refConjShortSymbolCompleteIEEE; |
| 139 static const itpp::cvec m_refConjLongSymbolCompleteIEEE; |
| 140 |
| 141 // Short and long training symbols reference in IT++ notation (and their conju
gates) |
| 142 static const itpp::cvec m_refShortSymbolComplete; |
| 143 static const itpp::cvec m_refLongSymbolComplete; |
| 144 static const itpp::cvec m_refConjShortSymbolComplete; |
| 145 static const itpp::cvec m_refConjLongSymbolComplete; |
| 146 |
| 147 static const itpp::Array<itpp::bvec> m_rateBits; |
| 148 |
| 149 }; |
| 150 |
| 151 } // namespace ns3 |
| 152 |
| 153 #endif /* PHYSIM_HELPER_H */ |
OLD | NEW |