sat-fwd-link-beam-hopping-example.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 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: Jani Puttonen <jani.puttonen@magister.fi>
19  *
20  */
21 
22 #include "ns3/applications-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 
29 using namespace ns3;
30 
43 NS_LOG_COMPONENT_DEFINE("sat-fwd-link-beam-hopping-example");
44 
45 int
46 main(int argc, char* argv[])
47 {
48  uint32_t endUsersPerUt(1);
49  bool enableBeamHopping(true);
50  Time simLength(Seconds(3.0));
51  bool scaleDown(true);
52 
53  std::string simulationName("sat-fwd-link-beam-hopping-example");
54  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>(simulationName);
55 
56  // read command line parameters given by user
57  CommandLine cmd;
58  cmd.AddValue("enableBeamHopping", "Enable FWD link beam hopping", enableBeamHopping);
59  cmd.AddValue("simTime", "Length of simulation", simLength);
60  cmd.AddValue("scaleDown",
61  "Scale down the bandwidth to see differences with less traffic",
62  scaleDown);
63  simulationHelper->AddDefaultUiArguments(cmd);
64  cmd.Parse(argc, argv);
65 
66  simulationHelper->SetDefaultValues();
67  simulationHelper->SetUserCountPerUt(endUsersPerUt);
68  if (enableBeamHopping)
69  simulationHelper->ConfigureFwdLinkBeamHopping();
70  if (scaleDown)
71  {
72  Config::SetDefault("ns3::SatConf::FwdCarrierAllocatedBandwidth",
73  DoubleValue(enableBeamHopping ? 1e+08 : 2.5e+07));
74  }
75  simulationHelper->SetSimulationTime(simLength.GetSeconds());
76 
77  // All spot-beams of GW-1 (14 in total)
78  simulationHelper->SetBeams("1 2 3 4 11 12 13 14 25 26 27 28 40 41");
79  std::map<uint32_t, uint32_t> utsInBeam = {{1, 30},
80  {2, 9},
81  {3, 15},
82  {4, 30},
83  {11, 15},
84  {12, 30},
85  {13, 9},
86  {14, 18},
87  {25, 9},
88  {26, 15},
89  {27, 18},
90  {28, 30},
91  {40, 9},
92  {41, 15}};
93 
94  // Set users unevenly in different beams
95  for (const auto it : utsInBeam)
96  {
97  simulationHelper->SetUtCountPerBeam(it.first, it.second);
98  }
99 
100  // Create the scenario
101  simulationHelper->CreateSatScenario();
102 
103  // Install traffic model
104  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(MilliSeconds(1)));
105  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(512));
106  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
109  Seconds(0.001),
110  simLength,
111  Seconds(0.001));
112 
113  auto stats = simulationHelper->GetStatisticsContainer();
114  stats->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
115  stats->AddPerBeamFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
116  stats->AddPerBeamBeamServiceTime(SatStatsHelper::OUTPUT_SCALAR_FILE);
117  stats->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
118  stats->AddGlobalFwdCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
119 
120  simulationHelper->EnableProgressLogs();
121  simulationHelper->RunSimulation();
122 
123  return 0;
124 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.