Loading...
Searching...
No Matches
sat-group-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
63
64NS_LOG_COMPONENT_DEFINE("sat-group-example");
65
72
73void
74ConfigureAllStats(Ptr<SatStatsHelperContainer> s)
75{
77 SatStatsHelper::OUTPUT_SCATTER_FILE; // Only format compatible with all per group statistics
78
79 s->AddPerBeamFwdAppDelay(outputType);
80
81 s->AddPerGroupFwdAppDelay(outputType);
82 s->AddPerGroupRtnAppDelay(outputType);
83
84 s->AddPerGroupFwdDevDelay(outputType);
85 s->AddPerGroupRtnDevDelay(outputType);
86 s->AddPerGroupFwdMacDelay(outputType);
87 s->AddPerGroupRtnMacDelay(outputType);
88 s->AddPerGroupFwdPhyDelay(outputType);
89 s->AddPerGroupRtnPhyDelay(outputType);
90
91 s->AddAverageGroupFwdAppDelay(outputType);
92 s->AddAverageGroupRtnAppDelay(outputType);
93
94 s->AddAverageGroupFwdDevDelay(outputType);
95 s->AddAverageGroupRtnDevDelay(outputType);
96 s->AddAverageGroupFwdMacDelay(outputType);
97 s->AddAverageGroupRtnMacDelay(outputType);
98 s->AddAverageGroupFwdPhyDelay(outputType);
99 s->AddAverageGroupRtnPhyDelay(outputType);
100
101 s->AddPerGroupFwdAppJitter(outputType);
102 s->AddPerGroupRtnAppJitter(outputType);
103
104 s->AddPerGroupFwdDevJitter(outputType);
105 s->AddPerGroupRtnDevJitter(outputType);
106 s->AddPerGroupFwdMacJitter(outputType);
107 s->AddPerGroupRtnMacJitter(outputType);
108 s->AddPerGroupFwdPhyJitter(outputType);
109 s->AddPerGroupRtnPhyJitter(outputType);
110
111 s->AddAverageGroupFwdAppJitter(outputType);
112 s->AddAverageGroupRtnAppJitter(outputType);
113
114 s->AddAverageGroupFwdDevJitter(outputType);
115 s->AddAverageGroupRtnDevJitter(outputType);
116 s->AddAverageGroupFwdMacJitter(outputType);
117 s->AddAverageGroupRtnMacJitter(outputType);
118 s->AddAverageGroupFwdPhyJitter(outputType);
119 s->AddAverageGroupRtnPhyJitter(outputType);
120
121 s->AddPerGroupFwdAppPlt(outputType);
122 s->AddPerGroupRtnAppPlt(outputType);
123
124 s->AddAverageGroupFwdAppPlt(outputType);
125 s->AddAverageGroupRtnAppPlt(outputType);
126
127 s->AddPerGroupFwdQueueBytes(outputType);
128 s->AddPerGroupRtnQueueBytes(outputType);
129
130 s->AddPerGroupFwdQueuePackets(outputType);
131 s->AddPerGroupRtnQueuePackets(outputType);
132
133 s->AddPerGroupFwdSignallingLoad(outputType);
134 s->AddPerGroupRtnSignallingLoad(outputType);
135
136 s->AddPerGroupFwdCompositeSinr(outputType);
137 s->AddPerGroupRtnCompositeSinr(outputType);
138
139 s->AddPerGroupFwdAppThroughput(outputType);
140 s->AddPerGroupRtnAppThroughput(outputType);
141
142 s->AddPerGroupFwdUserDevThroughput(outputType);
143 s->AddPerGroupRtnFeederDevThroughput(outputType);
144 s->AddPerGroupFwdUserMacThroughput(outputType);
145 s->AddPerGroupRtnFeederMacThroughput(outputType);
146 s->AddPerGroupFwdUserPhyThroughput(outputType);
147 s->AddPerGroupRtnFeederPhyThroughput(outputType);
148
149 s->AddAverageGroupFwdAppThroughput(outputType);
150 s->AddAverageGroupRtnAppThroughput(outputType);
151
152 s->AddAverageGroupFwdUserDevThroughput(outputType);
153 s->AddAverageGroupRtnFeederDevThroughput(outputType);
154 s->AddAverageGroupFwdUserMacThroughput(outputType);
155 s->AddAverageGroupRtnFeederMacThroughput(outputType);
156 s->AddAverageGroupFwdUserPhyThroughput(outputType);
157 s->AddAverageGroupRtnFeederPhyThroughput(outputType);
158
159 s->AddPerGroupFwdUserDaPacketError(outputType);
160 s->AddPerGroupRtnFeederDaPacketError(outputType);
161 s->AddPerGroupFeederSlottedAlohaPacketError(outputType);
162 s->AddPerGroupFeederCrdsaPacketError(outputType);
163 s->AddPerGroupFeederEssaPacketError(outputType);
164
165 s->AddPerGroupFeederSlottedAlohaPacketCollision(outputType);
166 s->AddPerGroupFeederCrdsaPacketCollision(outputType);
167 s->AddPerGroupFeederEssaPacketCollision(outputType);
168
169 s->AddPerGroupCapacityRequest(outputType);
170
171 s->AddPerGroupResourcesGranted(outputType);
172}
173
174int
175main(int argc, char* argv[])
176{
177 // Enable info logs
178 LogComponentEnable("sat-group-example", LOG_LEVEL_INFO);
179
180 // Variables
181 uint32_t beamId = 1;
182 uint32_t endUsersPerUt(1);
183 uint32_t utsPerBeam(20);
184
185 uint32_t packetSize(1500);
186 Time interval(Seconds(1.0));
187
188 Time appStartTime = Seconds(0.1);
189 Time simLength(Seconds(60.0));
190
191 Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("sat-group-example");
192
193 // Parse command-line
194 CommandLine cmd;
195 cmd.AddValue("UtsPerBeam", "Number of UTs per beam", utsPerBeam);
196 cmd.AddValue("PacketSize", "UDP packet size (in bytes)", packetSize);
197 cmd.AddValue("Interval", "CBR interval (in seconds, or add unit)", interval);
198 cmd.AddValue("SimLength", "Simulation length (in seconds, or add unit)", simLength);
199 simulationHelper->AddDefaultUiArguments(cmd);
200 cmd.Parse(argc, argv);
201
203 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
204 Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
205
206 simulationHelper->SetSimulationTime(simLength);
207 simulationHelper->SetUserCountPerUt(endUsersPerUt);
208 simulationHelper->SetUtCountPerBeam(utsPerBeam);
209
210 // Set beam ID
211 std::stringstream beamsEnabled;
212 beamsEnabled << beamId;
213 simulationHelper->SetBeams(beamsEnabled.str());
214
215 Ptr<SatGroupHelper> groupHelper = simulationHelper->GetGroupHelper();
216
217 // Create group 5 and create 100 UTs (in addition to the ones are created by SimulationHelper,
218 // using utsPerBeam) to in this group
219 groupHelper->CreateUtNodesFromPosition(5, 10, GeoCoordinate(56.4243, -16.042, 122.427), 100000);
220
221 simulationHelper->LoadScenario("geo-33E");
222
223 // Create reference system
224 simulationHelper->CreateSatScenario();
225
226 // Create groups
227 NodeContainer utNodes = Singleton<SatTopology>::Get()->GetUtNodes();
228
230
231 if (creationMethod == GroupCreationMethod_t::MANUAL)
232 {
233 groupHelper->AddUtNodeToGroup(1, utNodes.Get(0));
234
235 NodeContainer nodes2To10;
236 for (uint32_t i = 2; i < 11; i++)
237 {
238 nodes2To10.Add(utNodes.Get(i));
239 }
240 groupHelper->AddUtNodesToGroup(2, nodes2To10);
241 }
242 else if (creationMethod == GroupCreationMethod_t::POSITION)
243 {
244 // Add all nodes less than 100km from node 0
245 groupHelper->CreateGroupFromPosition(
246 2,
247 utNodes,
248 utNodes.Get(0)->GetObject<SatMobilityModel>()->GetGeoPosition(),
249 100000);
250 }
251 else if (creationMethod == GroupCreationMethod_t::NUMBER)
252 {
253 std::vector<uint32_t> groups = {1, 2, 3};
254 groupHelper->CreateGroupsUniformly(groups, utNodes);
255 }
256 else
257 {
258 NS_FATAL_ERROR("Unknown value of GroupCreationMethod_t: " << creationMethod);
259 }
260
261 // setup CBR traffic
262 Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(interval));
263 Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
264
265 // Setup custom traffics
266 Ptr<SatTrafficHelper> trafficHelper = simulationHelper->GetTrafficHelper();
267 trafficHelper->AddCbrTraffic(
270 MilliSeconds(100),
271 packetSize,
272 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
273 Singleton<SatTopology>::Get()->GetUtUserNodes(groupHelper->GetUtNodes(2)),
274 appStartTime,
275 appStartTime + simLength,
276 Seconds(0.05));
277
278 trafficHelper->AddCbrTraffic(
281 Seconds(1),
282 packetSize,
283 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
284 Singleton<SatTopology>::Get()->GetUtUserNodes(groupHelper->GetUtNodes(0)),
285 appStartTime,
286 appStartTime + simLength,
287 Seconds(0.05));
288
289 trafficHelper->AddHttpTraffic(
291 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
292 Singleton<SatTopology>::Get()->GetUtUserNodes(groupHelper->GetUtNodes(1)),
293 appStartTime,
294 appStartTime + simLength,
295 Seconds(0.05));
296
297 trafficHelper->AddVoipTraffic(
300 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
301 Singleton<SatTopology>::Get()->GetUtUserNodes(groupHelper->GetUtNodes(5)),
302 appStartTime,
303 appStartTime + simLength,
304 Seconds(0.05));
305
306 NS_LOG_INFO("--- sat-group-example ---");
307 NS_LOG_INFO(" Packet size in bytes: " << packetSize);
308 NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
309 NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
310 NS_LOG_INFO(" Number total of UTs: " << Singleton<SatTopology>::Get()->GetNUtNodes());
311 NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
312 NS_LOG_INFO(" Number of groups: " << groupHelper->GetN());
313 NS_LOG_INFO(" Nodes in default group: " << groupHelper->GetUtNodes(0).GetN());
314 std::list<uint32_t> groupIds = groupHelper->GetGroups();
315 groupIds.sort();
316 for (uint32_t groupId : groupIds)
317 {
318 NS_LOG_INFO(" Nodes in group " << groupId << ": "
319 << groupHelper->GetUtNodes(groupId).GetN());
320 }
321 NS_LOG_INFO(" ");
322
323 // Set statistics
324 Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
325 simulationHelper->EnableProgressLogs();
326
327 Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
328 Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
329 Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
330 ConfigStore outputConfig;
331 outputConfig.ConfigureDefaults();
332
334
335 simulationHelper->RunSimulation();
336
337 return 0;
338}
GeoCoordinate class is used to store and operate with geodetic coordinates.
Keep track of the current position and velocity of an object in satellite network.
GeoCoordinate GetGeoPosition(void) const
OutputType_t
Possible types and formats of statistics output.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
void ConfigureAllStats(Ptr< SatStatsHelperContainer > s)
GroupCreationMethod_t
@ POSITION