examples: Avoid wifi examples to fail if non-default parameters are used

This commit is contained in:
Sébastien Deronne
2017-02-05 19:40:56 +01:00
parent e7a33557c0
commit f111001430
8 changed files with 67 additions and 44 deletions

View File

@@ -62,12 +62,14 @@ int main (int argc, char *argv[])
uint64_t simulationTime = 10; //seconds
double distance = 5; //meters
bool enablePcap = 0;
bool verifyResults = 0; //used for regression
CommandLine cmd;
cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize);
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("distance", "Distance in meters between the station and the access point", distance);
cmd.AddValue ("enablePcap", "Enable/disable pcap file generation", enablePcap);
cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
cmd.Parse (argc, argv);
NodeContainer wifiStaNode;
@@ -310,7 +312,7 @@ int main (int argc, char *argv[])
uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverAppA.Get (0))->GetReceived ();
double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput for AC_BE with default TXOP limit (0ms): " << throughput << " Mbit/s" << '\n';
if (throughput < 28 || throughput > 29)
if (verifyResults && (throughput < 28 || throughput > 29))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -319,7 +321,7 @@ int main (int argc, char *argv[])
totalPacketsThrough = DynamicCast<UdpServer> (serverAppB.Get (0))->GetReceived ();
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput for AC_BE with non-default TXOP limit (3.008ms): " << throughput << " Mbit/s" << '\n';
if (throughput < 35.5 || throughput > 36.5)
if (verifyResults && (throughput < 35.5 || throughput > 36.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -328,7 +330,7 @@ int main (int argc, char *argv[])
totalPacketsThrough = DynamicCast<UdpServer> (serverAppC.Get (0))->GetReceived ();
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput for AC_VI with default TXOP limit (3.008ms): " << throughput << " Mbit/s" << '\n';
if (throughput < 36 || throughput > 37)
if (verifyResults && (throughput < 36 || throughput > 37))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -337,7 +339,7 @@ int main (int argc, char *argv[])
totalPacketsThrough = DynamicCast<UdpServer> (serverAppD.Get (0))->GetReceived ();
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput for AC_VI with non-default TXOP limit (0ms): " << throughput << " Mbit/s" << '\n';
if (throughput < 31.5 || throughput > 32.5)
if (verifyResults && (throughput < 31.5 || throughput > 32.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);

View File

@@ -30,13 +30,13 @@ cpp_examples = [
("ofdm-validation", "True", "True"),
("ofdm-vht-validation", "True", "True"),
("ofdm-he-validation", "True", "True"),
("ht-wifi-network --simulationTime=0.1", "True", "True"),
("vht-wifi-network --simulationTime=0.1", "True", "True"),
("he-wifi-network --simulationTime=0.25", "True", "True"),
("simple-ht-hidden-stations --simulationTime=1", "True", "True"),
("ht-wifi-network --simulationTime=0.1 --minExpectedThroughput=5 --maxExpectedThroughput=134", "True", "True"),
("vht-wifi-network --simulationTime=0.1 --minExpectedThroughput=5 --maxExpectedThroughput=555", "True", "True"),
("he-wifi-network --simulationTime=0.25 --minExpectedThroughput=6.5 --maxExpectedThroughput=754", "True", "True"),
("simple-ht-hidden-stations --simulationTime=1 --minExpectedThroughput=16.7 --maxExpectedThroughput=16.8", "True", "True"),
("mixed-network --simulationTime=1", "True", "True"),
("wifi-aggregation --simulationTime=1", "True", "True"),
("80211e-txop --simulationTime=1", "True", "True"),
("wifi-aggregation --simulationTime=1 --verifyResults=1", "True", "True"),
("80211e-txop --simulationTime=1 --verifyResults=1", "True", "True"),
("wifi-multi-tos --simulationTime=1 --nWifi=16 --useRts=1 --useShortGuardInterval=1", "True", "True"),
("wifi-tcp", "True", "True"),
("wifi-spectrum-per-example --distance=52 --index=3 --wifiType=ns3::SpectrumWifiPhy --simulationTime=1", "True", "True"),

View File

@@ -51,12 +51,16 @@ int main (int argc, char *argv[])
double simulationTime = 10; //seconds
double distance = 1.0; //meters
int mcs = -1; // -1 indicates an unset value
double minExpectedThroughput = 0;
double maxExpectedThroughput = 0;
CommandLine cmd;
cmd.AddValue ("distance", "Distance in meters between the station and the access point", distance);
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("udp", "UDP if set to 1, TCP otherwise", udp);
cmd.AddValue ("mcs", "if set, limit testing to a specific MCS (0-7)", mcs);
cmd.AddValue ("minExpectedThroughput", "if set, simulation fails if the lowest throughput is below this value", minExpectedThroughput);
cmd.AddValue ("maxExpectedThroughput", "if set, simulation fails if the highest throughput is above this value", maxExpectedThroughput);
cmd.Parse (argc,argv);
double prevThroughput [12];
@@ -216,18 +220,18 @@ int main (int argc, char *argv[])
double throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << gi << " ns\t\t\t" << throughput << " Mbit/s" << std::endl;
//test first element
if (udp && mcs == 0 && channelWidth == 20 && gi == 3200)
if (mcs == 0 && channelWidth == 20 && gi == 3200)
{
if (throughput < 6 || throughput > 7)
if (throughput < minExpectedThroughput)
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not expected!");
exit (1);
}
}
//test last element
if (udp && mcs == 11 && channelWidth == 160 && gi == 800)
if (mcs == 11 && channelWidth == 160 && gi == 800)
{
if (throughput < 750 || throughput > 800)
if (maxExpectedThroughput > 0 && throughput > maxExpectedThroughput)
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not expected!");
exit (1);

View File

@@ -53,6 +53,8 @@ int main (int argc, char *argv[])
double distance = 1.0; //meters
double frequency = 5.0; //whether 2.4 or 5.0 GHz
int mcs = -1; // -1 indicates an unset value
double minExpectedThroughput = 0;
double maxExpectedThroughput = 0;
CommandLine cmd;
cmd.AddValue ("frequency", "Whether working in the 2.4 or 5.0 GHz band (other values gets rejected)", frequency);
@@ -60,6 +62,8 @@ int main (int argc, char *argv[])
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("udp", "UDP if set to 1, TCP otherwise", udp);
cmd.AddValue ("mcs", "if set, limit testing to a specific MCS (0-7)", mcs);
cmd.AddValue ("minExpectedThroughput", "if set, simulation fails if the lowest throughput is below this value", minExpectedThroughput);
cmd.AddValue ("maxExpectedThroughput", "if set, simulation fails if the highest throughput is above this value", maxExpectedThroughput);
cmd.Parse (argc,argv);
double prevThroughput [8];
@@ -234,18 +238,18 @@ int main (int argc, char *argv[])
double throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << sgi << "\t\t\t" << throughput << " Mbit/s" << std::endl;
//test first element
if (udp && mcs == 0 && channelWidth == 20 && sgi == 0)
if (mcs == 0 && channelWidth == 20 && sgi == 0)
{
if (throughput < 5.25 || throughput > 6.25)
if (throughput < minExpectedThroughput)
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not expected!");
exit (1);
}
}
//test last element
if (udp && mcs == 7 && channelWidth == 40 && sgi == 1)
if (mcs == 7 && channelWidth == 40 && sgi == 1)
{
if (throughput < 133 || throughput > 135)
if (maxExpectedThroughput > 0 && throughput > maxExpectedThroughput)
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not expected!");
exit (1);

View File

@@ -416,10 +416,13 @@ int main (int argc, char *argv[])
params.payloadSize = 1472; //bytes
params.simulationTime = 10; //seconds
bool verifyResults = 0; //used for regression
CommandLine cmd;
cmd.AddValue ("payloadSize", "Payload size in bytes", params.payloadSize);
cmd.AddValue ("simulationTime", "Simulation time in seconds", params.simulationTime);
cmd.AddValue ("isUdp", "UDP if set to 1, TCP otherwise", params.isUdp);
cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
cmd.Parse (argc, argv);
Experiment experiment;
@@ -427,7 +430,7 @@ int main (int argc, char *argv[])
params.testName = "g only with all g features disabled";
throughput = experiment.Run (params);
if (throughput < 22.5 || throughput > 23.5)
if (verifyResults && (throughput < 22.5 || throughput > 23.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -440,7 +443,7 @@ int main (int argc, char *argv[])
params.enableShortPlcpPreamble = false;
params.nWifiB = 0;
throughput = experiment.Run (params);
if (throughput < 29 || throughput > 30)
if (verifyResults && (throughput < 29 || throughput > 30))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -453,7 +456,7 @@ int main (int argc, char *argv[])
params.enableShortPlcpPreamble = false;
params.nWifiB = 1;
throughput = experiment.Run (params);
if (throughput < 22.5 || throughput > 23.5)
if (verifyResults && (throughput < 22.5 || throughput > 23.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -466,7 +469,7 @@ int main (int argc, char *argv[])
params.enableShortPlcpPreamble = true;
params.nWifiB = 1;
throughput = experiment.Run (params);
if (throughput < 22.5 || throughput > 23.5)
if (verifyResults && (throughput < 22.5 || throughput > 23.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -480,7 +483,7 @@ int main (int argc, char *argv[])
params.enableShortPlcpPreamble = false;
params.nWifiB = 1;
throughput = experiment.Run (params);
if (throughput < 19 || throughput > 20)
if (verifyResults && (throughput < 19 || throughput > 20))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -493,7 +496,7 @@ int main (int argc, char *argv[])
params.enableShortPlcpPreamble = true;
params.nWifiB = 1;
throughput = experiment.Run (params);
if (throughput < 19 || throughput > 20)
if (verifyResults && (throughput < 19 || throughput > 20))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -507,7 +510,7 @@ int main (int argc, char *argv[])
params.enableShortPlcpPreamble = false;
params.nWifiB = 1;
throughput = experiment.Run (params);
if (throughput < 20.5 || throughput > 21.5)
if (verifyResults && (throughput < 20.5 || throughput > 21.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -520,7 +523,7 @@ int main (int argc, char *argv[])
params.enableShortPlcpPreamble = true;
params.nWifiB = 1;
throughput = experiment.Run (params);
if (throughput < 20.5 || throughput > 21.5)
if (verifyResults && (throughput < 20.5 || throughput > 21.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -542,7 +545,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 0;
params.nGreenfieldHasTraffic = false;
throughput = experiment.Run (params);
if (throughput < 43 || throughput > 44)
if (verifyResults && (throughput < 43 || throughput > 44))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -564,7 +567,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 1;
params.nGreenfieldHasTraffic = true;
throughput = experiment.Run (params);
if (throughput < 44 || throughput > 45)
if (verifyResults && (throughput < 44 || throughput > 45))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -586,7 +589,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 1;
params.nGreenfieldHasTraffic = true;
throughput = experiment.Run (params);
if (throughput < 43 || throughput > 44)
if (verifyResults && (throughput < 43 || throughput > 44))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -608,7 +611,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 1;
params.nGreenfieldHasTraffic = true;
throughput = experiment.Run (params);
if (throughput < 43 || throughput > 44)
if (verifyResults && (throughput < 43 || throughput > 44))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -630,7 +633,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 1;
params.nGreenfieldHasTraffic = true;
throughput = experiment.Run (params);
if (throughput < 44 || throughput > 45)
if (verifyResults && (throughput < 44 || throughput > 45))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -654,7 +657,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 0;
params.nGreenfieldHasTraffic = false;
throughput = experiment.Run (params);
if (throughput < 44 || throughput > 45)
if (verifyResults && (throughput < 44 || throughput > 45))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -678,7 +681,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 0;
params.nGreenfieldHasTraffic = false;
throughput = experiment.Run (params);
if (throughput < 44 || throughput > 45)
if (verifyResults && (throughput < 44 || throughput > 45))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -702,7 +705,7 @@ int main (int argc, char *argv[])
params.nWifiNGreenfield = 0;
params.nGreenfieldHasTraffic = false;
throughput = experiment.Run (params);
if (throughput < 43 || throughput > 44)
if (verifyResults && (throughput < 43 || throughput > 44))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);

View File

@@ -52,12 +52,16 @@ int main (int argc, char *argv[])
uint32_t nMpdus = 1;
uint32_t maxAmpduSize = 0;
bool enableRts = 0;
double minExpectedThroughput = 0;
double maxExpectedThroughput = 0;
CommandLine cmd;
cmd.AddValue ("nMpdus", "Number of aggregated MPDUs", nMpdus);
cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize);
cmd.AddValue ("enableRts", "Enable RTS/CTS", enableRts); // 1: RTS/CTS enabled; 0: RTS/CTS disabled
cmd.AddValue ("enableRts", "Enable RTS/CTS", enableRts);
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("minExpectedThroughput", "if set, simulation fails if the lowest throughput is below this value", minExpectedThroughput);
cmd.AddValue ("maxExpectedThroughput", "if set, simulation fails if the highest throughput is above this value", maxExpectedThroughput);
cmd.Parse (argc, argv);
if (!enableRts)
@@ -166,7 +170,7 @@ int main (int argc, char *argv[])
uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput: " << throughput << " Mbit/s" << '\n';
if (throughput < 16.75 || throughput > 17)
if (throughput < minExpectedThroughput || (maxExpectedThroughput > 0 && throughput > maxExpectedThroughput))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);

View File

@@ -51,12 +51,16 @@ int main (int argc, char *argv[])
double simulationTime = 10; //seconds
double distance = 1.0; //meters
int mcs = -1; // -1 indicates an unset value
double minExpectedThroughput = 0;
double maxExpectedThroughput = 0;
CommandLine cmd;
cmd.AddValue ("distance", "Distance in meters between the station and the access point", distance);
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("udp", "UDP if set to 1, TCP otherwise", udp);
cmd.AddValue ("mcs", "if set, limit testing to a specific MCS (0-7)", mcs);
cmd.AddValue ("minExpectedThroughput", "if set, simulation fails if the lowest throughput is below this value", minExpectedThroughput);
cmd.AddValue ("maxExpectedThroughput", "if set, simulation fails if the highest throughput is above this value", maxExpectedThroughput);
cmd.Parse (argc,argv);
double prevThroughput [8];
@@ -221,18 +225,18 @@ int main (int argc, char *argv[])
double throughput = (rxBytes * 8) / (simulationTime * 1000000.0); //Mbit/s
std::cout << mcs << "\t\t\t" << channelWidth << " MHz\t\t\t" << sgi << "\t\t\t" << throughput << " Mbit/s" << std::endl;
//test first element
if (udp && mcs == 0 && channelWidth == 20 && sgi == 0)
if (mcs == 0 && channelWidth == 20 && sgi == 0)
{
if (throughput < 5.1 || throughput > 6.1)
if (throughput < minExpectedThroughput)
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not expected!");
exit (1);
}
}
//test last element
if (udp && mcs == 9 && channelWidth == 160 && sgi == 1)
if (mcs == 9 && channelWidth == 160 && sgi == 1)
{
if (throughput < 550 || throughput > 650)
if (maxExpectedThroughput > 0 && throughput > maxExpectedThroughput)
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not expected!");
exit (1);

View File

@@ -69,6 +69,7 @@ int main (int argc, char *argv[])
double distance = 5; //meters
bool enableRts = 0;
bool enablePcap = 0;
bool verifyResults = 0; //used for regression
CommandLine cmd;
cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize);
@@ -76,6 +77,7 @@ int main (int argc, char *argv[])
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("distance", "Distance in meters between the station and the access point", distance);
cmd.AddValue ("enablePcap", "Enable/disable pcap file generation", enablePcap);
cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
cmd.Parse (argc, argv);
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", enableRts ? StringValue ("0") : StringValue ("999999"));
@@ -282,7 +284,7 @@ int main (int argc, char *argv[])
uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverAppA.Get (0))->GetReceived ();
double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput with default configuration (A-MPDU aggregation enabled, 65kB): " << throughput << " Mbit/s" << '\n';
if (throughput < 59.5 || throughput > 60.5)
if (verifyResults && (throughput < 59.5 || throughput > 60.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -291,7 +293,7 @@ int main (int argc, char *argv[])
totalPacketsThrough = DynamicCast<UdpServer> (serverAppB.Get (0))->GetReceived ();
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput with aggregation disabled: " << throughput << " Mbit/s" << '\n';
if (throughput < 30 || throughput > 30.5)
if (verifyResults && (throughput < 30 || throughput > 30.5))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -300,7 +302,7 @@ int main (int argc, char *argv[])
totalPacketsThrough = DynamicCast<UdpServer> (serverAppC.Get (0))->GetReceived ();
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput with A-MPDU disabled and A-MSDU enabled (8kB): " << throughput << " Mbit/s" << '\n';
if (throughput < 51 || throughput > 52)
if (verifyResults && (throughput < 51 || throughput > 52))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);
@@ -309,7 +311,7 @@ int main (int argc, char *argv[])
totalPacketsThrough = DynamicCast<UdpServer> (serverAppD.Get (0))->GetReceived ();
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
std::cout << "Throughput with A-MPDU enabled (32kB) and A-MSDU enabled (4kB): " << throughput << " Mbit/s" << '\n';
if (throughput < 58 || throughput > 59)
if (verifyResults && (throughput < 58 || throughput > 59))
{
NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
exit (1);