Skip to content

Commit

Permalink
wifi: Prepare some functions to receive multiple center frequencies t…
Browse files Browse the repository at this point in the history
…o generate a PSD
  • Loading branch information
sderonne committed Jun 29, 2024
1 parent c03e501 commit 75b4976
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 50 deletions.
39 changes: 24 additions & 15 deletions src/wifi/model/he/he-phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1324,9 +1324,18 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW,
HePpdu::TxPsdFlag flag) const
{
const auto& txVector = ppdu->GetTxVector();
uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector);
const auto& centerFrequencies = ppdu->GetTxCenterFreqs();
auto channelWidth = txVector.GetChannelWidth();
NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW << txVector);
auto printFrequencies = [](const std::vector<uint16_t>& v) {
std::stringstream ss;
for (const auto& centerFrequency : v)
{
ss << centerFrequency << " ";
}
return ss.str();
};
NS_LOG_FUNCTION(this << printFrequencies(centerFrequencies) << channelWidth << txPowerW
<< txVector);
const auto& puncturedSubchannels = txVector.GetInactiveSubchannels();
if (!puncturedSubchannels.empty())
{
Expand All @@ -1345,11 +1354,10 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW,
{
// non-HE portion is sent only on the 20 MHz channels covering the RU
const uint16_t staId = GetStaId(ppdu);
centerFrequency = GetCenterFrequencyForNonHePart(txVector, staId);
const auto ruWidth = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType());
channelWidth = (ruWidth < 20) ? 20 : ruWidth;
return WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity(
centerFrequency,
GetCenterFrequenciesForNonHePart(ppdu, staId).front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand All @@ -1362,7 +1370,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW,
{
const auto band = GetRuBandForTx(txVector, GetStaId(ppdu)).indices;
return WifiSpectrumValueHelper::CreateHeMuOfdmTxPowerSpectralDensity(
centerFrequency,
centerFrequencies.front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand All @@ -1373,7 +1381,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW,
if (flag == HePpdu::PSD_NON_HE_PORTION)
{
return WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity(
centerFrequency,
centerFrequencies.front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand All @@ -1385,7 +1393,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW,
else
{
return WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
centerFrequency,
centerFrequencies.front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand All @@ -1399,7 +1407,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW,
default: {
NS_ASSERT(puncturedSubchannels.empty());
return WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
centerFrequency,
centerFrequencies.front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand All @@ -1410,12 +1418,13 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW,
}
}

uint16_t
HePhy::GetCenterFrequencyForNonHePart(const WifiTxVector& txVector, uint16_t staId) const
std::vector<uint16_t>
HePhy::GetCenterFrequenciesForNonHePart(Ptr<const WifiPpdu> ppdu, uint16_t staId) const
{
NS_LOG_FUNCTION(this << txVector << staId);
NS_LOG_FUNCTION(this << ppdu << staId);
const auto& txVector = ppdu->GetTxVector();
NS_ASSERT(txVector.IsUlMu() && (txVector.GetModulationClass() >= WIFI_MOD_CLASS_HE));
uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector);
auto centerFrequencies = ppdu->GetTxCenterFreqs();
const auto currentWidth = txVector.GetChannelWidth();

HeRu::RuSpec ru = txVector.GetRu(staId);
Expand All @@ -1426,16 +1435,16 @@ HePhy::GetCenterFrequencyForNonHePart(const WifiTxVector& txVector, uint16_t sta
HeRu::RuSpec nonOfdmaRu =
HeRu::FindOverlappingRu(currentWidth, ru, HeRu::GetRuType(nonOfdmaWidth));

uint16_t startingFrequency = centerFrequency - (currentWidth / 2);
centerFrequency =
uint16_t startingFrequency = centerFrequencies.front() - (currentWidth / 2);
centerFrequencies.front() =
startingFrequency +
nonOfdmaWidth * (nonOfdmaRu.GetPhyIndex(
currentWidth,
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)) -
1) +
nonOfdmaWidth / 2;
}
return centerFrequency;
return centerFrequencies;
}

void
Expand Down
10 changes: 5 additions & 5 deletions src/wifi/model/he/he-phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ class HePhy : public VhtPhy
void SetTrigVector(const WifiTxVector& trigVector, Time validity);

/**
* Get the center frequency of the non-HE portion of the current TxVector for the
* given STA-ID.
* Note this method is only to be used for UL MU.
* Get the center frequency per segment of the non-HE portion of the current PPDU for the given
* STA-ID. Note this method is only to be used for UL MU.
*
* \param txVector the TXVECTOR that has the RU allocation
* \param ppdu the PPDU
* \param staId the STA-ID of the station taking part of the UL MU
* \return the center frequency in MHz corresponding to the non-HE portion of the HE TB PPDU
*/
uint16_t GetCenterFrequencyForNonHePart(const WifiTxVector& txVector, uint16_t staId) const;
std::vector<uint16_t> GetCenterFrequenciesForNonHePart(const Ptr<const WifiPpdu> ppdu,
uint16_t staId) const;

/**
* Sets the OBSS-PD algorithm.
Expand Down
7 changes: 4 additions & 3 deletions src/wifi/model/ht/ht-phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,14 @@ HtPhy::IsConfigSupported(Ptr<const WifiPpdu> ppdu) const
Ptr<SpectrumValue>
HtPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr<const WifiPpdu> ppdu) const
{
const auto& centerFrequencies = ppdu->GetTxCenterFreqs();
NS_ASSERT(centerFrequencies.size() == 1);
const auto& txVector = ppdu->GetTxVector();
uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector);
const auto channelWidth = txVector.GetChannelWidth();
NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW);
NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPowerW);
const auto& txMaskRejectionParams = GetTxMaskRejectionParams();
Ptr<SpectrumValue> v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity(
centerFrequency,
centerFrequencies.front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand Down
7 changes: 4 additions & 3 deletions src/wifi/model/non-ht/dsss-phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ DsssPhy::GetMeasurementChannelWidth(const Ptr<const WifiPpdu> ppdu) const
Ptr<SpectrumValue>
DsssPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr<const WifiPpdu> ppdu) const
{
const auto& centerFrequencies = ppdu->GetTxCenterFreqs();
NS_ASSERT(centerFrequencies.size() == 1);
const auto& txVector = ppdu->GetTxVector();
uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector);
const auto channelWidth = txVector.GetChannelWidth();
NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW);
NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPowerW);
NS_ABORT_MSG_IF(channelWidth != 22, "Invalid channel width for DSSS");
Ptr<SpectrumValue> v =
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity(centerFrequency,
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity(centerFrequencies.front(),
txPowerW,
GetGuardBandwidth(channelWidth));
return v;
Expand Down
10 changes: 6 additions & 4 deletions src/wifi/model/non-ht/ofdm-phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,17 @@ OfdmPhy::IsAllConfigSupported(WifiPpduField /* field */, Ptr<const WifiPpdu> ppd
Ptr<SpectrumValue>
OfdmPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr<const WifiPpdu> ppdu) const
{
const auto& centerFrequencies = ppdu->GetTxCenterFreqs();
NS_ASSERT(centerFrequencies.size() == 1);
const auto& txVector = ppdu->GetTxVector();
uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector);
const auto channelWidth = txVector.GetChannelWidth();
NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW);
NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPowerW);
const auto& txMaskRejectionParams = GetTxMaskRejectionParams();
Ptr<SpectrumValue> v;
if (txVector.IsNonHtDuplicate())
{
v = WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity(
centerFrequency,
centerFrequencies.front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand All @@ -386,8 +387,9 @@ OfdmPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr<const WifiPpdu> ppdu) co
}
else
{
NS_ASSERT(centerFrequencies.size() == 1);
v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity(
centerFrequency,
centerFrequencies.front(),
channelWidth,
txPowerW,
GetGuardBandwidth(channelWidth),
Expand Down
9 changes: 0 additions & 9 deletions src/wifi/model/phy-entity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1301,15 +1301,6 @@ PhyEntity::GetMaxDelayPpduSameUid(const WifiTxVector& /*txVector*/)
return Seconds(0);
}

uint16_t
PhyEntity::GetCenterFrequencyForChannelWidth(const WifiTxVector& txVector) const
{
NS_LOG_FUNCTION(this << txVector);

return m_wifiPhy->GetOperatingChannel().GetPrimaryChannelCenterFrequency(
txVector.GetChannelWidth());
}

void
PhyEntity::NotifyPayloadBegin(const WifiTxVector& txVector, const Time& payloadDuration)
{
Expand Down
10 changes: 0 additions & 10 deletions src/wifi/model/phy-entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -857,16 +857,6 @@ class PhyEntity : public SimpleRefCount<PhyEntity>
virtual Ptr<SpectrumValue> GetTxPowerSpectralDensity(double txPowerW,
Ptr<const WifiPpdu> ppdu) const = 0;

/**
* Get the center frequency of the channel corresponding the current TxVector rather than
* that of the supported channel width.
* Consider that this "primary channel" is on the lower part for the time being.
*
* \param txVector the TXVECTOR that has the channel width that is to be used
* \return the center frequency in MHz corresponding to the channel width to be used
*/
uint16_t GetCenterFrequencyForChannelWidth(const WifiTxVector& txVector) const;

/**
* Fire the trace indicating that the PHY is starting to receive the payload of a PPDU.
*
Expand Down
3 changes: 2 additions & 1 deletion src/wifi/test/wifi-phy-ofdma-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,8 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid,

// Send non-OFDMA part
Time nonOfdmaDuration = m_phy->GetHePhy()->CalculateNonHeDurationForHeTb(txVector);
uint32_t centerFrequency = m_phy->GetHePhy()->GetCenterFrequencyForNonHePart(txVector, staId);
uint32_t centerFrequency =
m_phy->GetHePhy()->GetCenterFrequenciesForNonHePart(ppdu, staId).front();
ChannelWidthMhz ruWidth = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType());
ChannelWidthMhz channelWidth = ruWidth < 20 ? 20 : ruWidth;
Ptr<SpectrumValue> rxPsd = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
Expand Down

0 comments on commit 75b4976

Please sign in to comment.