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"
55 int nDevs = node->GetNDevices();
56 for (
int j = 0; j < nDevs; j++)
61 if (imsi == uedev->GetImsi())
64 std::cout <<
"IMSI : " << uedev->GetImsi() <<
" at " << pos.x <<
"," << pos.y
84 <<
": connected to cell id " << cellid <<
" with RNTI " << rnti << std::endl;
99 <<
": successful connection of UE with IMSI " << imsi <<
" RNTI " << rnti
118 "IDLE_WAIT_MIB_SIB1",
121 "IDLE_CAMPED_NORMALLY",
123 "IDLE_RANDOM_ACCESS",
125 "CONNECTED_NORMALLY",
126 "CONNECTED_HANDOVER",
127 "CONNECTED_PHY_PROBLEM",
128 "CONNECTED_REESTABLISHING",
135static const std::string&
158 <<
" connected to cell " << cellId <<
" transitions from " <<
ToString(oldState)
159 <<
" to " <<
ToString(newState) << std::endl;
171EnbRrcTimeout(uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
174 <<
", Cell id " << cellId <<
", ENB RRC " << cause << std::endl;
187 std::cout <<
Simulator::Now() <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
188 <<
", UE context destroyed at eNodeB" << std::endl;
210 <<
", Cell id " << cellId <<
", " << type <<
", no of sync indications: " << +count
213 if (type ==
"Notify out of sync" && cellId == 1)
235 std::cout <<
Simulator::Now() <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
236 <<
", radio link failure detected" << std::endl
244 "T310 timer expired at wrong time");
259 <<
", Cell id " << cellId <<
", UE RRC Random access Failed" << std::endl;
274 <<
", Cell id " << cellId <<
", T300 expiration counter "
275 << (uint16_t)connEstFailCount <<
", UE RRC Connection timeout" << std::endl;
289 uint8_t preambleTxCounter,
290 uint8_t maxPreambleTxLimit)
293 << contention <<
", preamble Tx Counter " << (uint16_t)preambleTxCounter
294 <<
", Max Preamble Tx Limit " << (uint16_t)maxPreambleTxLimit
295 <<
", UE RA response timeout" << std::endl;
319 std::ofstream output;
323 output.open(fileName, std::ofstream::out);
328 output.open(fileName, std::ofstream::app);
355main(
int argc,
char* argv[])
359 uint16_t numberOfEnbs = 1;
360 double interSiteDistance = 1200;
364 bool useIdealRrc =
true;
365 bool enableCtrlErrorModel =
true;
366 bool enableDataErrorModel =
true;
367 bool enableNsLogs =
false;
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);
397 uint16_t numberOfUes = 1;
398 uint16_t numBearersPerUe = 1;
399 double eNodeB_txPower = 43;
411 lteHelper->SetEpcHelper(epcHelper);
414 lteHelper->SetPathlossModelAttribute(
"Exponent",
DoubleValue(3.9));
415 lteHelper->SetPathlossModelAttribute(
"ReferenceLoss",
417 lteHelper->SetPathlossModelAttribute(
"ReferenceDistance",
DoubleValue(1));
429 lteHelper->SetEnbDeviceAttribute(
"DlEarfcn",
UintegerValue(100));
430 lteHelper->SetEnbDeviceAttribute(
"UlEarfcn",
UintegerValue(18100));
431 lteHelper->SetEnbDeviceAttribute(
"DlBandwidth",
UintegerValue(25));
432 lteHelper->SetEnbDeviceAttribute(
"UlBandwidth",
UintegerValue(25));
435 lteHelper->SetSchedulerType(
"ns3::PfFfMacScheduler");
451 remoteHostContainer.
Create(1);
454 internet.Install(remoteHostContainer);
461 ipv4h.
SetBase(
"1.0.0.0",
"255.0.0.0");
467 remoteHostStaticRouting->AddNetworkRouteTo(
Ipv4Address(
"7.0.0.0"),
Ipv4Mask(
"255.0.0.0"), 1);
472 enbNodes.
Create(numberOfEnbs);
473 ueNodes.
Create(numberOfUes);
478 for (uint16_t i = 0; i < numberOfEnbs; i++)
480 positionAllocEnb->Add(Vector(interSiteDistance * i, 0, 0));
483 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
484 mobility.SetPositionAllocator(positionAllocEnb);
489 for (
int i = 0; i < numberOfUes; i++)
491 positionAllocUe->Add(Vector(200, 0, 0));
494 mobility.SetPositionAllocator(positionAllocUe);
495 mobility.SetMobilityModel(
"ns3::ConstantVelocityMobilityModel");
498 for (
int i = 0; i < numberOfUes; i++)
501 Vector(30, 0.0, 0.0));
504 NS_LOG_INFO(
"Install LTE Devices in eNB and UEs and fix random number stream");
508 int64_t randomStream = 1;
510 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
511 randomStream += lteHelper->AssignStreams(enbDevs, randomStream);
512 ueDevs = lteHelper->InstallUeDevice(ueNodes);
513 randomStream += lteHelper->AssignStreams(ueDevs, randomStream);
521 lteHelper->Attach(ueDevs);
523 NS_LOG_INFO(
"Install and start applications on UEs and remote host");
524 uint16_t dlPort = 10000;
525 uint16_t ulPort = 20000;
529 uint64_t bitRate = dataRateValue.Get().GetBitRate();
535 double interPacketInterval =
static_cast<double>(
packetSize * 8) / bitRate;
541 for (
uint32_t u = 0; u < numberOfUes; ++u)
547 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
549 for (
uint32_t b = 0; b < numBearersPerUe; ++b)
561 dlClientHelper.SetAttribute(
"Interval",
TimeValue(udpInterval));
563 dlClientHelper.SetAttribute(
"MaxPackets",
UintegerValue(1000000));
564 dlClientApps.
Add(dlClientHelper.Install(remoteHost));
568 dlServerApps.
Add(dlPacketSinkHelper.Install(ue));
572 ulClientHelper.SetAttribute(
"Interval",
TimeValue(udpInterval));
574 ulClientHelper.SetAttribute(
"MaxPackets",
UintegerValue(1000000));
575 ulClientApps.
Add(ulClientHelper.Install(ue));
579 ulServerApps.
Add(ulPacketSinkHelper.Install(remoteHost));
591 lteHelper->ActivateDedicatedEpsBearer(ueDevs.
Get(u), bearer, tft);
599 NS_LOG_INFO(
"Enable Lte traces and connect custom trace sinks");
601 lteHelper->EnableTraces();
607 Config::Connect(
"/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished",
609 Config::Connect(
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
626 "ComponentCarrierMapUe/*/LteUeMac/RaResponseTimeout",
630 std::ostringstream oss;
631 oss <<
"/NodeList/" << ueNodes.
Get(0)->
GetId() <<
"/ApplicationList/0/$ns3::PacketSink/Rx";
634 bool firstWrite =
true;
635 std::string rrcType = useIdealRrc == 1 ?
"ideal_rrc" :
"real_rrc";
636 std::string fileName =
"rlf_dl_thrput_" + std::to_string(enbNodes.
GetN()) +
"_eNB_" + rrcType;
647 "UE RRC should receive " << n310
648 <<
" 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.
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.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
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.
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.