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  bool updatePositionEachRequest(false);
58  Time updatePositionPeriod(Seconds(1));
59 
60  Time appStartTime = Seconds(0.1);
61  Time simLength(Seconds(7200.0));
62 
63  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("sat-mobility-example");
64 
65  // Parse command-line
66  CommandLine cmd;
67  cmd.AddValue("PacketSize", "UDP packet size (in bytes)", packetSize);
68  cmd.AddValue("Interval", "CBR interval (in seconds, or add unit)", interval);
69  cmd.AddValue("SimLength", "Simulation length (in seconds, or add unit)", simLength);
70  cmd.AddValue("UpdatePositionEachRequest",
71  "Enable position computation each time a packet is sent",
72  updatePositionEachRequest);
73  cmd.AddValue("UpdatePositionPeriod",
74  "Period of satellite position refresh, if not update on each request (in seconds, "
75  "or add unit)",
76  updatePositionPeriod);
77  simulationHelper->AddDefaultUiArguments(cmd);
78  cmd.Parse(argc, argv);
79 
81  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
82  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
83 
84  Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionEachRequest",
85  BooleanValue(updatePositionEachRequest));
86  Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionPeriod",
87  TimeValue(updatePositionPeriod));
88 
89  simulationHelper->SetSimulationTime(simLength);
90  simulationHelper->SetUserCountPerUt(endUsersPerUt);
91  simulationHelper->SetUtCountPerBeam(utsPerBeam);
92 
93  // Set beam ID
94  std::stringstream beamsEnabled;
95  beamsEnabled << beamId;
96  simulationHelper->SetBeams(beamsEnabled.str());
97 
98  simulationHelper->LoadScenario("leo-iss");
99 
100  // Create reference system
101  simulationHelper->CreateSatScenario();
102 
103  // setup CBR traffic
104  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
107  interval,
108  packetSize,
109  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
110  Singleton<SatTopology>::Get()->GetUtUserNodes(),
111  appStartTime,
112  simLength,
113  MilliSeconds(50));
114 
115  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
118  interval,
119  packetSize,
120  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
121  Singleton<SatTopology>::Get()->GetUtUserNodes(),
122  appStartTime,
123  simLength,
124  MilliSeconds(50));
125 
126  NS_LOG_INFO("--- sat-mobility-example ---");
127  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
128  NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
129  NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
130  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
131  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
132  NS_LOG_INFO(" ");
133 
134  // Set statistics
135  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
136  simulationHelper->EnableProgressLogs();
137 
138  Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
139  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
140  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
141  ConfigStore outputConfig;
142  outputConfig.ConfigureDefaults();
143 
144  s->AddGlobalFwdPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
145  s->AddGlobalFwdPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
146  s->AddGlobalRtnPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
147  s->AddGlobalRtnPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
148 
149  s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
150  s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
151  s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
152  s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
153 
154  s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
155  s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
156  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
157  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
158 
159  simulationHelper->RunSimulation();
160 
161  return 0;
162 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.