examples: Allow users to specify a set of MCS values for wifi examples

This commit is contained in:
Stefano Avallone
2024-06-17 12:58:46 +02:00
parent 012031c79d
commit 2066cabb80
4 changed files with 111 additions and 32 deletions

View File

@@ -6,6 +6,7 @@
* Author: Sebastien Deronne <sebastien.deronne@gmail.com>
*/
#include "ns3/attribute-container.h"
#include "ns3/boolean.h"
#include "ns3/command-line.h"
#include "ns3/config.h"
@@ -30,6 +31,7 @@
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
#include <algorithm>
#include <array>
#include <functional>
#include <numeric>
@@ -154,7 +156,8 @@ main(int argc, char* argv[])
std::string dlAckSeqType{"NO-OFDMA"};
bool enableUlOfdma{false};
bool enableBsrp{false};
int mcs{-1}; // -1 indicates an unset value
std::string mcsStr;
std::vector<uint64_t> mcsValues;
uint32_t payloadSize =
700; // must fit in the max TX duration when transmitting at MCS 0 over an RU of 26 tones
Time tputInterval{0}; // interval for detailed throughput measurement
@@ -226,7 +229,10 @@ main(int argc, char* argv[])
"muSchedAccessReqInterval",
"Duration of the interval between two requests for channel access made by the MU scheduler",
accessReqInterval);
cmd.AddValue("mcs", "if set, limit testing to a specific MCS (0-11)", mcs);
cmd.AddValue(
"mcs",
"list of comma separated MCS values to test; if unset, all MCS values (0-13) are tested",
mcsStr);
cmd.AddValue("payloadSize", "The application payload size in bytes", payloadSize);
cmd.AddValue("tputInterval", "duration of intervals for throughput measurement", tputInterval);
cmd.AddValue("minExpectedThroughput",
@@ -273,14 +279,27 @@ main(int argc, char* argv[])
<< "GI"
<< "\t\t\t"
<< "Throughput" << '\n';
int minMcs = 0;
int maxMcs = 13;
if (mcs >= 0 && mcs <= 13)
uint8_t minMcs = 0;
uint8_t maxMcs = 13;
if (mcsStr.empty())
{
minMcs = mcs;
maxMcs = mcs;
for (uint8_t mcs = minMcs; mcs <= maxMcs; ++mcs)
{
mcsValues.push_back(mcs);
}
}
for (int mcs = minMcs; mcs <= maxMcs; mcs++)
else
{
AttributeContainerValue<UintegerValue, ',', std::vector> attr;
auto checker = DynamicCast<AttributeContainerChecker>(MakeAttributeContainerChecker(attr));
checker->SetItemChecker(MakeUintegerChecker<uint8_t>());
attr.DeserializeFromString(mcsStr, checker);
mcsValues = attr.Get();
std::sort(mcsValues.begin(), mcsValues.end());
}
for (const auto mcs : mcsValues)
{
uint8_t index = 0;
double previous = 0;

View File

@@ -6,6 +6,7 @@
* Author: Sebastien Deronne <sebastien.deronne@gmail.com>
*/
#include "ns3/attribute-container.h"
#include "ns3/boolean.h"
#include "ns3/command-line.h"
#include "ns3/config.h"
@@ -31,6 +32,7 @@
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
#include <algorithm>
#include <functional>
// This is a simple example in order to show how to configure an IEEE 802.11ax Wi-Fi network.
@@ -70,7 +72,8 @@ main(int argc, char* argv[])
std::string dlAckSeqType{"NO-OFDMA"};
bool enableUlOfdma{false};
bool enableBsrp{false};
int mcs{-1}; // -1 indicates an unset value
std::string mcsStr;
std::vector<uint64_t> mcsValues;
uint32_t payloadSize =
700; // must fit in the max TX duration when transmitting at MCS 0 over an RU of 26 tones
std::string phyModel{"Yans"};
@@ -107,7 +110,10 @@ main(int argc, char* argv[])
"muSchedAccessReqInterval",
"Duration of the interval between two requests for channel access made by the MU scheduler",
accessReqInterval);
cmd.AddValue("mcs", "if set, limit testing to a specific MCS (0-11)", mcs);
cmd.AddValue(
"mcs",
"list of comma separated MCS values to test; if unset, all MCS values (0-11) are tested",
mcsStr);
cmd.AddValue("payloadSize", "The application payload size in bytes", payloadSize);
cmd.AddValue("phyModel",
"PHY model to use when OFDMA is disabled (Yans or Spectrum). If 80+80 MHz or "
@@ -168,14 +174,27 @@ main(int argc, char* argv[])
<< "GI"
<< "\t\t\t"
<< "Throughput" << '\n';
int minMcs = 0;
int maxMcs = 11;
if (mcs >= 0 && mcs <= 11)
uint8_t minMcs = 0;
uint8_t maxMcs = 11;
if (mcsStr.empty())
{
minMcs = mcs;
maxMcs = mcs;
for (uint8_t mcs = minMcs; mcs <= maxMcs; ++mcs)
{
mcsValues.push_back(mcs);
}
}
for (int mcs = minMcs; mcs <= maxMcs; mcs++)
else
{
AttributeContainerValue<UintegerValue, ',', std::vector> attr;
auto checker = DynamicCast<AttributeContainerChecker>(MakeAttributeContainerChecker(attr));
checker->SetItemChecker(MakeUintegerChecker<uint8_t>());
attr.DeserializeFromString(mcsStr, checker);
mcsValues = attr.Get();
std::sort(mcsValues.begin(), mcsValues.end());
}
for (const auto mcs : mcsValues)
{
uint8_t index = 0;
double previous = 0;

View File

@@ -31,6 +31,9 @@
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
#include <algorithm>
#include <vector>
// This is a simple example in order to show how to configure an IEEE 802.11n Wi-Fi network.
//
// It outputs the UDP or TCP goodput for every HT MCS value, which depends on the MCS value (0 to
@@ -59,7 +62,8 @@ main(int argc, char* argv[])
Time simulationTime{"10s"};
meter_u distance{1.0};
double frequency{5}; // whether 2.4 or 5 GHz
int mcs{-1}; // -1 indicates an unset value
std::string mcsStr;
std::vector<uint64_t> mcsValues;
double minExpectedThroughput{0.0};
double maxExpectedThroughput{0.0};
@@ -73,7 +77,10 @@ main(int argc, char* argv[])
cmd.AddValue("simulationTime", "Simulation time", simulationTime);
cmd.AddValue("udp", "UDP if set to 1, TCP otherwise", udp);
cmd.AddValue("useRts", "Enable/disable RTS/CTS", useRts);
cmd.AddValue("mcs", "if set, limit testing to a specific MCS (0-7)", mcs);
cmd.AddValue(
"mcs",
"list of comma separated MCS values to test; if unset, all MCS values (0-7) are tested",
mcsStr);
cmd.AddValue("minExpectedThroughput",
"if set, simulation fails if the lowest throughput is below this value",
minExpectedThroughput);
@@ -96,14 +103,27 @@ main(int argc, char* argv[])
<< "short GI"
<< "\t\t"
<< "Throughput" << '\n';
int minMcs = 0;
int maxMcs = 7;
if (mcs >= 0 && mcs <= 7)
uint8_t minMcs = 0;
uint8_t maxMcs = 7;
if (mcsStr.empty())
{
minMcs = mcs;
maxMcs = mcs;
for (uint8_t mcs = minMcs; mcs <= maxMcs; ++mcs)
{
mcsValues.push_back(mcs);
}
}
for (int mcs = minMcs; mcs <= maxMcs; mcs++)
else
{
AttributeContainerValue<UintegerValue, ',', std::vector> attr;
auto checker = DynamicCast<AttributeContainerChecker>(MakeAttributeContainerChecker(attr));
checker->SetItemChecker(MakeUintegerChecker<uint8_t>());
attr.DeserializeFromString(mcsStr, checker);
mcsValues = attr.Get();
std::sort(mcsValues.begin(), mcsValues.end());
}
for (const auto mcs : mcsValues)
{
uint8_t index = 0;
double previous = 0;

View File

@@ -6,6 +6,7 @@
* Author: Sebastien Deronne <sebastien.deronne@gmail.com>
*/
#include "ns3/attribute-container.h"
#include "ns3/boolean.h"
#include "ns3/command-line.h"
#include "ns3/config.h"
@@ -29,6 +30,9 @@
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
#include <algorithm>
#include <vector>
// This is a simple example in order to show how to configure an IEEE 802.11ac Wi-Fi network.
//
// It outputs the UDP or TCP goodput for every VHT MCS value, which depends on the MCS value (0 to
@@ -58,7 +62,8 @@ main(int argc, char* argv[])
bool use80Plus80{false};
Time simulationTime{"10s"};
meter_u distance{1.0};
int mcs{-1}; // -1 indicates an unset value
std::string mcsStr;
std::vector<uint64_t> mcsValues;
std::string phyModel{"Yans"};
double minExpectedThroughput{0.0};
double maxExpectedThroughput{0.0};
@@ -71,7 +76,10 @@ main(int argc, char* argv[])
cmd.AddValue("udp", "UDP if set to 1, TCP otherwise", udp);
cmd.AddValue("useRts", "Enable/disable RTS/CTS", useRts);
cmd.AddValue("use80Plus80", "Enable/disable use of 80+80 MHz", use80Plus80);
cmd.AddValue("mcs", "if set, limit testing to a specific MCS (0-9)", mcs);
cmd.AddValue(
"mcs",
"list of comma separated MCS values to test; if unset, all MCS values (0-9) are tested",
mcsStr);
cmd.AddValue("phyModel",
"PHY model to use (Yans or Spectrum). If 80+80 MHz is enabled, then Spectrum is "
"automatically selected",
@@ -108,14 +116,27 @@ main(int argc, char* argv[])
<< "short GI"
<< "\t\t"
<< "Throughput" << '\n';
int minMcs = 0;
int maxMcs = 9;
if (mcs >= 0 && mcs <= 9)
uint8_t minMcs = 0;
uint8_t maxMcs = 9;
if (mcsStr.empty())
{
minMcs = mcs;
maxMcs = mcs;
for (uint8_t mcs = minMcs; mcs <= maxMcs; ++mcs)
{
mcsValues.push_back(mcs);
}
}
for (int mcs = minMcs; mcs <= maxMcs; mcs++)
else
{
AttributeContainerValue<UintegerValue, ',', std::vector> attr;
auto checker = DynamicCast<AttributeContainerChecker>(MakeAttributeContainerChecker(attr));
checker->SetItemChecker(MakeUintegerChecker<uint8_t>());
attr.DeserializeFromString(mcsStr, checker);
mcsValues = attr.Get();
std::sort(mcsValues.begin(), mcsValues.end());
}
for (const auto mcs : mcsValues)
{
uint8_t index = 0;
double previous = 0;