sat-cbr-full-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: Jani Puttonen <jani.puttonen@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 #include "ns3/traffic-module.h"
29 
30 using namespace ns3;
31 
41 NS_LOG_COMPONENT_DEFINE("sat-cbr-full-example");
42 
43 int
44 main(int argc, char* argv[])
45 {
46  // LogComponentEnable ("CbrApplication", LOG_LEVEL_ALL);
47  // LogComponentEnable ("PacketSink", LOG_LEVEL_ALL);
48  // LogComponentEnable ("sat-arq-rtn-example", LOG_LEVEL_INFO);
49 
50  uint32_t endUsersPerUt(3);
51  uint32_t utsPerBeam(3);
52  uint32_t packetSize(128);
53  std::string interval("1s");
54  double simLength(10.0);
55 
56  Time appStartTime = Seconds(0.001);
57 
59  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
60 
62  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
63  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("example-cbr-full");
64 
65  // read command line parameters given by user
66  CommandLine cmd;
67  cmd.AddValue("endUsersPerUt", "Number of end users per UT", endUsersPerUt);
68  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
69  cmd.AddValue("packetSize", "Size of constant packet (bytes)", packetSize);
70  cmd.AddValue("interval", "Interval to sent packets in seconds, (e.g. (1s)", interval);
71  cmd.AddValue("simLength", "Simulation length in seconds", simLength);
72  simulationHelper->AddDefaultUiArguments(cmd);
73  cmd.Parse(argc, argv);
74 
75  simulationHelper->SetSimulationTime(simLength);
76 
77  // We set the UT count and UT user count using attributes when configuring a pre-defined
78  // scenario
79  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(utsPerBeam));
80  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(endUsersPerUt));
81 
82  // Configure a static error probability
84  double errorRate(0.2);
85  Config::SetDefault("ns3::SatUtHelper::FwdLinkConstantErrorRate", DoubleValue(errorRate));
86  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
87  Config::SetDefault("ns3::SatGwHelper::RtnLinkConstantErrorRate", DoubleValue(errorRate));
88  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
89 
90  // Create full scenario
91 
92  // Creating the reference system. Note, currently the satellite module supports
93  // only one reference system, which is named as "Scenario72". The string is utilized
94  // in mapping the scenario to the needed reference system configuration files. Arbitrary
95  // scenario name results in fatal error.
96  simulationHelper->CreateSatScenario(SatHelper::FULL);
97 
98  // >>> Start of actual test using Full scenario >>>
99  Config::SetDefault("ns3::CbrApplication::Interval", StringValue(interval));
100  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
101 
102  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
105  appStartTime,
106  Seconds(simLength),
107  Seconds(0.001));
108 
109  NS_LOG_INFO("--- sat-cbr-full-example ---");
110  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
111  NS_LOG_INFO(" Packet sending interval: " << interval);
112  NS_LOG_INFO(" Simulation length: " << simLength);
113  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
114  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
115  NS_LOG_INFO(" ");
116 
117  simulationHelper->RunSimulation();
118 
119  return 0;
120 
121 } // end of `int main (int argc, char *argv[])`
@ FULL
FULL Full scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.