Loading...
Searching...
No Matches
sat-list-position-ext-fading-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: Sami Rantanen <sami.rantanen@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
55
56NS_LOG_COMPONENT_DEFINE("sat-list-position-ext-fading-example");
57
58// callback called when packet is received by phy RX carrier
59static void
60LinkBudgetTraceCb(std::string context,
61 Ptr<SatSignalParameters> params,
62 Mac48Address ownAdd,
63 Mac48Address destAdd,
64 double ifPower,
65 double cSinr)
66{
67 // print only unicast message to prevent printing control messages like TBTP messages
68 if (!destAdd.IsBroadcast())
69 {
70 NS_LOG_INFO("" << params->m_channelType << " " << ownAdd << " " << destAdd << " "
71 << params->m_beamId << " " << SatUtils::LinearToDb(params->GetSinr()) << " "
72 << SatUtils::LinearToDb(cSinr));
73 }
74}
75
76int
77main(int argc, char* argv[])
78{
79 uint32_t utCount = 4;
80 uint32_t usersPerUt = 1;
81 uint32_t beamId = 1;
82 bool checkBeam = false;
83 std::string extUtPositions = SatEnvVariables::GetInstance()->LocateDataDirectory() +
84 "/additional-input/utpositions/BeamId-1_256_UT_Positions.txt";
85
86 Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
87
89 auto simulationHelper = CreateObject<SimulationHelper>("example-list-position-external-fading");
90 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
91
92 // read command line parameters can be given by user
93 CommandLine cmd;
94 cmd.AddValue("beamId", "The beam ID to be used.", beamId);
95 cmd.AddValue("checkBeam",
96 "Check that given beam is the best according in the configured positions.",
97 checkBeam);
98 cmd.AddValue("utCount", "Number of the UTs.", utCount);
99 cmd.AddValue("usersPerUt", "Users per UT.", usersPerUt);
100 cmd.AddValue("externalUtPositionFile", "UT position input file (in data/)", extUtPositions);
101 simulationHelper->AddDefaultUiArguments(cmd);
102 cmd.Parse(argc, argv);
103
104 // Set default values for some attributes for position setting and external fading trace
105 // This done before command line parsing in order to override them if needed
106
107 simulationHelper->SetUserCountPerUt(usersPerUt);
108 simulationHelper->SetUtCountPerBeam(utCount);
109 simulationHelper->SetBeamSet({beamId});
110 simulationHelper->SetSimulationTime(Seconds(1.1));
111
112 // Enable default fading traces
113 simulationHelper->EnableExternalFadingInputTrace();
114
115 // Enable UT positions from input file
116 simulationHelper->EnableUtListPositionsFromInputFile(extUtPositions, checkBeam);
117
118 // enable info logs
119 LogComponentEnable("sat-list-position-ext-fading-example", LOG_LEVEL_INFO);
120
121 simulationHelper->LoadScenario("geo-33E");
122
123 // Creating the reference system. Note, currently the satellite module supports
124 // only one reference system, which is named as "Scenario72". The string is utilized
125 // in mapping the scenario to the needed reference system configuration files. Arbitrary
126 // scenario name results in fatal error.
127 Ptr<SatHelper> helper = simulationHelper->CreateSatScenario();
128
129 // set callback traces where we want results out
130 Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
131 MakeCallback(&LinkBudgetTraceCb));
132
133 Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
134 MakeCallback(&LinkBudgetTraceCb));
135
136 Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
137 MakeCallback(&LinkBudgetTraceCb));
138
139 // Install CBR traffic model
140 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
143 MilliSeconds(100),
144 512,
145 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
146 Singleton<SatTopology>::Get()->GetUtUserNodes(),
147 Seconds(0.1),
148 Seconds(0.25),
149 Seconds(0));
150
151 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
154 MilliSeconds(100),
155 512,
156 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
157 Singleton<SatTopology>::Get()->GetUtUserNodes(),
158 Seconds(0.1),
159 Seconds(0.25),
160 Seconds(0));
161
162 NS_LOG_INFO("--- List Position External Fading Example ---");
163 NS_LOG_INFO("UT info (Beam ID, UT ID, Latitude, Longitude, Altitude + addresses");
164
165 // print UT info
166 NS_LOG_INFO(helper->GetBeamHelper()->GetUtInfo());
167 NS_LOG_INFO("Link results (Time, Channel type, Own address, Dest. address, Beam ID, SINR, "
168 "Composite SINR) :");
169 // results are printed out in callback (PacketTraceCb)
170
171 simulationHelper->RunSimulation();
172
173 return 0;
174}
static Ptr< SatEnvVariables > GetInstance()
static T LinearToDb(T linear)
Converts linear to decibels.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static void LinkBudgetTraceCb(std::string context, Ptr< SatSignalParameters > params, Mac48Address ownAdd, Mac48Address destAdd, double ifPower, double cSinr)