wifi: Add a ProbeDelay attribute to StaWifiMac

This commit is contained in:
Stefano Avallone
2022-06-18 16:45:38 +02:00
parent 31bd09673d
commit 8c6918ef4c
7 changed files with 46 additions and 9 deletions

View File

@@ -41,9 +41,9 @@ cpp_examples = [
("wifi-ht-network --simulationTime=0.2 --frequency=5 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=135", "True", "True"),
("wifi-ht-network --simulationTime=0.2 --frequency=5 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=131", "True", "True"),
("wifi-ht-network --simulationTime=0.2 --frequency=2.4 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=132", "True", "True"),
("wifi-ht-network --simulationTime=0.2 --frequency=2.4 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=128", "True", "True"),
("wifi-ht-network --simulationTime=0.2 --frequency=2.4 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=129", "True", "True"),
("wifi-vht-network --simulationTime=0.2 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=583", "True", "True"),
("wifi-vht-network --simulationTime=0.2 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=543", "True", "True"),
("wifi-vht-network --simulationTime=0.2 --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=547", "True", "True"),
("wifi-he-network --simulationTime=0.25 --frequency=5 --useRts=0 --minExpectedThroughput=6 --maxExpectedThroughput=844", "True", "True"),
("wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=0 --useExtendedBlockAck=1 --minExpectedThroughput=6 --maxExpectedThroughput=1033", "True", "True"),
("wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745", "True", "True"),

View File

@@ -396,7 +396,7 @@ int main (int argc, char *argv[])
throughput = totalPacketsThroughC * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "AC_VI with default TXOP limit (4.096ms): " << '\n'
<< " Throughput = " << throughput << " Mbit/s" << '\n';
if (verifyResults && (throughput < 37.0 || throughput > 37.5))
if (verifyResults && (throughput < 36.5 || throughput > 37.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);

View File

@@ -330,7 +330,7 @@ int main (int argc, char *argv[])
double throughput = totalPacketsThroughA * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput with default configuration (A-MPDU aggregation enabled, 65kB): " << throughput << " Mbit/s" << '\n';
if (verifyResults && (throughput < 58.5 || throughput > 59.5))
if (verifyResults && (throughput < 59.0 || throughput > 60.0))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);

View File

@@ -261,7 +261,7 @@ int main (int argc, char *argv[])
RngSeedManager::SetSeed (1);
RngSeedManager::SetRun (1);
int64_t streamNumber = 100;
int64_t streamNumber = 150;
streamNumber += wifi.AssignStreams (apDevice, streamNumber);
streamNumber += wifi.AssignStreams (staDevices, streamNumber);

View File

@@ -22,6 +22,7 @@
#include "ns3/wifi-net-device.h"
#include "ns3/ap-wifi-mac.h"
#include "ns3/sta-wifi-mac.h"
#include "ns3/ampdu-subframe-header.h"
#include "ns3/mobility-model.h"
#include "ns3/log.h"
@@ -992,11 +993,15 @@ WifiHelper::AssignStreams (NetDeviceContainer c, int64_t stream)
currentStream += bk_txop->AssignStreams (currentStream);
}
//if an AP, handle any beacon jitter
Ptr<ApWifiMac> apmac = DynamicCast<ApWifiMac> (mac);
if (apmac)
// if an AP, handle any beacon jitter
if (auto apMac = DynamicCast<ApWifiMac> (mac); apMac)
{
currentStream += apmac->AssignStreams (currentStream);
currentStream += apMac->AssignStreams (currentStream);
}
// if a STA, handle any probe request jitter
if (auto staMac = DynamicCast<StaWifiMac> (mac); staMac)
{
currentStream += staMac->AssignStreams (currentStream);
}
}
}

View File

@@ -23,7 +23,10 @@
#include "ns3/log.h"
#include "ns3/packet.h"
#include "ns3/pointer.h"
#include "ns3/random-variable-stream.h"
#include "ns3/simulator.h"
#include "ns3/string.h"
#include "qos-txop.h"
#include "sta-wifi-mac.h"
#include "wifi-phy.h"
@@ -73,6 +76,12 @@ StaWifiMac::GetTypeId (void)
BooleanValue (false),
MakeBooleanAccessor (&StaWifiMac::SetActiveProbing, &StaWifiMac::GetActiveProbing),
MakeBooleanChecker ())
.AddAttribute ("ProbeDelay",
"Delay (in microseconds) to be used prior to transmitting a "
"Probe frame during active scanning.",
StringValue ("ns3::UniformRandomVariable[Min=50.0|Max=250.0]"),
MakePointerAccessor (&StaWifiMac::m_probeDelay),
MakePointerChecker<RandomVariableStream> ())
.AddTraceSource ("Assoc", "Associated with an access point.",
MakeTraceSourceAccessor (&StaWifiMac::m_assocLogger),
"ns3::Mac48Address::TracedCallback")
@@ -114,6 +123,14 @@ StaWifiMac::~StaWifiMac ()
NS_LOG_FUNCTION (this);
}
int64_t
StaWifiMac::AssignStreams (int64_t stream)
{
NS_LOG_FUNCTION (this << stream);
m_probeDelay->SetStream (stream);
return 1;
}
uint16_t
StaWifiMac::GetAssociationId (void) const
{

View File

@@ -35,6 +35,8 @@ namespace ns3 {
class SupportedRates;
class CapabilityInformation;
class RandomVariableStream;
/**
* \ingroup wifi
@@ -194,6 +196,17 @@ public:
void NotifyChannelSwitching (void) override;
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
*
* \return the number of stream indices assigned by this model
*/
int64_t AssignStreams (int64_t stream);
private:
/**
* The current MAC state of the STA.
@@ -357,6 +370,8 @@ private:
Time m_beaconWatchdogEnd; ///< beacon watchdog end
uint32_t m_maxMissedBeacons; ///< maximum missed beacons
bool m_activeProbing; ///< active probing
Ptr<RandomVariableStream> m_probeDelay; ///< RandomVariable used to randomize the time
///< of the first Probe Response on each channel
std::vector<ApInfo> m_candidateAps; ///< list of candidate APs to associate to
// Note: std::multiset<ApInfo> might be a candidate container to implement
// this sorted list, but we are using a std::vector because we want to sort