Loading...
Searching...
No Matches
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
28using namespace ns3;
29
55NS_LOG_COMPONENT_DEFINE("sat-nrtv-example");
56
57int
58main(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 simulationHelper->LoadScenario("geo-33E");
103
104 // Creating the reference system.
105 simulationHelper->CreateSatScenario(satScenario);
106
107 // get users
108 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
109 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
110
111 NrtvHelper nrtvHelper(TypeId::LookupByName("ns3::TcpSocketFactory"));
112 nrtvHelper.InstallUsingIpv4(gwUsers.Get(0), utUsers);
113 nrtvHelper.GetServer().Start(Seconds(1.0));
114
115 auto apps = nrtvHelper.GetClients();
116 apps.Start(Seconds(3.0));
117 uint32_t i = 0;
118 std::vector<Ptr<ClientRxTracePlot>> plots;
119 for (auto app = apps.Begin(); app != apps.End(); app++, i++)
120 {
121 std::stringstream plotName;
122 plotName << "NRTV-TCP-client-" << i << "-trace";
123 plots.push_back(CreateObject<ClientRxTracePlot>(*app, plotName.str()));
124 }
125
126 NS_LOG_INFO("--- sat-nrtv-example ---");
127 NS_LOG_INFO(" Scenario used: " << scenario);
128 NS_LOG_INFO(" ");
129
130 simulationHelper->RunSimulation();
131 plots.clear();
132
133 return 0;
134
135} // 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.