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);
112 simulationHelper->LoadScenario(
"geo-33E");
115 Ptr<SatHelper> helper = simulationHelper->CreateSatScenario(satScenario);
119 if (scenario ==
"full")
124 NodeContainer uts = helper->GetBeamHelper()->GetUtNodes(0, beamIdInFullScenario);
125 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes(uts.Get(0));
126 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
131 PacketSinkHelper sinkHelper(
132 "ns3::UdpSocketFactory",
133 InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
134 CbrHelper cbrHelper(
"ns3::UdpSocketFactory",
135 InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
136 cbrHelper.SetAttribute(
"Interval", StringValue(interval));
137 cbrHelper.SetAttribute(
"PacketSize", UintegerValue(packetSize));
139 ApplicationContainer gwSink = sinkHelper.Install(gwUsers.Get(0));
140 gwSink.Start(Seconds(1.0));
141 gwSink.Stop(Seconds(10.0));
143 ApplicationContainer gwCbr = cbrHelper.Install(gwUsers.Get(0));
144 gwCbr.Start(Seconds(1.0));
145 gwCbr.Stop(Seconds(2.1));
148 sinkHelper.SetAttribute(
150 AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port))));
151 cbrHelper.SetAttribute(
153 AddressValue(Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port))));
155 ApplicationContainer utSink = sinkHelper.Install(utUsers.Get(0));
156 utSink.Start(Seconds(1.0));
157 utSink.Stop(Seconds(10.0));
159 ApplicationContainer utCbr = cbrHelper.Install(utUsers.Get(0));
160 utCbr.Start(Seconds(7.0));
161 utCbr.Stop(Seconds(9.1));
175 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
180 Singleton<SatTopology>::Get()->GetGwUserNodes(),
181 Singleton<SatTopology>::Get()->GetUtUserNodes(),
187 NS_LOG_INFO(
"--- sat-cbr-example ---");
188 NS_LOG_INFO(
" Scenario used: " << scenario);
189 if (scenario ==
"full")
191 NS_LOG_INFO(
" UT used in full scenario from beam: " << beamIdInFullScenario);
193 NS_LOG_INFO(
" PacketSize: " << packetSize);
194 NS_LOG_INFO(
" Interval: " << interval);
204 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.