Loading...
Searching...
No Matches
sat-dynamic-frequency-plan-example.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2018 CNES
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: Mathias Ettinger <mettinger@toulouse.viveris.fr>
19 *
20 */
21
22#include "ns3/config-store-module.h"
23#include "ns3/core-module.h"
24#include "ns3/internet-module.h"
25#include "ns3/network-module.h"
26#include "ns3/satellite-module.h"
27#include "ns3/traffic-module.h"
28
29using namespace ns3;
30
40
41NS_LOG_COMPONENT_DEFINE("sat-generic-launcher");
42
43static double g_txMaxPower = 5.0;
44static bool g_ascending = false;
45static Time g_cnoInterval = MilliSeconds(100);
46static Time g_simulationTime = Minutes(1);
47
48static void
49ChangeCno(const std::vector<Ptr<SatUtPhy>>& utsPhysicalLayers)
50{
51 g_txMaxPower += g_ascending ? 0.2 : -0.2;
52 g_ascending = (g_ascending && g_txMaxPower < 30.0) || (!g_ascending && g_txMaxPower < -30.0);
53
54 for (auto& phy : utsPhysicalLayers)
55 {
56 phy->SetAttribute("TxMaxPowerDbw", DoubleValue(g_txMaxPower));
57 phy->Initialize();
58 }
59
60 Simulator::Schedule(g_cnoInterval, &ChangeCno, utsPhysicalLayers);
61}
62
63int
64main(int argc, char* argv[])
65{
66 bool varyingCno(false);
67 uint32_t maxSubdivisions(0);
68 uint32_t frameConfigType(2);
69 double initialBandwidth(3.75e6);
70 Time superframeDuration(MicroSeconds(26500));
71 std::string inputFileNameWithPath =
72 SatEnvVariables::GetInstance()->LocateDirectory("contrib/satellite/examples") +
73 "/generic-input-attributes.xml";
74
75 Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("generic-launcher");
76 simulationHelper->SetDefaultValues();
77
78 CommandLine cmd;
79 cmd.AddValue("MaxCarrierSubdivision",
80 "The maximum amount of subdivision for a single carrier",
81 maxSubdivisions);
82 cmd.AddValue("FrameConfigType",
83 "The frame configuration type used for super frame",
84 frameConfigType);
85 cmd.AddValue("UseVaryingCno",
86 "Simulate varying C/N0 for UTs instead of changing their traffic overtime",
87 varyingCno);
88 simulationHelper->AddDefaultUiArguments(cmd, inputFileNameWithPath);
89 cmd.Parse(argc, argv);
90
91 Config::SetDefault("ns3::SimulationHelperConf::BeamsIDs", StringValue("12"));
92 Config::SetDefault("ns3::SimulationHelperConf::UtCountPerBeam",
93 StringValue("ns3::ConstantRandomVariable[Constant=30]"));
94 Config::SetDefault("ns3::SimulationHelperConf::UserCountPerUt",
95 StringValue("ns3::ConstantRandomVariable[Constant=1]"));
96
97 Config::SetDefault("ns3::SatSuperframeConf0::FrameCount", UintegerValue(1));
98 Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType",
99 StringValue("ConfigType_" + std::to_string(frameConfigType)));
100 Config::SetDefault("ns3::SatSuperframeConf0::MaxCarrierSubdivision",
101 UintegerValue(maxSubdivisions));
102 Config::SetDefault("ns3::SatSuperframeConf0::Frame0_AllocatedBandwidthHz",
103 DoubleValue(initialBandwidth));
104 Config::SetDefault("ns3::SatSuperframeConf0::Frame0_CarrierAllocatedBandwidthHz",
105 DoubleValue(initialBandwidth));
106 Config::SetDefault("ns3::SatSuperframeConf0::Frame0_CarrierRollOff", DoubleValue(0.2));
107 Config::SetDefault("ns3::SatSuperframeConf0::Frame0_CarrierSpacing", DoubleValue(0.0));
108 Config::SetDefault("ns3::SatSuperframeConf0::Frame0_RandomAccessFrame", BooleanValue(false));
109
110 Config::SetDefault("ns3::SatSuperframeSeq::TargetDuration", TimeValue(superframeDuration));
111 Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(superframeDuration));
112
113 Config::SetDefault("ns3::SatFwdLinkScheduler::CnoEstimationWindow",
114 TimeValue(MilliSeconds(500)));
115 Config::SetDefault("ns3::SatRequestManager::CnoReportInterval", TimeValue(g_cnoInterval));
116 Config::SetDefault("ns3::SatBeamScheduler::CnoEstimationMode",
117 StringValue("MinimumValueInWindow"));
118 Config::SetDefault("ns3::SatBeamScheduler::CnoEstimationWindow", TimeValue(g_cnoInterval));
119
120 Config::SetDefault("ns3::SatUtPhy::TxMaxPowerDbw", DoubleValue(g_txMaxPower));
121 Config::SetDefault("ns3::SatOrbiterUserPhy::TxMaxPowerDbw", DoubleValue(15.0));
122 Config::SetDefault("ns3::SatOrbiterFeederPhy::FixedAmplificationGainDb", DoubleValue(200.0));
123
124 simulationHelper->ReadInputAttributesFromFile(inputFileNameWithPath);
125
126 // Manual configuration of the simulation to avoid creating unnecessary traffic
127 Ptr<SimulationHelperConf> simulationConf = CreateObject<SimulationHelperConf>();
128 g_simulationTime = simulationConf->m_simTime;
129 simulationHelper->SetBeams(simulationConf->m_enabledBeams);
130 simulationHelper->SetUtCountPerBeam(simulationConf->m_utCount);
131 simulationHelper->SetUserCountPerUt(simulationConf->m_utUserCount);
132 simulationHelper->SetUserCountPerMobileUt(simulationConf->m_utMobileUserCount);
133 simulationHelper->SetSimulationTime(g_simulationTime);
134
135 simulationHelper->LoadScenario("geo-33E");
136
137 simulationHelper->CreateSatScenario(SatHelper::NONE, simulationConf->m_mobileUtsFolder);
138 if (simulationConf->m_activateProgressLogging)
139 {
140 simulationHelper->EnableProgressLogs();
141 }
142
143 simulationHelper->StoreAttributesToFile("parametersUsed.xml");
144
145 if (varyingCno)
146 {
147 std::vector<Ptr<SatUtPhy>> utsPhysicalLayers;
148 NodeContainer utNodes = Singleton<SatTopology>::Get()->GetUtNodes();
149 Ptr<Node> node;
150 for (NodeContainer::Iterator it = utNodes.Begin(); it != utNodes.End(); it++)
151 {
152 node = *it;
153 for (uint32_t j = 0; j < node->GetNDevices(); ++j)
154 {
155 Ptr<SatNetDevice> dev = DynamicCast<SatNetDevice>(node->GetDevice(j));
156 if (dev != nullptr)
157 {
158 Ptr<SatUtPhy> phy = DynamicCast<SatUtPhy>(dev->GetPhy());
159 if (phy != nullptr)
160 {
161 utsPhysicalLayers.push_back(phy);
162 }
163 }
164 }
165 }
166 Simulator::Schedule(Seconds(0), &ChangeCno, utsPhysicalLayers);
167
168 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
171 superframeDuration,
172 512,
173 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
174 Singleton<SatTopology>::Get()->GetUtUserNodes(),
175 Seconds(0),
177 MilliSeconds(50));
178 }
179 else
180 {
181 // Configure our own kind of traffic
182 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
185 superframeDuration,
186 40,
187 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
188 Singleton<SatTopology>::Get()->GetUtUserNodes(),
189 Seconds(0),
191 MilliSeconds(50));
192
193 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
196 superframeDuration,
197 25600,
198 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
199 Singleton<SatTopology>::Get()->GetUtUserNodes(),
200 Seconds(0),
201 Seconds(10),
202 MilliSeconds(50),
203 0.3);
204
205 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
208 superframeDuration,
209 1000,
210 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
211 Singleton<SatTopology>::Get()->GetUtUserNodes(),
212 Seconds(5),
213 Seconds(15),
214 MilliSeconds(50),
215 0.4);
216
217 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
220 superframeDuration,
221 1000,
222 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
223 Singleton<SatTopology>::Get()->GetUtUserNodes(),
224 Seconds(10),
225 Seconds(20),
226 MilliSeconds(50),
227 0.5);
228
229 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
232 superframeDuration,
233 40000,
234 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
235 Singleton<SatTopology>::Get()->GetUtUserNodes(),
236 Seconds(15),
237 Seconds(25),
238 MilliSeconds(50),
239 0.2);
240
241 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
244 superframeDuration,
245 1,
246 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
247 Singleton<SatTopology>::Get()->GetUtUserNodes(),
248 Seconds(20),
249 Seconds(30),
250 MilliSeconds(50),
251 0.7);
252
253 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
256 superframeDuration,
257 100,
258 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
259 Singleton<SatTopology>::Get()->GetUtUserNodes(),
260 Seconds(25),
261 Seconds(35),
262 MilliSeconds(50),
263 0.45);
264
265 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
268 superframeDuration,
269 3000,
270 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
271 Singleton<SatTopology>::Get()->GetUtUserNodes(),
272 Seconds(30),
273 Seconds(40),
274 MilliSeconds(50),
275 0.55);
276
277 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
280 superframeDuration,
281 40000,
282 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
283 Singleton<SatTopology>::Get()->GetUtUserNodes(),
284 Seconds(35),
285 Seconds(45),
286 MilliSeconds(50),
287 0.2);
288
289 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
292 superframeDuration,
293 30000,
294 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
295 Singleton<SatTopology>::Get()->GetUtUserNodes(),
296 Seconds(40),
297 Seconds(50),
298 MilliSeconds(50),
299 0.3);
300
301 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
304 superframeDuration,
305 1500,
306 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
307 Singleton<SatTopology>::Get()->GetUtUserNodes(),
308 Seconds(45),
309 Seconds(55),
310 MilliSeconds(50),
311 0.6);
312
313 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
316 superframeDuration,
317 800,
318 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
319 Singleton<SatTopology>::Get()->GetUtUserNodes(),
320 Seconds(50),
321 Seconds(60),
322 MilliSeconds(50),
323 0.9);
324 }
325
326 if (simulationConf->m_activateStatistics)
327 {
328 simulationHelper->CreateDefaultStats();
329 Ptr<SatStatsHelperContainer> stats = simulationHelper->GetStatisticsContainer();
330 stats->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
331 stats->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
332 stats->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
333 stats->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
334 stats->AddPerUtRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
335 stats->AddPerUtRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
336 stats->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
337 stats->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
338 stats->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
339 stats->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
340 stats->AddPerUtCarrierId(SatStatsHelper::OUTPUT_SCALAR_FILE);
341 stats->AddPerUtCarrierId(SatStatsHelper::OUTPUT_SCATTER_FILE);
342 stats->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
343 stats->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
344 }
345
346 simulationHelper->RunSimulation();
347}
static Ptr< SatEnvVariables > GetInstance()
@ NONE
NONE Not used.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static Time g_simulationTime
static double g_txMaxPower
static bool g_ascending
static void ChangeCno(const std::vector< Ptr< SatUtPhy > > &utsPhysicalLayers)
static Time g_cnoInterval