How to Start Cellular Network Projects Using NS3

To start the cellular network projects in NS3, we need to configure a network including base stations such as LTE eNodeBs, 5G gNBs and mobile devices (User Equipment or UEs), for data handling and inter-node interaction which associated to a core network (EPC). For LTE and 5G New Radio (NR) networks, NS3 environment offers the LTE and 5G-LENA modules that support the simulation of numerous aspects such as mobility, handovers, resource management, and more.

Following is a step-by-step procedure to help you get started with cellular network projects using NS3.

Steps to Start Cellular Network Projects in NS3

  1. Install NS3 and Cellular Network Modules
  1. Download and Install NS3:

git clone https://gitlab.com/nsnam/ns-3-dev.git ns-3

cd ns-3

./waf configure –enable-examples –enable-tests

./waf build

  1. Install LTE or 5G Modules: LTE module of NS3 is built-in, however we will need to install the 5G-LENA module for 5G NR simulations.

To install 5G-LENA:

git clone https://gitlab.com/5g-lena/nr.git src/nr

./waf configure –enable-examples –enable-tests

./waf build

  1. Verify Installation: Execute a basic LTE example verifying the installation.

./waf –run=lte-simple

  1. Understand Cellular Network Components in NS3

In cellular network projects, we will be used:

  • Base Stations: LTE eNodeB or 5G gNB nodes, which offer radio access.
  • UEs (User Equipment): Mobile devices linking to the network.
  • EPC (Evolved Packet Core): Core network modules for LTE, to manage the data routing.
  • Channel Models: Replicate radio propagation, path loss, and fading.
  • Applications: Mimic real-world traffic including UDP, TCP, or other applications.
  1. Set Up a Basic LTE/5G Network Topology

Initially, configure a basic network in which several UEs connect to a single eNodeB (for LTE) or gNB (for 5G). In NS3, it can support to know the basics of cellular network configuration

Example: Basic LTE Network with One eNodeB and Multiple UEs

Below is an instance that illustrates a simple LTE network setup.

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/mobility-module.h”

#include “ns3/lte-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

int main(int argc, char *argv[]) {

CommandLine cmd;

cmd.Parse(argc, argv);

// Create LTE and EPC helpers

Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();

Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper>();

lteHelper->SetEpcHelper(epcHelper);

// Get the PGW (Packet Gateway) node

Ptr<Node> pgw = epcHelper->GetPgwNode();

// Create a single eNodeB and multiple UEs

NodeContainer enbNodes;

enbNodes.Create(1);

NodeContainer ueNodes;

ueNodes.Create(3);

// Set up mobility for the eNodeB and UEs

MobilityHelper mobility;

mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);

mobility.Install(enbNodes);

mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,

“MinX”, DoubleValue(0.0),

“MinY”, DoubleValue(0.0),

“DeltaX”, DoubleValue(20.0),

“DeltaY”, DoubleValue(20.0),

“GridWidth”, UintegerValue(3),

“LayoutType”, StringValue(“RowFirst”));

mobility.SetMobilityModel(“ns3::RandomWalk2dMobilityModel”,

“Bounds”, RectangleValue(Rectangle(-50, 50, -25, 50)));

mobility.Install(ueNodes);

// Install LTE devices on eNodeB and UEs

NetDeviceContainer enbLteDevices = lteHelper->InstallEnbDevice(enbNodes);

NetDeviceContainer ueLteDevices = lteHelper->InstallUeDevice(ueNodes);

// Install Internet stack on UEs

InternetStackHelper internet;

internet.Install(ueNodes);

// Assign IP addresses to UEs

Ipv4InterfaceContainer ueIpIfaces = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueLteDevices));

// Attach UEs to eNodeB

for (uint32_t i = 0; i < ueNodes.GetN(); i++) {

lteHelper->Attach(ueLteDevices.Get(i), enbLteDevices.Get(0));

}

// Set up a UDP echo server on one of the UEs

uint16_t port = 9;

UdpEchoServerHelper echoServer(port);

