wifi: Rework WifiMode callbacks

This commit is contained in:
Sébastien Deronne
2021-07-04 20:13:10 +02:00
committed by Sebastien Deronne
parent 6a83a7be6b
commit 794d02e07e
14 changed files with 129 additions and 182 deletions

View File

@@ -1034,12 +1034,10 @@ HePhy::CreateHeMcs (uint8_t index)
WIFI_MOD_CLASS_HE,
MakeBoundCallback (&GetCodeRate, index),
MakeBoundCallback (&GetConstellationSize, index),
MakeBoundCallback (&GetPhyRate, index),
MakeCallback (&GetPhyRateFromTxVector),
MakeBoundCallback (&GetDataRate, index),
MakeCallback (&GetDataRateFromTxVector),
MakeBoundCallback (&GetNonHtReferenceRate, index),
MakeCallback (&IsModeAllowed));
MakeCallback (&IsAllowed));
}
WifiCodeRate
@@ -1170,7 +1168,7 @@ HePhy::CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellatio
}
bool
HePhy::IsModeAllowed (uint16_t /* channelWidth */, uint8_t /* nss */)
HePhy::IsAllowed (const WifiTxVector& /*txVector*/)
{
return true;
}

View File

@@ -357,15 +357,13 @@ public:
*/
static uint64_t GetNonHtReferenceRate (uint8_t mcsValue);
/**
* Check whether the combination of <MCS, channel width, NSS> is allowed.
* This function is used as a callback for WifiMode operation, and always
* returns true since there is no limitation for any MCS in HePhy.
* Check whether the combination in TXVECTOR is allowed.
* This function is used as a callback for WifiMode operation.
*
* \param channelWidth the considered channel width in MHz
* \param nss the considered number of streams
* \returns true.
* \param txVector the TXVECTOR
* \returns true if this combination is allowed, false otherwise.
*/
static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss);
static bool IsAllowed (const WifiTxVector& txVector);
protected:
PhyFieldRxStatus ProcessSigA (Ptr<Event> event, PhyFieldRxStatus status) override;

View File

@@ -551,12 +551,10 @@ HtPhy::CreateHtMcs (uint8_t index)
WIFI_MOD_CLASS_HT,
MakeBoundCallback (&GetHtCodeRate, index),
MakeBoundCallback (&GetHtConstellationSize, index),
MakeBoundCallback (&GetPhyRate, index),
MakeCallback (&GetPhyRateFromTxVector),
MakeBoundCallback (&GetDataRate, index),
MakeCallback (&GetDataRateFromTxVector),
MakeBoundCallback (&GetNonHtReferenceRate, index),
MakeCallback (&IsModeAllowed));
MakeCallback (&IsAllowed));
}
WifiCodeRate
@@ -763,7 +761,7 @@ HtPhy::CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellatio
}
bool
HtPhy::IsModeAllowed (uint16_t /* channelWidth */, uint8_t /* nss */)
HtPhy::IsAllowed (const WifiTxVector& /*txVector*/)
{
return true;
}

View File

@@ -437,15 +437,13 @@ public:
*/
static uint64_t GetNonHtReferenceRate (uint8_t mcsValue);
/**
* Check whether the combination of <MCS, channel width, NSS> is allowed.
* This function is used as a callback for WifiMode operation, and always
* returns true since there is no limitation for any MCS in HtPhy.
* Check whether the combination in TXVECTOR is allowed.
* This function is used as a callback for WifiMode operation.
*
* \param channelWidth the considered channel width in MHz
* \param nss the considered number of streams
* \returns true.
* \param txVector the TXVECTOR
* \returns true if this combination is allowed, false otherwise.
*/
static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss);
static bool IsAllowed (const WifiTxVector& txVector);
protected:
PhyFieldRxStatus DoEndReceiveField (WifiPpduField field, Ptr<Event> event) override;

View File

