Skip to content

Commit 7bcd85c

Browse files
committed
wifi: Extend PHY CCA tests to verify CCA indication is updated if threshold changes
1 parent 1fe6917 commit 7bcd85c

File tree

1 file changed

+123
-7
lines changed

1 file changed

+123
-7
lines changed

src/wifi/test/wifi-phy-cca-test.cc

Lines changed: 123 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,12 @@ class WifiPhyCcaIndicationTest : public TestCase
937937
*/
938938
void StopSignal(Ptr<WaveformGenerator> signalGenerator);
939939

940+
/**
941+
* Update the CCA threshold of the PHY
942+
* @param ccaThreshold the new CCA threshold value to be set
943+
*/
944+
void UpdateCcaThreshold(dBm_u ccaThreshold);
945+
940946
/**
941947
* Check the PHY state
942948
* @param scenario the scenario under test
@@ -1021,6 +1027,15 @@ class WifiPhyCcaIndicationTest : public TestCase
10211027
std::vector<Time> expectedPer20MhzDurations; //!< expected per-20 MHz CCA duration
10221028
};
10231029

1030+
/**
1031+
* structure that holds information to perform CCA threshold update
1032+
*/
1033+
struct CcaThresholdUpdatePoint
1034+
{
1035+
Time timePoint; //!< time at which the update will be performed
1036+
dBm_u ccaThreshold; //!< new CCA threshold value to be set
1037+
};
1038+
10241039
/**
10251040
* Schedule test to perform.
10261041
* @param delay the reference delay to schedule the events
@@ -1029,13 +1044,15 @@ class WifiPhyCcaIndicationTest : public TestCase
10291044
* @param generatedPpdus the vector of PPDUs to be generated
10301045
* @param stateCheckpoints the vector of PHY state checks
10311046
* @param ccaCheckpoints the vector of PHY CCA checks
1047+
* @param ccaThresholdUpdates the vector of CCA threshold updates
10321048
*/
10331049
void ScheduleTest(Time delay,
10341050
const std::string& scenario,
10351051
const std::vector<TxSignalInfo>& generatedSignals,
10361052
const std::vector<TxPpduInfo>& generatedPpdus,
10371053
const std::vector<StateCheckPoint>& stateCheckpoints,
1038-
const std::vector<CcaCheckPoint>& ccaCheckpoints);
1054+
const std::vector<CcaCheckPoint>& ccaCheckpoints,
1055+
const std::vector<CcaThresholdUpdatePoint>& ccaThresholdUpdates = {});
10391056

10401057
/**
10411058
* Reset function
@@ -1144,6 +1161,13 @@ WifiPhyCcaIndicationTest::SendSuPpdu(dBm_u txPower, MHz_u frequency, MHz_u bandw
11441161
m_uxPhy->Send(psdu, txVector);
11451162
}
11461163

1164+
void
1165+
WifiPhyCcaIndicationTest::UpdateCcaThreshold(dBm_u ccaThreshold)
1166+
{
1167+
NS_LOG_FUNCTION(this << ccaThreshold);
1168+
m_rxPhy->SetCcaEdThreshold(ccaThreshold);
1169+
}
1170+
11471171
void
11481172
WifiPhyCcaIndicationTest::CheckPhyState(const std::string& scenario, WifiPhyState expectedState)
11491173
{
@@ -1265,12 +1289,14 @@ WifiPhyCcaIndicationTest::LogScenario(const std::string& scenario) const
12651289
}
12661290

12671291
void
1268-
WifiPhyCcaIndicationTest::ScheduleTest(Time delay,
1269-
const std::string& scenario,
1270-
const std::vector<TxSignalInfo>& generatedSignals,
1271-
const std::vector<TxPpduInfo>& generatedPpdus,
1272-
const std::vector<StateCheckPoint>& stateCheckpoints,
1273-
const std::vector<CcaCheckPoint>& ccaCheckpoints)
1292+
WifiPhyCcaIndicationTest::ScheduleTest(
1293+
Time delay,
1294+
const std::string& scenario,
1295+
const std::vector<TxSignalInfo>& generatedSignals,
1296+
const std::vector<TxPpduInfo>& generatedPpdus,
1297+
const std::vector<StateCheckPoint>& stateCheckpoints,
1298+
const std::vector<CcaCheckPoint>& ccaCheckpoints,
1299+
const std::vector<CcaThresholdUpdatePoint>& ccaThresholdUpdates)
12741300
{
12751301
Simulator::Schedule(delay, &WifiPhyCcaIndicationTest::LogScenario, this, scenario);
12761302

@@ -1335,6 +1361,14 @@ WifiPhyCcaIndicationTest::ScheduleTest(Time delay,
13351361
scenario,
13361362
checkpoint.expectedPhyState);
13371363
}
1364+
1365+
for (const auto& ccaThresholdUpdate : ccaThresholdUpdates)
1366+
{
1367+
Simulator::Schedule(delay + ccaThresholdUpdate.timePoint,
1368+
&WifiPhyCcaIndicationTest::UpdateCcaThreshold,
1369+
this,
1370+
ccaThresholdUpdate.ccaThreshold);
1371+
}
13381372
}
13391373

13401374
void
@@ -1343,6 +1377,7 @@ WifiPhyCcaIndicationTest::Reset()
13431377
NS_LOG_FUNCTION(this);
13441378
m_rxPhy->ConfigureStandard(m_standard); // make sure to clear PHY states
13451379
m_rxPhyStateListener->Reset();
1380+
UpdateCcaThreshold(dBm_u{-62}); // restore default CCA threshold
13461381
}
13471382

13481383
void
@@ -1542,6 +1577,8 @@ WifiPhyCcaIndicationTest::RunOne()
15421577

15431578
const auto txDiff = tx2Start - tx1Start;
15441579

1580+
const auto thresholdUpdateTime = MicroSeconds(75);
1581+
15451582
//----------------------------------------------------------------------------------------------------------------------------------
15461583
// Verify PHY state stays IDLE and no CCA-BUSY indication is reported when a signal below the
15471584
// energy detection threshold occupies P20
@@ -3617,6 +3654,85 @@ WifiPhyCcaIndicationTest::RunOne()
36173654
ResetExpectedPer20MhzCcaBusyDurations();
36183655
}
36193656

3657+
if (m_channelWidth > MHz_u{20})
3658+
{
3659+
m_expectedPer20MhzCcaBusyDurations.at(0).at(0) = txDuration1;
3660+
m_expectedPer20MhzCcaBusyDurations.at(1).at(0) = Time();
3661+
}
3662+
3663+
ScheduleTest(
3664+
delay,
3665+
"Reception of signal above ED threshold that triggers CCA BUSY indication followed by CCA "
3666+
"IDLE indication when the threshold is increased",
3667+
{{dBm_u{-60}, tx1Start, txDuration1, P20_CENTER_FREQUENCY, MHz_u{20}}},
3668+
{},
3669+
{
3670+
{aCcaTimeWithDelta, WifiPhyState::CCA_BUSY}, // CCA-BUSY after aCcaTimeWithDelta
3671+
{thresholdUpdateTime - smallDelta,
3672+
WifiPhyState::CCA_BUSY}, // CCA-BUSY just before the threshold changes
3673+
{thresholdUpdateTime + smallDelta,
3674+
WifiPhyState::IDLE}, // IDLE just after the threshold changes
3675+
{txEndSignal1 - smallDelta,
3676+
WifiPhyState::IDLE}, // IDLE just before the transmission ends
3677+
{txEndSignal1 + smallDelta, WifiPhyState::IDLE} // IDLE just after the transmission ends
3678+
},
3679+
{{thresholdUpdateTime - smallDelta,
3680+
1, // first notification CCA busy until end of transmission
3681+
tx1Start,
3682+
txEndSignal1,
3683+
WIFI_CHANLIST_PRIMARY,
3684+
m_expectedPer20MhzCcaBusyDurations.at(0)},
3685+
{txEndSignal1 - smallDelta,
3686+
2, // second notification CCA busy ends when threshold changed
3687+
tx1Start,
3688+
thresholdUpdateTime,
3689+
WIFI_CHANLIST_PRIMARY,
3690+
m_expectedPer20MhzCcaBusyDurations.at(1)}},
3691+
{
3692+
{.timePoint = thresholdUpdateTime,
3693+
.ccaThreshold =
3694+
dBm_u{-50}}, // change CCA threshold during the reception to a higher value
3695+
});
3696+
delay += testStep;
3697+
ResetExpectedPer20MhzCcaBusyDurations();
3698+
3699+
if (m_channelWidth > MHz_u{20})
3700+
{
3701+
m_expectedPer20MhzCcaBusyDurations.at(0).at(0) = txDuration1 - thresholdUpdateTime;
3702+
}
3703+
3704+
ScheduleTest(
3705+
delay,
3706+
"Reception of signal below ED threshold that triggers CCA IDLE indication followed by CCA "
3707+
"BUSY indication when the threshold is decreased",
3708+
{{dBm_u{-65}, tx1Start, txDuration1, P20_CENTER_FREQUENCY, MHz_u{20}}},
3709+
{},
3710+
{
3711+
{aCcaTimeWithDelta, WifiPhyState::IDLE}, // IDLE after aCcaTimeWithDelta
3712+
{thresholdUpdateTime - smallDelta,
3713+
WifiPhyState::IDLE}, // IDLE just before the threshold changes
3714+
{thresholdUpdateTime + smallDelta,
3715+
WifiPhyState::CCA_BUSY}, // CCA-BUSY just after the threshold changes
3716+
{txEndSignal1 - smallDelta,
3717+
WifiPhyState::CCA_BUSY}, // CCA-BUSY just before the transmission ends
3718+
{txEndSignal1 + smallDelta, WifiPhyState::IDLE} // IDLE just after the transmission ends
3719+
},
3720+
{
3721+
{txEndSignal1 - smallDelta,
3722+
1, // first notification CCA busy until end of transmission since threshold changed
3723+
thresholdUpdateTime,
3724+
txEndSignal1,
3725+
WIFI_CHANLIST_PRIMARY,
3726+
m_expectedPer20MhzCcaBusyDurations.at(0)},
3727+
},
3728+
{
3729+
{.timePoint = thresholdUpdateTime,
3730+
.ccaThreshold =
3731+
dBm_u{-70}}, // change CCA threshold during the reception to a higher value
3732+
});
3733+
delay += testStep;
3734+
ResetExpectedPer20MhzCcaBusyDurations();
3735+
36203736
Simulator::Run();
36213737
}
36223738

0 commit comments

Comments
 (0)