sat-mobility-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: Bastien Tauran <bastien.tauran@viveris.fr>
19  *
20  */
21 
22 #include "ns3/applications-module.h"
23 #include "ns3/config-store-module.h"
24 #include "ns3/core-module.h"
25 #include "ns3/internet-module.h"
26 #include "ns3/network-module.h"
27 #include "ns3/satellite-module.h"
28 #include "ns3/traffic-module.h"
29 
30 using namespace ns3;
31 
41 NS_LOG_COMPONENT_DEFINE("sat-mobility-example");
42 
43 int
44 main(int argc, char* argv[])
45 {
46  // Enable info logs
47  LogComponentEnable("sat-mobility-example", LOG_LEVEL_INFO);
48 
49  // Variables
50  uint32_t beamId = 17;
51  uint32_t endUsersPerUt(1);
52  uint32_t utsPerBeam(1);
53 
54  uint32_t packetSize(100);
55  Time interval(Seconds(10.0));
56 
57  std::string tleFileName("tle_iss_zarya.txt");
58  std::string startDate("2014-09-29 12:05:48");
59  bool updatePositionEachRequest(false);
60  Time updatePositionPeriod(Seconds(1));
61 
62  Time appStartTime = Seconds(0.1);
63  Time simLength(Seconds(7200.0));
64 
65  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("sat-mobility-example");
66 
67  // Parse command-line
68  CommandLine cmd;
69  cmd.AddValue("PacketSize", "UDP packet size (in bytes)", packetSize);
70  cmd.AddValue("Interval", "CBR interval (in seconds, or add unit)", interval);
71  cmd.AddValue("SimLength", "Simulation length (in seconds, or add unit)", simLength);
72  cmd.AddValue("TleFileName",
73  "Name of TLE file to load (path from data/tle folder)",
74  tleFileName);
75  cmd.AddValue("StartDate",
76  "Simulation absolute UTC start time (format: YYYY-MM-DD hh:mm:ss)",
77  startDate);
78  cmd.AddValue("UpdatePositionEachRequest",
79  "Enable position computation each time a packet is sent",
80  updatePositionEachRequest);
81  cmd.AddValue("UpdatePositionPeriod",
82  "Period of satellite position refresh, if not update on each request (in seconds, "
83  "or add unit)",
84  updatePositionPeriod);
85  simulationHelper->AddDefaultUiArguments(cmd);
86  cmd.Parse(argc, argv);
87 
89  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
90  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
91 
92  Config::SetDefault("ns3::SatAntennaGainPatternContainer::PatternsFolder",
93  StringValue("SatAntennaGain72BeamsShifted"));
94 
95  Config::SetDefault("ns3::SatHelper::SatMobilitySGP4Enabled", BooleanValue(true));
96  Config::SetDefault("ns3::SatHelper::SatMobilitySGP4TleFileName", StringValue(tleFileName));
97  Config::SetDefault("ns3::SatSGP4MobilityModel::StartDateStr", StringValue(startDate));
98  Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionEachRequest",
99  BooleanValue(updatePositionEachRequest));
100  Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionPeriod",
101  TimeValue(updatePositionPeriod));
102 
103  simulationHelper->SetSimulationTime(simLength);
104  simulationHelper->SetUserCountPerUt(endUsersPerUt);
105  simulationHelper->SetUtCountPerBeam(utsPerBeam);
106 
107  // Set beam ID
108  std::stringstream beamsEnabled;
109  beamsEnabled << beamId;
110  simulationHelper->SetBeams(beamsEnabled.str());
111 
112  // Create reference system
113  simulationHelper->CreateSatScenario();
114 
115  // setup CBR traffic
116  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(interval));
117  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
118 
119  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
122  appStartTime,
123  simLength,
124  Seconds(0.05));
125 
126  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
129  appStartTime,
130  simLength,
131  Seconds(0.05));
132 
133  NS_LOG_INFO("--- sat-mobility-example ---");
134  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
135  NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
136  NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
137  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
138  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
139  NS_LOG_INFO(" ");
140 
141  // Set statistics
142  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
143  simulationHelper->EnableProgressLogs();
144 
145  Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
146  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
147  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
148  ConfigStore outputConfig;
149  outputConfig.ConfigureDefaults();
150 
151  s->AddGlobalFwdPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
152  s->AddGlobalFwdPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
153  s->AddGlobalRtnPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
154  s->AddGlobalRtnPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
155 
156  s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
157  s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
158  s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
159  s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
160 
161  s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
162  s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
163  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
164  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
165 
166  simulationHelper->RunSimulation();
167 
168  return 0;
169 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.