@@ -306,11 +306,9 @@ DsssPhy::CreateDsssMode (std::string uniqueName,
true,
MakeBoundCallback (&GetCodeRate, uniqueName),
MakeBoundCallback (&GetConstellationSize, uniqueName),
MakeBoundCallback (&GetDataRate, uniqueName, modClass), //PhyRate is equivalent to DataRate
MakeCallback (&GetDataRateFromTxVector), //PhyRate is equivalent to DataRate
MakeBoundCallback (&GetDataRate, uniqueName, modClass),
MakeCallback (&GetDataRateFromTxVector),
MakeCallback (&IsModeAllowed));
MakeCallback (&IsAllowed));
}
WifiCodeRate
@@ -330,12 +328,11 @@ DsssPhy::GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staI
{
WifiMode mode = txVector.GetMode ();
return DsssPhy::GetDataRate (mode.GetUniqueName (),
mode.GetModulationClass (),
22, 0, 1); //dummy values since unused
mode.GetModulationClass ());
}
uint64_t
DsssPhy::GetDataRate (const std::string& name, WifiModulationClass modClass, uint16_t /* channelWidth */, uint16_t /* guardInterval */, uint8_t /* nss */)
DsssPhy::GetDataRate (const std::string& name, WifiModulationClass modClass)
{
uint16_t constellationSize = GetConstellationSize (name);
uint16_t divisor = 0;
@@ -357,7 +354,7 @@ DsssPhy::GetDataRate (const std::string& name, WifiModulationClass modClass, uin
}
bool
DsssPhy::IsModeAllowed (uint16_t /* channelWidth */, uint8_t /* nss */)
DsssPhy::IsAllowed (const WifiTxVector& /*txVector*/)
{
return true;
}

View File

@@ -136,23 +136,18 @@ public:
*
* \param name the unique name of the DSSS or HR/DSSS mode
* \param modClass the modulation class, must be either WIFI_MOD_CLASS_DSSS or WIFI_MOD_CLASS_HR_DSSS
* \param channelWidth the considered channel width in MHz
* \param guardInterval the considered guard interval duration in nanoseconds
* \param nss the considered number of streams
*
* \return the data bit rate of this signal in bps.
*/
static uint64_t GetDataRate (const std::string& name, WifiModulationClass modClass, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
static uint64_t GetDataRate (const std::string& name, WifiModulationClass modClass);
/**
* Check whether the combination of <WifiMode, channel width, NSS> is allowed.
* This function is used as a callback for WifiMode operation, and always
* returns true since there is no limitation for any mode in DsssPhy.
* Check whether the combination in TXVECTOR is allowed.
* This function is used as a callback for WifiMode operation.
*
* \param channelWidth the considered channel width in MHz
* \param nss the considered number of streams
* \returns true.
* \param txVector the TXVECTOR
* \returns true if this combination is allowed, false otherwise.
*/
static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss);
static bool IsAllowed (const WifiTxVector& txVector);
private:
PhyFieldRxStatus DoEndReceiveField (WifiPpduField field, Ptr<Event> event) override;

View File

@@ -176,11 +176,9 @@ ErpOfdmPhy::CreateErpOfdmMode (std::string uniqueName, bool isMandatory)
isMandatory,
MakeBoundCallback (&GetCodeRate, uniqueName),
MakeBoundCallback (&GetConstellationSize, uniqueName),
MakeBoundCallback (&GetPhyRate, uniqueName),
MakeCallback (&GetPhyRateFromTxVector),
MakeBoundCallback (&GetDataRate, uniqueName),
MakeCallback (&GetDataRateFromTxVector),
MakeCallback (&IsModeAllowed));
MakeCallback (&IsAllowed));
}
WifiCodeRate
@@ -196,11 +194,11 @@ ErpOfdmPhy::GetConstellationSize (const std::string& name)
}
uint64_t
ErpOfdmPhy::GetPhyRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
ErpOfdmPhy::GetPhyRate (const std::string& name, uint16_t channelWidth)
{
WifiCodeRate codeRate = GetCodeRate (name);
uint16_t constellationSize = GetConstellationSize (name);
uint64_t dataRate = OfdmPhy::CalculateDataRate (codeRate, constellationSize, channelWidth, guardInterval, nss);
uint64_t dataRate = OfdmPhy::CalculateDataRate (codeRate, constellationSize, channelWidth);
return OfdmPhy::CalculatePhyRate (codeRate, dataRate);
}
@@ -208,30 +206,26 @@ uint64_t
ErpOfdmPhy::GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
{
return GetPhyRate (txVector.GetMode ().GetUniqueName (),
txVector.GetChannelWidth (),
txVector.GetGuardInterval (),
txVector.GetNss ());
txVector.GetChannelWidth ());
}
uint64_t
ErpOfdmPhy::GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
{
return GetDataRate (txVector.GetMode ().GetUniqueName (),
txVector.GetChannelWidth (),
txVector.GetGuardInterval (),
txVector.GetNss ());
txVector.GetChannelWidth ());
}
uint64_t
ErpOfdmPhy::GetDataRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
ErpOfdmPhy::GetDataRate (const std::string& name, uint16_t channelWidth)
{
WifiCodeRate codeRate = GetCodeRate (name);
uint16_t constellationSize = GetConstellationSize (name);
return OfdmPhy::CalculateDataRate (codeRate, constellationSize, channelWidth, guardInterval, nss);
return OfdmPhy::CalculateDataRate (codeRate, constellationSize, channelWidth);
}
bool
ErpOfdmPhy::IsModeAllowed (uint16_t /* channelWidth */, uint8_t /* nss */)
ErpOfdmPhy::IsAllowed (const WifiTxVector& /*txVector*/)
{
return true;
}

