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"
45 NS_LOG_COMPONENT_DEFINE(
"OnOff-example");
48 main(
int argc,
char* argv[])
50 uint32_t packetSize = 512;
51 std::string dataRate =
"500kb/s";
52 std::string onTime =
"1.0";
53 std::string offTime =
"0.5";
54 std::string scenario =
"simple";
55 std::string sender =
"both";
56 std::string simDuration =
"11s";
59 auto simulationHelper = CreateObject<SimulationHelper>(
"example-onoff");
60 Config::SetDefault(
"ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(
true));
61 Config::SetDefault(
"ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(
true));
64 Config::SetDefault(
"ns3::SatHelper::PacketTraceEnabled", BooleanValue(
true));
70 cmd.AddValue(
"packetSize",
"Size of constant packet (bytes e.g 512)", packetSize);
71 cmd.AddValue(
"dataRate",
"Data rate (e.g. 500kb/s)", dataRate);
72 cmd.AddValue(
"onTime",
"Time for packet sending is on in seconds, (e.g. (1.0)", onTime);
73 cmd.AddValue(
"offTime",
"Time for packet sending is off in seconds, (e.g. (0.5)", offTime);
74 cmd.AddValue(
"sender",
"Packet sender (ut, gw, or both).", sender);
75 cmd.AddValue(
"scenario",
"Test scenario to use. (simple, larger or full", scenario);
76 cmd.AddValue(
"simDuration",
"Duration of the simulation (Time)", simDuration);
77 simulationHelper->AddDefaultUiArguments(cmd);
78 cmd.Parse(argc, argv);
80 simulationHelper->SetSimulationTime(Time(simDuration));
81 simulationHelper->SetOutputTag(scenario);
84 if (scenario ==
"larger")
88 else if (scenario ==
"full")
94 LogComponentEnable(
"OnOffApplication", LOG_LEVEL_INFO);
95 LogComponentEnable(
"PacketSink", LOG_LEVEL_INFO);
96 LogComponentEnable(
"OnOff-example", LOG_LEVEL_INFO);
102 simulationHelper->LoadScenario(
"geo-33E");
105 simulationHelper->CreateSatScenario(satScenario);
110 NS_ASSERT_MSG(((sender ==
"gw") || (sender ==
"ut") || (sender ==
"both")),
111 "Sender argument invalid.");
115 if ((sender ==
"gw") || (sender ==
"both"))
117 simulationHelper->GetTrafficHelper()->AddOnOffTraffic(
122 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
123 Singleton<SatTopology>::Get()->GetUtUserNodes(),
124 "ns3::ConstantRandomVariable[Constant=" + onTime +
"]",
125 "ns3::ConstantRandomVariable[Constant=" + offTime +
"]",
133 if (sender ==
"ut" || sender ==
"both")
135 simulationHelper->GetTrafficHelper()->AddOnOffTraffic(
140 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
141 Singleton<SatTopology>::Get()->GetUtUserNodes(),
142 "ns3::ConstantRandomVariable[Constant=" + onTime +
"]",
143 "ns3::ConstantRandomVariable[Constant=" + offTime +
"]",
150 NS_LOG_INFO(
"--- sat-onoff-example ---");
151 NS_LOG_INFO(
" Scenario used: " << scenario);
152 NS_LOG_INFO(
" Sender: " << sender);
153 NS_LOG_INFO(
" PacketSize: " << packetSize);
154 NS_LOG_INFO(
" DataRate: " << dataRate);
155 NS_LOG_INFO(
" OnTime: " << onTime);
156 NS_LOG_INFO(
" OffTime: " << offTime);
157 NS_LOG_INFO(
" Duration: " << simDuration);
161 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.