9#include "ns3/applications-module.h"
10#include "ns3/core-module.h"
11#include "ns3/internet-module.h"
12#include "ns3/lte-module.h"
13#include "ns3/mobility-module.h"
14#include "ns3/network-module.h"
15#include "ns3/point-to-point-module.h"
44 int nDevs = node->GetNDevices();
45 for (
int j = 0; j < nDevs; j++)
50 if (imsi == uedev->GetImsi())
53 std::cout <<
"IMSI : " << uedev->GetImsi() <<
" at " << pos.x <<
"," << pos.y
73 <<
": connected to cell id " << cellid <<
" with RNTI " << rnti << std::endl;
88 <<
": successful connection of UE with IMSI " << imsi <<
" RNTI " << rnti
107 "IDLE_WAIT_MIB_SIB1",
110 "IDLE_CAMPED_NORMALLY",
112 "IDLE_RANDOM_ACCESS",
114 "CONNECTED_NORMALLY",
115 "CONNECTED_HANDOVER",
116 "CONNECTED_PHY_PROBLEM",
117 "CONNECTED_REESTABLISHING",
124static const std::string&
147 <<
" connected to cell " << cellId <<
" transitions from " <<
ToString(oldState)
148 <<
" to " <<
ToString(newState) << std::endl;
160EnbRrcTimeout(uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
163 <<
", Cell id " << cellId <<
", ENB RRC " << cause << std::endl;
176 std::cout <<
Simulator::Now() <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
177 <<
", UE context destroyed at eNodeB" << std::endl;
199 <<
", Cell id " << cellId <<
", " << type <<
", no of sync indications: " << +count
202 if (type ==
"Notify out of sync" && cellId == 1)
224 std::cout <<
Simulator::Now() <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
225 <<
", radio link failure detected" << std::endl
233 "T310 timer expired at wrong time");
248 <<
", Cell id " << cellId <<
", UE RRC Random access Failed" << std::endl;
263 <<
", Cell id " << cellId <<
", T300 expiration counter "
264 << (uint16_t)connEstFailCount <<
", UE RRC Connection timeout" << std::endl;
278 uint8_t preambleTxCounter,
279 uint8_t maxPreambleTxLimit)
282 << contention <<
", preamble Tx Counter " << (uint16_t)preambleTxCounter
283 <<
", Max Preamble Tx Limit " << (uint16_t)maxPreambleTxLimit
284 <<
", UE RA response timeout" << std::endl;
308 std::ofstream output;
312 output.open(fileName, std::ofstream::out);
317 output.open(fileName, std::ofstream::app);
344main(
int argc,
char* argv[])
348 uint16_t numberOfEnbs = 1;
349 double interSiteDistance = 1200;
353 bool useIdealRrc =
true;
354 bool enableCtrlErrorModel =
true;
355 bool enableDataErrorModel =
true;
356 bool enableNsLogs =
false;
359 cmd.AddValue(
"simTime",
"Total duration of the simulation (in seconds)", simTime);
360 cmd.AddValue(
"numberOfEnbs",
"Number of eNBs", numberOfEnbs);
361 cmd.AddValue(
"n311",
"Number of in-synch indication", n311);
362 cmd.AddValue(
"n310",
"Number of out-of-synch indication", n310);
363 cmd.AddValue(
"t310",
"Timer for detecting the Radio link failure (in seconds)", t310);
364 cmd.AddValue(
"interSiteDistance",
"Inter-site distance in meter", interSiteDistance);
365 cmd.AddValue(
"useIdealRrc",
"Use ideal RRC protocol", useIdealRrc);
366 cmd.AddValue(
"enableCtrlErrorModel",
"Enable control error model", enableCtrlErrorModel);
367 cmd.AddValue(
"enableDataErrorModel",
"Enable data error model", enableDataErrorModel);
368 cmd.AddValue(
"enableNsLogs",
"Enable ns-3 logging (debug builds)", enableNsLogs);
369 cmd.Parse(argc, argv);
386 uint16_t numberOfUes = 1;
387 uint16_t numBearersPerUe = 1;
388 double eNodeB_txPower = 43;
400 lteHelper->SetEpcHelper(epcHelper);
403 lteHelper->SetPathlossModelAttribute(
"Exponent",
DoubleValue(3.9));
404 lteHelper->SetPathlossModelAttribute(
"ReferenceLoss",
406 lteHelper->SetPathlossModelAttribute(
"ReferenceDistance",
DoubleValue(1));
418 lteHelper->SetEnbDeviceAttribute(
"DlEarfcn",
UintegerValue(100));
419 lteHelper->SetEnbDeviceAttribute(
"UlEarfcn",
UintegerValue(18100));
420 lteHelper->SetEnbDeviceAttribute(
"DlBandwidth",
UintegerValue(25));
421 lteHelper->SetEnbDeviceAttribute(
"UlBandwidth",
UintegerValue(25));
424 lteHelper->SetSchedulerType(
"ns3::PfFfMacScheduler");
440 remoteHostContainer.
Create(1);
443 internet.Install(remoteHostContainer);
450 ipv4h.
SetBase(
"1.0.0.0",
"255.0.0.0");
456 remoteHostStaticRouting->AddNetworkRouteTo(
Ipv4Address(
"7.0.0.0"),
Ipv4Mask(
"255.0.0.0"), 1);
461 enbNodes.
Create(numberOfEnbs);
462 ueNodes.
Create(numberOfUes);
467 for (uint16_t i = 0; i < numberOfEnbs; i++)
469 positionAllocEnb->Add(Vector(interSiteDistance * i, 0, 0));
472 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
473 mobility.SetPositionAllocator(positionAllocEnb);
478 for (
int i = 0; i < numberOfUes; i++)
480 positionAllocUe->Add(Vector(200, 0, 0));
483 mobility.SetPositionAllocator(positionAllocUe);
484 mobility.SetMobilityModel(
"ns3::ConstantVelocityMobilityModel");
487 for (
int i = 0; i < numberOfUes; i++)
490 Vector(30, 0.0, 0.0));
493 NS_LOG_INFO(
"Install LTE Devices in eNB and UEs and fix random number stream");
497 int64_t randomStream = 1;
499 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
500 randomStream += lteHelper->AssignStreams(enbDevs, randomStream);
501 ueDevs = lteHelper->InstallUeDevice(ueNodes);
502 randomStream += lteHelper->AssignStreams(ueDevs, randomStream);
510 lteHelper->Attach(ueDevs);
512 NS_LOG_INFO(
"Install and start applications on UEs and remote host");
513 uint16_t dlPort = 10000;
514 uint16_t ulPort = 20000;
524 double interPacketInterval =
static_cast<double>(
packetSize * 8) / bitRate;
530 for (
uint32_t u = 0; u < numberOfUes; ++u)
536 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
538 for (
uint32_t b = 0; b < numBearersPerUe; ++b)
550 dlClientHelper.SetAttribute(
"Interval",
TimeValue(udpInterval));
552 dlClientHelper.SetAttribute(
"MaxPackets",
UintegerValue(1000000));
553 dlClientApps.
Add(dlClientHelper.Install(remoteHost));
557 dlServerApps.
Add(dlPacketSinkHelper.Install(ue));
561 ulClientHelper.SetAttribute(
"Interval",
TimeValue(udpInterval));
563 ulClientHelper.SetAttribute(
"MaxPackets",
UintegerValue(1000000));
564 ulClientApps.
Add(ulClientHelper.Install(ue));
568 ulServerApps.
Add(ulPacketSinkHelper.Install(remoteHost));
580 lteHelper->ActivateDedicatedEpsBearer(ueDevs.
Get(u), bearer, tft);
588 NS_LOG_INFO(
"Enable Lte traces and connect custom trace sinks");
590 lteHelper->EnableTraces();
596 Config::Connect(
"/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished",
598 Config::Connect(
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
615 "ComponentCarrierMapUe/*/LteUeMac/RaResponseTimeout",
619 std::ostringstream oss;
620 oss <<
"/NodeList/" << ueNodes.
Get(0)->
GetId() <<
"/ApplicationList/0/$ns3::PacketSink/Rx";
623 bool firstWrite =
true;
624 std::string rrcType = useIdealRrc ?
"ideal_rrc" :
"real_rrc";
625 std::string fileName =
"rlf_dl_thrput_" + std::to_string(enbNodes.
GetN()) +
"_eNB_" + rrcType;
636 "UE RRC should receive " << n310
637 <<
" out-of-sync indications in Cell 1."
a polymophic address class
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.
Parse command-line arguments.
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.
uint64_t GetBitRate() const
Get the underlying bitrate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
This class contains the specification of EPS Bearers.
@ NGBR_IMS
Non-GBR IMS Signalling.
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.
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
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
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...
The LteUeNetDevice class implements the UE net device.
State
The states of the UE RRC entity.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time t310StartTimeFirstEnb
Time of first N310 indication.
void NotifyConnectionEstablishedEnb(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
eNB Notify connection established.
static const std::string & ToString(LteUeRrc::State s)
void NotifyRaResponseTimeoutUe(uint64_t imsi, bool contention, uint8_t preambleTxCounter, uint8_t maxPreambleTxLimit)
UE RA response timeout notification.
void NotifyConnectionTimeoutUe(uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t connEstFailCount)
UE Connection timeout notification.
uint32_t ByteCounter
Byte counter.
void EnbRrcTimeout(uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
eNB RRC timeout tracer.
uint16_t counterN310FirsteNB
Counter of N310 indications.
void NotifyConnectionEstablishedUe(std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
UE Notify connection established.
static const std::string g_ueRrcStateName[LteUeRrc::NUM_STATES]
Map each of UE RRC states to its string representation.
uint32_t oldByteCounter
Old Byte counter,.
void PhySyncDetection(uint16_t n310, uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string type, uint8_t count)
PHY sync detection tracer.
void PrintUePosition(uint64_t imsi)
Print the position of a UE with given IMSI.
void UeStateTransition(uint64_t imsi, uint16_t cellId, uint16_t rnti, LteUeRrc::State oldState, LteUeRrc::State newState)
UE state transition tracer.
void NotifyRandomAccessErrorUe(uint64_t imsi, uint16_t cellId, uint16_t rnti)
UE Random access error notification.
void RadioLinkFailure(Time t310, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Radio link failure tracer.
void NotifyConnectionReleaseAtEnodeB(uint64_t imsi, uint16_t cellId, uint16_t rnti)
Notification of connection release at eNB.
void Throughput(bool firstWrite, Time binSize, std::string fileName)
Write the throughput to file.
void ReceivePacket(Ptr< const Packet > packet, const Address &)
Receive a packet.
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.
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...
LogLevel
Logging severity classes and levels.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
uint16_t localPortEnd
end of the port number range of the UE
uint16_t remotePortEnd
end of the port number range of the remote host
uint16_t remotePortStart
start of the port number range of the remote host
uint16_t localPortStart
start of the port number range of the UE
static const uint32_t packetSize
Packet size generated at the AP.