Add CommandLine to all examples

This commit is contained in:
Peter D. Barnes, Jr.
2016-05-27 01:24:32 -04:00
parent a165e2edec
commit 38632b0e18
28 changed files with 88 additions and 4 deletions

View File

@@ -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 ----------------------------------------

View File

@@ -175,6 +175,9 @@ RxDrop (Ptr<const Packet> p)
int
main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
NodeContainer nodes;
nodes.Create (2);

View File

@@ -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);

View File

@@ -192,6 +192,9 @@ RxDrop (Ptr<PcapFileWrapper> file, Ptr<const Packet> p)
int
main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
NodeContainer nodes;
nodes.Create (2);

View File

@@ -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);

View File

@@ -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";

View File

@@ -24,4 +24,6 @@ int
main (int argc, char *argv[])
{
NS_LOG_UNCOND ("Scratch Simulator");
CommandLine cmd;
cmd.Parse (argc, argv);
}

View File

@@ -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<ConfigExample> a_obj = CreateObject<ConfigExample> ();

View File

@@ -145,6 +145,9 @@ test (void)
int
main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
while (true)
{
test ();

View File

@@ -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))

View File

@@ -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<LiIonEnergySource> 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> node = CreateObject<Node> ();

View File

@@ -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 <cmath>
@@ -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;

View File

@@ -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);

View File

@@ -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");
//

View File

@@ -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));

View File

@@ -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");

View File

@@ -87,6 +87,9 @@ RunSimulation (void)
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
RunSimulation ();
return 0;

View File

@@ -19,6 +19,7 @@
*/
#include <ns3/log.h>
#include <ns3/test.h>
#include <ns3/command-line.h>
#include <ns3/packet.h>
#include <ns3/lr-wpan-phy.h>
#include <ns3/lr-wpan-mac.h>
@@ -54,6 +55,9 @@ void SendOnePacket (Ptr<LrWpanPhy> sender, Ptr<LrWpanPhy> 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);

View File

@@ -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> lteHelper = CreateObject<LteHelper> ();
uint8_t bandwidth = 25;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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<PropagationLossModel> model,
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
GnuplotCollection gnuplots ("main-propagation-loss.pdf");
{

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -15,6 +15,7 @@
*
* Author: Junling Bu <linlinjavaer@gmail.com>
*/
#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 ();