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  // Creating the reference system. Note, currently the satellite module supports
99  // only one reference system, which is named as "Scenario72". The string is utilized
100  // in mapping the scenario to the needed reference system configuration files. Arbitrary
101  // scenario name results in fatal error.
102  Ptr<SatHelper> helper = simulationHelper->CreateSatScenario(satScenario);
103 
104  // get users
105  NodeContainer utUsers = helper->GetUtUsers();
106  NodeContainer gwUsers = helper->GetGwUsers();
107 
108  ThreeGppHttpHelper httpHelper;
109  httpHelper.InstallUsingIpv4(gwUsers.Get(0), utUsers);
110  httpHelper.GetServer().Start(Seconds(1.0));
111 
112  auto apps = httpHelper.GetClients();
113  apps.Start(Seconds(3.0));
114 
115  uint32_t i = 0;
116  std::vector<Ptr<ClientRxTracePlot>> plots;
117  for (auto app = apps.Begin(); app != apps.End(); app++, i++)
118  {
119  std::stringstream plotName;
120  plotName << "3GPP-HTTP-client-" << i << "-trace";
121  plots.push_back(CreateObject<ClientRxTracePlot>(*app, plotName.str()));
122  }
123 
124  NS_LOG_INFO("--- sat-http-example ---");
125  NS_LOG_INFO(" Scenario used: " << scenario);
126  NS_LOG_INFO(" ");
127 
128  simulationHelper->EnableProgressLogs();
129 
130  // Add PLT statistics
131  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
132  s->AddGlobalFwdAppPlt(SatStatsHelper::OUTPUT_SCALAR_FILE);
133  s->AddGlobalFwdAppPlt(SatStatsHelper::OUTPUT_SCATTER_FILE);
134  s->AddPerUtFwdAppPlt(SatStatsHelper::OUTPUT_SCALAR_FILE);
135  s->AddPerUtFwdAppPlt(SatStatsHelper::OUTPUT_SCATTER_FILE);
136  s->AddPerGwFwdAppPlt(SatStatsHelper::OUTPUT_SCALAR_FILE);
137  s->AddPerGwFwdAppPlt(SatStatsHelper::OUTPUT_SCATTER_FILE);
138 
139  simulationHelper->RunSimulation();
140 
141  plots.clear();
142 
143  return 0;
144 
145 } // 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.