From 7ea01038c318f548bfb7485cac970e914fe8c013 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 19 Dec 2014 18:28:40 -0800 Subject: [PATCH] bug 2030: provide default values for WifiTxVector --- src/wifi/model/wifi-tx-vector.cc | 22 +++++++++++++++++++++- src/wifi/model/wifi-tx-vector.h | 25 +++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/wifi/model/wifi-tx-vector.cc b/src/wifi/model/wifi-tx-vector.cc index e62cef7bf..ff0943b7e 100644 --- a/src/wifi/model/wifi-tx-vector.cc +++ b/src/wifi/model/wifi-tx-vector.cc @@ -20,10 +20,18 @@ */ #include "ns3/wifi-tx-vector.h" +#include "ns3/fatal-error.h" namespace ns3 { WifiTxVector::WifiTxVector () + : m_retries (0), + m_shortGuardInterval (false), + m_nss (1), + m_ness (0), + m_stbc (false), + m_modeInitialized (false), + m_txPowerLevelInitialized (false) { } @@ -35,18 +43,28 @@ WifiTxVector::WifiTxVector (WifiMode mode, uint8_t powerLevel, uint8_t retries, m_shortGuardInterval(shortGuardInterval), m_nss(nss), m_ness(ness), - m_stbc(stbc) + m_stbc(stbc), + m_modeInitialized (true), + m_txPowerLevelInitialized (true) { } WifiMode WifiTxVector::GetMode (void) const { + if (!m_modeInitialized) + { + NS_FATAL_ERROR ("WifiTxVector mode must be set before using"); + } return m_mode; } uint8_t WifiTxVector::GetTxPowerLevel (void) const { + if (!m_txPowerLevelInitialized) + { + NS_FATAL_ERROR ("WifiTxVector txPowerLevel must be set before using"); + } return m_txPowerLevel; } uint8_t @@ -79,11 +97,13 @@ void WifiTxVector::SetMode (WifiMode mode) { m_mode=mode; + m_modeInitialized = true; } void WifiTxVector::SetTxPowerLevel (uint8_t powerlevel) { m_txPowerLevel=powerlevel; + m_txPowerLevelInitialized = true; } void WifiTxVector::SetRetries (uint8_t retries) diff --git a/src/wifi/model/wifi-tx-vector.h b/src/wifi/model/wifi-tx-vector.h index 910c85021..f6295787c 100644 --- a/src/wifi/model/wifi-tx-vector.h +++ b/src/wifi/model/wifi-tx-vector.h @@ -35,6 +35,20 @@ namespace ns3 { * and also 15.4.4.2 "PMD_SAP peer-to-peer service primitive * parameters". * + * If this class is constructed with the constructor that takes no + * arguments, then the client must explicitly set the mode and + * transmit power level parameters before using them. Default + * member initializers are provided for the other parameters, to + * conform to a non-MIMO/long guard configuration, although these + * may also be explicitly set after object construction. + * + * When used in a infrastructure context, WifiTxVector values should be + * drawn from WifiRemoteStationManager parameters since rate adaptation + * is responsible for picking the mode, number of streams, etc., but in + * the case in which there is no such manager (e.g. mesh), the client + * still needs to initialize at least the mode and transmit power level + * appropriately. + * * \note the above reference is valid for the DSSS PHY only (clause * 15). TXVECTOR is defined also for the other PHYs, however they * don't include the TXPWRLVL explicitly in the TXVECTOR. This is @@ -144,10 +158,13 @@ private: to PMD_TXPWRLVL.request */ uint8_t m_retries; /**< The DATA_RETRIES/RTS_RETRIES parameter for Click radiotap information */ - bool m_shortGuardInterval; //true if short GI is going to be used - uint8_t m_nss; //number of streams - uint8_t m_ness; //number of streams in beamforming - bool m_stbc; //STBC used or not + bool m_shortGuardInterval; /**< true if short GI is going to be used */ + uint8_t m_nss; /**< number of streams */ + uint8_t m_ness; /**< number of streams in beamforming */ + bool m_stbc; /**< STBC used or not */ + + bool m_modeInitialized; //*< Internal initialization flag */ + bool m_txPowerLevelInitialized; //*< Internal initialization flag */ };