To import LTE-NET-DEVICE.H packages in NS3 read out the ideas that are shared by us in this page. The LteNetDevice class is designed for LTE network interfaces. It manages radio communication between eNodeBs (evolved NodeBs) and UEs (User Equipments). This class has methods for sending and receiving LTE packets, managing radio resources, and working with the LTE protocol stack. It allows for simulating different LTE network activities like data transfer, handovers, and signaling. Knowing lte-net-device.h is important for effectively modeling and studying LTE network performance in NS-3 simulations.
Follow the steps required for the installation of Lte-net-device.h.
PRE-REQUISITES:
- Fresh installation of Ubuntu 22.04 LTS:
Screenshot:
2.NS-3.35 Installation:
Screenshot:
HEADER FILE VERIFICATION:
- Locate to the ns3/scratch folder:
Screenshot:
2.Create the Lte-net-device_eg.cc file in the scratch folder:
Next we need to create the Lte-net-device_eg.cc file by using text editor in the ns3/scratch folder.
Screenshot:
Next we need to paste the below code to the Lte-net-device_eg.cc file and save the file in the ns3/scratch folder.
Code:
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/mobility-module.h”
#include “ns3/lte-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-helper.h”
#include “ns3/applications-module.h”
#include <iostream>
using namespace std;
using namespace ns3;
NS_LOG_COMPONENT_DEFINE (“SimpleLteExample”);
int main (int argc, char *argv[]){
double simTime = 10.0;
double distance = 500.0;
uint16_t numberOfNodes = 1;
CommandLine cmd;
cmd.AddValue(“simTime”, “Total duration of the simulation [s]”, simTime);
cmd.AddValue(“distance”, “Distance between eNodeB and UE [m]”, distance);
cmd.AddValue(“numberOfNodes”, “Number of eNodeBs + UE pairs”, numberOfNodes);
cmd.Parse(argc, argv);
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
lteHelper->SetEpcHelper(epcHelper);
Ptr<Node> pgw = epcHelper->GetPgwNode ();
NodeContainer remoteHostContainer;
remoteHostContainer.Create (1);
Ptr<Node> remoteHost = remoteHostContainer.Get (0);
InternetStackHelper internet;
internet.Install (remoteHostContainer);
PointToPointHelper p2ph;
p2ph.SetDeviceAttribute (“DataRate”, DataRateValue (DataRate (“100Gb/s”)));
p2ph.SetDeviceAttribute (“Mtu”, UintegerValue (1500));
p2ph.SetChannelAttribute (“Delay”, TimeValue (Seconds (0.010)));
NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
Ipv4AddressHelper ipv4h;
ipv4h.SetBase (“1.0.0.0”, “255.0.0.0”);
Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
NodeContainer ueNodes;
NodeContainer enbNodes;
enbNodes.Create (numberOfNodes);
ueNodes.Create (numberOfNodes);
MobilityHelper mobility;
mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);
mobility.Install (enbNodes);
mobility.SetPositionAllocator (“ns3::GridPositionAllocator”,
“MinX”, DoubleValue (0.0),
“MinY”, DoubleValue (0.0),
“DeltaX”, DoubleValue (distance),
“DeltaY”, DoubleValue (distance),
“GridWidth”, UintegerValue (3),
“LayoutType”, StringValue (“RowFirst”));
mobility.Install (ueNodes);
NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);
internet.Install (ueNodes);
Ipv4InterfaceContainer ueIpIface;
ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs));
lteHelper->Attach (ueLteDevs, enbLteDevs.Get (0));
Ptr<LteNetDevice> lteNetDev = DynamicCast<LteNetDevice> (ueLteDevs.Get (0));
Ptr<LteUeNetDevice> LteNetDev = DynamicCast<LteUeNetDevice> (ueLteDevs.Get (0));
if (LteNetDev)
{
Ptr<LteUeRrc> Rrc = LteNetDev->GetRrc();
std::cout << “LTE Net Device Information:” << std::endl;
std::cout << ” IMSI: ” << LteNetDev->GetImsi () << std::endl;
std::cout << ” Cell ID: ” << Rrc->GetCellId () << std::endl;
std::cout << ” RNTI: ” << Rrc->GetRnti () << std::endl;
}
uint16_t dlPort = 1234;
uint16_t ulPort = 2000;
ApplicationContainer clientApps;
ApplicationContainer serverApps;
UdpClientHelper dlClientHelper (ueIpIface.GetAddress (0), dlPort);
dlClientHelper.SetAttribute (“Interval”, TimeValue (MilliSeconds (100)));
dlClientHelper.SetAttribute (“MaxPackets”, UintegerValue (1000000));
clientApps.Add (dlClientHelper.Install (remoteHost));
UdpServerHelper dlPacketSinkHelper (dlPort);
serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (0)));
UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
ulClientHelper.SetAttribute (“Interval”, TimeValue (MilliSeconds (100)));
ulClientHelper.SetAttribute (“MaxPackets”, UintegerValue (1000000));
clientApps.Add (ulClientHelper.Install (ueNodes.Get (0)));
UdpServerHelper ulPacketSinkHelper (ulPort);
serverApps.Add (ulPacketSinkHelper.Install (remoteHost));
serverApps.Start (Seconds (0.01));
clientApps.Start (Seconds (0.01));
lteHelper->EnableTraces ();
Simulator::Stop (Seconds (simTime));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
Screenshot:
3.Open the Terminal:
Next, we need to launch the terminal by right clicking the mouse in the ns3 location.
Screenshot:
Screenshot:
4.NS-3.35 Configuration && Building Process:
Next, we need to configure and build the ns3 folder to make the copied files to the scratch need to store in configuration.
Command: “./waf configure && ./waf build”
Screenshot:
Screenshot:
5.Importing Lte-net-device.h:
Here we imported the Lte-net-device.h header file in this example program.
Screenshot:
Here we highlighted the code line that highlighted which is the part of the Lte-net-device.h that we will show class file that used in this code via propagation folder which represents propagation-module.
Screenshot:
Screenshot:
Here we will show the header file by opening Lte-net-device.h file to show the class imported from the Lte-net-device.h in the example code.
Screenshot:
6.Executing the Example Lte-net-device Program:
Then we need to run the Example Lte-net-device program to view output of the program.
Command: “./waf –run Lte-net-device_eg –vis”
Screenshot:
Here we shown the output of the example Lte-net-device program by using lte-net-device.h.
Screenshot:
Screenshot:
Screenshot: