wifi: Refactor detection thresholds in WifiPhy
This commit is contained in:
@@ -70,6 +70,10 @@ us a note on ns-developers mailing list.</p>
|
||||
RandomRectanglePositionAllocator, RandomDiscPositionAllocator,
|
||||
UniformDiscPositionAllocator.
|
||||
</li>
|
||||
<li>
|
||||
The WifiPhy attribute "CcaMode1Threshold" has been renamed to "CcaEdThreshold",
|
||||
and the WifiPhy attribute "EnergyDetectionThreshold" has been replaced by a new attribute called "RxSensitivity"
|
||||
</li>
|
||||
</ul>
|
||||
<h2>Changes to build system:</h2>
|
||||
<ul>
|
||||
|
||||
@@ -131,11 +131,6 @@ main (int argc, char *argv[])
|
||||
double interval = 1; // seconds
|
||||
double startTime = 0.0; // seconds
|
||||
double distanceToRx = 100.0; // meters
|
||||
/*
|
||||
* This is a magic number used to set the transmit power, based on other
|
||||
* configuration.
|
||||
*/
|
||||
double offset = 81;
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode);
|
||||
@@ -177,15 +172,12 @@ main (int argc, char *argv[])
|
||||
/** Wifi PHY **/
|
||||
/***************************************************************************/
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.Set ("RxGain", DoubleValue (-10));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Prss));
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0));
|
||||
/***************************************************************************/
|
||||
|
||||
/** wifi channel **/
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
|
||||
|
||||
// create wifi channel
|
||||
Ptr<YansWifiChannel> wifiChannelPtr = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (wifiChannelPtr);
|
||||
|
||||
@@ -169,11 +169,6 @@ main (int argc, char *argv[])
|
||||
double interval = 1; // seconds
|
||||
double startTime = 0.0; // seconds
|
||||
double distanceToRx = 100.0; // meters
|
||||
/*
|
||||
* This is a magic number used to set the transmit power, based on other
|
||||
* configuration.
|
||||
*/
|
||||
double offset = 81;
|
||||
|
||||
// Energy Harvester variables
|
||||
double harvestingUpdateInterval = 1; // seconds
|
||||
@@ -218,15 +213,12 @@ main (int argc, char *argv[])
|
||||
/** Wifi PHY **/
|
||||
/***************************************************************************/
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.Set ("RxGain", DoubleValue (-10));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Prss));
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0));
|
||||
/***************************************************************************/
|
||||
|
||||
/** wifi channel **/
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
|
||||
|
||||
// create wifi channel
|
||||
Ptr<YansWifiChannel> wifiChannelPtr = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (wifiChannelPtr);
|
||||
|
||||
@@ -208,8 +208,6 @@ int main (int argc, char *argv[])
|
||||
|
||||
NS_LOG_DEBUG (modes[i]);
|
||||
experiment = Experiment (modes[i]);
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-110.0) );
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-110.0) );
|
||||
wifiPhy.Set ("TxPowerStart", DoubleValue (15.0) );
|
||||
wifiPhy.Set ("TxPowerEnd", DoubleValue (15.0) );
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
|
||||
@@ -178,9 +178,6 @@ int main (int argc, char *argv[])
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0) );
|
||||
|
||||
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
@@ -200,7 +197,6 @@ int main (int argc, char *argv[])
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0));
|
||||
// This will disable these sending devices from detecting a signal
|
||||
// so that they do not backoff
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (0.0) );
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Prss) );
|
||||
devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (1)));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Irss) );
|
||||
|
||||
@@ -183,9 +183,6 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else if (wifiType == "ns3::SpectrumWifiPhy")
|
||||
{
|
||||
//Bug 2460: CcaMode1Threshold default should be set to -62 dBm when using Spectrum
|
||||
Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
|
||||
|
||||
Ptr<MultiModelSpectrumChannel> spectrumChannel
|
||||
= CreateObject<MultiModelSpectrumChannel> ();
|
||||
Ptr<FriisPropagationLossModel> lossModel
|
||||
|
||||
@@ -212,9 +212,6 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else if (wifiType == "ns3::SpectrumWifiPhy")
|
||||
{
|
||||
//Bug 2460: CcaMode1Threshold default should be set to -62 dBm when using Spectrum
|
||||
Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
|
||||
|
||||
spectrumChannel
|
||||
= CreateObject<MultiModelSpectrumChannel> ();
|
||||
Ptr<FriisPropagationLossModel> lossModel
|
||||
|
||||
@@ -178,9 +178,6 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else if (wifiType == "ns3::SpectrumWifiPhy")
|
||||
{
|
||||
//Bug 2460: CcaMode1Threshold default should be set to -62 dBm when using Spectrum
|
||||
Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
|
||||
|
||||
Ptr<MultiModelSpectrumChannel> spectrumChannel
|
||||
= CreateObject<MultiModelSpectrumChannel> ();
|
||||
Ptr<FriisPropagationLossModel> lossModel
|
||||
|
||||
@@ -119,14 +119,6 @@ main (int argc, char *argv[])
|
||||
/* Setup Physical Layer */
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
wifiPhy.Set ("TxPowerStart", DoubleValue (10.0));
|
||||
wifiPhy.Set ("TxPowerEnd", DoubleValue (10.0));
|
||||
wifiPhy.Set ("TxPowerLevels", UintegerValue (1));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (0));
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0));
|
||||
wifiPhy.Set ("RxNoiseFigure", DoubleValue (10));
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-79));
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-79 + 3));
|
||||
wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel");
|
||||
wifiHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode", StringValue (phyRate),
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -168,8 +168,7 @@ ChainRegressionTest::CreateDevices ()
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
Ptr<YansWifiChannel> chan = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (chan);
|
||||
wifiPhy.Set ("TxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
wifiPhy.Set ("RxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
|
||||
// This test suite output was originally based on YansErrorRateModel
|
||||
wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel");
|
||||
WifiHelper wifi;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -113,8 +113,7 @@ HwmpProactiveRegressionTest::CreateDevices ()
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
Ptr<YansWifiChannel> chan = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (chan);
|
||||
wifiPhy.Set ("TxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
wifiPhy.Set ("RxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
|
||||
// 2. setup mesh
|
||||
MeshHelper mesh = MeshHelper::Default ();
|
||||
mesh.SetStackInstaller ("ns3::Dot11sStack", "Root", Mac48AddressValue (Mac48Address ("00:00:00:00:00:0d")));
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -114,8 +114,6 @@ HwmpReactiveRegressionTest::CreateDevices ()
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
Ptr<YansWifiChannel> chan = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (chan);
|
||||
wifiPhy.Set ("TxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
wifiPhy.Set ("RxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
|
||||
// 2. setup mesh
|
||||
MeshHelper mesh = MeshHelper::Default ();
|
||||
|
||||
@@ -122,8 +122,7 @@ HwmpSimplestRegressionTest::CreateDevices ()
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
Ptr<YansWifiChannel> chan = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (chan);
|
||||
wifiPhy.Set ("TxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
wifiPhy.Set ("RxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
|
||||
// 2. setup mesh
|
||||
MeshHelper mesh = MeshHelper::Default ();
|
||||
mesh.SetStackInstaller ("ns3::Dot11sStack");
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -140,8 +140,7 @@ HwmpDoRfRegressionTest::CreateDevices ()
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
Ptr<YansWifiChannel> chan = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (chan);
|
||||
wifiPhy.Set ("TxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
wifiPhy.Set ("RxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
|
||||
// 2. setup mesh
|
||||
MeshHelper mesh = MeshHelper::Default ();
|
||||
mesh.SetStackInstaller ("ns3::Dot11sStack");
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -99,8 +99,7 @@ FlameRegressionTest::CreateDevices ()
|
||||
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
|
||||
Ptr<YansWifiChannel> chan = wifiChannel.Create ();
|
||||
wifiPhy.SetChannel (chan);
|
||||
wifiPhy.Set ("TxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
wifiPhy.Set ("RxGain", DoubleValue (1.0)); //this configuration should go away in future revision to the test
|
||||
|
||||
// 2. setup mesh
|
||||
MeshHelper mesh = MeshHelper::Default ();
|
||||
mesh.SetStackInstaller ("ns3::FlameStack");
|
||||
|
||||
@@ -137,10 +137,6 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs
|
||||
wifi.SetStandard (wifiStandard);
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// This is one parameter that matters when using FixedRssLossModel
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0) );
|
||||
|
||||
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||
@@ -172,7 +168,6 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs
|
||||
|
||||
// This will disable these sending devices from detecting a signal
|
||||
// so that they do not backoff
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (0.0) );
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Prss) );
|
||||
devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (1)));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Irss) );
|
||||
|
||||
@@ -284,8 +284,7 @@ The PHY layer can be in one of six states:
|
||||
#. SLEEP: the PHY is in a power save mode and cannot send nor receive frames.
|
||||
|
||||
Packet reception works as follows. The ``YansWifiPhy`` attribute
|
||||
CcaMode1Threshold
|
||||
corresponds to what the standard calls the "ED threshold" for CCA Mode 1.
|
||||
CcaEdThreshold corresponds to what the standard calls the "ED threshold" for CCA Mode 1.
|
||||
In section 16.4.8.5: "CCA Mode 1: Energy above threshold. CCA shall report
|
||||
a busy medium upon detection of any energy above the ED threshold."
|
||||
|
||||
@@ -295,23 +294,17 @@ However, the model doesn't support this, because there are no 'foreign'
|
||||
signals in the YansWifi model-- everything is a Wi-Fi signal.
|
||||
|
||||
In the standard, there is also what is called the "minimum modulation
|
||||
and coding rate sensitivity" in section 18.3.10.6 CCA requirements. This is
|
||||
the -82 dBm requirement for 20 MHz channels. This is analogous to the
|
||||
EnergyDetectionThreshold attribute in ``YansWifiPhy``. CCA busy state is
|
||||
not raised in this model when this threshold is exceeded but instead RX
|
||||
state is immediately reached, since it is assumed that PLCP sync always
|
||||
succeeds in this model. Even if the PLCP header reception fails, the
|
||||
and coding rate sensitivity" in section 18.3.10.6 CCA requirements.
|
||||
This is analogous to the RxSensitivity attribute in ``YansWifiPhy``.
|
||||
CCA busy state is not raised in this model when this threshold is exceeded
|
||||
but instead RX state is immediately reached, since it is assumed that PLCP
|
||||
sync always succeeds in this model. Even if the PLCP header reception fails, the
|
||||
channel state is still held in RX until YansWifiPhy::EndReceive().
|
||||
|
||||
In ns-3, the values of these attributes are set to small default values
|
||||
(-96 dBm for EnergyDetectionThreshold and -99 dBm for CcaMode1Threshold).
|
||||
So, if a signal comes in at > -96 dBm and the state is IDLE or CCA BUSY,
|
||||
this model will lock onto it for the signal duration and raise RX state.
|
||||
If it comes in at <= -96 dBm but >= -99 dBm, it will definitely raise
|
||||
CCA BUSY but not RX state. If it comes in < -99 dBm, it gets added to
|
||||
the interference tracker and, by itself, it will not raise CCA BUSY, but
|
||||
maybe a later signal will contribute more power so that the threshold
|
||||
of -99 dBm is reached at a later time.
|
||||
In ns-3, the values of these attributes are -101 dBm for RxSensitivity
|
||||
and -62 dBm for CcaEdThreshold.
|
||||
So, if a signal comes in at > -101 dBm and the state is IDLE or CCA BUSY,
|
||||
this model will lock onto it for the signal duration and raise RX state.
|
||||
|
||||
The energy of the signal intended to be received is
|
||||
calculated from the transmission power and adjusted based on the Tx gain
|
||||
@@ -443,12 +436,9 @@ add their received power to the noise, in the same way that
|
||||
unintended Wi-Fi signals (perhaps from a different SSID or arriving
|
||||
late from a hidden node) are added to the noise.
|
||||
|
||||
Third, the default value for CcaMode1Threshold attribute is -62 dBm
|
||||
rather than the value of -99 dBm used for YansWifiPhy. This is because,
|
||||
unlike YansWifiPhy, where there are no foreign signals, CCA BUSY state
|
||||
will be raised for foreign signals that are higher than this 'energy
|
||||
detection' threshold (see section 16.4.8.5 in the 802.11-2012 standard
|
||||
for definition of CCA Mode 1).
|
||||
Unlike YansWifiPhy, where there are no foreign signals, CCA BUSY state
|
||||
will be raised for foreign signals that are higher than CcaEdThreshold
|
||||
(see section 16.4.8.5 in the 802.11-2012 standard for definition of CCA Mode 1).
|
||||
|
||||
To support the Spectrum channel, the ``YansWifiPhy`` transmit and receive methods
|
||||
were adapted to use the Spectrum channel API. This required developing
|
||||
|
||||
@@ -336,9 +336,6 @@ int main (int argc, char *argv[])
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (serverSelectedStandard.m_standard);
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.Set ("RxNoiseFigure", DoubleValue (0.0));
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-110.0));
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-110.0));
|
||||
|
||||
Ptr<YansWifiChannel> wifiChannel = CreateObject<YansWifiChannel> ();
|
||||
Ptr<ConstantSpeedPropagationDelayModel> delayModel = CreateObject<ConstantSpeedPropagationDelayModel> ();
|
||||
|
||||
@@ -242,6 +242,14 @@ SpectrumWifiPhy::StartRx (Ptr<SpectrumSignalParameters> rxParams)
|
||||
|
||||
// Log the signal arrival to the trace source
|
||||
m_signalCb (wifiRxParams ? true : false, senderNodeId, WToDbm (rxPowerW), rxDuration);
|
||||
|
||||
// Do no further processing if signal is too weak
|
||||
// Current implementation assumes constant rx power over the packet duration
|
||||
if (WToDbm (rxPowerW) < GetRxSensitivity ())
|
||||
{
|
||||
NS_LOG_INFO ("Received signal too weak to process: " << WToDbm (rxPowerW) << " dBm");
|
||||
return;
|
||||
}
|
||||
if (wifiRxParams == 0)
|
||||
{
|
||||
NS_LOG_INFO ("Received non Wi-Fi signal");
|
||||
|
||||
@@ -517,6 +517,7 @@ WifiPhyStateHelper::SwitchMaybeToCcaBusy (Time duration)
|
||||
{
|
||||
m_startCcaBusy = now;
|
||||
}
|
||||
m_stateLogger (now, duration, WifiPhyState::CCA_BUSY);
|
||||
m_endCcaBusy = std::max (m_endCcaBusy, now + duration);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,15 +182,24 @@ WifiPhy::GetTypeId (void)
|
||||
.AddAttribute ("EnergyDetectionThreshold",
|
||||
"The energy of a received signal should be higher than "
|
||||
"this threshold (dbm) to allow the PHY layer to detect the signal.",
|
||||
DoubleValue (-96.0),
|
||||
DoubleValue (-101.0),
|
||||
MakeDoubleAccessor (&WifiPhy::SetEdThreshold),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("CcaMode1Threshold",
|
||||
MakeDoubleChecker<double> (),
|
||||
TypeId::DEPRECATED, "Replaced by RxSensitivity, this attribute has no effect.")
|
||||
.AddAttribute ("RxSensitivity",
|
||||
"The energy of a received signal should be higher than "
|
||||
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.",
|
||||
DoubleValue (-99.0),
|
||||
MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold,
|
||||
&WifiPhy::GetCcaMode1Threshold),
|
||||
"this threshold (dBm) for the PHY to detect the signal.",
|
||||
DoubleValue (-101.0),
|
||||
MakeDoubleAccessor (&WifiPhy::SetRxSensitivity,
|
||||
&WifiPhy::GetRxSensitivity),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("CcaEdThreshold",
|
||||
"The energy of a non Wi-Fi received signal should be higher than "
|
||||
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state. "
|
||||
"This check is performed on the 20 MHz primary channel only.",
|
||||
DoubleValue (-62.0),
|
||||
MakeDoubleAccessor (&WifiPhy::SetCcaEdThreshold,
|
||||
&WifiPhy::GetCcaEdThreshold),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("TxGain",
|
||||
"Transmission gain (dB).",
|
||||
@@ -414,6 +423,12 @@ WifiPhy::DoInitialize (void)
|
||||
InitializeFrequencyChannelNumber ();
|
||||
}
|
||||
|
||||
Ptr<WifiPhyStateHelper>
|
||||
WifiPhy::GetState (void) const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhy::SetReceiveOkCallback (RxOkCallback callback)
|
||||
{
|
||||
@@ -475,27 +490,33 @@ WifiPhy::InitializeFrequencyChannelNumber (void)
|
||||
void
|
||||
WifiPhy::SetEdThreshold (double threshold)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << threshold);
|
||||
m_edThresholdW = DbmToW (threshold);
|
||||
}
|
||||
|
||||
double
|
||||
WifiPhy::GetEdThreshold (void) const
|
||||
{
|
||||
return WToDbm (m_edThresholdW);
|
||||
SetRxSensitivity (threshold);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhy::SetCcaMode1Threshold (double threshold)
|
||||
WifiPhy::SetRxSensitivity (double threshold)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << threshold);
|
||||
m_ccaMode1ThresholdW = DbmToW (threshold);
|
||||
m_rxSensitivityW = DbmToW (threshold);
|
||||
}
|
||||
|
||||
double
|
||||
WifiPhy::GetCcaMode1Threshold (void) const
|
||||
WifiPhy::GetRxSensitivity (void) const
|
||||
{
|
||||
return WToDbm (m_ccaMode1ThresholdW);
|
||||
return WToDbm (m_rxSensitivityW);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhy::SetCcaEdThreshold (double threshold)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << threshold);
|
||||
m_ccaEdThresholdW = DbmToW (threshold);
|
||||
}
|
||||
|
||||
double
|
||||
WifiPhy::GetCcaEdThreshold (void) const
|
||||
{
|
||||
return WToDbm (m_ccaEdThresholdW);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1644,7 +1665,7 @@ WifiPhy::ResumeFromSleep (void)
|
||||
case WifiPhyState::SLEEP:
|
||||
{
|
||||
NS_LOG_DEBUG ("resuming from sleep mode");
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaMode1ThresholdW);
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaEdThresholdW);
|
||||
m_state->SwitchFromSleep (delayUntilCcaEnd);
|
||||
break;
|
||||
}
|
||||
@@ -1675,7 +1696,7 @@ WifiPhy::ResumeFromOff (void)
|
||||
case WifiPhyState::OFF:
|
||||
{
|
||||
NS_LOG_DEBUG ("resuming from off mode");
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1Threshold ()));
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaEdThreshold ()));
|
||||
m_state->SwitchFromOff (delayUntilCcaEnd);
|
||||
break;
|
||||
}
|
||||
@@ -2543,7 +2564,7 @@ WifiPhy::MaybeCcaBusyDuration ()
|
||||
//In this model, CCA becomes busy when the aggregation of all signals as
|
||||
//tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
|
||||
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1Threshold ()));
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaEdThreshold ()));
|
||||
if (!delayUntilCcaEnd.IsZero ())
|
||||
{
|
||||
m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
|
||||
@@ -3646,7 +3667,7 @@ WifiPhy::SwitchMaybeToCcaBusy (void)
|
||||
//In this model, CCA becomes busy when the aggregation of all signals as
|
||||
//tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
|
||||
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1Threshold ()));
|
||||
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaEdThreshold ()));
|
||||
if (!delayUntilCcaEnd.IsZero ())
|
||||
{
|
||||
NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S));
|
||||
@@ -3676,76 +3697,66 @@ void
|
||||
WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration);
|
||||
if (rxPowerW > m_edThresholdW) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
|
||||
|
||||
AmpduTag ampduTag;
|
||||
WifiPreamble preamble = txVector.GetPreambleType ();
|
||||
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false))
|
||||
{
|
||||
AmpduTag ampduTag;
|
||||
WifiPreamble preamble = txVector.GetPreambleType ();
|
||||
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false))
|
||||
{
|
||||
m_plcpSuccess = false;
|
||||
m_mpdusNum = 0;
|
||||
NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received");
|
||||
NotifyRxDrop (packet);
|
||||
MaybeCcaBusyDuration ();
|
||||
return;
|
||||
}
|
||||
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
|
||||
{
|
||||
//received the first MPDU in an MPDU
|
||||
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
|
||||
m_rxMpduReferenceNumber++;
|
||||
}
|
||||
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
|
||||
{
|
||||
//received the other MPDUs that are part of the A-MPDU
|
||||
if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1))
|
||||
{
|
||||
NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ());
|
||||
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mpdusNum--;
|
||||
}
|
||||
}
|
||||
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
|
||||
{
|
||||
NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost");
|
||||
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
|
||||
}
|
||||
else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
|
||||
{
|
||||
NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
|
||||
m_mpdusNum = 0;
|
||||
}
|
||||
|
||||
NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
|
||||
m_currentEvent = event;
|
||||
m_state->SwitchToRx (rxDuration);
|
||||
NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
|
||||
NotifyRxBegin (packet);
|
||||
m_interference.NotifyRxStart ();
|
||||
|
||||
if (preamble != WIFI_PREAMBLE_NONE)
|
||||
{
|
||||
NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
|
||||
Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector);
|
||||
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this,
|
||||
packet, txVector, mpdutype, event);
|
||||
}
|
||||
|
||||
NS_ASSERT (m_endRxEvent.IsExpired ());
|
||||
m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this,
|
||||
packet, preamble, mpdutype, event);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
|
||||
rxPowerW << "<" << m_edThresholdW << ")");
|
||||
NotifyRxDrop (packet);
|
||||
m_plcpSuccess = false;
|
||||
m_mpdusNum = 0;
|
||||
NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received");
|
||||
NotifyRxDrop (packet);
|
||||
MaybeCcaBusyDuration ();
|
||||
return;
|
||||
}
|
||||
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
|
||||
{
|
||||
//received the first MPDU in an MPDU
|
||||
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
|
||||
m_rxMpduReferenceNumber++;
|
||||
}
|
||||
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
|
||||
{
|
||||
//received the other MPDUs that are part of the A-MPDU
|
||||
if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1))
|
||||
{
|
||||
NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ());
|
||||
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mpdusNum--;
|
||||
}
|
||||
}
|
||||
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
|
||||
{
|
||||
NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost");
|
||||
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
|
||||
}
|
||||
else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
|
||||
{
|
||||
NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
|
||||
m_mpdusNum = 0;
|
||||
}
|
||||
|
||||
NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
|
||||
m_currentEvent = event;
|
||||
m_state->SwitchToRx (rxDuration);
|
||||
NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
|
||||
NotifyRxBegin (packet);
|
||||
m_interference.NotifyRxStart ();
|
||||
|
||||
if (preamble != WIFI_PREAMBLE_NONE)
|
||||
{
|
||||
NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
|
||||
Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector);
|
||||
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this,
|
||||
packet, txVector, mpdutype, event);
|
||||
}
|
||||
|
||||
NS_ASSERT (m_endRxEvent.IsExpired ());
|
||||
m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this,
|
||||
packet, preamble, mpdutype, event);
|
||||
}
|
||||
|
||||
int64_t
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#define WIFI_PHY_H
|
||||
|
||||
#include "ns3/event-id.h"
|
||||
#include "ns3/deprecated.h"
|
||||
#include "ns3/error-model.h"
|
||||
#include "wifi-mpdu-type.h"
|
||||
#include "wifi-phy-standard.h"
|
||||
@@ -73,6 +74,13 @@ public:
|
||||
|
||||
WifiPhy ();
|
||||
virtual ~WifiPhy ();
|
||||
|
||||
/**
|
||||
* Return the WifiPhyStateHelper of this PHY
|
||||
*
|
||||
* \return the WifiPhyStateHelper of this PHY
|
||||
*/
|
||||
Ptr<WifiPhyStateHelper> GetState (void) const;
|
||||
|
||||
/**
|
||||
* \param callback the callback to invoke
|
||||
@@ -1190,14 +1198,24 @@ public:
|
||||
* this threshold (dbm) to allow the PHY layer to detect the signal.
|
||||
*
|
||||
* \param threshold the energy detection threshold in dBm
|
||||
*
|
||||
* \deprecated
|
||||
*/
|
||||
void SetEdThreshold (double threshold);
|
||||
/**
|
||||
* Return the energy detection threshold (dBm).
|
||||
* Sets the receive sensitivity threshold (dBm).
|
||||
* The energy of a received signal should be higher than
|
||||
* this threshold to allow the PHY layer to detect the signal.
|
||||
*
|
||||
* \return the energy detection threshold in dBm
|
||||
* \param threshold the receive sensitivity threshold in dBm
|
||||
*/
|
||||
double GetEdThreshold (void) const;
|
||||
void SetRxSensitivity (double threshold);
|
||||
/**
|
||||
* Return the receive sensitivity threshold (dBm).
|
||||
*
|
||||
* \return the receive sensitivity threshold in dBm
|
||||
*/
|
||||
double GetRxSensitivity (void) const;
|
||||
/**
|
||||
* Sets the CCA threshold (dBm). The energy of a received signal
|
||||
* should be higher than this threshold to allow the PHY
|
||||
@@ -1205,13 +1223,13 @@ public:
|
||||
*
|
||||
* \param threshold the CCA threshold in dBm
|
||||
*/
|
||||
void SetCcaMode1Threshold (double threshold);
|
||||
void SetCcaEdThreshold (double threshold);
|
||||
/**
|
||||
* Return the CCA threshold (dBm).
|
||||
*
|
||||
* \return the CCA threshold in dBm
|
||||
*/
|
||||
double GetCcaMode1Threshold (void) const;
|
||||
double GetCcaEdThreshold (void) const;
|
||||
/**
|
||||
* Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
|
||||
*
|
||||
@@ -1493,7 +1511,7 @@ protected:
|
||||
* Check if Phy state should move to CCA busy state based on current
|
||||
* state of interference tracker. In this model, CCA becomes busy when
|
||||
* the aggregation of all signals as tracked by the InterferenceHelper
|
||||
* class is higher than the CcaMode1Threshold
|
||||
* class is higher than the CcaEdThreshold
|
||||
*/
|
||||
void SwitchMaybeToCcaBusy (void);
|
||||
|
||||
@@ -1755,8 +1773,8 @@ private:
|
||||
bool m_frequencyChannelNumberInitialized; //!< Store initialization state
|
||||
uint16_t m_channelWidth; //!< Channel width
|
||||
|
||||
double m_edThresholdW; //!< Energy detection threshold in watts
|
||||
double m_ccaMode1ThresholdW; //!< Clear channel assessment (CCA) threshold in watts
|
||||
double m_rxSensitivityW; //!< Receive sensitivity threshold in watts
|
||||
double m_ccaEdThresholdW; //!< Clear channel assessment (CCA) threshold in watts
|
||||
double m_txGainDb; //!< Transmission gain (dB)
|
||||
double m_rxGainDb; //!< Reception gain (dB)
|
||||
double m_txPowerBaseDbm; //!< Minimum transmission power (dBm)
|
||||
|
||||
@@ -125,6 +125,13 @@ void
|
||||
YansWifiChannel::Receive (Ptr<YansWifiPhy> phy, Ptr<Packet> packet, double rxPowerDbm, Time duration)
|
||||
{
|
||||
NS_LOG_FUNCTION (phy << packet << rxPowerDbm << duration.GetSeconds ());
|
||||
// Do no further processing if signal is too weak
|
||||
// Current implementation assumes constant rx power over the packet duration
|
||||
if ((rxPowerDbm + phy->GetRxGain ()) < phy->GetRxSensitivity ())
|
||||
{
|
||||
NS_LOG_INFO ("Received signal too weak to process: " << rxPowerDbm << " dBm");
|
||||
return;
|
||||
}
|
||||
phy->StartReceivePreambleAndHeader (packet, DbmToW (rxPowerDbm + phy->GetRxGain ()), duration);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,8 +167,6 @@ SpectrumWifiPhyBasicTest::DoSetup (void)
|
||||
m_phy->SetFrequency (FREQUENCY);
|
||||
m_phy->SetReceiveOkCallback (MakeCallback (&SpectrumWifiPhyBasicTest::SpectrumWifiPhyRxSuccess, this));
|
||||
m_phy->SetReceiveErrorCallback (MakeCallback (&SpectrumWifiPhyBasicTest::SpectrumWifiPhyRxFailure, this));
|
||||
//Bug 2460: CcaMode1Threshold default should be set to -62 dBm when using Spectrum
|
||||
m_phy->SetCcaMode1Threshold (-62.0);
|
||||
}
|
||||
|
||||
// Test that the expected number of packet receptions occur.
|
||||
|
||||
425
src/wifi/test/wifi-phy-thresholds-test.cc
Normal file
425
src/wifi/test/wifi-phy-thresholds-test.cc
Normal file
@@ -0,0 +1,425 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2018
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/test.h"
|
||||
#include "ns3/spectrum-wifi-helper.h"
|
||||
#include "ns3/wifi-spectrum-value-helper.h"
|
||||
#include "ns3/spectrum-wifi-phy.h"
|
||||
#include "ns3/nist-error-rate-model.h"
|
||||
#include "ns3/wifi-mac-header.h"
|
||||
#include "ns3/wifi-mac-trailer.h"
|
||||
#include "ns3/wifi-phy-tag.h"
|
||||
#include "ns3/wifi-spectrum-signal-parameters.h"
|
||||
#include "ns3/wifi-utils.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiPhyThresholdsTest");
|
||||
|
||||
static const uint8_t CHANNEL_NUMBER = 36;
|
||||
static const uint32_t FREQUENCY = 5180; //MHz
|
||||
static const uint16_t CHANNEL_WIDTH = 20; //MHz
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
*
|
||||
* \brief Wifi Phy Threshold Test base class
|
||||
*/
|
||||
class WifiPhyThresholdsTest : public TestCase
|
||||
{
|
||||
public:
|
||||
WifiPhyThresholdsTest (std::string test_name);
|
||||
virtual ~WifiPhyThresholdsTest ();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Make wifi signal function
|
||||
* \param txPowerWatts the transmit power in watts
|
||||
* \returns Ptr<SpectrumSignalParameters>
|
||||
*/
|
||||
virtual Ptr<SpectrumSignalParameters> MakeWifiSignal (double txPowerWatts);
|
||||
/**
|
||||
* Make foreign signal function
|
||||
* \param txPowerWatts the transmit power in watts
|
||||
* \returns Ptr<SpectrumSignalParameters>
|
||||
*/
|
||||
virtual Ptr<SpectrumSignalParameters> MakeForeignSignal (double txPowerWatts);
|
||||
/**
|
||||
* Send signal function
|
||||
* \param txPowerWatts the transmit power in watts
|
||||
* \param wifiSignal whether the signal is a wifi signal or not
|
||||
*/
|
||||
virtual void SendSignal (double txPowerWatts, bool wifiSignal);
|
||||
/**
|
||||
* PHY receive success callback function
|
||||
* \param p the packet
|
||||
* \param snr the SNR
|
||||
* \param txVector the transmit vector
|
||||
*/
|
||||
virtual void RxSuccess (Ptr<Packet> p, double snr, WifiTxVector txVector);
|
||||
/**
|
||||
* PHY receive failure callback function
|
||||
*/
|
||||
virtual void RxFailure (void);
|
||||
/**
|
||||
* PHY dropped packet callback function
|
||||
* \param p the packet
|
||||
*/
|
||||
virtual void RxDropped (Ptr<const Packet> p);
|
||||
/**
|
||||
* PHY state changed callback function
|
||||
* \param start the start time of the new state
|
||||
* \param duration the duration of the new state
|
||||
* \param newState the new state
|
||||
*/
|
||||
virtual void PhyStateChanged (Time start, Time duration, WifiPhyState newState);
|
||||
|
||||
Ptr<SpectrumWifiPhy> m_phy; ///< PHY object
|
||||
uint32_t m_rxSuccess; ///< count number of successfully received packets
|
||||
uint32_t m_rxFailure; ///< count number of unsuccessfully received packets
|
||||
uint32_t m_rxDropped; ///< count number of dropped packets
|
||||
uint32_t m_stateChanged; ///< count number of PHY state change
|
||||
uint32_t m_rxStateCount; ///< count number of PHY state change to RX state
|
||||
uint32_t m_idleStateCount; ///< count number of PHY state change to IDLE state
|
||||
uint32_t m_ccabusyStateCount; ///< count number of PHY state change to CCA_BUSY state
|
||||
|
||||
private:
|
||||
virtual void DoSetup (void);
|
||||
};
|
||||
|
||||
WifiPhyThresholdsTest::WifiPhyThresholdsTest (std::string test_name)
|
||||
: TestCase (test_name),
|
||||
m_rxSuccess (0),
|
||||
m_rxFailure (0),
|
||||
m_rxDropped (0),
|
||||
m_stateChanged (0),
|
||||
m_rxStateCount (0),
|
||||
m_idleStateCount (0),
|
||||
m_ccabusyStateCount (0)
|
||||
{
|
||||
}
|
||||
|
||||
WifiPhyThresholdsTest::~WifiPhyThresholdsTest ()
|
||||
{
|
||||
}
|
||||
|
||||
Ptr<SpectrumSignalParameters>
|
||||
WifiPhyThresholdsTest::MakeWifiSignal (double txPowerWatts)
|
||||
{
|
||||
WifiTxVector txVector = WifiTxVector (WifiPhy::GetOfdmRate6Mbps (), 0, WIFI_PREAMBLE_LONG, false, 1, 1, 0, 20, false, false);
|
||||
MpduType mpdutype = NORMAL_MPDU;
|
||||
|
||||
Ptr<Packet> pkt = Create<Packet> (1000);
|
||||
WifiMacHeader hdr;
|
||||
WifiMacTrailer trailer;
|
||||
|
||||
hdr.SetType (WIFI_MAC_QOSDATA);
|
||||
hdr.SetQosTid (0);
|
||||
uint32_t size = pkt->GetSize () + hdr.GetSize () + trailer.GetSerializedSize ();
|
||||
Time txDuration = m_phy->CalculateTxDuration (size, txVector, m_phy->GetFrequency (), mpdutype, 0);
|
||||
hdr.SetDuration (txDuration);
|
||||
|
||||
pkt->AddHeader (hdr);
|
||||
pkt->AddTrailer (trailer);
|
||||
WifiPhyTag tag (txVector, mpdutype, 1);
|
||||
pkt->AddPacketTag (tag);
|
||||
Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, txPowerWatts, CHANNEL_WIDTH);
|
||||
Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
|
||||
txParams->psd = txPowerSpectrum;
|
||||
txParams->txPhy = 0;
|
||||
txParams->duration = txDuration;
|
||||
txParams->packet = pkt;
|
||||
return txParams;
|
||||
}
|
||||
|
||||
Ptr<SpectrumSignalParameters>
|
||||
WifiPhyThresholdsTest::MakeForeignSignal (double txPowerWatts)
|
||||
{
|
||||
Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, txPowerWatts, CHANNEL_WIDTH);
|
||||
Ptr<SpectrumSignalParameters> txParams = Create<SpectrumSignalParameters> ();
|
||||
txParams->psd = txPowerSpectrum;
|
||||
txParams->txPhy = 0;
|
||||
txParams->duration = Seconds (0.5);
|
||||
return txParams;
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsTest::SendSignal (double txPowerWatts, bool wifiSignal)
|
||||
{
|
||||
if (wifiSignal)
|
||||
{
|
||||
m_phy->StartRx (MakeWifiSignal (txPowerWatts));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_phy->StartRx (MakeForeignSignal (txPowerWatts));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsTest::RxSuccess (Ptr<Packet> p, double snr, WifiTxVector txVector)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p << snr << txVector);
|
||||
m_rxSuccess++;
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsTest::RxFailure (void)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
m_rxFailure++;
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsTest::RxDropped (Ptr<const Packet> p)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p);
|
||||
m_rxDropped++;
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsTest::PhyStateChanged (Time start, Time duration, WifiPhyState newState)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << start << duration << newState);
|
||||
m_stateChanged++;
|
||||
if (newState == WifiPhyState::IDLE)
|
||||
{
|
||||
m_idleStateCount++;
|
||||
}
|
||||
else if (newState == WifiPhyState::RX)
|
||||
{
|
||||
m_rxStateCount++;
|
||||
}
|
||||
else if (newState == WifiPhyState::CCA_BUSY)
|
||||
{
|
||||
m_ccabusyStateCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsTest::DoSetup (void)
|
||||
{
|
||||
m_phy = CreateObject<SpectrumWifiPhy> ();
|
||||
m_phy->ConfigureStandard (WIFI_PHY_STANDARD_80211ax_5GHZ);
|
||||
Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
|
||||
m_phy->SetErrorRateModel (error);
|
||||
m_phy->SetChannelNumber (CHANNEL_NUMBER);
|
||||
m_phy->SetFrequency (FREQUENCY);
|
||||
m_phy->SetReceiveOkCallback (MakeCallback (&WifiPhyThresholdsTest::RxSuccess, this));
|
||||
m_phy->SetReceiveErrorCallback (MakeCallback (&WifiPhyThresholdsTest::RxFailure, this));
|
||||
m_phy->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&WifiPhyThresholdsTest::RxDropped, this));
|
||||
m_phy->GetState ()->TraceConnectWithoutContext ("State", MakeCallback (&WifiPhyThresholdsTest::PhyStateChanged, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
*
|
||||
* \brief Wifi Phy Threshold Weak Wifi Signal Test
|
||||
*
|
||||
* This test makes sure PHY ignores a Wi-Fi signal
|
||||
* if its received power lower than RxSensitivity.
|
||||
*/
|
||||
class WifiPhyThresholdsWeakWifiSignalTest : public WifiPhyThresholdsTest
|
||||
{
|
||||
public:
|
||||
WifiPhyThresholdsWeakWifiSignalTest ();
|
||||
virtual ~WifiPhyThresholdsWeakWifiSignalTest ();
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
WifiPhyThresholdsWeakWifiSignalTest::WifiPhyThresholdsWeakWifiSignalTest ()
|
||||
: WifiPhyThresholdsTest ("WifiPhy reception thresholds: test weak wifi signal reception")
|
||||
{
|
||||
}
|
||||
|
||||
WifiPhyThresholdsWeakWifiSignalTest::~WifiPhyThresholdsWeakWifiSignalTest ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsWeakWifiSignalTest::DoRun (void)
|
||||
{
|
||||
WifiHelper::EnableLogComponents ();
|
||||
|
||||
double txPowerWatts = DbmToW (-110);
|
||||
|
||||
Simulator::Schedule (Seconds (1), &WifiPhyThresholdsWeakWifiSignalTest::SendSignal, this, txPowerWatts, true);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (m_rxDropped + m_rxSuccess + m_rxFailure, 0, "Reception should not have been triggered if packet is weaker than RxSensitivity threshold");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_stateChanged, 0, "State should stay idle if reception involves a signal weaker than RxSensitivity threshold");
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
*
|
||||
* \brief Wifi Phy Threshold Weak Foreign Signal Test
|
||||
*
|
||||
* This test makes sure PHY keeps the state as IDLE if reception involves
|
||||
* a foreign signal with a received power lower than CcaEdThreshold.
|
||||
*/
|
||||
class WifiPhyThresholdsWeakForeignSignalTest : public WifiPhyThresholdsTest
|
||||
{
|
||||
public:
|
||||
WifiPhyThresholdsWeakForeignSignalTest ();
|
||||
virtual ~WifiPhyThresholdsWeakForeignSignalTest ();
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
WifiPhyThresholdsWeakForeignSignalTest::WifiPhyThresholdsWeakForeignSignalTest ()
|
||||
: WifiPhyThresholdsTest ("WifiPhy reception thresholds: test weak foreign signal reception")
|
||||
{
|
||||
}
|
||||
|
||||
WifiPhyThresholdsWeakForeignSignalTest::~WifiPhyThresholdsWeakForeignSignalTest ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsWeakForeignSignalTest::DoRun (void)
|
||||
{
|
||||
WifiHelper::EnableLogComponents ();
|
||||
|
||||
double txPowerWatts = DbmToW (-90);
|
||||
|
||||
Simulator::Schedule (Seconds (1), &WifiPhyThresholdsWeakForeignSignalTest::SendSignal, this, txPowerWatts, false);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (m_rxDropped + m_rxSuccess + m_rxFailure, 0, "Reception of non-wifi packet should not be triggered");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_stateChanged, 0, "State should stay idle if reception involves a signal weaker than RxSensitivity threshold");
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
*
|
||||
* \brief Wifi Phy Threshold Strong Wifi Signal Test
|
||||
*
|
||||
* This test makes sure PHY processes a Wi-Fi signal
|
||||
* with a received power higher than RxSensitivity.
|
||||
*/
|
||||
class WifiPhyThresholdsStrongWifiSignalTest : public WifiPhyThresholdsTest
|
||||
{
|
||||
public:
|
||||
WifiPhyThresholdsStrongWifiSignalTest ();
|
||||
virtual ~WifiPhyThresholdsStrongWifiSignalTest ();
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
WifiPhyThresholdsStrongWifiSignalTest::WifiPhyThresholdsStrongWifiSignalTest ()
|
||||
: WifiPhyThresholdsTest ("WifiPhy reception thresholds: test strong wifi signal reception")
|
||||
{
|
||||
}
|
||||
|
||||
WifiPhyThresholdsStrongWifiSignalTest::~WifiPhyThresholdsStrongWifiSignalTest ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsStrongWifiSignalTest::DoRun (void)
|
||||
{
|
||||
WifiHelper::EnableLogComponents ();
|
||||
|
||||
double txPowerWatts = DbmToW (-60);
|
||||
|
||||
Simulator::Schedule (Seconds (1), &WifiPhyThresholdsStrongWifiSignalTest::SendSignal, this, txPowerWatts, true);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (m_rxDropped + m_rxFailure, 0, "Packet reception should have been successfull");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_rxSuccess, 1, "Packet should have been successfully received");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_stateChanged, 2, "State should have moved to RX then back to IDLE");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_rxStateCount, 1, "State should have moved to RX once");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_idleStateCount, 1, "State should have moved to IDLE once");
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
*
|
||||
* \brief Wifi Phy Threshold Strong Foreign Signal Test
|
||||
*
|
||||
* This test makes sure PHY declare the state as CCA_BUSY if reception involves
|
||||
* a foreign signal with a received power higher than CcaEdThreshold.
|
||||
*/
|
||||
class WifiPhyThresholdsStrongForeignSignalTest : public WifiPhyThresholdsTest
|
||||
{
|
||||
public:
|
||||
WifiPhyThresholdsStrongForeignSignalTest ();
|
||||
virtual ~WifiPhyThresholdsStrongForeignSignalTest ();
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
WifiPhyThresholdsStrongForeignSignalTest::WifiPhyThresholdsStrongForeignSignalTest ()
|
||||
: WifiPhyThresholdsTest ("WifiPhy reception thresholds: test weak foreign signal reception")
|
||||
{
|
||||
}
|
||||
|
||||
WifiPhyThresholdsStrongForeignSignalTest::~WifiPhyThresholdsStrongForeignSignalTest ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhyThresholdsStrongForeignSignalTest::DoRun (void)
|
||||
{
|
||||
WifiHelper::EnableLogComponents ();
|
||||
|
||||
double txPowerWatts = DbmToW (-60);
|
||||
|
||||
Simulator::Schedule (Seconds (1), &WifiPhyThresholdsStrongForeignSignalTest::SendSignal, this, txPowerWatts, false);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (m_rxDropped + m_rxSuccess + m_rxFailure, 0, "Reception of non-wifi packet should not be triggered");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_ccabusyStateCount, 1, "State should have moved to CCA-BUSY");
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
*
|
||||
* \brief Wifi Phy Thresholds Test Suite
|
||||
*/
|
||||
class WifiPhyThresholdsTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
WifiPhyThresholdsTestSuite ();
|
||||
};
|
||||
|
||||
WifiPhyThresholdsTestSuite::WifiPhyThresholdsTestSuite ()
|
||||
: TestSuite ("wifi-phy-thresholds", UNIT)
|
||||
{
|
||||
AddTestCase (new WifiPhyThresholdsWeakWifiSignalTest, TestCase::QUICK);
|
||||
AddTestCase (new WifiPhyThresholdsWeakForeignSignalTest, TestCase::QUICK);
|
||||
AddTestCase (new WifiPhyThresholdsStrongWifiSignalTest, TestCase::QUICK);
|
||||
AddTestCase (new WifiPhyThresholdsStrongForeignSignalTest, TestCase::QUICK);
|
||||
}
|
||||
|
||||
static WifiPhyThresholdsTestSuite wifiPhyThresholdsTestSuite; ///< the test suite
|
||||
@@ -1290,7 +1290,6 @@ Bug2483TestCase::DoRun (void)
|
||||
spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
|
||||
spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
|
||||
spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
|
||||
spectrumPhy.Set ("CcaMode1Threshold", DoubleValue (-62.0));
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
|
||||
|
||||
@@ -111,6 +111,7 @@ def build(bld):
|
||||
'test/wifi-aggregation-test.cc',
|
||||
'test/wifi-error-rate-models-test.cc',
|
||||
'test/wifi-transmit-mask-test.cc',
|
||||
'test/wifi-phy-thresholds-test.cc',
|
||||
]
|
||||
|
||||
headers = bld(features='ns3header')
|
||||
|
||||
Reference in New Issue
Block a user