View File

@@ -144,12 +144,10 @@ public:
*
* \param name the unique name of the ERP-OFDM mode
* \param channelWidth the considered channel width in MHz
* \param guardInterval the considered guard interval duration in nanoseconds
* \param nss the considered number of streams
*
* \return the physical bit rate of this signal in bps.
*/
static uint64_t GetPhyRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
static uint64_t GetPhyRate (const std::string& name, uint16_t channelWidth);
/**
* Return the PHY rate corresponding to
* the supplied TXVECTOR.
@@ -179,22 +177,18 @@ public:
*
* \param name the unique name of the ERP-OFDM mode
* \param channelWidth the considered channel width in MHz
* \param guardInterval the considered guard interval duration in nanoseconds
* \param nss the considered number of streams
*
* \return the data bit rate of this signal in bps.
*/
static uint64_t GetDataRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
static uint64_t GetDataRate (const std::string& name, uint16_t channelWidth);
/**
* Check whether the combination of <WifiMode, channel width, NSS> is allowed.
* This function is used as a callback for WifiMode operation, and always
* returns true since there is no limitation for any mode in ErpOfdmPhy.
* Check whether the combination in TXVECTOR is allowed.
* This function is used as a callback for WifiMode operation.
*
* \param channelWidth the considered channel width in MHz
* \param nss the considered number of streams
* \returns true.
* \param txVector the TXVECTOR
* \returns true if this combination is allowed, false otherwise.
*/
static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss);
static bool IsAllowed (const WifiTxVector& txVector);
private:
WifiMode GetHeaderMode (const WifiTxVector& txVector) const override;

View File

