sat-arq-fwd-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-arq-fwd-example");
42 
43 int
44 main(int argc, char* argv[])
45 {
46  uint32_t beamId(1);
47  uint32_t endUsersPerUt(3);
48  uint32_t utsPerBeam(3);
49  uint32_t packetSize(128);
50  Time interval(Seconds(0.3));
51  Time simLength(Seconds(100.0));
52  Time appStartTime = Seconds(0.1);
53 
54  // enable info logs
55  // LogComponentEnable ("CbrApplication", LOG_LEVEL_INFO);
56  // LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);
57  // LogComponentEnable ("sat-arq-fwd-example", LOG_LEVEL_INFO);
58 
60  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
61 
63  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
64  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("example-arq-fwd");
65 
66  // read command line parameters given by user
67  CommandLine cmd;
68  cmd.AddValue("endUsersPerUt", "Number of end users per UT", endUsersPerUt);
69  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
70  simulationHelper->AddDefaultUiArguments(cmd);
71  cmd.Parse(argc, argv);
72 
73  simulationHelper->SetDefaultValues();
74  simulationHelper->SetUtCountPerBeam(utsPerBeam);
75  simulationHelper->SetUserCountPerUt(endUsersPerUt);
76  simulationHelper->SetSimulationTime(simLength);
77 
78  std::stringstream beamsEnabled;
79  beamsEnabled << beamId;
80  simulationHelper->SetBeams(beamsEnabled.str());
81 
82  // Configure error model
83  double errorRate(0.10);
84  Config::SetDefault("ns3::SatUtHelper::FwdLinkConstantErrorRate", DoubleValue(errorRate));
85  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel",
87  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel",
88  EnumValue(SatPhyRxCarrierConf::EM_NONE));
89 
90  // Enable ARQ
91  Config::SetDefault("ns3::SatLlc::RtnLinkArqEnabled", BooleanValue(false));
92  Config::SetDefault("ns3::SatLlc::FwdLinkArqEnabled", BooleanValue(true));
93 
94  // RTN link ARQ attributes
95  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::MaxNoOfRetransmissions",
96  UintegerValue(2));
97  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::WindowSize", UintegerValue(20));
98  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::RetransmissionTimer",
99  TimeValue(Seconds(0.6)));
100  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::RxWaitingTime",
101  TimeValue(Seconds(1.8)));
102 
103  // Creating the reference system. Note, currently the satellite module supports
104  // only one reference system, which is named as "Scenario72". The string is utilized
105  // in mapping the scenario to the needed reference system configuration files. Arbitrary
106  // scenario name results in fatal error.
107  simulationHelper->CreateSatScenario();
108 
109  //---- Start CBR application definitions
110 
111  NS_LOG_INFO("Creating CBR applications and sinks");
112 
113  if (endUsersPerUt * utsPerBeam > 0)
114  {
115  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(Time(interval)));
116  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
117 
119  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
122  appStartTime,
123  simLength,
124  Seconds(0.001));
125  }
126  //---- Stop CBR application definitions
127 
128  NS_LOG_INFO("--- sat-arq-fwd-example ---");
129  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
130  NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
131  NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
132  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
133  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
134  NS_LOG_INFO(" ");
135 
136  simulationHelper->EnableProgressLogs();
137  simulationHelper->RunSimulation();
138 
139  return 0;
140 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.