wifi: Extend tests for multiple PHY interfaces to verify rxing state of interference helper after channel has switched

This commit is contained in:
Sébastien Deronne
2024-05-07 08:29:50 +02:00
committed by Sébastien Deronne
parent 3467011116
commit db0804c455
2 changed files with 64 additions and 2 deletions

View File

@@ -352,6 +352,10 @@ class InterferenceHelper : public Object
const WifiTxVector& txVector,
uint16_t staId = SU_STA_ID) const;
protected:
std::map<FrequencyRange, bool>
m_rxing; //!< flag whether it is in receiving state for a given FrequencyRange
private:
/**
* Noise and Interference (thus Ni) event.
@@ -518,8 +522,6 @@ class InterferenceHelper : public Object
uint8_t m_numRxAntennas; //!< the number of RX antennas in the corresponding receiver
NiChangesPerBand m_niChanges; //!< NI Changes for each band
FirstPowerPerBand m_firstPowers; //!< first power of each band in watts
std::map<FrequencyRange, bool>
m_rxing; //!< flag whether it is in receiving state for a given FrequencyRange
/**
* Returns an iterator to the first NiChange that is later than moment

View File

@@ -60,6 +60,40 @@ class ExtSpectrumWifiPhy : public SpectrumWifiPhy
using WifiPhy::GetBand;
};
/**
* Extended InterferenceHelper class for the purpose of the tests.
*/
class ExtInterferenceHelper : public InterferenceHelper
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId()
{
static TypeId tid = TypeId("ns3::ExtInterferenceHelper")
.SetParent<InterferenceHelper>()
.SetGroupName("Wifi")
.AddConstructor<ExtInterferenceHelper>();
return tid;
}
/**
* Indicate whether the interference helper is in receiving state
*
* \return true if the interference helper is in receiving state, false otherwise
*/
bool IsRxing() const
{
return std::any_of(m_rxing.cbegin(), m_rxing.cend(), [](const auto& rxing) {
return rxing.second;
});
}
};
NS_OBJECT_ENSURE_REGISTERED(ExtInterferenceHelper);
/**
* \ingroup wifi-test
* \ingroup tests
@@ -909,6 +943,15 @@ class SpectrumWifiPhyMultipleInterfacesTest : public TestCase
*/
void CheckCcaIndication(std::size_t index, bool expectedCcaBusyIndication, Time switchingDelay);
/**
* Verify rxing state of the interference helper
*
* \param phy the PHY to which the interference helper instance is attached
* \param rxingExpected flag whether the interference helper is expected to be in rxing state or
* not
*/
void CheckRxingState(Ptr<SpectrumWifiPhy> phy, bool rxingExpected);
/**
* Reset function
*/
@@ -957,6 +1000,11 @@ SpectrumWifiPhyMultipleInterfacesTest::SwitchChannel(Ptr<SpectrumWifiPhy> phy,
listener->m_ccaBusyEnd = Seconds(0);
}
phy->SetOperatingChannel(WifiPhy::ChannelTuple{channelNumber, channelWidth, band, 0});
// verify rxing state of interference helper is reset after channel switch
Simulator::ScheduleNow(&SpectrumWifiPhyMultipleInterfacesTest::CheckRxingState,
this,
phy,
false);
}
void
@@ -1117,6 +1165,17 @@ SpectrumWifiPhyMultipleInterfacesTest::CheckCcaIndication(std::size_t index,
NS_TEST_ASSERT_MSG_EQ(ccaBusyEnd, expectedCcaBusyEnd, "CCA busy end mismatch");
}
void
SpectrumWifiPhyMultipleInterfacesTest::CheckRxingState(Ptr<SpectrumWifiPhy> phy, bool rxingExpected)
{
NS_LOG_FUNCTION(this << phy << rxingExpected);
PointerValue ptr;
phy->GetAttribute("InterferenceHelper", ptr);
auto interferenceHelper = DynamicCast<ExtInterferenceHelper>(ptr.Get<ExtInterferenceHelper>());
NS_ASSERT(interferenceHelper);
NS_TEST_ASSERT_MSG_EQ(interferenceHelper->IsRxing(), rxingExpected, "Incorrect rxing state");
}
void
SpectrumWifiPhyMultipleInterfacesTest::Reset()
{
@@ -1169,6 +1228,7 @@ SpectrumWifiPhyMultipleInterfacesTest::DoSetup()
wifi.SetStandard(WIFI_STANDARD_80211be);
SpectrumWifiPhyHelper phyHelper(4);
phyHelper.SetInterferenceHelper("ns3::ExtInterferenceHelper");
phyHelper.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
struct SpectrumPhyInterfaceInfo