A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lena-radio-link-failure.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Fraunhofer ESK
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Vignesh Babu <ns3-dev@esk.fraunhofer.de>
18 */
19
20#include "ns3/applications-module.h"
21#include "ns3/core-module.h"
22#include "ns3/internet-module.h"
23#include "ns3/lte-module.h"
24#include "ns3/mobility-module.h"
25#include "ns3/network-module.h"
26#include "ns3/point-to-point-module.h"
27
28#include <iomanip>
29#include <iostream>
30#include <stdio.h>
31#include <vector>
32
33using namespace ns3;
34
35NS_LOG_COMPONENT_DEFINE("LenaRadioLinkFailure");
36
37// Global values to check the simulation
38// behavior during and after the simulation.
39uint16_t counterN310FirsteNB = 0; //!< Counter of N310 indications.
40Time t310StartTimeFirstEnb = Seconds(0); //!< Time of first N310 indication.
41uint32_t ByteCounter = 0; //!< Byte counter.
42uint32_t oldByteCounter = 0; //!< Old Byte counter,
43
44/**
45 * Print the position of a UE with given IMSI.
46 *
47 * \param imsi The IMSI.
48 */
49void
50PrintUePosition(uint64_t imsi)
51{
52 for (auto it = NodeList::Begin(); it != NodeList::End(); ++it)
53 {
54 Ptr<Node> node = *it;
55 int nDevs = node->GetNDevices();
56 for (int j = 0; j < nDevs; j++)
57 {
58 Ptr<LteUeNetDevice> uedev = node->GetDevice(j)->GetObject<LteUeNetDevice>();
59 if (uedev)
60 {
61 if (imsi == uedev->GetImsi())
62 {
63 Vector pos = node->GetObject<MobilityModel>()->GetPosition();
64 std::cout << "IMSI : " << uedev->GetImsi() << " at " << pos.x << "," << pos.y
65 << std::endl;
66 }
67 }
68 }
69 }
70}
71
72/**
73 * UE Notify connection established.
74 *
75 * \param context The context.
76 * \param imsi The IMSI.
77 * \param cellid The Cell ID.
78 * \param rnti The RNTI.
79 */
80void
81NotifyConnectionEstablishedUe(std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
82{
83 std::cout << Simulator::Now().As(Time::S) << " " << context << " UE IMSI " << imsi
84 << ": connected to cell id " << cellid << " with RNTI " << rnti << std::endl;
85}
86
87/**
88 * eNB Notify connection established.
89 *
90 * \param context The context.
91 * \param imsi The IMSI.
92 * \param cellId The Cell ID.
93 * \param rnti The RNTI.
94 */
95void
96NotifyConnectionEstablishedEnb(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
97{
98 std::cout << Simulator::Now().As(Time::S) << " " << context << " eNB cell id " << cellId
99 << ": successful connection of UE with IMSI " << imsi << " RNTI " << rnti
100 << std::endl;
101 // In this example, a UE should experience RLF at least one time in
102 // cell 1. For the case, when there is only one eNB with ideal RRC,
103 // a UE might reconnects to the eNB multiple times due to more than
104 // one RLF. To handle this, we reset the counter here so, even if the UE
105 // connects multiple time to cell 1 we count N310
106 // indication correctly, i.e., for each RLF UE RRC should receive
107 // configured number of N310 indications.
108 if (cellId == 1)
109 {
111 }
112}
113
114/// Map each of UE RRC states to its string representation.
115static const std::string g_ueRrcStateName[LteUeRrc::NUM_STATES] = {
116 "IDLE_START",
117 "IDLE_CELL_SEARCH",
118 "IDLE_WAIT_MIB_SIB1",
119 "IDLE_WAIT_MIB",
120 "IDLE_WAIT_SIB1",
121 "IDLE_CAMPED_NORMALLY",
122 "IDLE_WAIT_SIB2",
123 "IDLE_RANDOM_ACCESS",
124 "IDLE_CONNECTING",
125 "CONNECTED_NORMALLY",
126 "CONNECTED_HANDOVER",
127 "CONNECTED_PHY_PROBLEM",
128 "CONNECTED_REESTABLISHING",
129};
130
131/**
132 * \param s The UE RRC state.
133 * \return The string representation of the given state.
134 */
135static const std::string&
137{
138 return g_ueRrcStateName[s];
139}
140
141/**
142 * UE state transition tracer.
143 *
144 * \param imsi The IMSI.
145 * \param cellId The Cell ID.
146 * \param rnti The RNTI.
147 * \param oldState The old state.
148 * \param newState The new state.
149 */
150void
151UeStateTransition(uint64_t imsi,
152 uint16_t cellId,
153 uint16_t rnti,
154 LteUeRrc::State oldState,
155 LteUeRrc::State newState)
156{
157 std::cout << Simulator::Now().As(Time::S) << " UE with IMSI " << imsi << " RNTI " << rnti
158 << " connected to cell " << cellId << " transitions from " << ToString(oldState)
159 << " to " << ToString(newState) << std::endl;
160}
161
162/**
163 * eNB RRC timeout tracer.
164 *
165 * \param imsi The IMSI.
166 * \param rnti The RNTI.
167 * \param cellId The Cell ID.
168 * \param cause The reason for timeout.
169 */
170void
171EnbRrcTimeout(uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
172{
173 std::cout << Simulator::Now().As(Time::S) << " IMSI " << imsi << ", RNTI " << rnti
174 << ", Cell id " << cellId << ", ENB RRC " << cause << std::endl;
175}
176
177/**
178 * Notification of connection release at eNB.
179 *
180 * \param imsi The IMSI.
181 * \param cellId The Cell ID.
182 * \param rnti The RNTI.
183 */
184void
185NotifyConnectionReleaseAtEnodeB(uint64_t imsi, uint16_t cellId, uint16_t rnti)
186{
187 std::cout << Simulator::Now() << " IMSI " << imsi << ", RNTI " << rnti << ", Cell id " << cellId
188 << ", UE context destroyed at eNodeB" << std::endl;
189}
190
191/**
192 * PHY sync detection tracer.
193 *
194 * \param n310 310 data.
195 * \param imsi The IMSI.
196 * \param rnti The RNTI.
197 * \param cellId The Cell ID.
198 * \param type The type.
199 * \param count The count.
200 */
201void
202PhySyncDetection(uint16_t n310,
203 uint64_t imsi,
204 uint16_t rnti,
205 uint16_t cellId,
206 std::string type,
207 uint8_t count)
208{
209 std::cout << Simulator::Now().As(Time::S) << " IMSI " << imsi << ", RNTI " << rnti
210 << ", Cell id " << cellId << ", " << type << ", no of sync indications: " << +count
211 << std::endl;
212
213 if (type == "Notify out of sync" && cellId == 1)
214 {
216 if (counterN310FirsteNB == n310)
217 {
219 }
220 NS_LOG_DEBUG("counterN310FirsteNB = " << counterN310FirsteNB);
221 }
222}
223
224/**
225 * Radio link failure tracer.
226 *
227 * \param t310 310 data.
228 * \param imsi The IMSI.
229 * \param cellId The Cell ID.
230 * \param rnti The RNTI.
231 */
232void
233RadioLinkFailure(Time t310, uint64_t imsi, uint16_t cellId, uint16_t rnti)
234{
235 std::cout << Simulator::Now() << " IMSI " << imsi << ", RNTI " << rnti << ", Cell id " << cellId
236 << ", radio link failure detected" << std::endl
237 << std::endl;
238
239 PrintUePosition(imsi);
240
241 if (cellId == 1)
242 {
244 "T310 timer expired at wrong time");
245 }
246}
247
248/**
249 * UE Random access error notification.
250 *
251 * \param imsi The IMSI.
252 * \param cellId The Cell ID.
253 * \param rnti The RNTI.
254 */
255void
256NotifyRandomAccessErrorUe(uint64_t imsi, uint16_t cellId, uint16_t rnti)
257{
258 std::cout << Simulator::Now().As(Time::S) << " IMSI " << imsi << ", RNTI " << rnti
259 << ", Cell id " << cellId << ", UE RRC Random access Failed" << std::endl;
260}
261
262/**
263 * UE Connection timeout notification.
264 *
265 * \param imsi The IMSI.
266 * \param cellId The Cell ID.
267 * \param rnti The RNTI.
268 * \param connEstFailCount Connection failure count.
269 */
270void
271NotifyConnectionTimeoutUe(uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t connEstFailCount)
272{
273 std::cout << Simulator::Now().As(Time::S) << " IMSI " << imsi << ", RNTI " << rnti
274 << ", Cell id " << cellId << ", T300 expiration counter "
275 << (uint16_t)connEstFailCount << ", UE RRC Connection timeout" << std::endl;
276}
277
278/**
279 * UE RA response timeout notification.
280 *
281 * \param imsi The IMSI.
282 * \param contention Contention flag.
283 * \param preambleTxCounter Preamble Tx counter.
284 * \param maxPreambleTxLimit Max preamble Ts limit.
285 */
286void
288 bool contention,
289 uint8_t preambleTxCounter,
290 uint8_t maxPreambleTxLimit)
291{
292 std::cout << Simulator::Now().As(Time::S) << " IMSI " << imsi << ", Contention flag "
293 << contention << ", preamble Tx Counter " << (uint16_t)preambleTxCounter
294 << ", Max Preamble Tx Limit " << (uint16_t)maxPreambleTxLimit
295 << ", UE RA response timeout" << std::endl;
296}
297
298/**
299 * Receive a packet.
300 *
301 * \param packet The packet.
302 */
303void
305{
306 ByteCounter += packet->GetSize();
307}
308
309/**
310 * Write the throughput to file.
311 *
312 * \param firstWrite True if first time writing.
313 * \param binSize Bin size.
314 * \param fileName Output filename.
315 */
316void
317Throughput(bool firstWrite, Time binSize, std::string fileName)
318{
319 std::ofstream output;
320
321 if (firstWrite)
322 {
323 output.open(fileName, std::ofstream::out);
324 firstWrite = false;
325 }
326 else
327 {
328 output.open(fileName, std::ofstream::app);
329 }
330
331 // Instantaneous throughput every 200 ms
332
333 double throughput = (ByteCounter - oldByteCounter) * 8 / binSize.GetSeconds() / 1024 / 1024;
334 output << Simulator::Now().As(Time::S) << " " << throughput << std::endl;
336 Simulator::Schedule(binSize, &Throughput, firstWrite, binSize, fileName);
337}
338
339/**
340 * Sample simulation script for radio link failure.
341 * By default, only one eNodeB and one UE is considered for verifying
342 * radio link failure. The UE is initially in the coverage of
343 * eNodeB and a RRC connection gets established.
344 * As the UE moves away from the eNodeB, the signal degrades
345 * and out-of-sync indications are counted. When the T310 timer
346 * expires, radio link is considered to have failed and UE
347 * leaves the CONNECTED_NORMALLY state and performs cell
348 * selection again.
349 *
350 * The example can be run as follows:
351 *
352 * ./ns3 run "lena-radio-link-failure --numberOfEnbs=1 --simTime=25"
353 */
354int
355main(int argc, char* argv[])
356{
357 // Configurable parameters
358 Time simTime = Seconds(25);
359 uint16_t numberOfEnbs = 1;
360 double interSiteDistance = 1200;
361 uint16_t n311 = 1;
362 uint16_t n310 = 1;
363 Time t310 = Seconds(1);
364 bool useIdealRrc = true;
365 bool enableCtrlErrorModel = true;
366 bool enableDataErrorModel = true;
367 bool enableNsLogs = false;
368
369 CommandLine cmd(__FILE__);
370 cmd.AddValue("simTime", "Total duration of the simulation (in seconds)", simTime);
371 cmd.AddValue("numberOfEnbs", "Number of eNBs", numberOfEnbs);
372 cmd.AddValue("n311", "Number of in-synch indication", n311);
373 cmd.AddValue("n310", "Number of out-of-synch indication", n310);
374 cmd.AddValue("t310", "Timer for detecting the Radio link failure (in seconds)", t310);
375 cmd.AddValue("interSiteDistance", "Inter-site distance in meter", interSiteDistance);
376 cmd.AddValue("useIdealRrc", "Use ideal RRC protocol", useIdealRrc);
377 cmd.AddValue("enableCtrlErrorModel", "Enable control error model", enableCtrlErrorModel);
378 cmd.AddValue("enableDataErrorModel", "Enable data error model", enableDataErrorModel);
379 cmd.AddValue("enableNsLogs", "Enable ns-3 logging (debug builds)", enableNsLogs);
380 cmd.Parse(argc, argv);
381
382 if (enableNsLogs)
383 {
384 auto logLevel =
386 LogComponentEnable("LteUeRrc", logLevel);
387 LogComponentEnable("LteUeMac", logLevel);
388 LogComponentEnable("LteUePhy", logLevel);
389
390 LogComponentEnable("LteEnbRrc", logLevel);
391 LogComponentEnable("LteEnbMac", logLevel);
392 LogComponentEnable("LteEnbPhy", logLevel);
393
394 LogComponentEnable("LenaRadioLinkFailure", logLevel);
395 }
396
397 uint16_t numberOfUes = 1;
398 uint16_t numBearersPerUe = 1;
399 double eNodeB_txPower = 43;
400
401 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(useIdealRrc));
402 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled",
403 BooleanValue(enableCtrlErrorModel));
404 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled",
405 BooleanValue(enableDataErrorModel));
406
407 Config::SetDefault("ns3::LteRlcUm::MaxTxBufferSize", UintegerValue(60 * 1024));
408
409 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
410 Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper>();
411 lteHelper->SetEpcHelper(epcHelper);
412
413 lteHelper->SetPathlossModelType(TypeId::LookupByName("ns3::LogDistancePropagationLossModel"));
414 lteHelper->SetPathlossModelAttribute("Exponent", DoubleValue(3.9));
415 lteHelper->SetPathlossModelAttribute("ReferenceLoss",
416 DoubleValue(38.57)); // ref. loss in dB at 1m for 2.025GHz
417 lteHelper->SetPathlossModelAttribute("ReferenceDistance", DoubleValue(1));
418
419 //----power related (equal for all base stations)----
420 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(eNodeB_txPower));
421 Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(23));
422 Config::SetDefault("ns3::LteUePhy::NoiseFigure", DoubleValue(7));
423 Config::SetDefault("ns3::LteEnbPhy::NoiseFigure", DoubleValue(2));
424 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(true));
425 Config::SetDefault("ns3::LteUePowerControl::ClosedLoop", BooleanValue(true));
426 Config::SetDefault("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue(true));
427
428 //----frequency related----
429 lteHelper->SetEnbDeviceAttribute("DlEarfcn", UintegerValue(100)); // 2120MHz
430 lteHelper->SetEnbDeviceAttribute("UlEarfcn", UintegerValue(18100)); // 1930MHz
431 lteHelper->SetEnbDeviceAttribute("DlBandwidth", UintegerValue(25)); // 5MHz
432 lteHelper->SetEnbDeviceAttribute("UlBandwidth", UintegerValue(25)); // 5MHz
433
434 //----others----
435 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
436 Config::SetDefault("ns3::LteAmc::AmcModel", EnumValue(LteAmc::PiroEW2010));
437 Config::SetDefault("ns3::LteAmc::Ber", DoubleValue(0.01));
438 Config::SetDefault("ns3::PfFfMacScheduler::HarqEnabled", BooleanValue(true));
439
440 Config::SetDefault("ns3::FfMacScheduler::UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
441
442 // Radio link failure detection parameters
443 Config::SetDefault("ns3::LteUeRrc::N310", UintegerValue(n310));
444 Config::SetDefault("ns3::LteUeRrc::N311", UintegerValue(n311));
445 Config::SetDefault("ns3::LteUeRrc::T310", TimeValue(t310));
446
447 NS_LOG_INFO("Create the internet");
448 Ptr<Node> pgw = epcHelper->GetPgwNode();
449 // Create a single RemoteHost0x18ab460
450 NodeContainer remoteHostContainer;
451 remoteHostContainer.Create(1);
452 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
454 internet.Install(remoteHostContainer);
456 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
457 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
458 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.010)));
459 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
460 Ipv4AddressHelper ipv4h;
461 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
462 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
463 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
464 Ipv4StaticRoutingHelper ipv4RoutingHelper;
465 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
466 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
467 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"), Ipv4Mask("255.0.0.0"), 1);
468
469 NS_LOG_INFO("Create eNodeB and UE nodes");
470 NodeContainer enbNodes;
471 NodeContainer ueNodes;
472 enbNodes.Create(numberOfEnbs);
473 ueNodes.Create(numberOfUes);
474
475 NS_LOG_INFO("Assign mobility");
476 Ptr<ListPositionAllocator> positionAllocEnb = CreateObject<ListPositionAllocator>();
477
478 for (uint16_t i = 0; i < numberOfEnbs; i++)
479 {
480 positionAllocEnb->Add(Vector(interSiteDistance * i, 0, 0));
481 }
483 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
484 mobility.SetPositionAllocator(positionAllocEnb);
485 mobility.Install(enbNodes);
486
487 Ptr<ListPositionAllocator> positionAllocUe = CreateObject<ListPositionAllocator>();
488
489 for (int i = 0; i < numberOfUes; i++)
490 {
491 positionAllocUe->Add(Vector(200, 0, 0));
492 }
493
494 mobility.SetPositionAllocator(positionAllocUe);
495 mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel");
496 mobility.Install(ueNodes);
497
498 for (int i = 0; i < numberOfUes; i++)
499 {
500 ueNodes.Get(i)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(
501 Vector(30, 0.0, 0.0));
502 }
503
504 NS_LOG_INFO("Install LTE Devices in eNB and UEs and fix random number stream");
505 NetDeviceContainer enbDevs;
506 NetDeviceContainer ueDevs;
507
508 int64_t randomStream = 1;
509
510 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
511 randomStream += lteHelper->AssignStreams(enbDevs, randomStream);
512 ueDevs = lteHelper->InstallUeDevice(ueNodes);
513 randomStream += lteHelper->AssignStreams(ueDevs, randomStream);
514
515 NS_LOG_INFO("Install the IP stack on the UEs");
516 internet.Install(ueNodes);
517 Ipv4InterfaceContainer ueIpIfaces;
518 ueIpIfaces = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
519
520 NS_LOG_INFO("Attach a UE to a eNB");
521 lteHelper->Attach(ueDevs);
522
523 NS_LOG_INFO("Install and start applications on UEs and remote host");
524 uint16_t dlPort = 10000;
525 uint16_t ulPort = 20000;
526
527 DataRateValue dataRateValue = DataRate("18.6Mbps");
528
529 uint64_t bitRate = dataRateValue.Get().GetBitRate();
530
531 uint32_t packetSize = 1024; // bytes
532
533 NS_LOG_DEBUG("bit rate " << bitRate);
534
535 double interPacketInterval = static_cast<double>(packetSize * 8) / bitRate;
536
537 Time udpInterval = Seconds(interPacketInterval);
538
539 NS_LOG_DEBUG("UDP will use application interval " << udpInterval.As(Time::S) << " sec");
540
541 for (uint32_t u = 0; u < numberOfUes; ++u)
542 {
543 Ptr<Node> ue = ueNodes.Get(u);
544 // Set the default gateway for the UE
545 Ptr<Ipv4StaticRouting> ueStaticRouting =
546 ipv4RoutingHelper.GetStaticRouting(ue->GetObject<Ipv4>());
547 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
548
549 for (uint32_t b = 0; b < numBearersPerUe; ++b)
550 {
551 ApplicationContainer ulClientApps;
552 ApplicationContainer ulServerApps;
553 ApplicationContainer dlClientApps;
554 ApplicationContainer dlServerApps;
555
556 ++dlPort;
557 ++ulPort;
558
559 NS_LOG_LOGIC("installing UDP DL app for UE " << u + 1);
560 UdpClientHelper dlClientHelper(ueIpIfaces.GetAddress(u), dlPort);
561 dlClientHelper.SetAttribute("Interval", TimeValue(udpInterval));
562 dlClientHelper.SetAttribute("PacketSize", UintegerValue(packetSize));
563 dlClientHelper.SetAttribute("MaxPackets", UintegerValue(1000000));
564 dlClientApps.Add(dlClientHelper.Install(remoteHost));
565
566 PacketSinkHelper dlPacketSinkHelper("ns3::UdpSocketFactory",
568 dlServerApps.Add(dlPacketSinkHelper.Install(ue));
569
570 NS_LOG_LOGIC("installing UDP UL app for UE " << u + 1);
571 UdpClientHelper ulClientHelper(remoteHostAddr, ulPort);
572 ulClientHelper.SetAttribute("Interval", TimeValue(udpInterval));
573 dlClientHelper.SetAttribute("PacketSize", UintegerValue(packetSize));
574 ulClientHelper.SetAttribute("MaxPackets", UintegerValue(1000000));
575 ulClientApps.Add(ulClientHelper.Install(ue));
576
577 PacketSinkHelper ulPacketSinkHelper("ns3::UdpSocketFactory",
579 ulServerApps.Add(ulPacketSinkHelper.Install(remoteHost));
580
581 Ptr<EpcTft> tft = Create<EpcTft>();
583 dlpf.localPortStart = dlPort;
584 dlpf.localPortEnd = dlPort;
585 tft->Add(dlpf);
587 ulpf.remotePortStart = ulPort;
588 ulpf.remotePortEnd = ulPort;
589 tft->Add(ulpf);
591 lteHelper->ActivateDedicatedEpsBearer(ueDevs.Get(u), bearer, tft);
592
593 dlServerApps.Start(Seconds(0.27));
594 dlClientApps.Start(Seconds(0.27));
595 ulServerApps.Start(Seconds(0.27));
596 ulClientApps.Start(Seconds(0.27));
597 } // end for b
598 }
599 NS_LOG_INFO("Enable Lte traces and connect custom trace sinks");
600
601 lteHelper->EnableTraces();
602 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
603 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(0.05)));
604 Ptr<RadioBearerStatsCalculator> pdcpStats = lteHelper->GetPdcpStats();
605 pdcpStats->SetAttribute("EpochDuration", TimeValue(Seconds(0.05)));
606
607 Config::Connect("/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished",
609 Config::Connect("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
611 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/LteUeRrc/StateTransition",
613 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/LteUeRrc/PhySyncDetection",
615 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/LteUeRrc/RadioLinkFailure",
617 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/LteEnbRrc/NotifyConnectionRelease",
619 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/LteEnbRrc/RrcTimeout",
621 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/LteUeRrc/RandomAccessError",
623 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
625 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::LteUeNetDevice/"
626 "ComponentCarrierMapUe/*/LteUeMac/RaResponseTimeout",
628
629 // Trace sink for the packet sink of UE
630 std::ostringstream oss;
631 oss << "/NodeList/" << ueNodes.Get(0)->GetId() << "/ApplicationList/0/$ns3::PacketSink/Rx";
633
634 bool firstWrite = true;
635 std::string rrcType = useIdealRrc ? "ideal_rrc" : "real_rrc";
636 std::string fileName = "rlf_dl_thrput_" + std::to_string(enbNodes.GetN()) + "_eNB_" + rrcType;
637 Time binSize = Seconds(0.2);
638 Simulator::Schedule(Seconds(0.47), &Throughput, firstWrite, binSize, fileName);
639
640 NS_LOG_INFO("Starting simulation...");
641
642 Simulator::Stop(simTime);
643
645
647 "UE RRC should receive " << n310
648 << " out-of-sync indications in Cell 1."
649 " Total received = "
651
653
654 return 0;
655}
a polymophic address class
Definition: address.h:101
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Parse command-line arguments.
Definition: command-line.h:232
Mobility model for which the current speed does not change once it has been set and until it is set a...
Class for representing data rates.
Definition: data-rate.h:89
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:305
AttributeValue implementation for DataRate.
Definition: data-rate.h:296
DataRate Get() const
Definition: data-rate.cc:31
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:62
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
@ NGBR_IMS
Non-GBR IMS Signalling.
Definition: eps-bearer.h:120
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:80
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
@ PiroEW2010
Definition: lte-amc.h:63
The LteUeNetDevice class implements the UE net device.
State
The states of the UE RRC entity.
Definition: lte-ue-rrc.h:99
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t GetId() const
Definition: node.cc:117
static Iterator Begin()
Definition: node-list.cc:237
static Iterator End()
Definition: node-list.cc:244
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:415
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:403
@ S
second
Definition: nstime.h:116
AttributeValue implementation for Time.
Definition: nstime.h:1406
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:836
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Hold an unsigned integer type.
Definition: uinteger.h:45
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:978
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:954
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:767
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:706
LogLevel
Logging severity classes and levels.
Definition: log.h:94
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition: log.h:118
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
Definition: log.h:119
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
Definition: log.h:120
ns cmd
Definition: second.py:40
ns mobility
Definition: third.py:105
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:71
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:132
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:130
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:129
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:131
std::ofstream throughput
static const uint32_t packetSize
Packet size generated at the AP.