Loading...
Searching...
No Matches
sat-cbr-user-defined-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
29using namespace ns3;
30
46
47NS_LOG_COMPONENT_DEFINE("sat-cbr-user-defined-example");
48
49// callback called when packet is received by phy RX carrier
50static void
51CrTraceCb(Time now, Mac48Address addr, Ptr<SatCrMessage> crMsg)
52{
53 NS_LOG_INFO("General info: " << addr << " " << crMsg->GetNumCapacityRequestElements() << " "
54 << crMsg->GetSizeInBytes() << " " << crMsg->GetCnoEstimate());
55
56 SatCrMessage::RequestContainer_t c = crMsg->GetCapacityRequestContent();
57 for (SatCrMessage::RequestContainer_t::const_iterator it = c.begin(); it != c.end(); ++it)
58 {
59 NS_LOG_INFO("CR component: " << (uint32_t)(it->first.first) << " " << it->first.second
60 << " " << it->second);
61 }
62}
63
64int
65main(int argc, char* argv[])
66{
67 // enable info logs
68 // LogComponentEnable ("CbrApplication", LOG_LEVEL_INFO);
69 // LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);
70 // LogComponentEnable ("sat-cbr-user-defined-example", LOG_LEVEL_INFO);
71
72 uint32_t beamId = 1;
73 uint32_t endUsersPerUt(3);
74 uint32_t utsPerBeam(3);
75 uint32_t packetSize(128);
76 Time interval(Seconds(1.0));
77 Time simLength(Seconds(20.0));
78 Time appStartTime = Seconds(0.1);
79
81 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
82
84 Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
85 Ptr<SimulationHelper> simulationHelper =
86 CreateObject<SimulationHelper>("example-cbr-user-defined");
87
88 // read command line parameters given by user
89 CommandLine cmd;
90 cmd.AddValue("endUsersPerUt", "Number of end users per UT", endUsersPerUt);
91 cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
92 simulationHelper->AddDefaultUiArguments(cmd);
93 cmd.Parse(argc, argv);
94
95 // dama-input-attributes.xml
96 // tn8-profiling-input-attributes.xml
97 // tn9-dama-input-attributes.xml
98 // tn9-ra-input-attributes.xml
99 // training-input-attributes.xml
100
101 simulationHelper->SetSimulationTime(simLength);
102 simulationHelper->SetUserCountPerUt(endUsersPerUt);
103 simulationHelper->SetUtCountPerBeam(utsPerBeam);
104
105 // Set beam ID
106 std::stringstream beamsEnabled;
107 beamsEnabled << beamId;
108 simulationHelper->SetBeams(beamsEnabled.str());
109
110 // Configure error model
112 Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
113 Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
114 // Config::SetDefault ("ns3::SatUtMac::CrUpdatePeriod", TimeValue(Seconds(10.0)));
115
116 simulationHelper->LoadScenario("geo-33E");
117
118 // Create reference system
119 simulationHelper->CreateSatScenario();
120
121 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/SatLlc/SatRequestManager/CrTrace",
122 MakeCallback(&CrTraceCb));
123
124 // >>> Start of actual test using Full scenario >>>
125
126 // setup CBR traffic
127 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
130 Time(interval),
131 packetSize,
132 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
133 Singleton<SatTopology>::Get()->GetUtUserNodes(),
134 appStartTime,
135 simLength,
136 Seconds(0.05));
137
138 NS_LOG_INFO("--- sat-cbr-user-defined-example ---");
139 NS_LOG_INFO(" Packet size in bytes: " << packetSize);
140 NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
141 NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
142 NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
143 NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
144 NS_LOG_INFO(" ");
145
146 simulationHelper->RunSimulation();
147
148 return 0;
149}
std::map< RequestDescriptor_t, uint16_t > RequestContainer_t
Define type RequestContainer_t.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static void CrTraceCb(Time now, Mac48Address addr, Ptr< SatCrMessage > crMsg)