@@ -492,11 +492,9 @@ OfdmPhy::CreateOfdmMode (std::string uniqueName, bool isMandatory)
isMandatory,
MakeBoundCallback (&GetCodeRate, uniqueName),
MakeBoundCallback (&GetConstellationSize, uniqueName),
MakeBoundCallback (&GetPhyRate, uniqueName),
MakeCallback (&GetPhyRateFromTxVector),
MakeBoundCallback (&GetDataRate, uniqueName),
MakeCallback (&GetDataRateFromTxVector),
MakeCallback (&IsModeAllowed));
MakeCallback (&IsAllowed));
}
WifiCodeRate
@@ -512,10 +510,10 @@ OfdmPhy::GetConstellationSize (const std::string& name)
}
uint64_t
OfdmPhy::GetPhyRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
OfdmPhy::GetPhyRate (const std::string& name, uint16_t channelWidth)
{
WifiCodeRate codeRate = GetCodeRate (name);
uint64_t dataRate = GetDataRate (name, channelWidth, guardInterval, nss);
uint64_t dataRate = GetDataRate (name, channelWidth);
return CalculatePhyRate (codeRate, dataRate);
}
@@ -529,9 +527,7 @@ uint64_t
OfdmPhy::GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
{
return GetPhyRate (txVector.GetMode ().GetUniqueName (),
txVector.GetChannelWidth (),
txVector.GetGuardInterval (),
txVector.GetNss ());
txVector.GetChannelWidth ());
}
double
@@ -556,21 +552,19 @@ uint64_t
OfdmPhy::GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
{
return GetDataRate (txVector.GetMode ().GetUniqueName (),
txVector.GetChannelWidth (),
txVector.GetGuardInterval (),
txVector.GetNss ());
txVector.GetChannelWidth ());
}
uint64_t
OfdmPhy::GetDataRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
OfdmPhy::GetDataRate (const std::string& name, uint16_t channelWidth)
{
WifiCodeRate codeRate = GetCodeRate (name);
uint16_t constellationSize = GetConstellationSize (name);
return CalculateDataRate (codeRate, constellationSize, channelWidth, guardInterval, nss);
return CalculateDataRate (codeRate, constellationSize, channelWidth);
}
uint64_t
OfdmPhy::CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth, uint16_t /* guardInterval */, uint8_t /* nss */)
OfdmPhy::CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
{
double symbolDuration = 3.2; //in us
uint16_t guardInterval = 800; //in ns
@@ -599,7 +593,7 @@ OfdmPhy::CalculateDataRate (double symbolDuration, uint16_t guardInterval,
}
bool
OfdmPhy::IsModeAllowed (uint16_t /* channelWidth */, uint8_t /* nss */)
OfdmPhy::IsAllowed (const WifiTxVector& /*txVector*/)
{
return true;
}

View File

@@ -265,12 +265,10 @@ public:
*
* \param name the unique name of the OFDM mode
* \param channelWidth the considered channel width in MHz
* \param guardInterval the considered guard interval duration in nanoseconds
* \param nss the considered number of streams
*
* \return the physical bit rate of this signal in bps.
*/
static uint64_t GetPhyRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
static uint64_t GetPhyRate (const std::string& name, uint16_t channelWidth);
/**
* Return the PHY rate corresponding to
@@ -301,22 +299,18 @@ public:
*
* \param name the unique name of the OFDM mode
* \param channelWidth the considered channel width in MHz
* \param guardInterval the considered guard interval duration in nanoseconds
* \param nss the considered number of streams
*
* \return the data bit rate of this signal in bps.
*/
static uint64_t GetDataRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
static uint64_t GetDataRate (const std::string& name, uint16_t channelWidth);
/**
* Check whether the combination of <WifiMode, channel width, NSS> is allowed.
* This function is used as a callback for WifiMode operation, and always
* returns true since there is no limitation for any mode in OfdmPhy.
* Check whether the combination in TXVECTOR is allowed.
* This function is used as a callback for WifiMode operation.
*
* \param channelWidth the considered channel width in MHz
* \param nss the considered number of streams
* \returns true.
* \param txVector the TXVECTOR
* \returns true if this combination is allowed, false otherwise.
*/
static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss);
static bool IsAllowed (const WifiTxVector& txVector);
protected:
PhyFieldRxStatus DoEndReceiveField (WifiPpduField field, Ptr<Event> event) override;
@@ -399,13 +393,10 @@ protected:
* \param codeRate the code rate of the mode
* \param constellationSize the size of modulation constellation
* \param channelWidth the considered channel width in MHz
* \param guardInterval the considered guard interval duration in nanoseconds
* \param nss the considered number of streams
*
* \return the data bit rate of this signal in bps.
*/
static uint64_t CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth,
uint16_t guardInterval, uint8_t nss);
static uint64_t CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth);
/**
* Calculates data rate from the supplied parameters.
*

View File

@@ -379,12 +379,10 @@ VhtPhy::CreateVhtMcs (uint8_t index)
WIFI_MOD_CLASS_VHT,
MakeBoundCallback (&GetCodeRate, index),
MakeBoundCallback (&GetConstellationSize, index),
MakeBoundCallback (&GetPhyRate, index),
MakeCallback (&GetPhyRateFromTxVector),
MakeBoundCallback (&GetDataRate, index),
MakeCallback (&GetDataRateFromTxVector),
MakeBoundCallback (&GetNonHtReferenceRate, index),
MakeBoundCallback (&IsModeAllowed, index));
MakeCallback (&IsAllowed));
}
WifiCodeRate
@@ -445,7 +443,7 @@ VhtPhy::GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInte
{
NS_ASSERT (guardInterval == 800 || guardInterval == 400);
NS_ASSERT (nss <= 8);
NS_ASSERT_MSG (IsModeAllowed (mcsValue, channelWidth, nss), "VHT MCS " << +mcsValue << " forbidden at " << channelWidth << " MHz when NSS is " << +nss);
NS_ASSERT_MSG (IsCombinationAllowed (mcsValue, channelWidth, nss), "VHT MCS " << +mcsValue << " forbidden at " << channelWidth << " MHz when NSS is " << +nss);
return HtPhy::CalculateDataRate (3.2, guardInterval,
GetUsableSubcarriers (channelWidth),
static_cast<uint16_t> (log2 (GetConstellationSize (mcsValue))),
@@ -497,7 +495,15 @@ VhtPhy::CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellati
}
bool
VhtPhy::IsModeAllowed (uint8_t mcsValue, uint16_t channelWidth, uint8_t nss)
VhtPhy::IsAllowed (const WifiTxVector& txVector)
{
return IsCombinationAllowed (txVector.GetMode ().GetMcsValue (),
txVector.GetChannelWidth (),
txVector.GetNss ());
}
bool
VhtPhy::IsCombinationAllowed (uint8_t mcsValue, uint16_t channelWidth, uint8_t nss)
{
if (mcsValue == 9 && channelWidth == 20 && nss != 3)
{

View File

@@ -253,7 +253,15 @@ public:
* \param nss the considered number of streams
* \returns true if this <MCS, channel width, NSS> combination is allowed, false otherwise.
*/
static bool IsModeAllowed (uint8_t mcsValue, uint16_t channelWidth, uint8_t nss);
static bool IsCombinationAllowed (uint8_t mcsValue, uint16_t channelWidth, uint8_t nss);
/**
* Check whether the combination in TXVECTOR is allowed.
* This function is used as a callback for WifiMode operation.
*
* \param txVector the TXVECTOR
* \returns true if this combination is allowed, false otherwise.
*/
static bool IsAllowed (const WifiTxVector& txVector);
protected:
WifiMode GetHtSigMode (void) const override;

