21 #include "ns3/core-module.h" 22 #include "ns3/network-module.h" 23 #include "ns3/internet-module.h" 24 #include "ns3/mobility-module.h" 25 #include "ns3/lte-module.h" 26 #include "ns3/applications-module.h" 27 #include "ns3/point-to-point-module.h" 53 for (
int j = 0; j < nDevs; j++)
61 std::cout <<
"IMSI : " << uedev->
GetImsi () <<
" at " << pos.x <<
"," << pos.y << std::endl;
76 <<
" UE IMSI " << imsi
77 <<
": connected to cell id " << cellid
78 <<
" with RNTI " << rnti
90 <<
" eNB cell id " << cellId
91 <<
": successful connection of UE with IMSI " << imsi
112 "IDLE_WAIT_MIB_SIB1",
115 "IDLE_CAMPED_NORMALLY",
117 "IDLE_RANDOM_ACCESS",
119 "CONNECTED_NORMALLY",
120 "CONNECTED_HANDOVER",
121 "CONNECTED_PHY_PROBLEM",
122 "CONNECTED_REESTABLISHING" 139 <<
" UE with IMSI " << imsi <<
" RNTI " << rnti
140 <<
" connected to cell " << cellId <<
" transitions from " 146 EnbRrcTimeout (uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
150 <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
151 <<
", ENB RRC " << cause << std::endl;
158 <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
159 <<
", UE context destroyed at eNodeB" << std::endl;
162 void PhySyncDetection (uint16_t n310, uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string type, uint8_t count)
166 <<
" IMSI " << imsi <<
", RNTI " << rnti
167 <<
", Cell id " << cellId <<
", " << type <<
", no of sync indications: " << +count
170 if (type ==
"Notify out of sync" && cellId == 1)
184 <<
" IMSI " << imsi <<
", RNTI " << rnti
185 <<
", Cell id " << cellId <<
", radio link failure detected" 186 << std::endl << std::endl;
200 <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
201 <<
", UE RRC Random access Failed" << std::endl;
206 uint8_t connEstFailCount)
209 <<
" IMSI " << imsi <<
", RNTI " << rnti
210 <<
", Cell id " << cellId
211 <<
", T300 expiration counter " << (uint16_t) connEstFailCount
212 <<
", UE RRC Connection timeout" << std::endl;
217 uint8_t preambleTxCounter,
218 uint8_t maxPreambleTxLimit)
221 <<
" IMSI " << imsi <<
", Contention flag " << contention
222 <<
", preamble Tx Counter " << (uint16_t) preambleTxCounter
223 <<
", Max Preamble Tx Limit " << (uint16_t) maxPreambleTxLimit
224 <<
", UE RA response timeout" << std::endl;
237 std::ofstream output;
239 if (firstWrite ==
true)
241 output.open (fileName.c_str (), std::ofstream::out);
246 output.open (fileName.c_str (), std::ofstream::app);
273 main (
int argc,
char *argv[])
277 uint16_t numberOfEnbs = 1;
278 double interSiteDistance = 1200;
282 bool useIdealRrc =
true;
283 bool enableCtrlErrorModel =
true;
284 bool enableDataErrorModel =
true;
285 bool enableNsLogs =
false;
288 cmd.AddValue (
"simTime",
"Total duration of the simulation (in seconds)", simTime);
289 cmd.AddValue (
"numberOfEnbs",
"Number of eNBs", numberOfEnbs);
290 cmd.AddValue (
"n311",
"Number of in-synch indication", n311);
291 cmd.AddValue (
"n310",
"Number of out-of-synch indication", n310);
292 cmd.AddValue (
"t310",
"Timer for detecting the Radio link failure (in seconds)", t310);
293 cmd.AddValue (
"interSiteDistance",
"Inter-site distance in meter", interSiteDistance);
294 cmd.AddValue (
"useIdealRrc",
"Use ideal RRC protocol", useIdealRrc);
295 cmd.AddValue (
"enableCtrlErrorModel",
"Enable control error model", enableCtrlErrorModel);
296 cmd.AddValue (
"enableDataErrorModel",
"Enable data error model", enableDataErrorModel);
297 cmd.AddValue (
"enableNsLogs",
"Enable ns-3 logging (debug builds)", enableNsLogs);
298 cmd.Parse (argc, argv);
314 uint16_t numberOfUes = 1;
315 uint16_t numBearersPerUe = 1;
316 double eNodeB_txPower = 43;
362 Ptr<Node> pgw = epcHelper->GetPgwNode ();
365 remoteHostContainer.
Create (1);
368 internet.
Install (remoteHostContainer);
375 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
385 enbNodes.
Create (numberOfEnbs);
386 ueNodes.
Create (numberOfUes);
391 for (uint16_t i = 0; i < numberOfEnbs; i++)
393 positionAllocEnb->
Add (Vector (interSiteDistance * i, 0, 0));
396 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
397 mobility.SetPositionAllocator (positionAllocEnb);
402 for (
int i = 0; i < numberOfUes; i++)
404 positionAllocUe->
Add (Vector (200, 0, 0));
407 mobility.SetPositionAllocator (positionAllocUe);
408 mobility.SetMobilityModel (
"ns3::ConstantVelocityMobilityModel");
411 for (
int i = 0; i < numberOfUes; i++)
416 NS_LOG_INFO (
"Install LTE Devices in eNB and UEs and fix random number stream");
420 int64_t randomStream = 1;
423 randomStream += lteHelper->
AssignStreams (enbDevs, randomStream);
425 randomStream += lteHelper->
AssignStreams (ueDevs, randomStream);
434 lteHelper->
Attach (ueDevs);
436 NS_LOG_INFO (
"Install and start applications on UEs and remote host");
437 uint16_t dlPort = 10000;
438 uint16_t ulPort = 20000;
448 double interPacketInterval =
static_cast<double> (
packetSize * 8) / bitRate;
455 for (uint32_t u = 0; u < numberOfUes; ++u)
460 ueStaticRouting->
SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
462 for (uint32_t b = 0; b < numBearersPerUe; ++b)
472 NS_LOG_LOGIC (
"installing UDP DL app for UE " << u + 1);
476 dlClientHelper.SetAttribute (
"MaxPackets",
UintegerValue (1000000));
477 dlClientApps.
Add (dlClientHelper.Install (remoteHost));
480 dlServerApps.
Add (dlPacketSinkHelper.Install (ue));
482 NS_LOG_LOGIC (
"installing UDP UL app for UE " << u + 1);
484 ulClientHelper.SetAttribute (
"Interval",
TimeValue (udpInterval));
486 ulClientHelper.SetAttribute (
"MaxPackets",
UintegerValue (1000000));
487 ulClientApps.
Add (ulClientHelper.Install (ue));
490 ulServerApps.
Add (ulPacketSinkHelper.Install (remoteHost));
495 dlpf.localPortEnd = dlPort;
510 NS_LOG_INFO (
"Enable Lte traces and connect custom trace sinks");
518 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished",
520 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
540 std::ostringstream oss;
541 oss <<
"/NodeList/" << ueNodes.
Get (0)->
GetId () <<
"/ApplicationList/0/$ns3::PacketSink/Rx";
544 bool firstWrite =
true;
545 std::string rrcType = useIdealRrc == 1 ?
"ideal_rrc" :
"real_rrc";
546 std::string fileName =
"rlf_dl_thrput_" + std::to_string (enbNodes.
GetN ()) +
"_eNB_" + rrcType;
557 << n310 <<
" out-of-sync indications in Cell 1." uint16_t counterN310FirsteNB
holds a vector of ns3::Application pointers.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
void SetPathlossModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the path loss models to be created.
Prefix all trace prints with simulation node.
static Ipv4Address GetAny(void)
void PrintUePosition(uint64_t imsi)
AttributeValue implementation for Boolean.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
uint32_t GetId(void) const
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
static const uint32_t packetSize
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void NotifyRandomAccessErrorUe(uint64_t imsi, uint16_t cellId, uint16_t rnti)
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static void Run(void)
Run the simulation.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
void RadioLinkFailure(Time t310, uint64_t imsi, uint16_t cellId, uint16_t rnti)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
void PhySyncDetection(uint16_t n310, uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string type, uint8_t count)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
static Vector GetPosition(Ptr< Node > node)
uint64_t GetBitRate() const
Get the underlying bitrate.
void EnbRrcTimeout(uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
a polymophic address class
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Class for representing data rates.
Keep track of the current position and velocity of an object.
uint64_t GetImsi() const
Get the IMSI.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Hold variables of type enum.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
AttributeValue implementation for Time.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
void Throughput(bool firstWrite, Time binSize, std::string fileName)
void EnableTraces(void)
Enables trace sinks for PHY, MAC, RLC and PDCP.
Hold an unsigned integer type.
static Iterator End(void)
void NotifyConnectionEstablishedUe(std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
holds a vector of ns3::NetDevice pointers
void SetPathlossModelType(TypeId type)
Set the type of path loss model to be used for both DL and UL channels.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void Connect(std::string path, const CallbackBase &cb)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
Access to the IPv4 forwarding table, interfaces, and configuration.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Prefix all trace prints with simulation time.
uint16_t remotePortEnd
end of the port number range of the remote host
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void UeStateTransition(uint64_t imsi, uint16_t cellId, uint16_t rnti, LteUeRrc::State oldState, LteUeRrc::State newState)
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
This class contains the specification of EPS Bearers.
static Time Now(void)
Return the current simulation virtual time.
void NotifyConnectionEstablishedEnb(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
void ReceivePacket(Ptr< const Packet > packet, const Address &)
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
LogLevel
Logging severity classes and levels.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ptr< RadioBearerStatsCalculator > GetRlcStats(void)
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Ptr< RadioBearerStatsCalculator > GetPdcpStats(void)
State
The states of the UE RRC entity.
void NotifyConnectionReleaseAtEnodeB(uint64_t imsi, uint16_t cellId, uint16_t rnti)
Helper class used to assign positions and mobility models to nodes.
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table.
Ipv4 addresses are stored in host order in this class.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static const std::string & ToString(EpcUeNas::State s)
void SetEpcHelper(Ptr< EpcHelper > h)
Set the EpcHelper to be used to setup the EPC network in conjunction with the setup of the LTE radio ...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Helper class that adds ns3::Ipv4StaticRouting objects.
AttributeValue implementation for DataRate.
static Iterator Begin(void)
Prefix all trace prints with function.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
void NotifyConnectionTimeoutUe(uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t connEstFailCount)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
void Add(Vector v)
Add a position to the list of positions.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Mobility model for which the current speed does not change once it has been set and until it is set a...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
static const std::string g_ueRrcStateName[LteUeRrc::NUM_STATES]
Map each of UE RRC states to its string representation.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Time t310StartTimeFirstEnb
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
uint16_t remotePortStart
start of the port number range of the remote host
uint32_t GetNDevices(void) const
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...
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
uint16_t localPortStart
start of the port number range of the UE
void NotifyRaResponseTimeoutUe(uint64_t imsi, bool contention, uint8_t preambleTxCounter, uint8_t maxPreambleTxLimit)
The LteUeNetDevice class implements the UE net device.