ApplicationContainer serverApp = echoServer.Install(ueNodes.Get(0)); // First UE acts as server

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(ueIpIfaces.GetAddress(0), port); // Server IP

echoClient.SetAttribute(“MaxPackets”, UintegerValue(10));

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));

echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer clientApp = echoClient.Install(ueNodes.Get(1)); // Another UE as client

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(10.0));

Simulator::Run();

Simulator::Destroy();

return 0;

}

  1. Experiment with Channel and Propagation Models

Set up channel and propagation models replicating the realistic conditions:

  • PathLossModel: It mimics free-space or urban path loss.
  • FadingModel: Inserts multipath fading impacts such as Rayleigh or Rician fading.

Example:

lteHelper->SetAttribute(“PathlossModel”, StringValue(“ns3::FriisPropagationLossModel”));

lteHelper->SetAttribute(“FadingModel”, StringValue(“ns3::TraceFadingLossModel”));

  1. Configure Mobility for UEs

In cellular networks, mobility is significant. Replicate moving UEs utilizing mobility models such as RandomWalk2dMobilityModel or ConstantVelocityMobilityModel.

Example:

mobility.SetMobilityModel(“ns3::ConstantVelocityMobilityModel”);

ueNodes.Get(0)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(Vector(10.0, 0.0, 0.0)); // 10 m/s

  1. Set Up Applications for Traffic Generation

Make traffic to utilize applications such as OnOffApplication, UdpEchoApplication, or BulkSendApplication, focus on how the cellular network manages diverse kinds of traffic.

Example:

OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(ueIpIfaces.GetAddress(0), port));

onOff.SetAttribute(“DataRate”, StringValue(“1Mbps”));

onOff.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer app = onOff.Install(ueNodes.Get(1)); // Install on a UE

app.Start(Seconds(2.0));

app.Stop(Seconds(10.0));

  1. Enable Handover for Mobility Scenarios

Since UEs travel among eNodeBs, LTE supports handovers. We can be allowed X2-based handovers to learn how the network handles the UEs’ mobility among cells.

Example:

lteHelper->AddX2Interface(enbNodes);

lteHelper->HandoverRequest(Seconds(5.0), ueLteDevices.Get(0), enbLteDevices.Get(0), enbLteDevices.Get(1)); // Trigger a handover

  1. Collect and Analyze Performance Metrics

Examine performance parameters such as:

  • Throughput: To measure the data rate.
  • Latency: Estimating the delay within data delivery.
  • Packet Loss: We compute the reliability.
  • Handover Performance: Examine the success rate and latency of handovers.

Use FlowMonitor to gather metrics:

FlowMonitorHelper flowmon;

Ptr<FlowMonitor> monitor = flowmon.InstallAll();

monitor->SerializeToXmlFile(“cellular-network-flowmon.xml”, true, true);

  1. Visualize the Network
  • NetAnim: Node movement and packet flow in real-time we need to be visualized.
  • Trace Analysis: Consider NS3 trace files examining the network events.
  • Plotting Tools: Transfer data plotting parameters such as throughput and latency over time.
  1. Experiment with Advanced Features

After learning the fundamentals, then we discover complex situations:

  • Multiple eNodeBs/gNBs: Make larger networks including numerous base stations.
  • Interference Management: In dense networks, we can learn the influence of interference.
  • QoS and Slicing: Execute the Quality of Service (QoS) for diverse traffic types or implement network slicing for 5G projects.

In this manual, we clearly expounded and established the stepwise approach for Cellular Network projects that were started, analysed and visualized the outcomes using NS3 tool. Also we will outline the further information on how Cellular network will perform in other tools.

Our team specialise in LTE and 5G New Radio (NR) networks, and the NS3 environment provides the LTE and 5G-LENA modules essential for your projects. At phdprojects.org, we offer innovative research guidance and customized research topics to align with your interests, helping you kickstart your Cellular Network Projects using the NS3 tool. For further assistance, feel free to email us for exceptional ideas and simulation support.