Loading...
Searching...
No Matches
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
30using namespace ns3;
31
40
41NS_LOG_COMPONENT_DEFINE("sat-arq-fwd-example");
42
43int
44main(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",
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 simulationHelper->LoadScenario("geo-33E");
104
105 // Creating the reference system.
106 simulationHelper->CreateSatScenario();
107
108 //---- Start CBR application definitions
109
110 NS_LOG_INFO("Creating CBR applications and sinks");
111
112 if (endUsersPerUt * utsPerBeam > 0)
113 {
115 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
118 interval,
119 packetSize,
120 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
121 Singleton<SatTopology>::Get()->GetUtUserNodes(),
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.