wifi: Add function to SpectrumWifiPhy to get the band corresponding to a given width in a selected range
This commit is contained in:
committed by
Sebastien Deronne
parent
c622338aaa
commit
30ec962813
@@ -553,9 +553,17 @@ SpectrumWifiPhy::GetGuardBandwidth(uint16_t currentChannelWidth) const
|
||||
}
|
||||
|
||||
WifiSpectrumBand
|
||||
SpectrumWifiPhy::GetBand(uint16_t bandWidth, uint8_t bandIndex)
|
||||
SpectrumWifiPhy::GetBand(uint16_t bandWidth, uint8_t bandIndex /* = 0 */)
|
||||
{
|
||||
return GetBandForInterface(bandWidth, bandIndex, GetCurrentFrequencyRange(), GetChannelWidth());
|
||||
}
|
||||
|
||||
WifiSpectrumBand
|
||||
SpectrumWifiPhy::GetBandForInterface(uint16_t bandWidth,
|
||||
uint8_t bandIndex,
|
||||
FrequencyRange range,
|
||||
uint16_t channelWidth)
|
||||
{
|
||||
uint16_t channelWidth = GetChannelWidth();
|
||||
uint32_t bandBandwidth = GetBandBandwidth();
|
||||
size_t numBandsInChannel = static_cast<size_t>(channelWidth * 1e6 / bandBandwidth);
|
||||
size_t numBandsInBand = static_cast<size_t>(bandWidth * 1e6 / bandBandwidth);
|
||||
@@ -563,12 +571,12 @@ SpectrumWifiPhy::GetBand(uint16_t bandWidth, uint8_t bandIndex)
|
||||
{
|
||||
numBandsInChannel += 1; // symmetry around center frequency
|
||||
}
|
||||
NS_ABORT_IF(!m_currentSpectrumPhyInterface);
|
||||
size_t totalNumBands = m_currentSpectrumPhyInterface->GetRxSpectrumModel()->GetNumBands();
|
||||
size_t totalNumBands = m_spectrumPhyInterfaces.at(range)->GetRxSpectrumModel()->GetNumBands();
|
||||
NS_ASSERT_MSG((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1),
|
||||
"Should have odd number of bands");
|
||||
NS_ASSERT_MSG((bandIndex * bandWidth) < channelWidth, "Band index is out of bound");
|
||||
WifiSpectrumBand band;
|
||||
NS_ASSERT(totalNumBands >= numBandsInChannel);
|
||||
band.first = ((totalNumBands - numBandsInChannel) / 2) + (bandIndex * numBandsInBand);
|
||||
band.second = band.first + numBandsInBand - 1;
|
||||
if (band.first >= totalNumBands / 2)
|
||||
|
||||
@@ -118,6 +118,22 @@ class SpectrumWifiPhy : public WifiPhy
|
||||
*/
|
||||
uint32_t GetBandBandwidth() const;
|
||||
|
||||
/**
|
||||
* Get the start band index and the stop band index for a given band and a given spectrum PHY
|
||||
* interface
|
||||
*
|
||||
* \param bandWidth the width of the band to be returned (MHz)
|
||||
* \param bandIndex the index of the band to be returned
|
||||
* \param range the frequency range identifying the spectrum PHY interface
|
||||
* \param channelWidth the channel width currently used by the spectrum PHY interface
|
||||
*
|
||||
* \return a pair of start and stop indexes that defines the band
|
||||
*/
|
||||
WifiSpectrumBand GetBandForInterface(uint16_t bandWidth,
|
||||
uint8_t bandIndex,
|
||||
FrequencyRange range,
|
||||
uint16_t channelWidth);
|
||||
|
||||
/**
|
||||
* Callback invoked when the PHY model starts to process a signal
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user