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"
48 NS_LOG_COMPONENT_DEFINE(
"sat-cbr-example");
51 main(
int argc,
char* argv[])
53 uint32_t beamIdInFullScenario = 10;
54 uint32_t packetSize = 512;
55 std::string interval =
"1s";
56 std::string scenario =
"simple";
67 Config::SetDefault(
"ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(
true));
70 Config::SetDefault(
"ns3::SatHelper::PacketTraceEnabled", BooleanValue(
true));
71 Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>(
"example-cbr");
75 cmd.AddValue(
"beamIdInFullScenario",
76 "Id where Sending/Receiving UT is selected in FULL scenario. (used only when "
78 beamIdInFullScenario);
79 cmd.AddValue(
"packetSize",
"Size of constant packet (bytes)", packetSize);
80 cmd.AddValue(
"interval",
"Interval to sent packets in seconds, (e.g. (1s)", interval);
81 cmd.AddValue(
"scenario",
"Test scenario to use. (simple, larger or full", scenario);
82 simulationHelper->AddDefaultUiArguments(cmd);
83 cmd.Parse(argc, argv);
85 if (scenario ==
"larger")
89 else if (scenario ==
"full")
94 simulationHelper->SetOutputTag(scenario);
96 simulationHelper->SetSimulationTime(Seconds(11));
99 std::stringstream beamsEnabled;
100 beamsEnabled << beamIdInFullScenario;
101 simulationHelper->SetBeams(beamsEnabled.str());
104 LogComponentEnable(
"CbrApplication", LOG_LEVEL_INFO);
105 LogComponentEnable(
"PacketSink", LOG_LEVEL_INFO);
106 LogComponentEnable(
"sat-cbr-example", LOG_LEVEL_INFO);
118 Ptr<SatHelper> helper = simulationHelper->CreateSatScenario(satScenario);
122 if (scenario ==
"full")
127 NodeContainer uts = helper->GetBeamHelper()->GetUtNodes(0, beamIdInFullScenario);
128 NodeContainer utUsers = helper->GetUserHelper()->GetUtUsers(uts.Get(0));
130 NodeContainer gwUsers = helper->GetGwUsers();
135 PacketSinkHelper sinkHelper(
136 "ns3::UdpSocketFactory",
137 InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
138 CbrHelper cbrHelper(
"ns3::UdpSocketFactory",
139 InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
140 cbrHelper.SetAttribute(
"Interval", StringValue(interval));
141 cbrHelper.SetAttribute(
"PacketSize", UintegerValue(packetSize));
143 ApplicationContainer gwSink = sinkHelper.Install(gwUsers.Get(0));
144 gwSink.Start(Seconds(1.0));
145 gwSink.Stop(Seconds(10.0));
147 ApplicationContainer gwCbr = cbrHelper.Install(gwUsers.Get(0));
148 gwCbr.Start(Seconds(1.0));
149 gwCbr.Stop(Seconds(2.1));
152 sinkHelper.SetAttribute(
154 AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port))));
155 cbrHelper.SetAttribute(
157 AddressValue(Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port))));
159 ApplicationContainer utSink = sinkHelper.Install(utUsers.Get(0));
160 utSink.Start(Seconds(1.0));
161 utSink.Stop(Seconds(10.0));
163 ApplicationContainer utCbr = cbrHelper.Install(utUsers.Get(0));
164 utCbr.Start(Seconds(7.0));
165 utCbr.Stop(Seconds(9.1));
169 Config::SetDefault(
"ns3::CbrApplication::Interval", StringValue(interval));
170 Config::SetDefault(
"ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
182 NS_LOG_INFO(
"--- sat-cbr-example ---");
183 NS_LOG_INFO(
" Scenario used: " << scenario);
184 if (scenario ==
"full")
186 NS_LOG_INFO(
" UT used in full scenario from beam: " << beamIdInFullScenario);
188 NS_LOG_INFO(
" PacketSize: " << packetSize);
189 NS_LOG_INFO(
" Interval: " << interval);
199 simulationHelper->RunSimulation();
PreDefinedScenario_t
Values for pre-defined scenarios to be used by helper when building satellite network topology base.
@ LARGER
LARGER Larger scenario used as base.
@ FULL
FULL Full scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.