From 2066cabb80223c5e2689de143da481d187f4a3cb Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Mon, 17 Jun 2024 12:58:46 +0200 Subject: [PATCH] examples: Allow users to specify a set of MCS values for wifi examples --- examples/wireless/wifi-eht-network.cc | 35 +++++++++++++++++++------ examples/wireless/wifi-he-network.cc | 35 +++++++++++++++++++------ examples/wireless/wifi-ht-network.cc | 36 ++++++++++++++++++++------ examples/wireless/wifi-vht-network.cc | 37 +++++++++++++++++++++------ 4 files changed, 111 insertions(+), 32 deletions(-) diff --git a/examples/wireless/wifi-eht-network.cc b/examples/wireless/wifi-eht-network.cc index a5ee804fd..d4e39f918 100644 --- a/examples/wireless/wifi-eht-network.cc +++ b/examples/wireless/wifi-eht-network.cc @@ -6,6 +6,7 @@ * Author: Sebastien Deronne */ +#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 #include #include #include @@ -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 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 attr; + auto checker = DynamicCast(MakeAttributeContainerChecker(attr)); + checker->SetItemChecker(MakeUintegerChecker()); + 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; diff --git a/examples/wireless/wifi-he-network.cc b/examples/wireless/wifi-he-network.cc index 602e20328..3fd9dcbc1 100644 --- a/examples/wireless/wifi-he-network.cc +++ b/examples/wireless/wifi-he-network.cc @@ -6,6 +6,7 @@ * Author: Sebastien Deronne */ +#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 #include // 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 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 attr; + auto checker = DynamicCast(MakeAttributeContainerChecker(attr)); + checker->SetItemChecker(MakeUintegerChecker()); + 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; diff --git a/examples/wireless/wifi-ht-network.cc b/examples/wireless/wifi-ht-network.cc index 4d94b2acd..2cd7e8202 100644 --- a/examples/wireless/wifi-ht-network.cc +++ b/examples/wireless/wifi-ht-network.cc @@ -31,6 +31,9 @@ #include "ns3/yans-wifi-channel.h" #include "ns3/yans-wifi-helper.h" +#include +#include + // 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 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 attr; + auto checker = DynamicCast(MakeAttributeContainerChecker(attr)); + checker->SetItemChecker(MakeUintegerChecker()); + 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; diff --git a/examples/wireless/wifi-vht-network.cc b/examples/wireless/wifi-vht-network.cc index 5aa3bc387..8827779fe 100644 --- a/examples/wireless/wifi-vht-network.cc +++ b/examples/wireless/wifi-vht-network.cc @@ -6,6 +6,7 @@ * Author: Sebastien Deronne */ +#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 +#include + // 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 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 attr; + auto checker = DynamicCast(MakeAttributeContainerChecker(attr)); + checker->SetItemChecker(MakeUintegerChecker()); + 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;