View File

@@ -58,9 +58,19 @@ std::istream & operator >> (std::istream &is, WifiMode &mode)
bool
WifiMode::IsAllowed (uint16_t channelWidth, uint8_t nss) const
{
WifiTxVector txVector;
txVector.SetMode (WifiMode (m_uid));
txVector.SetChannelWidth (channelWidth);
txVector.SetNss (nss);
return IsAllowed (txVector);
}
bool
WifiMode::IsAllowed (const WifiTxVector& txVector) const
{
WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid);
return item->IsModeAllowedCallback (channelWidth, nss);
return item->IsAllowedCallback (txVector);
}
uint64_t
@@ -72,15 +82,19 @@ WifiMode::GetPhyRate (uint16_t channelWidth) const
uint64_t
WifiMode::GetPhyRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
{
WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid);
return item->GetPhyRateCallback (channelWidth, guardInterval, nss);
WifiTxVector txVector;
txVector.SetMode (WifiMode (m_uid));
txVector.SetChannelWidth (channelWidth);
txVector.SetGuardInterval (guardInterval);
txVector.SetNss (nss);
return GetPhyRate (txVector);
}
uint64_t
WifiMode::GetPhyRate (const WifiTxVector& txVector, uint16_t staId) const
{
WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid);
return item->GetPhyRateFromTxVectorCallback (txVector, staId);
return item->GetPhyRateCallback (txVector, staId);
}
uint64_t
@@ -93,15 +107,19 @@ uint64_t
WifiMode::GetDataRate (const WifiTxVector& txVector, uint16_t staId) const
{
WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid);
return item->GetDataRateFromTxVectorCallback (txVector, staId);
return item->GetDataRateCallback (txVector, staId);
}
uint64_t
WifiMode::GetDataRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
{
NS_ASSERT (nss <= 8);
WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid);
return item->GetDataRateCallback (channelWidth, guardInterval, nss);
WifiTxVector txVector;
txVector.SetMode (WifiMode (m_uid));
txVector.SetChannelWidth (channelWidth);
txVector.SetGuardInterval (guardInterval);
txVector.SetNss (nss);
return GetDataRate (txVector);
}
WifiCodeRate
@@ -245,10 +263,8 @@ WifiModeFactory::CreateWifiMode (std::string uniqueName,
CodeRateCallback codeRateCallback,
ConstellationSizeCallback constellationSizeCallback,
PhyRateCallback phyRateCallback,
PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
DataRateCallback dataRateCallback,
DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
ModeAllowedCallback isModeAllowedCallback)
AllowedCallback isAllowedCallback)
{
WifiModeFactory *factory = GetFactory ();
uint32_t uid = factory->AllocateUid (uniqueName);
@@ -274,11 +290,9 @@ WifiModeFactory::CreateWifiMode (std::string uniqueName,
item->GetCodeRateCallback = codeRateCallback;
item->GetConstellationSizeCallback = constellationSizeCallback;
item->GetPhyRateCallback = phyRateCallback;
item->GetPhyRateFromTxVectorCallback = phyRateFromTxVectorCallback;
item->GetDataRateCallback = dataRateCallback;
item->GetDataRateFromTxVectorCallback = dataRateFromTxVectorCallback;
item->GetNonHtReferenceRateCallback = MakeNullCallback<uint64_t> ();
item->IsModeAllowedCallback = isModeAllowedCallback;
item->IsAllowedCallback = isAllowedCallback;
NS_ASSERT (modClass < WIFI_MOD_CLASS_HT);
//fill unused MCS item with a dummy value
@@ -294,11 +308,9 @@ WifiModeFactory::CreateWifiMcs (std::string uniqueName,
CodeRateCallback codeRateCallback,
ConstellationSizeCallback constellationSizeCallback,
PhyRateCallback phyRateCallback,
PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
DataRateCallback dataRateCallback,
DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
NonHtReferenceRateCallback nonHtReferenceRateCallback,
ModeAllowedCallback isModeAllowedCallback)
AllowedCallback isAllowedCallback)
{
WifiModeFactory *factory = GetFactory ();
uint32_t uid = factory->AllocateUid (uniqueName);
@@ -312,11 +324,9 @@ WifiModeFactory::CreateWifiMcs (std::string uniqueName,
item->GetCodeRateCallback = codeRateCallback;
item->GetConstellationSizeCallback = constellationSizeCallback;
item->GetPhyRateCallback = phyRateCallback;
item->GetPhyRateFromTxVectorCallback = phyRateFromTxVectorCallback;
item->GetDataRateCallback = dataRateCallback;
item->GetDataRateFromTxVectorCallback = dataRateFromTxVectorCallback;
item->GetNonHtReferenceRateCallback = nonHtReferenceRateCallback;
item->IsModeAllowedCallback = isModeAllowedCallback;
item->IsAllowedCallback = isAllowedCallback;
//fill unused items with dummy values
item->isMandatory = false;
@@ -399,12 +409,10 @@ WifiModeFactory::GetFactory (void)
item->mcsValue = 0;
item->GetCodeRateCallback = MakeNullCallback<WifiCodeRate> ();
item->GetConstellationSizeCallback = MakeNullCallback<uint16_t> ();
item->GetPhyRateCallback = MakeNullCallback<uint64_t, uint16_t, uint16_t, uint8_t> ();
item->GetPhyRateFromTxVectorCallback = MakeNullCallback<uint64_t, const WifiTxVector&, uint16_t> ();
item->GetDataRateCallback = MakeNullCallback<uint64_t, uint16_t, uint16_t, uint8_t> ();
item->GetDataRateFromTxVectorCallback = MakeNullCallback<uint64_t, const WifiTxVector&, uint16_t> ();
item->GetPhyRateCallback = MakeNullCallback<uint64_t, const WifiTxVector&, uint16_t> ();
item->GetDataRateCallback = MakeNullCallback<uint64_t, const WifiTxVector&, uint16_t> ();
item->GetNonHtReferenceRateCallback = MakeNullCallback<uint64_t> ();
item->IsModeAllowedCallback = MakeNullCallback<bool, uint16_t, uint8_t> ();
item->IsAllowedCallback = MakeNullCallback<bool, const WifiTxVector&> ();
isFirstTime = false;
}
return &factory;

View File

@@ -54,6 +54,12 @@ public:
* \param nss the considered number of streams
*/
bool IsAllowed (uint16_t channelWidth, uint8_t nss) const;
/**
* \returns true if this TXVECTOR combination is allowed, false otherwise.
*
* \param txVector the const WifiTxVector& of the signal
*/
bool IsAllowed (const WifiTxVector& txVector) const;
/**
*
* \param channelWidth the considered channel width in MHz
@@ -279,42 +285,22 @@ public:
typedef Callback<uint16_t> ConstellationSizeCallback;
/**
* Typedef for callback used to calculate PHY rate of a WifiMode
*
* \param channelWidth the channel width in MHz
* \param guardInterval the guard interval duration in nanoseconds
* \param nss the number of streams
* \return the physical bit rate of the signal in bps.
*/
typedef Callback<uint64_t, uint16_t /* channelWidth */, uint16_t /* guardInterval */, uint8_t /* nss */> PhyRateCallback;
/**
* Typedef for callback used to calculate PHY rate of a WifiMode
* from a TXVECTOR. This is mostly useful in HE or later amendments.
* For the others it's a simple wrapper of \see PhyRateCallback.
* from a TXVECTOR.
*
* \param txVector the TXVECTOR used for the transmission
* \param staId the station ID
* \return the physical bit rate of the signal in bps.
*/
typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> PhyRateFromTxVectorCallback;
typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> PhyRateCallback;
/**
* Typedef for callback used to calculate data rate of a WifiMode
*
* \param channelWidth the channel width in MHz
* \param guardInterval the guard interval duration in nanoseconds
* \param nss the number of streams
* \return the data rate of the signal in bps.
*/
typedef Callback<uint64_t, uint16_t /* channelWidth */, uint16_t /* guardInterval */, uint8_t /* nss */> DataRateCallback;
/**
* Typedef for callback used to calculate data rate of a WifiMode
* from a TXVECTOR. This is mostly useful in HE or later amendments.
* For the others it's a simple wrapper of \see DataRateCallback.
* from a TXVECTOR.
*
* \param txVector the TXVECTOR used for the transmission
* \param staId the station ID
* \return the data rate of the signal in bps.
*/
typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> DataRateFromTxVectorCallback;
typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> DataRateCallback;
/**
* Typedef for callback used to calculate Non-HT Reference Rate of
* an MCS defined in HT or later amendment. For Non-HT modes (DSSS, OFDM,
@@ -324,14 +310,12 @@ public:
*/
typedef Callback<uint64_t> NonHtReferenceRateCallback;
/**
* Typedef for callback used to check whether the combination of <current
* WifiMode, channel width (in MHz), number of stream> is allowed
* Typedef for callback used to check whether a given combination is allowed
*
* \param channelWidth the channel width in MHz
* \param nss the number of streams
* \return true if combination of current WifiMode and supplied parameters is allowed.
* \param txVector the TXVECTOR containing the combination to check
* \return true if combination of current WifiMode and TXVECTOR is allowed.
*/
typedef Callback<bool, uint16_t /* channelWidth */, uint8_t /* nss */> ModeAllowedCallback;
typedef Callback<bool, const WifiTxVector& /* txVector */> AllowedCallback;
/**
* \param uniqueName the name of the associated WifiMode. This name
@@ -347,15 +331,10 @@ public:
* order of the constellation used.
* \param phyRateCallback a callback function to calculate the PHY rate (in
* bps) of this WifiMode.
* \param phyRateFromTxVectorCallback a callback function to calculate the PHY rate
* (in bps) of this WifiMode using a TXVECTOR as input.
* \param dataRateCallback a callback function to calculate the data rate
* (in bps) of this WifiMode.
* \param dataRateFromTxVectorCallback a callback function to calculate the data rate
* (in bps) of this WifiMode using a TXVECTOR as input.
* \param isModeAllowedCallback a callback function to check whether a
* specific combination of this WifiMode, channel width (MHz), and
* NSS are allowed.
* \param isAllowedCallback a callback function to check whether a
* specific combination of this WifiMode is allowed.
*
* \return WifiMode
*
@@ -367,10 +346,8 @@ public:
CodeRateCallback codeRateCallback,
ConstellationSizeCallback constellationSizeCallback,
PhyRateCallback phyRateCallback,
PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
DataRateCallback dataRateCallback,
DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
ModeAllowedCallback isModeAllowedCallback);
AllowedCallback isAllowedCallback);
/**
* \param uniqueName the name of the associated WifiMode. This name
@@ -383,17 +360,12 @@ public:
* of modulation constellation of this WifiMode.
* \param phyRateCallback a callback function to calculate the PHY rate (in
* bps) of this WifiMode.
* \param phyRateFromTxVectorCallback a callback function to calculate the PHY rate
* (in bps) of this WifiMode using a TXVECTOR as input.
* \param dataRateCallback a callback function to calculate the data rate (in
* bps) of this WifiMode.
* \param dataRateFromTxVectorCallback a callback function to calculate the data rate
* (in bps) of this WifiMode using a TXVECTOR as input.
* \param nonHtReferenceRateCallback a callback function to calculate the rate
* (in bps) of the non-HT Reference Rate of this WifiMode.
* \param isModeAllowedCallback a callback function to calculate whether a
* combination of <MCS index, channel width (MHz), number of spatial
* stream> is allowed for this WifiMode.
* \param isAllowedCallback a callback function to calculate whether a given
* combination of is allowed for this WifiMode.
*
* \return WifiMode
*
@@ -405,11 +377,9 @@ public:
CodeRateCallback codeRateCallback,
ConstellationSizeCallback constellationSizeCallback,
PhyRateCallback phyRateCallback,
PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
DataRateCallback dataRateCallback,
DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
NonHtReferenceRateCallback nonHtReferenceRateCallback,
ModeAllowedCallback isModeAllowedCallback);
AllowedCallback isAllowedCallback);
private:
@@ -439,11 +409,9 @@ private:
CodeRateCallback GetCodeRateCallback; ///< Callback to retrieve code rate of this WifiModeItem
ConstellationSizeCallback GetConstellationSizeCallback; ///< Callback to retrieve constellation size of this WifiModeItem
PhyRateCallback GetPhyRateCallback; ///< Callback to calculate PHY rate in bps of this WifiModeItem
PhyRateFromTxVectorCallback GetPhyRateFromTxVectorCallback; ///< Callback to calculate PHY rate in bps of this WifiModeItem using a TXVECTOR as input
DataRateCallback GetDataRateCallback; ///< Callback to calculate data rate in bps of this WifiModeItem
DataRateFromTxVectorCallback GetDataRateFromTxVectorCallback; ///< Callback to calculate data rate in bps of this WifiModeItem using a TXVECTOR as input
NonHtReferenceRateCallback GetNonHtReferenceRateCallback; ///< Callback to calculate non-HT reference rate of this WifiModeItem
ModeAllowedCallback IsModeAllowedCallback; ///< Callback to check whether the combination of <MCS, channel width (MHz), NSS> is allowed
AllowedCallback IsAllowedCallback; ///< Callback to check whether a given combination of is allowed
};
/**