Loading...
Searching...
No Matches
satellite-traffic-helper.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2016 Magister Solutions
4 * Copyright (c) 2020 CNES
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Bastien Tauran <bastien.tauran@viveris.fr>
20 */
21
23
25#include "simulation-helper.h"
26
27#include "ns3/cbr-helper.h"
28#include "ns3/log.h"
29#include "ns3/lora-periodic-sender.h"
30#include "ns3/nrtv-helper.h"
31#include "ns3/packet-sink-helper.h"
32#include "ns3/packet-sink.h"
33#include "ns3/satellite-topology.h"
34#include "ns3/singleton.h"
35#include "ns3/three-gpp-http-satellite-helper.h"
36#include "ns3/type-id.h"
37
38#include <string>
39#include <utility>
40#include <vector>
41
42NS_LOG_COMPONENT_DEFINE("SatelliteTrafficHelper");
43
44namespace ns3
45{
46
47NS_OBJECT_ENSURE_REGISTERED(SatTrafficHelperConf);
48
58#define SIM_ADD_TRAFFIC_MODEL_PROTOCOL_ATTRIBUTE(index, value) \
59 AddAttribute("Traffic" TOSTRING(index) "Protocol", \
60 "Network protocol that this traffic model will use", \
61 EnumValue(value), \
62 MakeEnumAccessor<SatTrafficHelperConf::TransportLayerProtocol_t>( \
63 &SatTrafficHelperConf::SetTraffic##index##Protocol, \
64 &SatTrafficHelperConf::GetTraffic##index##Protocol), \
65 MakeEnumChecker(SatTrafficHelperConf::PROTOCOL_UDP, \
66 "UDP", \
67 SatTrafficHelperConf::PROTOCOL_TCP, \
68 "TCP", \
69 SatTrafficHelperConf::PROTOCOL_BOTH, \
70 "BOTH"))
71
72#define SIM_ADD_TRAFFIC_MODEL_DIRECTION_ATTRIBUTE(index, value) \
73 AddAttribute("Traffic" TOSTRING(index) "Direction", \
74 "Satellite link direction that this traffic model will use", \
75 EnumValue(value), \
76 MakeEnumAccessor<SatTrafficHelperConf::TrafficDirection_t>( \
77 &SatTrafficHelperConf::SetTraffic##index##Direction, \
78 &SatTrafficHelperConf::GetTraffic##index##Direction), \
79 MakeEnumChecker(SatTrafficHelperConf::RTN_LINK, \
80 "ReturnLink", \
81 SatTrafficHelperConf::FWD_LINK, \
82 "ForwardLink", \
83 SatTrafficHelperConf::BOTH_LINK, \
84 "BothLinks"))
85
86#define SIM_ADD_TRAFFIC_MODEL_INTERVAL_ATTRIBUTE(index, value) \
87 AddAttribute("Traffic" TOSTRING(index) "Interval", \
88 "Interval between packets", \
89 TimeValue(value), \
90 MakeTimeAccessor(&SatTrafficHelperConf::SetTraffic##index##Interval, \
91 &SatTrafficHelperConf::GetTraffic##index##Interval), \
92 MakeTimeChecker())
93
94#define SIM_ADD_TRAFFIC_MODEL_DATA_RATE_ATTRIBUTE(index, value) \
95 AddAttribute("Traffic" TOSTRING(index) "DataRate", \
96 "Data rate of traffic", \
97 DataRateValue(value), \
98 MakeDataRateAccessor(&SatTrafficHelperConf::SetTraffic##index##DataRate, \
99 &SatTrafficHelperConf::GetTraffic##index##DataRate), \
100 MakeDataRateChecker())
101
102#define SIM_ADD_TRAFFIC_MODEL_PACKET_SIZE_ATTRIBUTE(index, value) \
103 AddAttribute("Traffic" TOSTRING(index) "PacketSize", \
104 "Packet size in bytes", \
105 UintegerValue(value), \
106 MakeUintegerAccessor(&SatTrafficHelperConf::SetTraffic##index##PacketSize, \
107 &SatTrafficHelperConf::GetTraffic##index##PacketSize), \
108 MakeUintegerChecker<uint32_t>())
109
110#define SIM_ADD_TRAFFIC_MODEL_ON_TIME_PATTERN_ATTRIBUTE(index, value) \
111 AddAttribute("Traffic" TOSTRING(index) "OnTimePattern", \
112 "On time patter for on/off traffic", \
113 StringValue(value), \
114 MakeStringAccessor(&SatTrafficHelperConf::SetTraffic##index##OnTimePattern, \
115 &SatTrafficHelperConf::GetTraffic##index##OnTimePattern), \
116 MakeStringChecker())
117
118#define SIM_ADD_TRAFFIC_MODEL_OFF_TIME_PATTERN_ATTRIBUTE(index, value) \
119 AddAttribute("Traffic" TOSTRING(index) "OffTimePattern", \
120 "Off time patter for on/off traffic", \
121 StringValue(value), \
122 MakeStringAccessor(&SatTrafficHelperConf::SetTraffic##index##OffTimePattern, \
123 &SatTrafficHelperConf::GetTraffic##index##OffTimePattern), \
124 MakeStringChecker())
125
126#define SIM_ADD_TRAFFIC_MODEL_ON_TIME_ATTRIBUTE(index, value) \
127 AddAttribute("Traffic" TOSTRING(index) "OnTime", \
128 "On time value for Poisson traffic", \
129 TimeValue(value), \
130 MakeTimeAccessor(&SatTrafficHelperConf::SetTraffic##index##OnTime, \
131 &SatTrafficHelperConf::GetTraffic##index##OnTime), \
132 MakeTimeChecker())
133
134#define SIM_ADD_TRAFFIC_MODEL_OFF_TIME_ATTRIBUTE(index, value) \
135 AddAttribute("Traffic" TOSTRING(index) "OffTime", \
136 "Off time value for Poisson traffic", \
137 TimeValue(value), \
138 MakeTimeAccessor(&SatTrafficHelperConf::SetTraffic##index##OffTime, \
139 &SatTrafficHelperConf::GetTraffic##index##OffTime), \
140 MakeTimeChecker())
141
142#define SIM_ADD_TRAFFIC_MODEL_CODEC_ATTRIBUTE(index, value) \
143 AddAttribute("Traffic" TOSTRING(index) "Codec", \
144 "Codec used for VoIP traffic", \
145 EnumValue(value), \
146 MakeEnumAccessor<SatTrafficHelper::VoipCodec_t>( \
147 &SatTrafficHelperConf::SetTraffic##index##Codec, \
148 &SatTrafficHelperConf::GetTraffic##index##Codec), \
149 MakeEnumChecker(SatTrafficHelper::G_711_1, \
150 "G_711_1", \
151 SatTrafficHelper::G_711_2, \
152 "G_711_2", \
153 SatTrafficHelper::G_723_1, \
154 "G_723_1", \
155 SatTrafficHelper::G_729_2, \
156 "G_729_2", \
157 SatTrafficHelper::G_729_3, \
158 "G_729_3"))
159
160#define SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(index, value) \
161 AddAttribute("Traffic" TOSTRING(index) "StartTime", \
162 "Time into the simulation when this traffic model will be started on each user", \
163 TimeValue(value), \
164 MakeTimeAccessor(&SatTrafficHelperConf::SetTraffic##index##StartTime, \
165 &SatTrafficHelperConf::GetTraffic##index##StartTime), \
166 MakeTimeChecker())
167
168#define SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(index, value) \
169 AddAttribute("Traffic" TOSTRING(index) "StopTime", \
170 "Time into the simulation when this traffic model will be stopped " \
171 "on each user. 0 means endless traffic generation.", \
172 TimeValue(value), \
173 MakeTimeAccessor(&SatTrafficHelperConf::SetTraffic##index##StopTime, \
174 &SatTrafficHelperConf::GetTraffic##index##StopTime), \
175 MakeTimeChecker())
176
177#define SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(index, value) \
178 AddAttribute("Traffic" TOSTRING(index) "StartDelay", \
179 "Cummulative delay for each user before starting this traffic model", \
180 TimeValue(value), \
181 MakeTimeAccessor(&SatTrafficHelperConf::SetTraffic##index##StartDelay, \
182 &SatTrafficHelperConf::GetTraffic##index##StartDelay), \
183 MakeTimeChecker())
184
185#define SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(index, value) \
186 AddAttribute("Traffic" TOSTRING(index) "Percentage", \
187 "Percentage of final users that will use this traffic model", \
188 DoubleValue(value), \
189 MakeDoubleAccessor(&SatTrafficHelperConf::SetTraffic##index##Percentage, \
190 &SatTrafficHelperConf::GetTraffic##index##Percentage), \
191 MakeDoubleChecker<double>(0, 1))
192
193TypeId
195{
196 static TypeId tid =
197 TypeId("ns3::SatTrafficHelperConf")
198 .SetParent<Object>()
199 .AddConstructor<SatTrafficHelperConf>()
200 .SIM_ADD_TRAFFIC_MODEL_INTERVAL_ATTRIBUTE(LoraPeriodic, Seconds(1))
201 .SIM_ADD_TRAFFIC_MODEL_PACKET_SIZE_ATTRIBUTE(LoraPeriodic, 512)
202 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(LoraPeriodic, Seconds(0.1))
203 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(LoraPeriodic, Seconds(0))
204 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(LoraPeriodic, MilliSeconds(10))
205 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(LoraPeriodic, 0)
206
207 .SIM_ADD_TRAFFIC_MODEL_INTERVAL_ATTRIBUTE(LoraCbr, Seconds(1))
208 .SIM_ADD_TRAFFIC_MODEL_PACKET_SIZE_ATTRIBUTE(LoraCbr, 512)
209 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(LoraCbr, Seconds(0.1))
210 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(LoraCbr, Seconds(0))
211 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(LoraCbr, MilliSeconds(10))
212 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(LoraCbr, 0)
213
214 .SIM_ADD_TRAFFIC_MODEL_PROTOCOL_ATTRIBUTE(Cbr, SatTrafficHelperConf::PROTOCOL_UDP)
215 .SIM_ADD_TRAFFIC_MODEL_DIRECTION_ATTRIBUTE(Cbr, SatTrafficHelperConf::RTN_LINK)
216 .SIM_ADD_TRAFFIC_MODEL_INTERVAL_ATTRIBUTE(Cbr, Seconds(1))
217 .SIM_ADD_TRAFFIC_MODEL_PACKET_SIZE_ATTRIBUTE(Cbr, 512)
218 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(Cbr, Seconds(0.1))
219 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(Cbr, Seconds(0))
220 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(Cbr, MilliSeconds(10))
221 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(Cbr, 1)
222
223 .SIM_ADD_TRAFFIC_MODEL_PROTOCOL_ATTRIBUTE(OnOff, SatTrafficHelperConf::PROTOCOL_UDP)
224 .SIM_ADD_TRAFFIC_MODEL_DIRECTION_ATTRIBUTE(OnOff, SatTrafficHelperConf::RTN_LINK)
225 .SIM_ADD_TRAFFIC_MODEL_DATA_RATE_ATTRIBUTE(OnOff, DataRate("500kb/s"))
226 .SIM_ADD_TRAFFIC_MODEL_PACKET_SIZE_ATTRIBUTE(OnOff, 512)
227 .SIM_ADD_TRAFFIC_MODEL_ON_TIME_PATTERN_ATTRIBUTE(
228 OnOff,
229 "ns3::ConstantRandomVariable[Constant=1000]")
230 .SIM_ADD_TRAFFIC_MODEL_OFF_TIME_PATTERN_ATTRIBUTE(
231 OnOff,
232 "ns3::ConstantRandomVariable[Constant=0]")
233 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(OnOff, Seconds(0.1))
234 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(OnOff, Seconds(0))
235 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(OnOff, MilliSeconds(10))
236 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(OnOff, 0)
237
238 .SIM_ADD_TRAFFIC_MODEL_DIRECTION_ATTRIBUTE(Http, SatTrafficHelperConf::RTN_LINK)
239 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(Http, Seconds(0.1))
240 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(Http, Seconds(0))
241 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(Http, MilliSeconds(10))
242 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(Http, 0)
243
244 .SIM_ADD_TRAFFIC_MODEL_DIRECTION_ATTRIBUTE(Nrtv, SatTrafficHelperConf::RTN_LINK)
245 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(Nrtv, Seconds(0.1))
246 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(Nrtv, Seconds(0))
247 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(Nrtv, MilliSeconds(10))
248 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(Nrtv, 0)
249
250 .SIM_ADD_TRAFFIC_MODEL_DIRECTION_ATTRIBUTE(Poisson, SatTrafficHelperConf::RTN_LINK)
251 .SIM_ADD_TRAFFIC_MODEL_ON_TIME_ATTRIBUTE(Poisson, Seconds(1))
252 .SIM_ADD_TRAFFIC_MODEL_OFF_TIME_ATTRIBUTE(Poisson, MilliSeconds(100))
253 .SIM_ADD_TRAFFIC_MODEL_DATA_RATE_ATTRIBUTE(Poisson, DataRate("500kb/s"))
254 .SIM_ADD_TRAFFIC_MODEL_PACKET_SIZE_ATTRIBUTE(Poisson, 512)
255 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(Poisson, Seconds(0.1))
256 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(Poisson, Seconds(0))
257 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(Poisson, MilliSeconds(10))
258 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(Poisson, 0)
259
260 .SIM_ADD_TRAFFIC_MODEL_DIRECTION_ATTRIBUTE(Voip, SatTrafficHelperConf::RTN_LINK)
261 .SIM_ADD_TRAFFIC_MODEL_CODEC_ATTRIBUTE(Voip, SatTrafficHelper::VoipCodec_t::G_711_1)
262 .SIM_ADD_TRAFFIC_MODEL_START_TIME_ATTRIBUTE(Voip, Seconds(0.1))
263 .SIM_ADD_TRAFFIC_MODEL_STOP_TIME_ATTRIBUTE(Voip, Seconds(0))
264 .SIM_ADD_TRAFFIC_MODEL_START_DELAY_ATTRIBUTE(Voip, MilliSeconds(10))
265 .SIM_ADD_TRAFFIC_MODEL_PERCENTAGE_ATTRIBUTE(Voip, 0);
266
267 return tid;
268}
269
271 : m_simTime(Seconds(0)),
272 m_trafficHelper(nullptr)
273{
274 NS_LOG_FUNCTION(this);
275
276 NS_FATAL_ERROR("Default constructor not in use");
277}
278
279SatTrafficHelperConf::SatTrafficHelperConf(Ptr<SatTrafficHelper> trafficHelper, Time simTime)
280 : m_simTime(simTime),
281 m_trafficHelper(trafficHelper)
282{
283 NS_LOG_FUNCTION(this << simTime << trafficHelper);
284}
285
287{
288 NS_LOG_FUNCTION(this);
289}
290
291NS_OBJECT_ENSURE_REGISTERED(SatTrafficHelper);
292
293TypeId
295{
296 static TypeId tid =
297 TypeId("ns3::SatTrafficHelper")
298 .SetParent<Object>()
299 .AddConstructor<SatTrafficHelper>()
300 .AddAttribute("EnableDefaultStatistics",
301 "Enable outputing values from stats helpers",
302 BooleanValue(true),
304 MakeBooleanChecker());
305 return tid;
306}
307
309 : m_satHelper(nullptr),
311{
312 NS_FATAL_ERROR("Default constructor of SatTrafficHelper cannot be used.");
313}
314
315SatTrafficHelper::SatTrafficHelper(Ptr<SatHelper> satHelper,
316 Ptr<SatStatsHelperContainer> satStatsHelperContainer)
317 : m_satHelper(satHelper),
318 m_satStatsHelperContainer(satStatsHelperContainer),
320{
321 m_last_custom_application.created = false;
322}
323
324void
326 uint32_t packetSize,
327 NodeContainer uts,
328 Time startTime,
329 Time stopTime,
330 Time startDelay)
331{
332 NS_LOG_FUNCTION(this << interval << packetSize << startTime << stopTime << startDelay);
333
334 if (uts.GetN() == 0)
335 {
336 NS_LOG_WARN("UT container is empty");
337 return;
338 }
339
340 PacketSinkHelper sinkHelper("ns3::UdpSocketFactory", Address());
341 CbrHelper cbrHelper("ns3::UdpSocketFactory", Address());
342 ApplicationContainer sinkContainer;
343 ApplicationContainer cbrContainer;
344
345 Ptr<Node> node;
346
347 // create Lora Periodic sender applications from UT users to GW users
348 for (uint32_t i = 0; i < uts.GetN(); i++)
349 {
350 node = uts.Get(i);
351 Ptr<LoraPeriodicSender> app = CreateObject<LoraPeriodicSender>();
352
353 app->SetInterval(interval);
354 NS_LOG_DEBUG("Created an application with interval = " << interval.GetHours() << " hours");
355
356 app->SetStartTime(startTime + (i + 1) * startDelay);
357 app->SetStopTime(stopTime);
358 app->SetPacketSize(packetSize);
359
360 app->SetNode(node);
361 node->AddApplication(app);
362 }
363}
364
365void
367 uint32_t packetSize,
368 NodeContainer uts,
369 Time startTime,
370 Time stopTime,
371 Time startDelay,
372 double percentage)
373{
374 NS_LOG_FUNCTION(this << interval << packetSize << startTime << stopTime << startDelay
375 << percentage);
376
377 // Filter UTs to keep only a given percentage on which installing the application
378 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
379 NodeContainer utsUpdated;
380 for (uint32_t i = 0; i < uts.GetN(); ++i)
381 {
382 if (rng->GetValue(0.0, 1.0) < percentage)
383 {
384 utsUpdated.Add(uts.Get(i));
385 }
386 }
387
388 AddLoraPeriodicTraffic(interval, packetSize, utsUpdated, startTime, stopTime, startDelay);
389}
390
391void
393 uint32_t packetSize,
394 NodeContainer gwUsers,
395 NodeContainer utUsers,
396 Time startTime,
397 Time stopTime,
398 Time startDelay)
399{
400 NS_LOG_FUNCTION(this << interval << packetSize << startTime << stopTime << startDelay);
401
402 if (gwUsers.GetN() == 0)
403 {
404 NS_LOG_WARN("Gateway users container is empty");
405 return;
406 }
407 if (utUsers.GetN() == 0)
408 {
409 NS_LOG_WARN("UT users container is empty");
410 return;
411 }
412
413 uint16_t port = 9;
414
415 PacketSinkHelper sinkHelper("ns3::UdpSocketFactory", Address());
416 CbrHelper cbrHelper("ns3::UdpSocketFactory", Address());
417 ApplicationContainer sinkContainer;
418 ApplicationContainer cbrContainer;
419
420 // create CBR applications from UT users to GW users
421 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
422 {
423 for (uint32_t i = 0; i < utUsers.GetN(); i++)
424 {
425 InetSocketAddress gwUserAddr =
426 InetSocketAddress(m_satHelper->GetUserAddress(gwUsers.Get(j)), port);
427 if (!HasSinkInstalled(gwUsers.Get(j), port))
428 {
429 sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
430 sinkContainer.Add(sinkHelper.Install(gwUsers.Get(j)));
431 }
432
433 cbrHelper.SetConstantTraffic(interval, packetSize);
434 cbrHelper.SetAttribute("Remote", AddressValue(Address(gwUserAddr)));
435 auto app = cbrHelper.Install(utUsers.Get(i)).Get(0);
436 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
437 cbrContainer.Add(app);
438 }
439 }
440
441 sinkContainer.Start(startTime);
442 sinkContainer.Stop(stopTime);
443}
444
445void
447 uint32_t packetSize,
448 NodeContainer gwUsers,
449 NodeContainer utUsers,
450 Time startTime,
451 Time stopTime,
452 Time startDelay,
453 double percentage)
454{
455 NS_LOG_FUNCTION(this << interval << packetSize << startTime << stopTime << startDelay
456 << percentage);
457
458 // Filter UT users to keep only a given percentage on which installing the application
459 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
460 NodeContainer utUsersUpdated;
461 for (uint32_t i = 0; i < utUsers.GetN(); ++i)
462 {
463 if (rng->GetValue(0.0, 1.0) < percentage)
464 {
465 utUsersUpdated.Add(utUsers.Get(i));
466 }
467 }
468
469 AddLoraCbrTraffic(interval,
470 packetSize,
471 gwUsers,
472 utUsersUpdated,
473 startTime,
474 stopTime,
475 startDelay);
476}
477
478void
481 Time interval,
482 uint32_t packetSize,
483 NodeContainer gwUsers,
484 NodeContainer utUsers,
485 Time startTime,
486 Time stopTime,
487 Time startDelay)
488{
489 NS_LOG_FUNCTION(this << interval << packetSize << startTime << stopTime << startDelay);
490
491 if (gwUsers.GetN() == 0)
492 {
493 NS_LOG_WARN("Gateway users container is empty");
494 return;
495 }
496 if (utUsers.GetN() == 0)
497 {
498 NS_LOG_WARN("UT users container is empty");
499 return;
500 }
501
502 std::string socketFactory =
503 (protocol == SatTrafficHelper::TCP ? "ns3::TcpSocketFactory" : "ns3::UdpSocketFactory");
504 uint16_t port = 9;
505
506 PacketSinkHelper sinkHelper(socketFactory, Address());
507 CbrHelper cbrHelper(socketFactory, Address());
508 ApplicationContainer sinkContainer;
509 ApplicationContainer cbrContainer;
510
511 // create CBR applications from GWs to UT users
512 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
513 {
514 for (uint32_t i = 0; i < utUsers.GetN(); i++)
515 {
516 if (direction == RTN_LINK)
517 {
518 InetSocketAddress gwUserAddr =
519 InetSocketAddress(m_satHelper->GetUserAddress(gwUsers.Get(j)), port);
520 if (!HasSinkInstalled(gwUsers.Get(j), port))
521 {
522 sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
523 sinkContainer.Add(sinkHelper.Install(gwUsers.Get(j)));
524 }
525
526 cbrHelper.SetConstantTraffic(interval, packetSize);
527 cbrHelper.SetAttribute("Remote", AddressValue(Address(gwUserAddr)));
528 auto app = cbrHelper.Install(utUsers.Get(i)).Get(0);
529 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
530 cbrContainer.Add(app);
531 }
532 else if (direction == FWD_LINK)
533 {
534 InetSocketAddress utUserAddr =
535 InetSocketAddress(m_satHelper->GetUserAddress(utUsers.Get(i)), port);
536 if (!HasSinkInstalled(utUsers.Get(i), port))
537 {
538 sinkHelper.SetAttribute("Local", AddressValue(Address(utUserAddr)));
539 sinkContainer.Add(sinkHelper.Install(utUsers.Get(i)));
540 }
541
542 cbrHelper.SetConstantTraffic(interval, packetSize);
543 cbrHelper.SetAttribute("Remote", AddressValue(Address(utUserAddr)));
544 auto app = cbrHelper.Install(gwUsers.Get(j)).Get(0);
545 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
546 cbrContainer.Add(app);
547 }
548 }
549 }
550
551 sinkContainer.Start(startTime);
552 sinkContainer.Stop(stopTime);
553
555 {
556 // Add throuhgput statistics
557 if (direction == FWD_LINK)
558 {
559 // Global scalar
560 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
562 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
564 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
566
567 // Global scatter
568 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
570 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
572 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
574
575 // Per UT scalar
577 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
579 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
581
582 // Per UT scatter
583 m_satStatsHelperContainer->AddPerUtFwdAppThroughput(
585 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
587 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
589
590 // Per GW scalar
592 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
594 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
596
597 // Per GW scatter
598 m_satStatsHelperContainer->AddPerGwFwdAppThroughput(
600 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
602 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
604 }
605 else if (direction == RTN_LINK)
606 {
607 // Global scalar
608 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
610 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
612 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
614
615 // Global scatter
616 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
618 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
620 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
622
623 // Per UT scalar
625 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
627 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
629
630 // Per UT scatter
631 m_satStatsHelperContainer->AddPerUtRtnAppThroughput(
633 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
635 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
637
638 // Per GW scalar
640 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
642 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
644
645 // Per GW scatter
646 m_satStatsHelperContainer->AddPerGwRtnAppThroughput(
648 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
650 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
652 }
653 }
654}
655
656void
659 Time interval,
660 uint32_t packetSize,
661 NodeContainer gwUsers,
662 NodeContainer utUsers,
663 Time startTime,
664 Time stopTime,
665 Time startDelay,
666 double percentage)
667{
668 NS_LOG_FUNCTION(this << interval << packetSize << startTime << stopTime << startDelay
669 << percentage);
670
671 // Filter UT users to keep only a given percentage on which installing the application
672 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
673 NodeContainer utUsersUpdated;
674 for (uint32_t i = 0; i < utUsers.GetN(); ++i)
675 {
676 if (rng->GetValue(0.0, 1.0) < percentage)
677 {
678 utUsersUpdated.Add(utUsers.Get(i));
679 }
680 }
681
682 AddCbrTraffic(direction,
683 protocol,
684 interval,
685 packetSize,
686 gwUsers,
687 utUsersUpdated,
688 startTime,
689 stopTime,
690 startDelay);
691}
692
693void
696 DataRate dataRate,
697 uint32_t packetSize,
698 NodeContainer gwUsers,
699 NodeContainer utUsers,
700 std::string onTimePattern,
701 std::string offTimePattern,
702 Time startTime,
703 Time stopTime,
704 Time startDelay)
705{
706 NS_LOG_FUNCTION(this << dataRate << packetSize << onTimePattern << offTimePattern << startTime
707 << stopTime << startDelay);
708
709 if (gwUsers.GetN() == 0)
710 {
711 NS_LOG_WARN("Gateway users container is empty");
712 return;
713 }
714 if (utUsers.GetN() == 0)
715 {
716 NS_LOG_WARN("UT users container is empty");
717 return;
718 }
719
720 std::string socketFactory =
721 (protocol == SatTrafficHelper::TCP ? "ns3::TcpSocketFactory" : "ns3::UdpSocketFactory");
722 uint16_t port = 9;
723
724 PacketSinkHelper sinkHelper(socketFactory, Address());
725 SatOnOffHelper onOffHelper(socketFactory, Address());
726 ApplicationContainer sinkContainer;
727 ApplicationContainer onOffContainer;
728
729 onOffHelper.SetAttribute("OnTime", StringValue(onTimePattern));
730 onOffHelper.SetAttribute("OffTime", StringValue(offTimePattern));
731 onOffHelper.SetAttribute("DataRate", DataRateValue(dataRate));
732 onOffHelper.SetAttribute("PacketSize", UintegerValue(packetSize));
733
734 // create ONOFF applications from GWs to UT users
735 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
736 {
737 for (uint32_t i = 0; i < utUsers.GetN(); i++)
738 {
739 if (direction == RTN_LINK)
740 {
741 InetSocketAddress gwUserAddr =
742 InetSocketAddress(m_satHelper->GetUserAddress(gwUsers.Get(j)), port);
743 if (!HasSinkInstalled(gwUsers.Get(j), port))
744 {
745 sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
746 sinkContainer.Add(sinkHelper.Install(gwUsers.Get(j)));
747 }
748
749 onOffHelper.SetAttribute("Remote", AddressValue(Address(gwUserAddr)));
750 auto app = onOffHelper.Install(utUsers.Get(i)).Get(0);
751 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
752 onOffContainer.Add(app);
753 }
754 else if (direction == FWD_LINK)
755 {
756 InetSocketAddress utUserAddr =
757 InetSocketAddress(m_satHelper->GetUserAddress(utUsers.Get(i)), port);
758 if (!HasSinkInstalled(utUsers.Get(i), port))
759 {
760 sinkHelper.SetAttribute("Local", AddressValue(Address(utUserAddr)));
761 sinkContainer.Add(sinkHelper.Install(utUsers.Get(i)));
762 }
763
764 onOffHelper.SetAttribute("Remote", AddressValue(Address(utUserAddr)));
765 auto app = onOffHelper.Install(gwUsers.Get(j)).Get(0);
766 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
767 onOffContainer.Add(app);
768 }
769 }
770 }
771
772 sinkContainer.Start(startTime);
773 sinkContainer.Stop(stopTime);
774
776 {
777 // Add throuhgput statistics
778 if (direction == FWD_LINK)
779 {
780 // Global scalar
781 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
783 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
785 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
787
788 // Global scatter
789 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
791 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
793 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
795
796 // Per UT scalar
798 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
800 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
802
803 // Per UT scatter
804 m_satStatsHelperContainer->AddPerUtFwdAppThroughput(
806 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
808 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
810
811 // Per GW scalar
813 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
815 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
817
818 // Per GW scatter
819 m_satStatsHelperContainer->AddPerGwFwdAppThroughput(
821 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
823 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
825 }
826 else if (direction == RTN_LINK)
827 {
828 // Global scalar
829 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
831 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
833 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
835
836 // Global scatter
837 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
839 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
841 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
843
844 // Per UT scalar
846 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
848 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
850
851 // Per UT scatter
852 m_satStatsHelperContainer->AddPerUtRtnAppThroughput(
854 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
856 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
858
859 // Per GW scalar
861 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
863 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
865
866 // Per GW scatter
867 m_satStatsHelperContainer->AddPerGwRtnAppThroughput(
869 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
871 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
873 }
874 }
875}
876
877void
880 DataRate dataRate,
881 uint32_t packetSize,
882 NodeContainer gwUsers,
883 NodeContainer utUsers,
884 std::string onTimePattern,
885 std::string offTimePattern,
886 Time startTime,
887 Time stopTime,
888 Time startDelay,
889 double percentage)
890{
891 NS_LOG_FUNCTION(this << dataRate << packetSize << onTimePattern << offTimePattern << startTime
892 << stopTime << startDelay << percentage);
893
894 // Filter UT users to keep only a given percentage on which installing the application
895 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
896 NodeContainer utUsersUpdated;
897 for (uint32_t i = 0; i < utUsers.GetN(); ++i)
898 {
899 if (rng->GetValue(0.0, 1.0) < percentage)
900 {
901 utUsersUpdated.Add(utUsers.Get(i));
902 }
903 }
904
905 AddOnOffTraffic(direction,
906 protocol,
907 dataRate,
908 packetSize,
909 gwUsers,
910 utUsersUpdated,
911 onTimePattern,
912 offTimePattern,
913 startTime,
914 stopTime,
915 startDelay);
916}
917
918void
920 NodeContainer gwUsers,
921 NodeContainer utUsers,
922 Time startTime,
923 Time stopTime,
924 Time startDelay)
925{
926 NS_LOG_FUNCTION(this << direction << startTime << stopTime << startDelay);
927
928 if (gwUsers.GetN() == 0)
929 {
930 NS_LOG_WARN("Gateway users container is empty");
931 return;
932 }
933 if (utUsers.GetN() == 0)
934 {
935 NS_LOG_WARN("UT users container is empty");
936 return;
937 }
938
939 ThreeGppHttpHelper httpHelper;
940 if (direction == FWD_LINK)
941 {
942 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
943 {
944 auto app = httpHelper.InstallUsingIpv4(gwUsers.Get(j), utUsers).Get(1);
945 app->SetStartTime(startTime + (j + 1) * startDelay);
946 httpHelper.GetServer().Start(startTime);
947 httpHelper.GetServer().Stop(stopTime);
948 }
949 }
950 else if (direction == RTN_LINK)
951 {
952 for (uint32_t i = 0; i < utUsers.GetN(); i++)
953 {
954 auto app = httpHelper.InstallUsingIpv4(utUsers.Get(i), gwUsers).Get(1);
955 app->SetStartTime(startTime + (i + 1) * startDelay);
956 httpHelper.GetServer().Start(startTime);
957 httpHelper.GetServer().Stop(stopTime);
958 }
959 }
960
962 {
963 // Add PLT statistics
964 if (direction == FWD_LINK)
965 {
972 }
973 else if (direction == RTN_LINK)
974 {
981 }
982
983 // Add throuhgput statistics
984 if (direction == FWD_LINK)
985 {
986 // Global scalar
987 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
989 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
991 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
993
994 // Global scatter
995 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
997 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
999 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1001
1002 // Per UT scalar
1004 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1006 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1008
1009 // Per UT scatter
1010 m_satStatsHelperContainer->AddPerUtFwdAppThroughput(
1012 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1014 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1016
1017 // Per GW scalar
1019 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1021 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1023
1024 // Per GW scatter
1025 m_satStatsHelperContainer->AddPerGwFwdAppThroughput(
1027 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1029 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1031 }
1032 else if (direction == RTN_LINK)
1033 {
1034 // Global scalar
1035 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1037 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1039 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1041
1042 // Global scatter
1043 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1045 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1047 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1049
1050 // Per UT scalar
1052 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1054 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1056
1057 // Per UT scatter
1058 m_satStatsHelperContainer->AddPerUtRtnAppThroughput(
1060 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1062 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1064
1065 // Per GW scalar
1067 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1069 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1071
1072 // Per GW scatter
1073 m_satStatsHelperContainer->AddPerGwRtnAppThroughput(
1075 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1077 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1079 }
1080 }
1081}
1082
1083void
1085 NodeContainer gwUsers,
1086 NodeContainer utUsers,
1087 Time startTime,
1088 Time stopTime,
1089 Time startDelay,
1090 double percentage)
1091{
1092 NS_LOG_FUNCTION(this << direction << startTime << stopTime << startDelay << percentage);
1093
1094 // Filter UT users to keep only a given percentage on which installing the application
1095 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
1096 NodeContainer utUsersUpdated;
1097 for (uint32_t i = 0; i < utUsers.GetN(); ++i)
1098 {
1099 if (rng->GetValue(0.0, 1.0) < percentage)
1100 {
1101 utUsersUpdated.Add(utUsers.Get(i));
1102 }
1103 }
1104
1105 AddHttpTraffic(direction, gwUsers, utUsersUpdated, startTime, stopTime, startDelay);
1106}
1107
1108void
1110 NodeContainer gwUsers,
1111 NodeContainer utUsers,
1112 Time startTime,
1113 Time stopTime,
1114 Time startDelay)
1115{
1116 NS_LOG_FUNCTION(this << direction << startTime << stopTime << startDelay);
1117
1118 if (gwUsers.GetN() == 0)
1119 {
1120 NS_LOG_WARN("Gateway users container is empty");
1121 return;
1122 }
1123 if (utUsers.GetN() == 0)
1124 {
1125 NS_LOG_WARN("UT users container is empty");
1126 return;
1127 }
1128
1129 std::string socketFactory = "ns3::TcpSocketFactory";
1130
1131 NrtvHelper nrtvHelper(TypeId::LookupByName(socketFactory));
1132 if (direction == FWD_LINK)
1133 {
1134 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
1135 {
1136 auto app = nrtvHelper.InstallUsingIpv4(gwUsers.Get(j), utUsers).Get(1);
1137 app->SetStartTime(startTime + (j + 1) * startDelay);
1138 nrtvHelper.GetServer().Start(startTime);
1139 nrtvHelper.GetServer().Stop(stopTime);
1140 }
1141 }
1142 else if (direction == RTN_LINK)
1143 {
1144 for (uint32_t i = 0; i < utUsers.GetN(); i++)
1145 {
1146 auto app = nrtvHelper.InstallUsingIpv4(utUsers.Get(i), gwUsers).Get(1);
1147 app->SetStartTime(startTime + (i + 1) * startDelay);
1148 nrtvHelper.GetServer().Start(startTime);
1149 nrtvHelper.GetServer().Stop(stopTime);
1150 }
1151 }
1152
1154 {
1155 // Add throuhgput statistics
1156 if (direction == FWD_LINK)
1157 {
1158 // Global scalar
1159 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1161 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1163 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1165
1166 // Global scatter
1167 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1169 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1171 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1173
1174 // Per UT scalar
1176 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1178 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1180
1181 // Per UT scatter
1182 m_satStatsHelperContainer->AddPerUtFwdAppThroughput(
1184 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1186 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1188
1189 // Per GW scalar
1191 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1193 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1195
1196 // Per GW scatter
1197 m_satStatsHelperContainer->AddPerGwFwdAppThroughput(
1199 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1201 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1203 }
1204 else if (direction == RTN_LINK)
1205 {
1206 // Global scalar
1207 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1209 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1211 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1213
1214 // Global scatter
1215 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1217 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1219 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1221
1222 // Per UT scalar
1224 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1226 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1228
1229 // Per UT scatter
1230 m_satStatsHelperContainer->AddPerUtRtnAppThroughput(
1232 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1234 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1236
1237 // Per GW scalar
1239 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1241 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1243
1244 // Per GW scatter
1245 m_satStatsHelperContainer->AddPerGwRtnAppThroughput(
1247 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1249 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1251 }
1252 }
1253}
1254
1255void
1257 NodeContainer gwUsers,
1258 NodeContainer utUsers,
1259 Time startTime,
1260 Time stopTime,
1261 Time startDelay,
1262 double percentage)
1263{
1264 NS_LOG_FUNCTION(this << direction << startTime << stopTime << startDelay << percentage);
1265
1266 // Filter UT users to keep only a given percentage on which installing the application
1267 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
1268 NodeContainer utUsersUpdated;
1269 for (uint32_t i = 0; i < utUsers.GetN(); ++i)
1270 {
1271 if (rng->GetValue(0.0, 1.0) < percentage)
1272 {
1273 utUsersUpdated.Add(utUsers.Get(i));
1274 }
1275 }
1276
1277 AddNrtvTraffic(direction, gwUsers, utUsersUpdated, startTime, stopTime, startDelay);
1278}
1279
1280void
1282 Time onTime,
1283 Time offTimeExpMean,
1284 DataRate rate,
1285 uint32_t packetSize,
1286 NodeContainer gwUsers,
1287 NodeContainer utUsers,
1288 Time startTime,
1289 Time stopTime,
1290 Time startDelay)
1291{
1292 NS_LOG_FUNCTION(this << direction << onTime << offTimeExpMean << rate << packetSize << startTime
1293 << stopTime << startDelay);
1294
1295 if (gwUsers.GetN() == 0)
1296 {
1297 NS_LOG_WARN("Gateway users container is empty");
1298 return;
1299 }
1300 if (utUsers.GetN() == 0)
1301 {
1302 NS_LOG_WARN("UT users container is empty");
1303 return;
1304 }
1305
1306 std::string socketFactory = "ns3::UdpSocketFactory";
1307
1308 uint16_t port = 9;
1309
1310 PacketSinkHelper sinkHelper(socketFactory, Address());
1311 SatOnOffHelper onOffHelper(socketFactory, Address());
1312 ApplicationContainer sinkContainer;
1313 ApplicationContainer onOffContainer;
1314
1315 // create CBR applications from GWs to UT users
1316 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
1317 {
1318 for (uint32_t i = 0; i < utUsers.GetN(); i++)
1319 {
1320 if (direction == RTN_LINK)
1321 {
1322 InetSocketAddress gwUserAddr =
1323 InetSocketAddress(m_satHelper->GetUserAddress(gwUsers.Get(j)), port);
1324
1325 if (!HasSinkInstalled(gwUsers.Get(j), port))
1326 {
1327 sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
1328 sinkContainer.Add(sinkHelper.Install(gwUsers.Get(j)));
1329 }
1330
1331 onOffHelper.SetAttribute("OnTime",
1332 StringValue("ns3::ConstantRandomVariable[Constant=" +
1333 std::to_string(onTime.GetSeconds()) + "]"));
1334 onOffHelper.SetAttribute("OffTime",
1335 StringValue("ns3::ExponentialRandomVariable[Mean=" +
1336 std::to_string(offTimeExpMean.GetSeconds()) +
1337 "]"));
1338 onOffHelper.SetAttribute("DataRate", DataRateValue(rate));
1339 onOffHelper.SetAttribute("PacketSize", UintegerValue(packetSize));
1340 onOffHelper.SetAttribute("Remote", AddressValue(Address(gwUserAddr)));
1341
1342 auto app = onOffHelper.Install(utUsers.Get(i)).Get(0);
1343 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
1344 onOffContainer.Add(app);
1345 }
1346 else if (direction == FWD_LINK)
1347 {
1348 InetSocketAddress utUserAddr =
1349 InetSocketAddress(m_satHelper->GetUserAddress(utUsers.Get(i)), port);
1350
1351 if (!HasSinkInstalled(utUsers.Get(i), port))
1352 {
1353 sinkHelper.SetAttribute("Local", AddressValue(Address(utUserAddr)));
1354 sinkContainer.Add(sinkHelper.Install(utUsers.Get(i)));
1355 }
1356
1357 onOffHelper.SetAttribute("OnTime",
1358 StringValue("ns3::ConstantRandomVariable[Constant=" +
1359 std::to_string(onTime.GetSeconds()) + "]"));
1360 onOffHelper.SetAttribute("OffTime",
1361 StringValue("ns3::ExponentialRandomVariable[Mean=" +
1362 std::to_string(offTimeExpMean.GetSeconds()) +
1363 "]"));
1364 onOffHelper.SetAttribute("DataRate", DataRateValue(rate));
1365 onOffHelper.SetAttribute("PacketSize", UintegerValue(packetSize));
1366 onOffHelper.SetAttribute("Remote", AddressValue(Address(utUserAddr)));
1367
1368 auto app = onOffHelper.Install(gwUsers.Get(j)).Get(0);
1369 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
1370 onOffContainer.Add(app);
1371 }
1372 }
1373 }
1374 sinkContainer.Start(startTime);
1375 sinkContainer.Stop(stopTime);
1376
1378 {
1379 // Add throuhgput statistics
1380 if (direction == FWD_LINK)
1381 {
1382 // Global scalar
1383 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1385 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1387 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1389
1390 // Global scatter
1391 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1393 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1395 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1397
1398 // Per UT scalar
1400 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1402 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1404
1405 // Per UT scatter
1406 m_satStatsHelperContainer->AddPerUtFwdAppThroughput(
1408 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1410 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1412
1413 // Per GW scalar
1415 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1417 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1419
1420 // Per GW scatter
1421 m_satStatsHelperContainer->AddPerGwFwdAppThroughput(
1423 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1425 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1427 }
1428 else if (direction == RTN_LINK)
1429 {
1430 // Global scalar
1431 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1433 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1435 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1437
1438 // Global scatter
1439 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1441 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1443 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1445
1446 // Per UT scalar
1448 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1450 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1452
1453 // Per UT scatter
1454 m_satStatsHelperContainer->AddPerUtRtnAppThroughput(
1456 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1458 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1460
1461 // Per GW scalar
1463 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1465 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1467
1468 // Per GW scatter
1469 m_satStatsHelperContainer->AddPerGwRtnAppThroughput(
1471 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1473 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1475 }
1476 }
1477}
1478
1479void
1481 Time onTime,
1482 Time offTimeExpMean,
1483 DataRate rate,
1484 uint32_t packetSize,
1485 NodeContainer gwUsers,
1486 NodeContainer utUsers,
1487 Time startTime,
1488 Time stopTime,
1489 Time startDelay,
1490 double percentage)
1491{
1492 NS_LOG_FUNCTION(this << direction << onTime << offTimeExpMean << rate << packetSize << startTime
1493 << stopTime << startDelay << percentage);
1494
1495 // Filter UT users to keep only a given percentage on which installing the application
1496 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
1497 NodeContainer utUsersUpdated;
1498 for (uint32_t i = 0; i < utUsers.GetN(); ++i)
1499 {
1500 if (rng->GetValue(0.0, 1.0) < percentage)
1501 {
1502 utUsersUpdated.Add(utUsers.Get(i));
1503 }
1504 }
1505
1506 AddPoissonTraffic(direction,
1507 onTime,
1508 offTimeExpMean,
1509 rate,
1510 packetSize,
1511 gwUsers,
1512 utUsersUpdated,
1513 startTime,
1514 stopTime,
1515 startDelay);
1516}
1517
1518void
1520 VoipCodec_t codec,
1521 NodeContainer gwUsers,
1522 NodeContainer utUsers,
1523 Time startTime,
1524 Time stopTime,
1525 Time startDelay)
1526{
1527 NS_LOG_FUNCTION(this << direction << codec << startTime << stopTime << startDelay);
1528
1529 if (gwUsers.GetN() == 0)
1530 {
1531 NS_LOG_WARN("Gateway users container is empty");
1532 return;
1533 }
1534 if (utUsers.GetN() == 0)
1535 {
1536 NS_LOG_WARN("UT users container is empty");
1537 return;
1538 }
1539
1540 std::string socketFactory = "ns3::UdpSocketFactory";
1541 uint16_t port = 9;
1542
1543 double onTime;
1544 double offTime;
1545 std::string rate;
1546 uint32_t packetSize;
1547
1548 switch (codec)
1549 {
1550 case G_711_1:
1551 onTime = 0.5;
1552 offTime = 0.05;
1553 rate = "70kbps"; // 64kbps globally
1554 packetSize = 80;
1555 break;
1556 case G_711_2:
1557 onTime = 0.5;
1558 offTime = 0.05;
1559 rate = "70kbps"; // 64kbps globally
1560 packetSize = 160;
1561 break;
1562 case G_723_1:
1563 onTime = 0.5;
1564 offTime = 0.05;
1565 rate = "6864bps"; // 6240bps globally
1566 packetSize = 30;
1567 break;
1568 case G_729_2:
1569 onTime = 0.5;
1570 offTime = 0.05;
1571 rate = "8800bps"; // 8kbps globally
1572 packetSize = 20;
1573 break;
1574 case G_729_3:
1575 onTime = 0.5;
1576 offTime = 0.05;
1577 rate = "7920bps"; // 7200bps globally
1578 packetSize = 30;
1579 break;
1580 default:
1581 NS_FATAL_ERROR("VoIP codec does not exist or is not implemented");
1582 }
1583
1584 PacketSinkHelper sinkHelper(socketFactory, Address());
1585 SatOnOffHelper onOffHelper(socketFactory, Address());
1586 ApplicationContainer sinkContainer;
1587 ApplicationContainer onOffContainer;
1588
1589 // create CBR applications from GWs to UT users
1590 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
1591 {
1592 for (uint32_t i = 0; i < utUsers.GetN(); i++)
1593 {
1594 if (direction == RTN_LINK)
1595 {
1596 InetSocketAddress gwUserAddr =
1597 InetSocketAddress(m_satHelper->GetUserAddress(gwUsers.Get(j)), port);
1598
1599 if (!HasSinkInstalled(gwUsers.Get(j), port))
1600 {
1601 sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
1602 sinkContainer.Add(sinkHelper.Install(gwUsers.Get(j)));
1603 }
1604
1605 onOffHelper.SetAttribute("OnTime",
1606 StringValue("ns3::ConstantRandomVariable[Constant=" +
1607 std::to_string(onTime) + "]"));
1608 onOffHelper.SetAttribute("OffTime",
1609 StringValue("ns3::ConstantRandomVariable[Constant=" +
1610 std::to_string(offTime) + "]"));
1611 onOffHelper.SetAttribute("DataRate", DataRateValue(rate));
1612 onOffHelper.SetAttribute("PacketSize", UintegerValue(packetSize));
1613 onOffHelper.SetAttribute("Remote", AddressValue(Address(gwUserAddr)));
1614
1615 auto app = onOffHelper.Install(utUsers.Get(i)).Get(0);
1616 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
1617 onOffContainer.Add(app);
1618 }
1619 else if (direction == FWD_LINK)
1620 {
1621 InetSocketAddress utUserAddr =
1622 InetSocketAddress(m_satHelper->GetUserAddress(utUsers.Get(i)), port);
1623
1624 if (!HasSinkInstalled(utUsers.Get(i), port))
1625 {
1626 sinkHelper.SetAttribute("Local", AddressValue(Address(utUserAddr)));
1627 sinkContainer.Add(sinkHelper.Install(utUsers.Get(i)));
1628 }
1629
1630 onOffHelper.SetAttribute("OnTime",
1631 StringValue("ns3::ConstantRandomVariable[Constant=" +
1632 std::to_string(onTime) + "]"));
1633 onOffHelper.SetAttribute("OffTime",
1634 StringValue("ns3::ConstantRandomVariable[Constant=" +
1635 std::to_string(offTime) + "]"));
1636 onOffHelper.SetAttribute("DataRate", DataRateValue(rate));
1637 onOffHelper.SetAttribute("PacketSize", UintegerValue(packetSize));
1638 onOffHelper.SetAttribute("Remote", AddressValue(Address(utUserAddr)));
1639
1640 auto app = onOffHelper.Install(gwUsers.Get(j)).Get(0);
1641 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
1642 onOffContainer.Add(app);
1643 }
1644 }
1645 }
1646 sinkContainer.Start(startTime);
1647 sinkContainer.Stop(stopTime);
1648
1650 {
1651 // Add jitter statistics
1652 if (direction == FWD_LINK)
1653 {
1654 // Global
1657
1658 // Per UT
1661
1662 // Per GW
1665 }
1666 else if (direction == RTN_LINK)
1667 {
1668 // Global
1671
1672 // Per UT
1675
1676 // Per GW
1679 }
1680
1681 // Add throuhgput statistics
1682 if (direction == FWD_LINK)
1683 {
1684 // Global scalar
1685 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1687 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1689 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1691
1692 // Global scatter
1693 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1695 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1697 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1699
1700 // Per UT scalar
1702 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1704 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1706
1707 // Per UT scatter
1708 m_satStatsHelperContainer->AddPerUtFwdAppThroughput(
1710 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1712 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1714
1715 // Per GW scalar
1717 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1719 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1721
1722 // Per GW scatter
1723 m_satStatsHelperContainer->AddPerGwFwdAppThroughput(
1725 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1727 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1729 }
1730 else if (direction == RTN_LINK)
1731 {
1732 // Global scalar
1733 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1735 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1737 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1739
1740 // Global scatter
1741 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1743 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1745 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1747
1748 // Per UT scalar
1750 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1752 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1754
1755 // Per UT scatter
1756 m_satStatsHelperContainer->AddPerUtRtnAppThroughput(
1758 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1760 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1762
1763 // Per GW scalar
1765 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1767 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1769
1770 // Per GW scatter
1771 m_satStatsHelperContainer->AddPerGwRtnAppThroughput(
1773 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1775 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1777 }
1778 }
1779}
1780
1781void
1783 VoipCodec_t codec,
1784 NodeContainer gwUsers,
1785 NodeContainer utUsers,
1786 Time startTime,
1787 Time stopTime,
1788 Time startDelay,
1789 double percentage)
1790{
1791 NS_LOG_FUNCTION(this << direction << codec << startTime << stopTime << startDelay
1792 << percentage);
1793
1794 // Filter UT users to keep only a given percentage on which installing the application
1795 Ptr<UniformRandomVariable> rng = CreateObject<UniformRandomVariable>();
1796 NodeContainer utUsersUpdated;
1797 for (uint32_t i = 0; i < utUsers.GetN(); ++i)
1798 {
1799 if (rng->GetValue(0.0, 1.0) < percentage)
1800 {
1801 utUsersUpdated.Add(utUsers.Get(i));
1802 }
1803 }
1804
1805 AddVoipTraffic(direction, codec, gwUsers, utUsersUpdated, startTime, stopTime, startDelay);
1806}
1807
1808void
1810 std::string interval,
1811 uint32_t packetSize,
1812 NodeContainer gwUsers,
1813 NodeContainer utUsers,
1814 Time startTime,
1815 Time stopTime,
1816 Time startDelay)
1817{
1818 NS_LOG_FUNCTION(this << direction << interval << packetSize << startTime << stopTime
1819 << startDelay);
1820
1821 if (gwUsers.GetN() == 0)
1822 {
1823 NS_LOG_WARN("Gateway users container is empty");
1824 return;
1825 }
1826 if (utUsers.GetN() == 0)
1827 {
1828 NS_LOG_WARN("UT users container is empty");
1829 return;
1830 }
1831
1832 std::string socketFactory = "ns3::UdpSocketFactory";
1833 uint16_t port = 9;
1834
1835 PacketSinkHelper sinkHelper(socketFactory, Address());
1836
1837 ObjectFactory factory;
1838 factory.SetTypeId("ns3::CbrApplication");
1839 factory.Set("Protocol", StringValue(socketFactory));
1840 ApplicationContainer sinkContainer;
1841 ApplicationContainer cbrContainer;
1842
1843 // create CBR applications from GWs to UT users
1844 for (uint32_t j = 0; j < gwUsers.GetN(); j++)
1845 {
1846 for (uint32_t i = 0; i < utUsers.GetN(); i++)
1847 {
1848 if (direction == RTN_LINK)
1849 {
1850 InetSocketAddress gwUserAddr =
1851 InetSocketAddress(m_satHelper->GetUserAddress(gwUsers.Get(j)), port);
1852 if (!HasSinkInstalled(gwUsers.Get(j), port))
1853 {
1854 sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
1855 sinkContainer.Add(sinkHelper.Install(gwUsers.Get(j)));
1856 }
1857
1858 factory.Set("Interval", TimeValue(Time(interval)));
1859 factory.Set("PacketSize", UintegerValue(packetSize));
1860 factory.Set("Remote", AddressValue(Address(gwUserAddr)));
1861 Ptr<CbrApplication> p_app = factory.Create<CbrApplication>();
1862 utUsers.Get(i)->AddApplication(p_app);
1863 auto app = ApplicationContainer(p_app).Get(0);
1864 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
1865 cbrContainer.Add(app);
1866 }
1867 else if (direction == FWD_LINK)
1868 {
1869 InetSocketAddress utUserAddr =
1870 InetSocketAddress(m_satHelper->GetUserAddress(utUsers.Get(i)), port);
1871 if (!HasSinkInstalled(utUsers.Get(i), port))
1872 {
1873 sinkHelper.SetAttribute("Local", AddressValue(Address(utUserAddr)));
1874 sinkContainer.Add(sinkHelper.Install(utUsers.Get(i)));
1875 }
1876
1877 factory.Set("Interval", TimeValue(Time(interval)));
1878 factory.Set("PacketSize", UintegerValue(packetSize));
1879 factory.Set("Remote", AddressValue(Address(utUserAddr)));
1880 Ptr<CbrApplication> p_app = factory.Create<CbrApplication>();
1881 gwUsers.Get(j)->AddApplication(p_app);
1882 auto app = ApplicationContainer(p_app).Get(0);
1883 app->SetStartTime(startTime + (i + j * gwUsers.GetN() + 1) * startDelay);
1884 cbrContainer.Add(app);
1885 }
1886 }
1887 }
1888
1889 sinkContainer.Start(startTime);
1890 sinkContainer.Stop(stopTime);
1891
1892 m_last_custom_application.application = cbrContainer;
1893 m_last_custom_application.start = startTime;
1894 m_last_custom_application.stop = stopTime;
1895 m_last_custom_application.created = true;
1896
1898 {
1899 // Add throuhgput statistics
1900 if (direction == FWD_LINK)
1901 {
1902 // Global scalar
1903 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1905 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1907 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1909
1910 // Global scatter
1911 m_satStatsHelperContainer->AddGlobalFwdAppThroughput(
1913 m_satStatsHelperContainer->AddGlobalFwdFeederMacThroughput(
1915 m_satStatsHelperContainer->AddGlobalFwdUserMacThroughput(
1917
1918 // Per UT scalar
1920 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1922 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1924
1925 // Per UT scatter
1926 m_satStatsHelperContainer->AddPerUtFwdAppThroughput(
1928 m_satStatsHelperContainer->AddPerUtFwdFeederMacThroughput(
1930 m_satStatsHelperContainer->AddPerUtFwdUserMacThroughput(
1932
1933 // Per GW scalar
1935 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1937 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1939
1940 // Per GW scatter
1941 m_satStatsHelperContainer->AddPerGwFwdAppThroughput(
1943 m_satStatsHelperContainer->AddPerGwFwdFeederMacThroughput(
1945 m_satStatsHelperContainer->AddPerGwFwdUserMacThroughput(
1947 }
1948 else if (direction == RTN_LINK)
1949 {
1950 // Global scalar
1951 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1953 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1955 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1957
1958 // Global scatter
1959 m_satStatsHelperContainer->AddGlobalRtnAppThroughput(
1961 m_satStatsHelperContainer->AddGlobalRtnFeederMacThroughput(
1963 m_satStatsHelperContainer->AddGlobalRtnUserMacThroughput(
1965
1966 // Per UT scalar
1968 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1970 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1972
1973 // Per UT scatter
1974 m_satStatsHelperContainer->AddPerUtRtnAppThroughput(
1976 m_satStatsHelperContainer->AddPerUtRtnFeederMacThroughput(
1978 m_satStatsHelperContainer->AddPerUtRtnUserMacThroughput(
1980
1981 // Per GW scalar
1983 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1985 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1987
1988 // Per GW scatter
1989 m_satStatsHelperContainer->AddPerGwRtnAppThroughput(
1991 m_satStatsHelperContainer->AddPerGwRtnFeederMacThroughput(
1993 m_satStatsHelperContainer->AddPerGwRtnUserMacThroughput(
1995 }
1996 }
1997}
1998
1999void
2000SatTrafficHelper::ChangeCustomTraffic(Time delay, std::string interval, uint32_t packetSize)
2001{
2002 NS_LOG_FUNCTION(this << delay << interval << packetSize);
2003
2004 if (!m_last_custom_application.created)
2005 {
2006 NS_FATAL_ERROR("No custom traffic created when calling the method "
2007 "SatTrafficHelper::ChangeCustomTraffic for the first time.");
2008 }
2010 {
2011 NS_FATAL_ERROR("Custom traffic updated after its stop time.");
2012 }
2013 for (auto i = m_last_custom_application.application.Begin();
2014 i != m_last_custom_application.application.End();
2015 ++i)
2016 {
2017 Ptr<CbrApplication> app = (dynamic_cast<CbrApplication*>(PeekPointer(*i)));
2018 Simulator::Schedule(m_last_custom_application.start + delay,
2020 this,
2021 app,
2022 interval,
2023 packetSize);
2024 }
2025}
2026
2027void
2028SatTrafficHelper::UpdateAttribute(Ptr<CbrApplication> application,
2029 std::string interval,
2030 uint32_t packetSize)
2031{
2032 NS_LOG_FUNCTION(this << application << interval << packetSize);
2033
2034 application->SetInterval(Time(interval));
2035 application->SetPacketSize(packetSize);
2036}
2037
2038bool
2039SatTrafficHelper::HasSinkInstalled(Ptr<Node> node, uint16_t port)
2040{
2041 NS_LOG_FUNCTION(this << node->GetId() << port);
2042
2043 for (uint32_t i = 0; i < node->GetNApplications(); i++)
2044 {
2045 auto sink = DynamicCast<PacketSink>(node->GetApplication(i));
2046 if (sink != nullptr)
2047 {
2048 AddressValue av;
2049 sink->GetAttribute("Local", av);
2050 if (InetSocketAddress::ConvertFrom(av.Get()).GetPort() == port)
2051 {
2052 return true;
2053 }
2054 }
2055 }
2056 return false;
2057}
2058
2059void
2061{
2062 NS_LOG_FUNCTION(this);
2063
2064 NS_ASSERT_MSG(m_trafficHelper != nullptr, "Traffic helper must be defined");
2065
2066 for (const std::pair<const std::string, SatTrafficHelperConf::TrafficConfiguration_t>&
2067 trafficModel : m_trafficModel)
2068 {
2070 if (trafficModel.first == "LoraCbr")
2071 {
2073 }
2074 else if (trafficModel.first == "LoraPeriodic")
2075 {
2076 modelName = SatTrafficHelper::LORA_CBR;
2077 }
2078 else if (trafficModel.first == "Cbr")
2079 {
2080 modelName = SatTrafficHelper::CBR;
2081 }
2082 else if (trafficModel.first == "OnOff")
2083 {
2084 modelName = SatTrafficHelper::ONOFF;
2085 }
2086 else if (trafficModel.first == "Http")
2087 {
2088 modelName = SatTrafficHelper::HTTP;
2089 }
2090 else if (trafficModel.first == "Nrtv")
2091 {
2092 modelName = SatTrafficHelper::NRTV;
2093 }
2094 else if (trafficModel.first == "Poisson")
2095 {
2096 modelName = SatTrafficHelper::POISSON;
2097 }
2098 else if (trafficModel.first == "Voip")
2099 {
2100 modelName = SatTrafficHelper::VOIP;
2101 }
2102 else
2103 {
2104 NS_FATAL_ERROR("Unknown traffic model has been configured: " << trafficModel.first);
2105 }
2106
2107 std::vector<SatTrafficHelper::TransportLayerProtocol_t> protocols;
2108 switch (trafficModel.second.m_protocol)
2109 {
2111 protocols.push_back(SatTrafficHelper::UDP);
2112 break;
2113 }
2115 protocols.push_back(SatTrafficHelper::TCP);
2116 break;
2117 }
2119 protocols.push_back(SatTrafficHelper::TCP);
2120 protocols.push_back(SatTrafficHelper::UDP);
2121 break;
2122 }
2123 default: {
2124 NS_FATAL_ERROR("Unknown traffic protocol");
2125 }
2126 }
2127
2128 std::vector<SatTrafficHelper::TrafficDirection_t> directions;
2129 switch (trafficModel.second.m_direction)
2130 {
2132 directions.push_back(SatTrafficHelper::RTN_LINK);
2133 break;
2134 }
2136 directions.push_back(SatTrafficHelper::FWD_LINK);
2137 break;
2138 }
2140 directions.push_back(SatTrafficHelper::FWD_LINK);
2141 directions.push_back(SatTrafficHelper::RTN_LINK);
2142 break;
2143 }
2144 default: {
2145 NS_FATAL_ERROR("Unknown traffic protocol");
2146 }
2147 }
2148
2149 if (trafficModel.second.m_percentage > 0.0)
2150 {
2151 SatTrafficHelperConf::TrafficConfiguration_t conf = trafficModel.second;
2152 Time startTime = conf.m_startTime;
2153 if (startTime > m_simTime)
2154 {
2155 NS_FATAL_ERROR("Traffic model "
2156 << trafficModel.first
2157 << " configured to start after the simulation ended");
2158 }
2159
2160 Time stopTime = conf.m_stopTime;
2161 if (stopTime == Seconds(0))
2162 {
2163 stopTime = m_simTime + Seconds(1);
2164 }
2165 if (stopTime < startTime)
2166 {
2167 NS_FATAL_ERROR("Traffic model " << trafficModel.first
2168 << " configured to stop before it is started");
2169 }
2170
2171 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwUserNodes();
2172 NodeContainer uts;
2173 if (modelName == SatTrafficHelper::LORA_PERIODIC)
2174 {
2175 uts = Singleton<SatTopology>::Get()->GetUtNodes();
2176 }
2177 else
2178 {
2179 uts = Singleton<SatTopology>::Get()->GetUtUserNodes();
2180 }
2181
2182 for (SatTrafficHelper::TransportLayerProtocol_t& protocol : protocols)
2183 {
2184 for (SatTrafficHelper::TrafficDirection_t& direction : directions)
2185 {
2186 switch (modelName)
2187 {
2189 m_trafficHelper->AddLoraPeriodicTraffic(conf.m_interval,
2190 conf.m_packetSize,
2191 uts,
2192 startTime,
2193 stopTime,
2194 conf.m_startDelay,
2195 conf.m_percentage);
2196 break;
2197 }
2199 m_trafficHelper->AddLoraCbrTraffic(conf.m_interval,
2200 conf.m_packetSize,
2201 gws,
2202 uts,
2203 startTime,
2204 stopTime,
2205 conf.m_startDelay,
2206 conf.m_percentage);
2207 break;
2208 }
2209 case SatTrafficHelper::CBR: {
2210 m_trafficHelper->AddCbrTraffic(direction,
2211 protocol,
2212 conf.m_interval,
2213 conf.m_packetSize,
2214 gws,
2215 uts,
2216 startTime,
2217 stopTime,
2218 conf.m_startDelay,
2219 conf.m_percentage);
2220 break;
2221 }
2223 m_trafficHelper->AddOnOffTraffic(direction,
2224 protocol,
2225 conf.m_dataRate,
2226 conf.m_packetSize,
2227 gws,
2228 uts,
2229 conf.m_onTimePattern,
2230 conf.m_offTimePattern,
2231 startTime,
2232 stopTime,
2233 conf.m_startDelay,
2234 conf.m_percentage);
2235 break;
2236 }
2238 m_trafficHelper->AddHttpTraffic(direction,
2239 gws,
2240 uts,
2241 startTime,
2242 stopTime,
2243 conf.m_startDelay,
2244 conf.m_percentage);
2245 break;
2246 }
2248 m_trafficHelper->AddNrtvTraffic(direction,
2249 gws,
2250 uts,
2251 startTime,
2252 stopTime,
2253 conf.m_startDelay,
2254 conf.m_percentage);
2255 break;
2256 }
2258 m_trafficHelper->AddPoissonTraffic(direction,
2259 conf.m_onTime,
2260 conf.m_offTime,
2261 conf.m_dataRate,
2262 conf.m_packetSize,
2263 gws,
2264 uts,
2265 startTime,
2266 stopTime,
2267 conf.m_startDelay,
2268 conf.m_percentage);
2269 break;
2270 }
2272 m_trafficHelper->AddVoipTraffic(direction,
2273 conf.m_codec,
2274 gws,
2275 uts,
2276 startTime,
2277 stopTime,
2278 conf.m_startDelay,
2279 conf.m_percentage);
2280 break;
2281 }
2282 default:
2283 NS_FATAL_ERROR("Unknown traffic model has been configured: " << modelName);
2284 }
2285 }
2286 }
2287 }
2288 }
2289}
2290
2291} // namespace ns3
A helper to make it easier to instantiate an ns3::SatOnOffApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::SatOnOffApplication on each node of the input container configured with all the attri...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
virtual ~SatTrafficHelperConf()
Destructor.
SatTrafficHelperConf()
Default constructor.
void InstallTrafficModels()
Install traffic models from configuration files.
static TypeId GetTypeId(void)
Derived from Object.
Ptr< SatTrafficHelper > m_trafficHelper
std::map< std::string, TrafficConfiguration_t > m_trafficModel
Creates pre-defined trafics.
void AddNrtvTraffic(TrafficDirection_t direction, NodeContainer gwUsers, NodeContainer utUsers, Time startTime, Time stopTime, Time startDelay)
Add a new TCP/NRTV traffic between chosen GWs and UTs.
void AddCustomTraffic(TrafficDirection_t direction, std::string interval, uint32_t packetSize, NodeContainer gwUsers, NodeContainer utUsers, Time startTime, Time stopTime, Time startDelay)
Add a new CBR traffic between chosen GWs and UTs that can be customized.
SatTrafficHelper()
Default constructor.
void ChangeCustomTraffic(Time delay, std::string interval, uint32_t packetSize)
Change the parameters of the last custom traffic created.
CustomTrafficInfo_s m_last_custom_application
void AddCbrTraffic(TrafficDirection_t direction, TransportLayerProtocol_t protocol, Time interval, uint32_t packetSize, NodeContainer gwUsers, NodeContainer utUsers, Time startTime, Time stopTime, Time startDelay)
Add a new CBR traffic between chosen GWs and UTs.
bool HasSinkInstalled(Ptr< Node > node, uint16_t port)
Check if node has a PacketSink installed at certain port.
void AddOnOffTraffic(TrafficDirection_t direction, TransportLayerProtocol_t protocol, DataRate dataRate, uint32_t packetSize, NodeContainer gwUsers, NodeContainer utUsers, std::string onTimePattern, std::string offTimePattern, Time startTime, Time stopTime, Time startDelay)
Add a new ONOFF traffic between chosen GWs and UTs.
static TypeId GetTypeId(void)
Get the type ID.
void AddPoissonTraffic(TrafficDirection_t direction, Time onTime, Time offTimeExpMean, DataRate rate, uint32_t packetSize, NodeContainer gwUsers, NodeContainer utUsers, Time startTime, Time stopTime, Time startDelay)
Add a new Poisson traffic between chosen GWs and UTs.
void AddVoipTraffic(TrafficDirection_t direction, VoipCodec_t codec, NodeContainer gwUsers, NodeContainer utUsers, Time startTime, Time stopTime, Time startDelay)
Add a new Poisson traffic between chosen GWs and UTs.
TrafficType_t
List of available traffics.
Ptr< SatStatsHelperContainer > m_satStatsHelperContainer
void AddHttpTraffic(TrafficDirection_t direction, NodeContainer gwUsers, NodeContainer utUsers, Time startTime, Time stopTime, Time startDelay)
Add a new TCP/HTTP traffic between chosen GWs and UTs.
void AddLoraPeriodicTraffic(Time interval, uint32_t packetSize, NodeContainer uts, Time startTime, Time stopTime, Time startDelay)
Add Lora periodic traffic between chosen GWs and UTs.
void UpdateAttribute(Ptr< CbrApplication > application, std::string interval, uint32_t packetSize)
Update the chosen attribute of a custom traffic.
void AddLoraCbrTraffic(Time interval, uint32_t packetSize, NodeContainer gwUsers, NodeContainer utUsers, Time startTime, Time stopTime, Time startDelay)
Add Lora CBR traffic between chosen GWs and UTs.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.