From 38632b0e18a9be4ddc118b171e4a51aa2512da95 Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr." Date: Fri, 27 May 2016 01:24:32 -0400 Subject: [PATCH] Add CommandLine to all examples --- examples/matrix-topology/matrix-topology.cc | 3 +++ examples/tutorial/fifth.cc | 3 +++ examples/tutorial/first.cc | 3 +++ examples/tutorial/sixth.cc | 3 +++ examples/wireless/wifi-blockack.cc | 5 ++++- examples/wireless/wifi-hidden-terminal.cc | 3 +++ scratch/subdir/scratch-simulator-subdir.cc | 2 ++ src/config-store/examples/config-store-save.cc | 3 +++ src/core/examples/main-test-sync.cc | 3 +++ src/core/examples/sample-simulator.py | 3 ++- src/energy/examples/li-ion-energy-source.cc | 6 +++++- src/energy/examples/rv-battery-model-test.cc | 4 ++++ src/fd-net-device/examples/dummy-network.cc | 3 +++ src/fd-net-device/examples/fd-tap-ping6.cc | 3 +++ src/fd-net-device/examples/realtime-dummy-network.cc | 2 ++ src/fd-net-device/examples/realtime-fd2fd-onoff.cc | 4 +++- src/internet/examples/main-simple.cc | 3 +++ src/lr-wpan/examples/lr-wpan-phy-test.cc | 4 ++++ src/lte/examples/lena-uplink-power-control.cc | 3 +++ src/mobility/examples/mobility-trace-example.cc | 3 +++ src/nix-vector-routing/examples/nix-simple.cc | 3 +++ src/propagation/examples/main-propagation-loss.cc | 4 ++++ src/sixlowpan/examples/example-ping-lr-wpan.cc | 3 +++ src/spectrum/examples/tv-trans-example.cc | 3 +++ src/spectrum/examples/tv-trans-regional-example.cc | 3 +++ src/tap-bridge/examples/tap-csma-virtual-machine.py | 3 +++ src/tap-bridge/examples/tap-wifi-virtual-machine.py | 3 +++ src/wave/examples/wave-simple-device.cc | 4 ++++ 28 files changed, 88 insertions(+), 4 deletions(-) diff --git a/examples/matrix-topology/matrix-topology.cc b/examples/matrix-topology/matrix-topology.cc index e6b6004bb..e7a1ae940 100644 --- a/examples/matrix-topology/matrix-topology.cc +++ b/examples/matrix-topology/matrix-topology.cc @@ -99,6 +99,9 @@ int main (int argc, char *argv[]) std::string adj_mat_file_name ("examples/matrix-topology/adjacency_matrix.txt"); std::string node_coordinates_file_name ("examples/matrix-topology/node_coordinates.txt"); + CommandLine cmd; + cmd.Parse (argc, argv); + // ---------- End of Simulation Variables ---------------------------------- // ---------- Read Adjacency Matrix ---------------------------------------- diff --git a/examples/tutorial/fifth.cc b/examples/tutorial/fifth.cc index 9964baa97..934d34dd8 100644 --- a/examples/tutorial/fifth.cc +++ b/examples/tutorial/fifth.cc @@ -175,6 +175,9 @@ RxDrop (Ptr p) int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + NodeContainer nodes; nodes.Create (2); diff --git a/examples/tutorial/first.cc b/examples/tutorial/first.cc index 747d5bc7e..73cdf1fe2 100644 --- a/examples/tutorial/first.cc +++ b/examples/tutorial/first.cc @@ -27,6 +27,9 @@ NS_LOG_COMPONENT_DEFINE ("FirstScriptExample"); int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + Time::SetResolution (Time::NS); LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); diff --git a/examples/tutorial/sixth.cc b/examples/tutorial/sixth.cc index 6901ad800..0f15ae62c 100644 --- a/examples/tutorial/sixth.cc +++ b/examples/tutorial/sixth.cc @@ -192,6 +192,9 @@ RxDrop (Ptr file, Ptr p) int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + NodeContainer nodes; nodes.Create (2); diff --git a/examples/wireless/wifi-blockack.cc b/examples/wireless/wifi-blockack.cc index 5807d9a6f..96ce5ed21 100644 --- a/examples/wireless/wifi-blockack.cc +++ b/examples/wireless/wifi-blockack.cc @@ -50,8 +50,11 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE ("Test-block-ack"); -int main (int argc, char const* argv[]) +int main (int argc, char * argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG); LogComponentEnable ("BlockAckManager", LOG_LEVEL_INFO); diff --git a/examples/wireless/wifi-hidden-terminal.cc b/examples/wireless/wifi-hidden-terminal.cc index 9b23ded09..69956e096 100644 --- a/examples/wireless/wifi-hidden-terminal.cc +++ b/examples/wireless/wifi-hidden-terminal.cc @@ -177,6 +177,9 @@ void experiment (bool enableCtsRts) int main (int argc, char **argv) { + CommandLine cmd; + cmd.Parse (argc, argv); + std::cout << "Hidden station experiment with RTS/CTS disabled:\n" << std::flush; experiment (false); std::cout << "------------------------------------------------\n"; diff --git a/scratch/subdir/scratch-simulator-subdir.cc b/scratch/subdir/scratch-simulator-subdir.cc index c23a18b6f..ef16be0be 100644 --- a/scratch/subdir/scratch-simulator-subdir.cc +++ b/scratch/subdir/scratch-simulator-subdir.cc @@ -24,4 +24,6 @@ int main (int argc, char *argv[]) { NS_LOG_UNCOND ("Scratch Simulator"); + CommandLine cmd; + cmd.Parse (argc, argv); } diff --git a/src/config-store/examples/config-store-save.cc b/src/config-store/examples/config-store-save.cc index 81c956da3..783b6d309 100644 --- a/src/config-store/examples/config-store-save.cc +++ b/src/config-store/examples/config-store-save.cc @@ -30,6 +30,9 @@ NS_OBJECT_ENSURE_REGISTERED (ConfigExample); // int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + Config::SetDefault ("ns3::ConfigExample::TestInt16", IntegerValue (-5)); Ptr a_obj = CreateObject (); diff --git a/src/core/examples/main-test-sync.cc b/src/core/examples/main-test-sync.cc index fd0275465..a5300bbe0 100644 --- a/src/core/examples/main-test-sync.cc +++ b/src/core/examples/main-test-sync.cc @@ -145,6 +145,9 @@ test (void) int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + while (true) { test (); diff --git a/src/core/examples/sample-simulator.py b/src/core/examples/sample-simulator.py index 9a7e02c2e..35d58550d 100755 --- a/src/core/examples/sample-simulator.py +++ b/src/core/examples/sample-simulator.py @@ -48,7 +48,8 @@ def CancelledEvent(): print "I should never be called... " def main(dummy_argv): - + ns.core.CommandLine().Parse(dummy_argv) + model = MyModel() v = ns.core.UniformRandomVariable() v.SetAttribute("Min", ns.core.DoubleValue (10)) diff --git a/src/energy/examples/li-ion-energy-source.cc b/src/energy/examples/li-ion-energy-source.cc index f6909b73d..c130e6b11 100644 --- a/src/energy/examples/li-ion-energy-source.cc +++ b/src/energy/examples/li-ion-energy-source.cc @@ -20,6 +20,7 @@ #include "ns3/log.h" #include "ns3/simulator.h" +#include "ns3/command-line.h" #include "ns3/simple-device-energy-model.h" #include "ns3/li-ion-energy-source.h" #include "ns3/energy-source-container.h" @@ -60,7 +61,10 @@ PrintCellInfo (Ptr es) int main (int argc, char **argv) { - // uncomment below to see the energy consumption details + CommandLine cmd; + cmd.Parse (argc, argv); + + // uncomment below to see the energy consumption details // LogComponentEnable ("LiIonEnergySource", LOG_LEVEL_DEBUG); Ptr node = CreateObject (); diff --git a/src/energy/examples/rv-battery-model-test.cc b/src/energy/examples/rv-battery-model-test.cc index 6373222e6..6841979e3 100644 --- a/src/energy/examples/rv-battery-model-test.cc +++ b/src/energy/examples/rv-battery-model-test.cc @@ -29,6 +29,7 @@ #include "ns3/simulator.h" #include "ns3/double.h" #include "ns3/config.h" +#include "ns3/command-line.h" #include "ns3/string.h" #include "ns3/yans-wifi-helper.h" #include @@ -636,6 +637,9 @@ BatteryLifetimeTest::CreateLoadProfiles (void) int main (int argc, char **argv) { + CommandLine cmd; + cmd.Parse (argc, argv); + NS_LOG_DEBUG ("Constant load run."); BatteryLifetimeTest test; diff --git a/src/fd-net-device/examples/dummy-network.cc b/src/fd-net-device/examples/dummy-network.cc index baca48398..45a5e666b 100644 --- a/src/fd-net-device/examples/dummy-network.cc +++ b/src/fd-net-device/examples/dummy-network.cc @@ -35,6 +35,9 @@ NS_LOG_COMPONENT_DEFINE ("DummyNetworkExample"); int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + NodeContainer nodes; nodes.Create (2); diff --git a/src/fd-net-device/examples/fd-tap-ping6.cc b/src/fd-net-device/examples/fd-tap-ping6.cc index 456752e35..3bfac1bf7 100644 --- a/src/fd-net-device/examples/fd-tap-ping6.cc +++ b/src/fd-net-device/examples/fd-tap-ping6.cc @@ -60,6 +60,9 @@ NS_LOG_COMPONENT_DEFINE ("TAPPing6Example"); int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + NS_LOG_INFO ("Ping6 Emulation Example with TAP"); // diff --git a/src/fd-net-device/examples/realtime-dummy-network.cc b/src/fd-net-device/examples/realtime-dummy-network.cc index 8df0c5c79..178ad184b 100644 --- a/src/fd-net-device/examples/realtime-dummy-network.cc +++ b/src/fd-net-device/examples/realtime-dummy-network.cc @@ -35,6 +35,8 @@ NS_LOG_COMPONENT_DEFINE ("RealtimeDummyNetworkExample"); int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl")); GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true)); diff --git a/src/fd-net-device/examples/realtime-fd2fd-onoff.cc b/src/fd-net-device/examples/realtime-fd2fd-onoff.cc index 96f1e35b1..2b91da137 100644 --- a/src/fd-net-device/examples/realtime-fd2fd-onoff.cc +++ b/src/fd-net-device/examples/realtime-fd2fd-onoff.cc @@ -56,7 +56,9 @@ NS_LOG_COMPONENT_DEFINE ("RealtimeFdNetDeviceSaturationExample"); int main (int argc, char *argv[]) { - + CommandLine cmd; + cmd.Parse (argc, argv); + uint16_t sinkPort = 8000; uint32_t packetSize = 10000; // bytes std::string dataRate("1000Mb/s"); diff --git a/src/internet/examples/main-simple.cc b/src/internet/examples/main-simple.cc index 18f331fe9..e09b72534 100644 --- a/src/internet/examples/main-simple.cc +++ b/src/internet/examples/main-simple.cc @@ -87,6 +87,9 @@ RunSimulation (void) int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + RunSimulation (); return 0; diff --git a/src/lr-wpan/examples/lr-wpan-phy-test.cc b/src/lr-wpan/examples/lr-wpan-phy-test.cc index 5f7ad6cf8..d4b838c07 100644 --- a/src/lr-wpan/examples/lr-wpan-phy-test.cc +++ b/src/lr-wpan/examples/lr-wpan-phy-test.cc @@ -19,6 +19,7 @@ */ #include #include +#include #include #include #include @@ -54,6 +55,9 @@ void SendOnePacket (Ptr sender, Ptr receiver) int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + LogComponentEnableAll (LOG_PREFIX_FUNC); LogComponentEnable ("LrWpanPhy", LOG_LEVEL_ALL); LogComponentEnable ("SingleModelSpectrumChannel", LOG_LEVEL_ALL); diff --git a/src/lte/examples/lena-uplink-power-control.cc b/src/lte/examples/lena-uplink-power-control.cc index 6d3fd8268..e13a303ea 100644 --- a/src/lte/examples/lena-uplink-power-control.cc +++ b/src/lte/examples/lena-uplink-power-control.cc @@ -45,6 +45,9 @@ int main (int argc, char *argv[]) Config::SetDefault ("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue (true)); Config::SetDefault ("ns3::LteUePowerControl::Alpha", DoubleValue (1.0)); + CommandLine cmd; + cmd.Parse (argc, argv); + Ptr lteHelper = CreateObject (); uint8_t bandwidth = 25; diff --git a/src/mobility/examples/mobility-trace-example.cc b/src/mobility/examples/mobility-trace-example.cc index 2759e0ffd..8f004af19 100644 --- a/src/mobility/examples/mobility-trace-example.cc +++ b/src/mobility/examples/mobility-trace-example.cc @@ -26,6 +26,9 @@ using namespace ns3; int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + NodeContainer sta; sta.Create (4); MobilityHelper mobility; diff --git a/src/nix-vector-routing/examples/nix-simple.cc b/src/nix-vector-routing/examples/nix-simple.cc index b3398ecb5..2f0aa97c5 100644 --- a/src/nix-vector-routing/examples/nix-simple.cc +++ b/src/nix-vector-routing/examples/nix-simple.cc @@ -45,6 +45,9 @@ NS_LOG_COMPONENT_DEFINE ("NixSimpleExample"); int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); diff --git a/src/propagation/examples/main-propagation-loss.cc b/src/propagation/examples/main-propagation-loss.cc index 9e5bd5b92..ad2d6a342 100644 --- a/src/propagation/examples/main-propagation-loss.cc +++ b/src/propagation/examples/main-propagation-loss.cc @@ -23,6 +23,7 @@ #include "ns3/constant-position-mobility-model.h" #include "ns3/config.h" +#include "ns3/command-line.h" #include "ns3/string.h" #include "ns3/boolean.h" #include "ns3/double.h" @@ -218,6 +219,9 @@ TestDeterministicByTime (Ptr model, int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + GnuplotCollection gnuplots ("main-propagation-loss.pdf"); { diff --git a/src/sixlowpan/examples/example-ping-lr-wpan.cc b/src/sixlowpan/examples/example-ping-lr-wpan.cc index 6448915f6..81e12184a 100644 --- a/src/sixlowpan/examples/example-ping-lr-wpan.cc +++ b/src/sixlowpan/examples/example-ping-lr-wpan.cc @@ -38,6 +38,9 @@ using namespace ns3; int main (int argc, char** argv) { + CommandLine cmd; + cmd.Parse (argc, argv); + #if 0 LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL); LogComponentEnable ("LrWpanMac",LOG_LEVEL_ALL); diff --git a/src/spectrum/examples/tv-trans-example.cc b/src/spectrum/examples/tv-trans-example.cc index f26a844cd..f41f57ca4 100644 --- a/src/spectrum/examples/tv-trans-example.cc +++ b/src/spectrum/examples/tv-trans-example.cc @@ -41,6 +41,9 @@ using namespace ns3; */ int main (int argc, char** argv) { + CommandLine cmd; + cmd.Parse (argc, argv); + /* nodes and positions */ NodeContainer tvTransmitterNodes; NodeContainer spectrumAnalyzerNodes; diff --git a/src/spectrum/examples/tv-trans-regional-example.cc b/src/spectrum/examples/tv-trans-regional-example.cc index c88203369..2b8fe812f 100644 --- a/src/spectrum/examples/tv-trans-regional-example.cc +++ b/src/spectrum/examples/tv-trans-regional-example.cc @@ -41,6 +41,9 @@ using namespace ns3; */ int main (int argc, char** argv) { + CommandLine cmd; + cmd.Parse (argc, argv); + /* random seed and run number; adjust these to change random draws */ RngSeedManager::SetSeed(1); RngSeedManager::SetRun(3); diff --git a/src/tap-bridge/examples/tap-csma-virtual-machine.py b/src/tap-bridge/examples/tap-csma-virtual-machine.py index 2dd130895..4b77bba3a 100644 --- a/src/tap-bridge/examples/tap-csma-virtual-machine.py +++ b/src/tap-bridge/examples/tap-csma-virtual-machine.py @@ -25,6 +25,9 @@ import ns.network import ns.tap_bridge def main(argv): + + ns.core.CommandLine().Parse(argv) + # # We are interacting with the outside, real, world. This means we have to # interact in real-time and therefore we have to use the real-time simulator diff --git a/src/tap-bridge/examples/tap-wifi-virtual-machine.py b/src/tap-bridge/examples/tap-wifi-virtual-machine.py index e076fdac7..6cd9e7ce7 100644 --- a/src/tap-bridge/examples/tap-wifi-virtual-machine.py +++ b/src/tap-bridge/examples/tap-wifi-virtual-machine.py @@ -25,6 +25,9 @@ import ns.tap_bridge import ns.wifi def main(argv): + + ns.core.CommandLine().Parse(argv) + # # We are interacting with the outside, real, world. This means we have to # interact in real-time and therefore we have to use the real-time simulator diff --git a/src/wave/examples/wave-simple-device.cc b/src/wave/examples/wave-simple-device.cc index 8ce5edda2..6ad831857 100644 --- a/src/wave/examples/wave-simple-device.cc +++ b/src/wave/examples/wave-simple-device.cc @@ -15,6 +15,7 @@ * * Author: Junling Bu */ +#include "ns3/command-line.h" #include "ns3/node.h" #include "ns3/packet.h" #include "ns3/simulator.h" @@ -249,6 +250,9 @@ WaveNetDeviceExample::SendWsaExample () int main (int argc, char *argv[]) { + CommandLine cmd; + cmd.Parse (argc, argv); + WaveNetDeviceExample example; std::cout << "run WAVE WSMP routing service case:" << std::endl; example.SendWsmpExample ();