wifi: Move DSSS and HR-DSSS rates handling in ErrorRateModel base class

This commit is contained in:
Sébastien Deronne
2020-10-11 19:40:54 +02:00
committed by Sebastien Deronne
parent da2d775744
commit 6ca8731d82
6 changed files with 52 additions and 43 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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.
*

View File

@@ -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;
}

View File

@@ -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.
*