sat-arq-rtn-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/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 
40 NS_LOG_COMPONENT_DEFINE("sat-arq-rtn-example");
41 
42 int
43 main(int argc, char* argv[])
44 {
45  uint32_t beamId = 1;
46  uint32_t endUsersPerUt(1);
47  uint32_t utsPerBeam(3);
48  uint32_t packetSize(128);
49  Time interval(Seconds(0.3));
50  Time simLength(Seconds(100.0));
51  Time appStartTime = Seconds(0.1);
52 
53  // enable info logs
54  // LogComponentEnable ("CbrApplication", LOG_LEVEL_INFO);
55  // LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);
56  // LogComponentEnable ("sat-arq-rtn-example", LOG_LEVEL_INFO);
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-arq-rtn");
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  simulationHelper->AddDefaultUiArguments(cmd);
70  cmd.Parse(argc, argv);
71 
72  simulationHelper->SetUtCountPerBeam(utsPerBeam);
73  simulationHelper->SetUserCountPerUt(endUsersPerUt);
74  simulationHelper->SetSimulationTime(simLength);
75 
76  std::stringstream beamsEnabled;
77  beamsEnabled << beamId;
78  simulationHelper->SetBeams(beamsEnabled.str());
79 
80  // Configure error model
81  double errorRate(0.1);
82  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel",
83  EnumValue(SatPhyRxCarrierConf::EM_NONE));
84  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel",
86  Config::SetDefault("ns3::SatGwHelper::RtnLinkConstantErrorRate", DoubleValue(errorRate));
87 
88  // Enable ARQ
89  Config::SetDefault("ns3::SatLlc::RtnLinkArqEnabled", BooleanValue(true));
90  Config::SetDefault("ns3::SatLlc::FwdLinkArqEnabled", BooleanValue(false));
91 
92  // RTN link ARQ attributes
93  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::MaxNoOfRetransmissions",
94  UintegerValue(2));
95  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::WindowSize", UintegerValue(20));
96  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::RetransmissionTimer",
97  TimeValue(Seconds(0.6)));
98  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::RxWaitingTime", TimeValue(Seconds(1.8)));
99 
100  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
101  BooleanValue(true));
102  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantServiceRate",
103  StringValue("ns3::ConstantRandomVariable[Constant=10]"));
104  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
105  BooleanValue(false));
106  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
107  BooleanValue(false));
108 
109  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
110  BooleanValue(true));
111  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantServiceRate",
112  StringValue("ns3::ConstantRandomVariable[Constant=100]"));
113  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
114  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
115  BooleanValue(false));
116 
117  // Creating the reference system. Note, currently the satellite module supports
118  // only one reference system, which is named as "Scenario72". The string is utilized
119  // in mapping the scenario to the needed reference system configuration files. Arbitrary
120  // scenario name results in fatal error.
121  simulationHelper->CreateSatScenario();
122 
123  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(Time(interval)));
124  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
125 
127  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
130  appStartTime,
131  simLength,
132  Seconds(0.05));
133 
134  NS_LOG_INFO("--- sat-arq-rtn-example ---");
135  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
136  NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
137  NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
138  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
139  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
140  NS_LOG_INFO(" ");
141 
142  simulationHelper->EnableProgressLogs();
143  simulationHelper->RunSimulation();
144 
145  return 0;
146 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.