sat-http-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-http-example");
56 
57 int
58 main(int argc, char* argv[])
59 {
60  std::string scenario = "simple";
61  double duration = 1000;
63 
64  Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
65 
66  auto simulationHelper = CreateObject<SimulationHelper>("example-http");
67  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
68 
69  // read command line parameters given by user
70  CommandLine cmd;
71  cmd.AddValue("scenario", "Test scenario to use. (simple, larger or full)", scenario);
72  cmd.AddValue("duration", "Simulation duration (in seconds)", duration);
73  simulationHelper->AddDefaultUiArguments(cmd);
74  cmd.Parse(argc, argv);
75 
76  if (scenario == "larger")
77  {
78  satScenario = SatHelper::LARGER;
79  }
80  else if (scenario == "full")
81  {
82  satScenario = SatHelper::FULL;
83  }
84 
86  simulationHelper->SetSimulationTime(duration);
87  simulationHelper->SetOutputTag(scenario);
88 
89  // LogComponentEnableAll (LOG_PREFIX_ALL);
90  // LogComponentEnable ("HttpClient", LOG_LEVEL_ALL);
91  // LogComponentEnable ("HttpServer", LOG_LEVEL_ALL);
92  LogComponentEnable("sat-http-example", LOG_LEVEL_INFO);
93 
94  // remove next line from comments to run real time simulation
95  // GlobalValue::Bind ("SimulatorImplementationType", StringValue
96  // ("ns3::RealtimeSimulatorImpl"));
97 
98  simulationHelper->LoadScenario("geo-33E");
99 
100  // Creating the reference system.
101  simulationHelper->CreateSatScenario(satScenario);
102 
103  // get users
104  NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
105  NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
106 
107  ThreeGppHttpHelper httpHelper;
108  httpHelper.InstallUsingIpv4(gwUsers.Get(0), utUsers);
109  httpHelper.GetServer().Start(Seconds(1.0));
110 
111  auto apps = httpHelper.GetClients();
112  apps.Start(Seconds(3.0));
113 
114  uint32_t i = 0;
115  std::vector<Ptr<ClientRxTracePlot>> plots;
116  for (auto app = apps.Begin(); app != apps.End(); app++, i++)
117  {
118  std::stringstream plotName;
119  plotName << "3GPP-HTTP-client-" << i << "-trace";
120  plots.push_back(CreateObject<ClientRxTracePlot>(*app, plotName.str()));
121  }
122 
123  NS_LOG_INFO("--- sat-http-example ---");
124  NS_LOG_INFO(" Scenario used: " << scenario);
125  NS_LOG_INFO(" ");
126 
127  simulationHelper->EnableProgressLogs();
128 
129  // Add PLT statistics
130  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
131  s->AddGlobalFwdAppPlt(SatStatsHelper::OUTPUT_SCALAR_FILE);
132  s->AddGlobalFwdAppPlt(SatStatsHelper::OUTPUT_SCATTER_FILE);
133  s->AddPerUtFwdAppPlt(SatStatsHelper::OUTPUT_SCALAR_FILE);
134  s->AddPerUtFwdAppPlt(SatStatsHelper::OUTPUT_SCATTER_FILE);
135  s->AddPerGwFwdAppPlt(SatStatsHelper::OUTPUT_SCALAR_FILE);
136  s->AddPerGwFwdAppPlt(SatStatsHelper::OUTPUT_SCATTER_FILE);
137 
138  simulationHelper->RunSimulation();
139 
140  plots.clear();
141 
142  return 0;
143 
144 } // 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.