wifi: Rework SIG-A and SIG-B processing functions to avoid duplicated code

This commit is contained in:
Sebastien Deronne
2022-06-22 08:33:50 +02:00
parent fe6149948e
commit c4a7058738
4 changed files with 98 additions and 90 deletions

View File

@@ -546,6 +546,23 @@ HePhy::GetStaId (const Ptr<const WifiPpdu> ppdu) const
return PhyEntity::GetStaId (ppdu);
}
PhyEntity::PhyFieldRxStatus
HePhy::ProcessSig (Ptr<Event> event, PhyFieldRxStatus status, WifiPpduField field)
{
NS_LOG_FUNCTION (this << *event << status << field);
NS_ASSERT (event->GetTxVector ().GetPreambleType () >= WIFI_PREAMBLE_HE_SU);
switch (field)
{
case WIFI_PPDU_FIELD_SIG_A:
return ProcessSigA (event, status);
case WIFI_PPDU_FIELD_SIG_B:
return ProcessSigB (event, status);
default:
NS_ASSERT_MSG (false, "Invalid PPDU field");
}
return status;
}
PhyEntity::PhyFieldRxStatus
HePhy::ProcessSigA (Ptr<Event> event, PhyFieldRxStatus status)
{
@@ -643,6 +660,7 @@ PhyEntity::PhyFieldRxStatus
HePhy::ProcessSigB (Ptr<Event> event, PhyFieldRxStatus status)
{
NS_LOG_FUNCTION (this << *event << status);
NS_ASSERT (IsDlMu (event->GetTxVector ().GetPreambleType ()));
if (status.isSuccess)
{
//Check if PPDU is filtered only if the SIG-B content is supported (not explicitly stated but assumed based on behavior for SIG-A)

View File

@@ -382,8 +382,7 @@ public:
static bool IsAllowed (const WifiTxVector& txVector);
protected:
PhyFieldRxStatus ProcessSigA (Ptr<Event> event, PhyFieldRxStatus status) override;
PhyFieldRxStatus ProcessSigB (Ptr<Event> event, PhyFieldRxStatus status) override;
PhyFieldRxStatus ProcessSig (Ptr<Event> event, PhyFieldRxStatus status, WifiPpduField field) override;
Ptr<Event> DoGetEvent (Ptr<const WifiPpdu> ppdu, RxPowerWattPerChannelBand& rxPowersW) override;
bool IsConfigSupported (Ptr<const WifiPpdu> ppdu) const override;
Time DoStartReceivePayload (Ptr<Event> event) override;
@@ -400,6 +399,26 @@ protected:
uint32_t GetMaxPsduSize (void) const override;
WifiConstPsduMap GetWifiConstPsduMap (Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) const override;
/**
* Process SIG-A, perform amendment-specific actions, and
* provide an updated status of the reception.
*
* \param event the event holding incoming PPDU's information
* \param status the status of the reception of the correctly received SIG-A after the configuration support check
* \return the updated status of the reception of the SIG-A
*/
virtual PhyFieldRxStatus ProcessSigA (Ptr<Event> event, PhyFieldRxStatus status);
/**
* Process SIG-B, perform amendment-specific actions, and
* provide an updated status of the reception.
*
* \param event the event holding incoming PPDU's information
* \param status the status of the reception of the correctly received SIG-A after the configuration support check
* \return the updated status of the reception of the SIG-B
*/
virtual PhyFieldRxStatus ProcessSigB (Ptr<Event> event, PhyFieldRxStatus status);
/**
* Start receiving the PSDU (i.e. the first symbol of the PSDU has arrived) of an UL-OFDMA transmission.
* This function is called upon the RX event corresponding to the OFDMA part of the UL MU PPDU.

View File

@@ -254,78 +254,59 @@ VhtPhy::DoEndReceiveField (WifiPpduField field, Ptr<Event> event)
switch (field)
{
case WIFI_PPDU_FIELD_SIG_A:
return EndReceiveSigA (event);
[[fallthrough]];
case WIFI_PPDU_FIELD_SIG_B:
return EndReceiveSigB (event);
return EndReceiveSig (event, field);
default:
return HtPhy::DoEndReceiveField (field, event);
}
}
PhyEntity::PhyFieldRxStatus
VhtPhy::EndReceiveSigA (Ptr<Event> event)
VhtPhy::EndReceiveSig (Ptr<Event> event, WifiPpduField field)
{
NS_LOG_FUNCTION (this << *event);
NS_LOG_FUNCTION (this << *event << field);
SnrPer snrPer = GetPhyHeaderSnrPer (field, event);
NS_LOG_DEBUG (field << ": SNR(dB)=" << RatioToDb (snrPer.snr) << ", PER=" << snrPer.per);
PhyFieldRxStatus status (GetRandomValue () > snrPer.per);
if (status.isSuccess)
{
NS_LOG_DEBUG ("Received " << field);
if (!IsAllConfigSupported (WIFI_PPDU_FIELD_SIG_A, event->GetPpdu ()))
{
status = PhyFieldRxStatus (false, UNSUPPORTED_SETTINGS, DROP);
}
status = ProcessSig (event, status, field);
}
else
{
NS_LOG_DEBUG ("Drop packet because " << field << " reception failed");
status.reason = GetFailureReason (field);
status.actionIfFailure = DROP;
}
return status;
}
WifiPhyRxfailureReason
VhtPhy::GetFailureReason (WifiPpduField field) const
{
switch (field)
{
case WIFI_PPDU_FIELD_SIG_A:
return SIG_A_FAILURE;
case WIFI_PPDU_FIELD_SIG_B:
return SIG_B_FAILURE;
default:
NS_ASSERT_MSG (false, "Unknown PPDU field");
return UNKNOWN;
}
}
PhyEntity::PhyFieldRxStatus
VhtPhy::ProcessSig (Ptr<Event> event, PhyFieldRxStatus status, WifiPpduField field)
{
NS_LOG_FUNCTION (this << *event << status << field);
NS_ASSERT (event->GetTxVector ().GetPreambleType () >= WIFI_PREAMBLE_VHT_SU);
SnrPer snrPer = GetPhyHeaderSnrPer (WIFI_PPDU_FIELD_SIG_A, event);
NS_LOG_DEBUG ("SIG-A: SNR(dB)=" << RatioToDb (snrPer.snr) << ", PER=" << snrPer.per);
PhyFieldRxStatus status (GetRandomValue () > snrPer.per);
if (status.isSuccess)
{
NS_LOG_DEBUG ("Received SIG-A");
if (!IsAllConfigSupported (WIFI_PPDU_FIELD_SIG_A, event->GetPpdu ()))
{
status = PhyFieldRxStatus (false, UNSUPPORTED_SETTINGS, DROP);
}
status = ProcessSigA (event, status);
}
else
{
NS_LOG_DEBUG ("Drop packet because SIG-A reception failed");
status.reason = SIG_A_FAILURE;
status.actionIfFailure = DROP;
}
return status;
}
PhyEntity::PhyFieldRxStatus
VhtPhy::ProcessSigA (Ptr<Event> event, PhyFieldRxStatus status)
{
NS_LOG_FUNCTION (this << *event << status);
//TODO see if something should be done here once MU-MIMO is supported
return status; //nothing special for VHT
}
PhyEntity::PhyFieldRxStatus
VhtPhy::EndReceiveSigB (Ptr<Event> event)
{
NS_LOG_FUNCTION (this << *event);
NS_ASSERT (event->GetPpdu ()->GetType () == WIFI_PPDU_TYPE_DL_MU);
SnrPer snrPer = GetPhyHeaderSnrPer (WIFI_PPDU_FIELD_SIG_B, event);
NS_LOG_DEBUG ("SIG-B: SNR(dB)=" << RatioToDb (snrPer.snr) << ", PER=" << snrPer.per);
PhyFieldRxStatus status (GetRandomValue () > snrPer.per);
if (status.isSuccess)
{
NS_LOG_DEBUG ("Received SIG-B");
if (!IsAllConfigSupported (WIFI_PPDU_FIELD_SIG_A, event->GetPpdu ()))
{
status = PhyFieldRxStatus (false, UNSUPPORTED_SETTINGS, DROP);
}
status = ProcessSigB (event, status);
}
else
{
NS_LOG_DEBUG ("Drop reception because SIG-B reception failed");
status.reason = SIG_B_FAILURE;
status.actionIfFailure = DROP;
}
return status;
}
PhyEntity::PhyFieldRxStatus
VhtPhy::ProcessSigB (Ptr<Event> event, PhyFieldRxStatus status)
{
NS_LOG_FUNCTION (this << *event << status);
//TODO see if something should be done here once MU-MIMO is supported
return status; //nothing special for VHT
}

View File

@@ -274,46 +274,36 @@ protected:
CcaIndication GetCcaIndication (const Ptr<const WifiPpdu> ppdu) override;
/**
* End receiving the SIG-A, perform VHT-specific actions, and
* End receiving the SIG-A or SIG-B, perform VHT-specific actions, and
* provide the status of the reception.
*
* Child classes can perform amendment-specific actions by specializing
* \see ProcessSigA.
* \see ProcessSig.
*
* \param event the event holding incoming PPDU's information
* \return status of the reception of the SIG-A
* \param field the current PPDU field
* \return status of the reception of the SIG-A of SIG-B
*/
PhyFieldRxStatus EndReceiveSigA (Ptr<Event> event);
/**
* End receiving the SIG-B, perform VHT-specific actions, and
* provide the status of the reception.
*
* Child classes can perform amendment-specific actions by specializing
* \see ProcessSigB.
*
* \param event the event holding incoming PPDU's information
* \return status of the reception of the SIG-B
*/
PhyFieldRxStatus EndReceiveSigB (Ptr<Event> event);
PhyFieldRxStatus EndReceiveSig (Ptr<Event> event, WifiPpduField field);
/**
* Process SIG-A, perform amendment-specific actions, and
* provide an updated status of the reception.
* Get the failure reason corresponding to the unsuccessful processing of a given PPDU field.
*
* \param event the event holding incoming PPDU's information
* \param status the status of the reception of the correctly received SIG-A after the configuration support check
* \return the updated status of the reception of the SIG-A
* \param field the PPDU field
* \return the failure reason corresponding to the unsuccessful processing of the PPDU field
*/
virtual PhyFieldRxStatus ProcessSigA (Ptr<Event> event, PhyFieldRxStatus status);
virtual WifiPhyRxfailureReason GetFailureReason (WifiPpduField field) const;
/**
* Process SIG-B, perform amendment-specific actions, and
* Process SIG-A or SIG-B, perform amendment-specific actions, and
* provide an updated status of the reception.
*
* \param event the event holding incoming PPDU's information
* \param status the status of the reception of the correctly received SIG-B after the configuration support check
* \return the updated status of the reception of the SIG-B
* \param status the status of the reception of the correctly received SIG-A or SIG-B after the configuration support check
* \param field the current PPDU field to identify whether it is SIG-A or SIG-B
* \return the updated status of the reception of the SIG-A or SIG-B
*/
virtual PhyFieldRxStatus ProcessSigB (Ptr<Event> event, PhyFieldRxStatus status);
virtual PhyFieldRxStatus ProcessSig (Ptr<Event> event, PhyFieldRxStatus status, WifiPpduField field);
/**
* Return the rate (in bps) of the non-HT Reference Rate