diff --git a/src/wifi/model/error-rate-model.cc b/src/wifi/model/error-rate-model.cc index 26164a3c0..618bc001a 100644 --- a/src/wifi/model/error-rate-model.cc +++ b/src/wifi/model/error-rate-model.cc @@ -19,7 +19,8 @@ */ #include "error-rate-model.h" -#include "ns3/wifi-tx-vector.h" +#include "dsss-error-rate-model.h" +#include "wifi-tx-vector.h" namespace ns3 { @@ -58,4 +59,30 @@ ErrorRateModel::CalculateSnr (WifiTxVector txVector, double ber) const return low; } +double +ErrorRateModel::GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const +{ + if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) + { + switch (mode.GetDataRate (22, 0, 1)) + { + case 1000000: + return DsssErrorRateModel::GetDsssDbpskSuccessRate (snr, nbits); + case 2000000: + return DsssErrorRateModel::GetDsssDqpskSuccessRate (snr, nbits); + case 5500000: + return DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (snr, nbits); + case 11000000: + return DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (snr, nbits); + default: + NS_ASSERT ("undefined DSSS/HR-DSSS datarate"); + } + } + else + { + return DoGetChunkSuccessRate (mode, txVector, snr, nbits); + } + return 0; +} + } //namespace ns3 diff --git a/src/wifi/model/error-rate-model.h b/src/wifi/model/error-rate-model.h index 444ca5377..f9f5a6d43 100644 --- a/src/wifi/model/error-rate-model.h +++ b/src/wifi/model/error-rate-model.h @@ -51,7 +51,6 @@ public: double CalculateSnr (WifiTxVector txVector, double ber) const; /** - * A pure virtual method that must be implemented in the subclass. * This method returns the probability that the given 'chunk' of the * packet will be successfully received by the PHY. * @@ -66,6 +65,9 @@ public: * to calculate the chunk error rate, and the txVector is used for * other information as needed. * + * This method handles 802.11b rates by using the DSSS error rate model. + * For all other rates, the method implemented by the subclass is called. + * * \param mode the Wi-Fi mode applicable to this chunk * \param txVector TXVECTOR of the overall transmission * \param snr the SNR of the chunk @@ -73,7 +75,21 @@ public: * * \return probability of successfully receiving the chunk */ - virtual double GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const = 0; + double GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const; + + +private: + /** + * A pure virtual method that must be implemented in the subclass. + * + * \param mode the Wi-Fi mode applicable to this chunk + * \param txVector TXVECTOR of the overall transmission + * \param snr the SNR of the chunk + * \param nbits the number of bits in this chunk + * + * \return probability of successfully receiving the chunk + */ + virtual double DoGetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const = 0; }; } //namespace ns3 diff --git a/src/wifi/model/nist-error-rate-model.cc b/src/wifi/model/nist-error-rate-model.cc index 386b014f1..a62fbf36f 100644 --- a/src/wifi/model/nist-error-rate-model.cc +++ b/src/wifi/model/nist-error-rate-model.cc @@ -21,7 +21,6 @@ #include "ns3/log.h" #include "nist-error-rate-model.h" -#include "dsss-error-rate-model.h" #include "wifi-phy.h" namespace ns3 { @@ -274,7 +273,7 @@ NistErrorRateModel::GetFec1024QamBer (double snr, uint64_t nbits, } double -NistErrorRateModel::GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const +NistErrorRateModel::DoGetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const { NS_LOG_FUNCTION (this << mode << txVector.GetMode () << snr << nbits); if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM @@ -384,22 +383,6 @@ NistErrorRateModel::GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, d } } } - else if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) - { - switch (mode.GetDataRate (20)) - { - case 1000000: - return DsssErrorRateModel::GetDsssDbpskSuccessRate (snr, nbits); - case 2000000: - return DsssErrorRateModel::GetDsssDqpskSuccessRate (snr, nbits); - case 5500000: - return DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (snr, nbits); - case 11000000: - return DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (snr, nbits); - default: - NS_ASSERT ("undefined DSSS/HR-DSSS datarate"); - } - } return 0; } diff --git a/src/wifi/model/nist-error-rate-model.h b/src/wifi/model/nist-error-rate-model.h index ae1b2066b..a2e5f12e6 100644 --- a/src/wifi/model/nist-error-rate-model.h +++ b/src/wifi/model/nist-error-rate-model.h @@ -44,10 +44,10 @@ public: NistErrorRateModel (); - double GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const; - private: + //Inherited from ErrorRateModel + double DoGetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const; /** * Return the coded BER for the given p and b. * diff --git a/src/wifi/model/yans-error-rate-model.cc b/src/wifi/model/yans-error-rate-model.cc index e194361ce..091f1f09b 100644 --- a/src/wifi/model/yans-error-rate-model.cc +++ b/src/wifi/model/yans-error-rate-model.cc @@ -21,7 +21,6 @@ #include "ns3/log.h" #include "yans-error-rate-model.h" -#include "dsss-error-rate-model.h" #include "wifi-utils.h" #include "wifi-phy.h" @@ -180,7 +179,7 @@ YansErrorRateModel::GetFecQamBer (double snr, uint64_t nbits, } double -YansErrorRateModel::GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const +YansErrorRateModel::DoGetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const { NS_LOG_FUNCTION (this << mode << txVector.GetMode () << snr << nbits); if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM @@ -352,22 +351,6 @@ YansErrorRateModel::GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, d } } } - else if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) - { - switch (mode.GetDataRate (20)) - { - case 1000000: - return DsssErrorRateModel::GetDsssDbpskSuccessRate (snr, nbits); - case 2000000: - return DsssErrorRateModel::GetDsssDqpskSuccessRate (snr, nbits); - case 5500000: - return DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (snr, nbits); - case 11000000: - return DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (snr, nbits); - default: - NS_ASSERT ("undefined DSSS/HR-DSSS datarate"); - } - } return 0; } diff --git a/src/wifi/model/yans-error-rate-model.h b/src/wifi/model/yans-error-rate-model.h index f4c2678d3..7612cb3cb 100644 --- a/src/wifi/model/yans-error-rate-model.h +++ b/src/wifi/model/yans-error-rate-model.h @@ -61,10 +61,10 @@ public: YansErrorRateModel (); - virtual double GetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const; - private: + //Inherited from ErrorRateModel + double DoGetChunkSuccessRate (WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const; /** * Return BER of BPSK with the given parameters. *