Loading...
Searching...
No Matches
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
30using namespace ns3;
31
41
42NS_LOG_COMPONENT_DEFINE("sat-mobility-example");
43
44int
45main(int argc, char* argv[])
46{
47 // Enable info logs
48 LogComponentEnable("sat-mobility-example", LOG_LEVEL_INFO);
49
50 // Variables
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::SatConf::ForwardLinkRegenerationMode",
83 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
85
87 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
88 Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
89
90 Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionEachRequest",
91 BooleanValue(updatePositionEachRequest));
92 Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionPeriod",
93 TimeValue(updatePositionPeriod));
94
95 Config::SetDefault("ns3::SatGwMac::DisableSchedulingIfNoDeviceConnected", BooleanValue(true));
96 Config::SetDefault("ns3::SatOrbiterMac::DisableSchedulingIfNoDeviceConnected",
97 BooleanValue(true));
98
99 simulationHelper->SetSimulationTime(simLength);
100 simulationHelper->SetUserCountPerUt(endUsersPerUt);
101 simulationHelper->SetUtCountPerBeam(utsPerBeam);
102
103 // Set beam ID
104 std::set<uint32_t> beamSetAll = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
105 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
106 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
107 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
108 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72};
109 simulationHelper->SetBeamSet(beamSetAll);
110
111 simulationHelper->LoadScenario("leo-iss");
112
113 // Create reference system
114 simulationHelper->CreateSatScenario();
115
116 // setup CBR traffic
117 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
120 interval,
121 packetSize,
122 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
123 Singleton<SatTopology>::Get()->GetUtUserNodes(),
124 appStartTime,
125 simLength,
126 MilliSeconds(50));
127
128 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
131 interval,
132 packetSize,
133 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
134 Singleton<SatTopology>::Get()->GetUtUserNodes(),
135 appStartTime,
136 simLength,
137 MilliSeconds(50));
138
139 NS_LOG_INFO("--- sat-mobility-example ---");
140 NS_LOG_INFO(" Packet size in bytes: " << packetSize);
141 NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
142 NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
143 NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
144 NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
145 NS_LOG_INFO(" ");
146
147 // Set statistics
148 Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
149 simulationHelper->EnableProgressLogs();
150
151 Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
152 Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
153 Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
154 ConfigStore outputConfig;
155 outputConfig.ConfigureDefaults();
156
157 s->AddGlobalFwdPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
158 s->AddGlobalFwdPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
159 s->AddGlobalRtnPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
160 s->AddGlobalRtnPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
161
162 s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
163 s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
164 s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
165 s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
166
167 s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
168 s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
169 s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
170 s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
171
172 simulationHelper->RunSimulation();
173
174 return 0;
175}
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.