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
120 <<
" connected to cell " << cellId <<
" transitions from " << oldState <<
" to "
121 << newState << std::endl;
133EnbRrcTimeout(uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
136 <<
", Cell id " << cellId <<
", ENB RRC " << cause << std::endl;
149 std::cout <<
Simulator::Now() <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
150 <<
", UE context destroyed at eNodeB" << std::endl;
172 <<
", Cell id " << cellId <<
", " << type <<
", no of sync indications: " << +count
175 if (type ==
"Notify out of sync" && cellId == 1)
197 std::cout <<
Simulator::Now() <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
198 <<
", radio link failure detected" << std::endl
206 "T310 timer expired at wrong time");
221 <<
", Cell id " << cellId <<
", UE RRC Random access Failed" << std::endl;
236 <<
", Cell id " << cellId <<
", T300 expiration counter "
237 << (uint16_t)connEstFailCount <<
", UE RRC Connection timeout" << std::endl;
251 uint8_t preambleTxCounter,
252 uint8_t maxPreambleTxLimit)
255 << contention <<
", preamble Tx Counter " << (uint16_t)preambleTxCounter
256 <<
", Max Preamble Tx Limit " << (uint16_t)maxPreambleTxLimit
257 <<
", UE RA response timeout" << std::endl;
281 std::ofstream output;
285 output.open(fileName, std::ofstream::out);
290 output.open(fileName, std::ofstream::app);
317main(
int argc,
char* argv[])
321 uint16_t numberOfEnbs = 1;
322 double interSiteDistance = 1200;
326 bool useIdealRrc =
true;
327 bool enableCtrlErrorModel =
true;
328 bool enableDataErrorModel =
true;
329 bool enableNsLogs =
false;
332 cmd.AddValue(
"simTime",
"Total duration of the simulation (in seconds)", simTime);
333 cmd.AddValue(
"numberOfEnbs",
"Number of eNBs", numberOfEnbs);
334 cmd.AddValue(
"n311",
"Number of in-synch indication", n311);
335 cmd.AddValue(
"n310",
"Number of out-of-synch indication", n310);
336 cmd.AddValue(
"t310",
"Timer for detecting the Radio link failure (in seconds)", t310);
337 cmd.AddValue(
"interSiteDistance",
"Inter-site distance in meter", interSiteDistance);
338 cmd.AddValue(
"useIdealRrc",
"Use ideal RRC protocol", useIdealRrc);
339 cmd.AddValue(
"enableCtrlErrorModel",
"Enable control error model", enableCtrlErrorModel);
340 cmd.AddValue(
"enableDataErrorModel",
"Enable data error model", enableDataErrorModel);
341 cmd.AddValue(
"enableNsLogs",
"Enable ns-3 logging (debug builds)", enableNsLogs);
342 cmd.Parse(argc, argv);
359 uint16_t numberOfUes = 1;
360 uint16_t numBearersPerUe = 1;
361 double eNodeB_txPower = 43;
373 lteHelper->SetEpcHelper(epcHelper);
376 lteHelper->SetPathlossModelAttribute(
"Exponent",
DoubleValue(3.9));
377 lteHelper->SetPathlossModelAttribute(
"ReferenceLoss",
379 lteHelper->SetPathlossModelAttribute(
"ReferenceDistance",
DoubleValue(1));
391 lteHelper->SetEnbDeviceAttribute(
"DlEarfcn",
UintegerValue(100));
392 lteHelper->SetEnbDeviceAttribute(
"UlEarfcn",
UintegerValue(18100));
393 lteHelper->SetEnbDeviceAttribute(
"DlBandwidth",
UintegerValue(25));
394 lteHelper->SetEnbDeviceAttribute(
"UlBandwidth",
UintegerValue(25));
397 lteHelper->SetSchedulerType(
"ns3::PfFfMacScheduler");
413 remoteHostContainer.
Create(1);
416 internet.Install(remoteHostContainer);
423 ipv4h.
SetBase(
"1.0.0.0",
"255.0.0.0");
429 remoteHostStaticRouting->AddNetworkRouteTo(
Ipv4Address(
"7.0.0.0"),
Ipv4Mask(
"255.0.0.0"), 1);
434 enbNodes.
Create(numberOfEnbs);
435 ueNodes.
Create(numberOfUes);
440 for (uint16_t i = 0; i < numberOfEnbs; i++)
442 positionAllocEnb->Add(Vector(interSiteDistance * i, 0, 0));
445 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
446 mobility.SetPositionAllocator(positionAllocEnb);
451 for (
int i = 0; i < numberOfUes; i++)
453 positionAllocUe->Add(Vector(200, 0, 0));
456 mobility.SetPositionAllocator(positionAllocUe);
457 mobility.SetMobilityModel(
"ns3::ConstantVelocityMobilityModel");
460 for (
int i = 0; i < numberOfUes; i++)
463 Vector(30, 0.0, 0.0));
466 NS_LOG_INFO(
"Install LTE Devices in eNB and UEs and fix random number stream");
470 int64_t randomStream = 1;
472 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
473 randomStream += lteHelper->AssignStreams(enbDevs, randomStream);
474 ueDevs = lteHelper->InstallUeDevice(ueNodes);
475 randomStream += lteHelper->AssignStreams(ueDevs, randomStream);
483 lteHelper->Attach(ueDevs);
485 NS_LOG_INFO(
"Install and start applications on UEs and remote host");
486 uint16_t dlPort = 10000;
487 uint16_t ulPort = 20000;
497 double interPacketInterval =
static_cast<double>(
packetSize * 8) / bitRate;
503 for (
uint32_t u = 0; u < numberOfUes; ++u)
509 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
511 for (
uint32_t b = 0; b < numBearersPerUe; ++b)
523 dlClientHelper.SetAttribute(
"Interval",
TimeValue(udpInterval));
525 dlClientHelper.SetAttribute(
"MaxPackets",
UintegerValue(1000000));
526 dlClientApps.
Add(dlClientHelper.Install(remoteHost));
530 dlServerApps.
Add(dlPacketSinkHelper.Install(ue));
534 ulClientHelper.SetAttribute(
"Interval",
TimeValue(udpInterval));
536 ulClientHelper.SetAttribute(
"MaxPackets",
UintegerValue(1000000));
537 ulClientApps.
Add(ulClientHelper.Install(ue));
541 ulServerApps.
Add(ulPacketSinkHelper.Install(remoteHost));
553 lteHelper->ActivateDedicatedEpsBearer(ueDevs.
Get(u), bearer, tft);
561 NS_LOG_INFO(
"Enable Lte traces and connect custom trace sinks");
563 lteHelper->EnableTraces();
569 Config::Connect(
"/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished",
571 Config::Connect(
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
588 "ComponentCarrierMapUe/*/LteUeMac/RaResponseTimeout",
592 std::ostringstream oss;
593 oss <<
"/NodeList/" << ueNodes.
Get(0)->
GetId() <<
"/ApplicationList/0/$ns3::PacketSink/Rx";
596 bool firstWrite =
true;
597 std::string rrcType = useIdealRrc ?
"ideal_rrc" :
"real_rrc";
598 std::string fileName =
"rlf_dl_thrput_" + std::to_string(enbNodes.
GetN()) +
"_eNB_" + rrcType;
609 "UE RRC should receive " << n310
610 <<
" 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.
AttributeValue implementation for Boolean.
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.
AttributeValue implementation for DataRate.
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.
AttributeValue implementation for Time.
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.
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.
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.