sat-nrtv-example.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Budiarto Herman <budiarto.herman@magister.fi>
19  *
20  */
21 
22 #include "ns3/core-module.h"
23 #include "ns3/internet-module.h"
24 #include "ns3/network-module.h"
25 #include "ns3/satellite-module.h"
26 #include "ns3/traffic-module.h"
27 
28 using namespace ns3;
29 
55 NS_LOG_COMPONENT_DEFINE("sat-nrtv-example");
56 
57 int
58 main(int argc, char* argv[])
59 {
60  // a workaround to partially resolve weird splitting in lower layer
61  // Config::SetDefault ("ns3::TcpL4Protocol::SocketType",
62  // StringValue ("ns3::TcpRfc793"));
63 
64  std::string scenario = "simple";
65  double duration = 100;
67 
69  auto simulationHelper = CreateObject<SimulationHelper>("example-nrtv");
70  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
71  Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
72 
73  // read command line parameters given by user
74  CommandLine cmd;
75  cmd.AddValue("scenario", "Test scenario to use. (simple, larger or full)", scenario);
76  cmd.AddValue("duration", "Simulation duration (in seconds)", duration);
77  simulationHelper->AddDefaultUiArguments(cmd);
78  cmd.Parse(argc, argv);
79 
80  if (scenario == "larger")
81  {
82  satScenario = SatHelper::LARGER;
83  }
84  else if (scenario == "full")
85  {
86  satScenario = SatHelper::FULL;
87  }
88 
90  simulationHelper->SetOutputTag(scenario);
91  simulationHelper->SetSimulationTime(duration);
92 
93  // LogComponentEnableAll (LOG_PREFIX_ALL);
94  // LogComponentEnable ("NrtvClient", LOG_LEVEL_ALL);
95  // LogComponentEnable ("NrtvServer", LOG_LEVEL_ALL);
96  LogComponentEnable("sat-nrtv-example", LOG_LEVEL_INFO);
97 
98  // remove next line from comments to run real time simulation
99  // GlobalValue::Bind ("SimulatorImplementationType", StringValue
100  // ("ns3::RealtimeSimulatorImpl"));
101 
102  // Creating the reference system. Note, currently the satellite module supports
103  // only one reference system, which is named as "Scenario72". The string is utilized
104  // in mapping the scenario to the needed reference system configuration files. Arbitrary
105  // scenario name results in fatal error.
106  Ptr<SatHelper> helper = simulationHelper->CreateSatScenario(satScenario);
107 
108  // get users
109  NodeContainer utUsers = helper->GetUtUsers();
110  NodeContainer gwUsers = helper->GetGwUsers();
111 
112  NrtvHelper nrtvHelper(TypeId::LookupByName("ns3::TcpSocketFactory"));
113  nrtvHelper.InstallUsingIpv4(gwUsers.Get(0), utUsers);
114  nrtvHelper.GetServer().Start(Seconds(1.0));
115 
116  auto apps = nrtvHelper.GetClients();
117  apps.Start(Seconds(3.0));
118  uint32_t i = 0;
119  std::vector<Ptr<ClientRxTracePlot>> plots;
120  for (auto app = apps.Begin(); app != apps.End(); app++, i++)
121  {
122  std::stringstream plotName;
123  plotName << "NRTV-TCP-client-" << i << "-trace";
124  plots.push_back(CreateObject<ClientRxTracePlot>(*app, plotName.str()));
125  }
126 
127  NS_LOG_INFO("--- sat-nrtv-example ---");
128  NS_LOG_INFO(" Scenario used: " << scenario);
129  NS_LOG_INFO(" ");
130 
131  simulationHelper->RunSimulation();
132  plots.clear();
133 
134  return 0;
135 
136 } // end of `int main (int argc, char *argv[])`
PreDefinedScenario_t
Values for pre-defined scenarios to be used by helper when building satellite network topology base.
@ LARGER
LARGER Larger scenario used as base.
@ FULL
FULL Full scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.