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;
75 <<
" UE IMSI " << imsi
76 <<
": connected to cell id " << cellid
77 <<
" with RNTI " << rnti
88 <<
" eNB cell id " << cellId
89 <<
": successful connection of UE with IMSI " << imsi
110 "IDLE_WAIT_MIB_SIB1",
113 "IDLE_CAMPED_NORMALLY",
115 "IDLE_RANDOM_ACCESS",
117 "CONNECTED_NORMALLY",
118 "CONNECTED_HANDOVER",
119 "CONNECTED_PHY_PROBLEM",
120 "CONNECTED_REESTABLISHING" 136 <<
" UE with IMSI " << imsi <<
" RNTI " << rnti <<
" connected to cell " << cellId <<
137 " transitions from " <<
ToString (oldState) <<
" to " <<
ToString (newState) << std::endl;
141 EnbRrcTimeout (uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string cause)
144 <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
145 <<
", ENB RRC " << cause << std::endl;
152 <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
153 <<
", UE context destroyed at eNodeB" << std::endl;
156 void PhySyncDetection (uint16_t n310, uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string type, uint8_t count)
159 <<
" IMSI " << imsi <<
", RNTI " << rnti
160 <<
", Cell id " << cellId <<
", " << type <<
", no of sync indications: " << +count
163 if (type ==
"Notify out of sync" && cellId == 1)
177 <<
" IMSI " << imsi <<
", RNTI " << rnti
178 <<
", Cell id " << cellId <<
", radio link failure detected" 179 << std::endl << std::endl;
193 <<
" IMSI " << imsi <<
", RNTI " << rnti <<
", Cell id " << cellId
194 <<
", UE RRC Random access Failed" << std::endl;
199 uint8_t connEstFailCount)
202 <<
" IMSI " << imsi <<
", RNTI " << rnti
203 <<
", Cell id " << cellId
204 <<
", T300 expiration counter " << (uint16_t) connEstFailCount
205 <<
", UE RRC Connection timeout" << std::endl;
210 uint8_t preambleTxCounter,
211 uint8_t maxPreambleTxLimit)
214 <<
" IMSI " << imsi <<
", Contention flag " << contention
215 <<
", preamble Tx Counter " << (uint16_t) preambleTxCounter
216 <<
", Max Preamble Tx Limit " << (uint16_t) maxPreambleTxLimit
217 <<
", UE RA response timeout" << std::endl;
230 std::ofstream output;
232 if (firstWrite ==
true)
234 output.open (fileName.c_str (), std::ofstream::out);
239 output.open (fileName.c_str (), std::ofstream::app);
265 main (
int argc,
char *argv[])
269 uint16_t numberOfEnbs = 1;
270 double interSiteDistance = 1200;
274 bool useIdealRrc =
true;
275 bool enableCtrlErrorModel =
true;
276 bool enableDataErrorModel =
true;
277 bool enableNsLogs =
false;
280 cmd.AddValue (
"simTime",
"Total duration of the simulation (in seconds)", simTime);
281 cmd.AddValue (
"numberOfEnbs",
"Number of eNBs", numberOfEnbs);
282 cmd.AddValue (
"n311",
"Number of in-synch indication", n311);
283 cmd.AddValue (
"n310",
"Number of out-of-synch indication", n310);
284 cmd.AddValue (
"t310",
"Timer for detecting the Radio link failure (in seconds)", t310);
285 cmd.AddValue (
"interSiteDistance",
"Inter-site distance in meter", interSiteDistance);
286 cmd.AddValue (
"useIdealRrc",
"Use ideal RRC protocol", useIdealRrc);
287 cmd.AddValue (
"enableCtrlErrorModel",
"Enable control error model", enableCtrlErrorModel);
288 cmd.AddValue (
"enableDataErrorModel",
"Enable data error model", enableDataErrorModel);
289 cmd.AddValue (
"enableNsLogs",
"Enable ns-3 logging (debug builds)", enableNsLogs);
290 cmd.Parse (argc, argv);
306 uint16_t numberOfUes = 1;
307 uint16_t numBearersPerUe = 1;
308 double eNodeB_txPower = 43;
354 Ptr<Node> pgw = epcHelper->GetPgwNode ();
357 remoteHostContainer.
Create (1);
360 internet.
Install (remoteHostContainer);
367 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
377 enbNodes.
Create (numberOfEnbs);
378 ueNodes.
Create (numberOfUes);
383 for (uint16_t i = 0; i < numberOfEnbs; i++)
385 positionAllocEnb->
Add (Vector (interSiteDistance * i, 0, 0));
388 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
389 mobility.SetPositionAllocator (positionAllocEnb);
394 for (
int i = 0; i < numberOfUes; i++)
396 positionAllocUe->
Add (Vector (200, 0, 0));
399 mobility.SetPositionAllocator (positionAllocUe);
400 mobility.SetMobilityModel (
"ns3::ConstantVelocityMobilityModel");
403 for (
int i = 0; i < numberOfUes; i++)
408 NS_LOG_INFO (
"Install LTE Devices in eNB and UEs and fix random number stream");
412 int64_t randomStream = 1;
415 randomStream += lteHelper->
AssignStreams (enbDevs, randomStream);
417 randomStream += lteHelper->
AssignStreams (ueDevs, randomStream);
426 lteHelper->
Attach (ueDevs);
428 NS_LOG_INFO (
"Install and start applications on UEs and remote host");
429 uint16_t dlPort = 10000;
430 uint16_t ulPort = 20000;
440 double interPacketInterval =
static_cast<double> (
packetSize * 8) / bitRate;
447 for (uint32_t u = 0; u < numberOfUes; ++u)
452 ueStaticRouting->
SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
454 for (uint32_t b = 0; b < numBearersPerUe; ++b)
464 NS_LOG_LOGIC (
"installing UDP DL app for UE " << u + 1);
468 dlClientHelper.SetAttribute (
"MaxPackets",
UintegerValue (1000000));
469 dlClientApps.
Add (dlClientHelper.Install (remoteHost));
472 dlServerApps.
Add (dlPacketSinkHelper.Install (ue));
474 NS_LOG_LOGIC (
"installing UDP UL app for UE " << u + 1);
476 ulClientHelper.SetAttribute (
"Interval",
TimeValue (udpInterval));
478 ulClientHelper.SetAttribute (
"MaxPackets",
UintegerValue (1000000));
479 ulClientApps.
Add (ulClientHelper.Install (ue));
482 ulServerApps.
Add (ulPacketSinkHelper.Install (remoteHost));
487 dlpf.localPortEnd = dlPort;
502 NS_LOG_INFO (
"Enable Lte traces and connect custom trace sinks");
510 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished",
512 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
532 std::ostringstream oss;
533 oss <<
"/NodeList/" << ueNodes.
Get (0)->
GetId () <<
"/ApplicationList/0/$ns3::PacketSink/Rx";
536 bool firstWrite =
true;
537 std::string rrcType = useIdealRrc == 1 ?
"ideal_rrc":
"real_rrc";
538 std::string fileName =
"rlf_dl_thrput_" + std::to_string (enbNodes.
GetN ()) +
"_eNB_" + rrcType;
549 << 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.
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.