Loading...
Searching...
No Matches
sat-per-packet-if-sim-tn9.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: Budiarto Herman <budiarto.herman@magister.fi>
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
29#include <sys/stat.h>
30#include <unistd.h>
31
32using namespace ns3;
33
43
44NS_LOG_COMPONENT_DEFINE("sat-per-packet-if-sim-tn9");
45
46int
47main(int argc, char* argv[])
48{
49 uint32_t endUsersPerUt(1);
50 uint32_t utsPerBeam(220); // expected to be equivalent with 70% system load
51 DataRate dataRate(32000); // in bps
52 uint32_t beamConf(0);
53 uint32_t fadingConf(0);
54
55 uint32_t packetSize(1280); // in bytes
56 double simLength(50.0); // in seconds
57 Time appStartTime = Seconds(0.1);
58
60 auto simulationHelper = CreateObject<SimulationHelper>("example-per-packet-if-sim-tn9");
61 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
62
63 // To read attributes from file
64 std::string pathToFile = SatEnvVariables::GetInstance()->LocateFile(
65 "contrib/satellite/examples/tn9-dama-input-attributes.xml");
66
101
102 // read command line parameters given by user
103 CommandLine cmd;
104 cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
105 cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
106 cmd.AddValue("beamConf", "Beam configuration", beamConf);
107 cmd.AddValue("fadingConf", "Fading configuration (0: Markov, 1: Rain)", fadingConf);
108 simulationHelper->AddDefaultUiArguments(cmd, pathToFile);
109 cmd.Parse(argc, argv);
110
111 Config::SetDefault("ns3::ConfigStore::Filename", StringValue(pathToFile));
112 Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
113 Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
114
115 ConfigStore inputConfig;
116 inputConfig.ConfigureDefaults();
117
118 // NCC configuration
119 Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
120 Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
121
122 // RBDC
123 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
124 BooleanValue(false));
125 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
126 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
127 UintegerValue(16));
128 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
129 BooleanValue(false));
130 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_OFF));
131 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
132
133 // Per-packet interference
134 Config::SetDefault("ns3::SatUtHelper::DaFwdLinkInterferenceModel",
136 Config::SetDefault("ns3::SatOrbiterHelper::DaFwdLinkInterferenceModel",
138 Config::SetDefault("ns3::SatOrbiterHelper::DaRtnLinkInterferenceModel",
140 Config::SetDefault("ns3::SatGwHelper::DaRtnLinkInterferenceModel",
142
143 switch (fadingConf)
144 {
145 case 0: {
146 // Markov fading
147 Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_MARKOV));
148 break;
149 }
150 case 1: {
151 Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
152
153 // Rain fading
154 // Note, that the positions of the fading files do not necessarily match with the
155 // beam location, since this example is not using list position allocator!
156 Config::SetDefault("ns3::SatChannel::EnableExternalFadingInputTrace", BooleanValue(true));
157 Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtFwdDownIndexFileName",
158 StringValue("BeamId-1_256_UT_fading_fwddwn_trace_index.txt"));
159 Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtRtnUpIndexFileName",
160 StringValue("BeamId-1_256_UT_fading_rtnup_trace_index.txt"));
161
162 break;
163 }
164 default: {
165 NS_FATAL_ERROR("Unsupported fadingConf: " << fadingConf);
166 break;
167 }
168 }
169
170 simulationHelper->SetSimulationTime(simLength);
171 simulationHelper->SetUtCountPerBeam(utsPerBeam);
172 simulationHelper->SetUserCountPerUt(endUsersPerUt);
173 switch (beamConf)
174 {
175 // Single beam
176 case 0: {
177 // Spot-beam over Finland
178 simulationHelper->SetBeamSet({18});
179 break;
180 }
181 // All co-channel beams (e.g., color 1 with 72/4 = 18 beams)
182 case 1: {
183 // choose beams from user link frequency ID = 1 (TN3 appendix A)
184 simulationHelper->SetBeamSet(
185 {1, 3, 5, 7, 9, 22, 24, 26, 28, 30, 44, 46, 48, 50, 59, 61, 70, 72});
186 break;
187 }
188 default: {
189 NS_FATAL_ERROR("Unsupported beam configuration: " << beamConf);
190 }
191 }
192
193 simulationHelper->LoadScenario("geo-33E");
194
195 // Creating the reference system.
196 simulationHelper->CreateSatScenario();
197
198 simulationHelper->GetTrafficHelper()->AddOnOffTraffic(
201 dataRate,
202 packetSize,
203 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
204 Singleton<SatTopology>::Get()->GetUtUserNodes(),
205 "ns3::ConstantRandomVariable[Constant=1000]",
206 "ns3::ConstantRandomVariable[Constant=0]",
207 appStartTime,
208 Seconds(simLength + 1),
209 MilliSeconds(50));
210
214 Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
215
216 s->AddGlobalFwdCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
217 s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
218
219 s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_CDF_FILE);
220 s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_CDF_FILE);
221
222 s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_CDF_FILE);
223 s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_CDF_FILE);
224
225 NS_LOG_INFO("--- sat-per-packet-if-sim-tn9 ---");
226 NS_LOG_INFO(" Packet size: " << packetSize);
227 NS_LOG_INFO(" Simulation length: " << simLength);
228 NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
229 NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
230 NS_LOG_INFO(" ");
231
235 // std::stringstream filename;
236 // filename << "tn9-per-packet-if-output-attributes-ut" << utsPerBeam
237 // << "-conf" << beamConf << ".xml";
238 //
239 // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
240 // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
241 // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
242 // ConfigStore outputConfig;
243 // outputConfig.ConfigureDefaults ();
244
248 simulationHelper->RunSimulation();
249
250 return 0;
251}
static Ptr< SatEnvVariables > GetInstance()
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.