5G Network Simulation with NS3 Report
5G Network Simulation with NS3 Report
Bachelor of Technology
in
2023-2024
DECLARATION
I hereby declare that the project entitled “5G NETWORK SIMULATION USING
NS3” submitted to Malla Reddy Institute of Engineering and Technology, UGC
Autonomous Institution, affiliated to Jawaharlal Nehru Technological University
Hyderabad (JNTUH) as part of III Year B. Tech – II Semester and for the partial
fulfillment of the requirement for the award of Bachelor of Technology in Computer
Science and Engineering ( Data Science/AIML) is a result of original research work
done by me.
It is further declared that the project report or any part thereof has not been
previously submitted to any University or Institute for the award of degree or
diploma.
This is to certify that this is the bonafide record of the project titled “5G
NETWORK SIMULATION USING NS3” submitted by Rampalli Nikhil
Sai, bearing Roll no 20N31A6947 Student of B Tech III Year – II Semester in
the partial fulfillment of the requirements for the degree of Bachelor of
Technology in Computer Science and Engineering (Data Science/AIML),
Dept. of CSE (DS, AIML) during the year 2023-2024. The results embodied in
this project report have not been submitted to any other university or institute for
the award of any degree or diploma.
EXTERNAL EXAMINER
First and foremost, I am grateful to the Principal Dr. P. SRINIVAS, for providing me
with all the resources in the college to make my project a success. I thank him for his
valuable suggestions at the time of seminars which encouraged me to give my best in
the project.
I would also like to thank all the supporting staff of the Dept. of CSE(DS,AIML) and all
other departments who have been helpful directly or indirectly in making the project a
success.
I am extremely grateful to my parents for their blessings and prayers for my completion
of project that gave me strength to do my project
XXXXXXXX 19W91A05XX
XXXXXXXX 19W91A05XX
XXXXXXXX 19W91A05XX
XXXXXXXX 19W91A05XX
I
ABSTRACT
II
TABLE OF CONTENTS
1 Introduction 1-9
1.1 Introduction 1-4
1.2 Motivation 5
1.3 Literature Review 6-8
1.4 Problem Definition 8
1.5 Objective of the Project 8-9
2 System Analysis 10-14
2.1 Existing and Proposed System 10-12
3.1 Software 15
6 Implementation 27-63
7 Testing 64-66
I
I
8 Output Screen 67-68
8.1 Screenshots 67
10 References 71
10.1 Websites 71
10.2 Books 71
II
I
LIST OF FIGURES
2 Handover process 3
4 PDCP in detail 12
5 Ns3 logo 15
6 Wireshark Logo 17
7 Dataflow Diagram 20
8 Architectural Diagram 21
9 Class Diagram 21
10 Sequential Diagram 22
11 Phases of SDLC 23
12 BlackBox Testing 64
13 67
14 67
15 67
16 68
17 68
18 68
19 68
I
V
LIST OF TABLES
V
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION
Wireless communication is the transmission of data over long
distances without the need for physical cables. Understanding its
foundational principles is essential for grasping the intricacies of
5G technology.
●Transmission Mediums and Propagation: Different transmission
mediums, such as air or space, affect signal propagation.
Understanding how signals propagate through various mediums is
crucial.
● Frequency Spectrum Allocation: The allocation of frequency
bands determines the capacity and performance of wireless
communication systems.
● Modulation Techniques: Modulation schemes convert digital
data into analog signals for transmission, with techniques like
amplitude modulation (AM) and frequency modulation (FM).
● Signal Encoding and Decoding: Encoding and decoding methods
ensure accurate data transmission and reception.
1
Radio Signal Properties
Radio signals are the carriers of wireless communication,
transmitting data through electromagnetic waves. Understanding
their properties is essential for optimizing signal transmission and
reception.
●Frequency and Wavelength: Frequency determines the number
of cycles per second, while wavelength is the distance between
two consecutive peaks.
● Amplitude and Phase Modulation: Modulation techniques that
alter the amplitude or phase of the carrier signal to encode data.
● Signal Attenuation and Propagation Loss: Signal attenuation
refers to the weakening of signals over distance, influenced by
factors like obstacles and interference.
●Signal-to-Noise Ratio (SNR) and Signal Strength: SNR measures
the ratio of signal power to noise power, while signal strength
indicates the power of the received signal.
Factors Affecting Data Rate
The data rate, or throughput, of a wireless communication system
depends on various factors. Understanding these factors is
essential for optimizing network performance.
● Channel Bandwidth and Spectral Efficiency: Wider bandwidth
allows for higher data rates, while spectral efficiency maximizes
the data throughput within the available bandwidth.
●Signal-to-Interference Ratio (SIR): SIR measures the quality of
the received signal relative to interference from other sources.
● Multipath Propagation and Fading: Multipath propagation occur
when signals reach the receiver via multiple paths, leading to
fading and signal degradation.
● Coding and Error Correction Techniques: Error correction
codes ensure data integrity by detecting and correcting errors
that occur during transmission. General Concepts Behind Cellular
Communication
Cellular communication divides geographical areas into cells
served by base stations, enabling widespread wireless
connectivity. Understanding its concepts is crucial for
2
understanding the evolution to 5G networks.
●Cell Layout and Frequency Reuse: Cells are arranged in a grid
pattern, with frequency reuse maximizing spectral efficiency.
3
●Handover and Mobility Management: Handover ensures seamless
transition between cells as mobile devices move, while mobility
management tracks device locations.
● Cell Site Infrastructure and Network Topology: Cell sites consist
of base stations, antennas, and other infrastructure components,
interconnected to form a cellular network.
●Cellular Protocols and Standards: Various protocols and
standards govern cellular communication, ensuring
interoperability and compatibility between different network
elements.
6
● Massive Machine Type Communications (mMTC): Supports a
massive number of IoT devices with low-power and low-complexity
connectivity.
● Ultra-Reliable Low-Latency Communications (URLLC): Ensures
ultra-low latency and high reliability for mission-critical
applications such as autonomous vehicles and industrial
automation.
1.2 MOTIVATION
8
1.3 LITERATURE REVIEW
1
0
[5] Boccardi, Federico - "Spectrum Allocation and Interference
Management in 5G"
Federico Boccardi's research explores the complexities of
spectrum allocation and interference management in 5G networks.
Effectively managing spectrum resources and mitigating
interference are crucial for optimizing network performance,
particularly in densely populated urban environments. This
research investigates techniques and strategies to ensure efficient
spectrum utilization and minimize interference, enhancing the
quality of service for users.
[6] Dhillon, Harpreet Singh - "Security and Privacy Concerns in 5G
Networks"
Harpreet Singh Dhillon's research highlights the security and
privacy concerns associated with 5G networks. As 5G facilitates
the exchange of sensitive data across a multitude of devices,
robust security protocols and privacy protections are essential to
prevent security breaches, data breaches, and unauthorized
access. This research explores vulnerabilities inherent in 5G
infrastructure and proposes strategies to enhance security and
privacy safeguards.
[7] Wang, Yingying - "Future Directions: Network Slicing and
Virtualization"
Yingying Wang's research discusses future directions for 5G
technology, with a focus on network slicing and virtualization.
Network slicing enables the creation of virtualized network
instances tailored to specific applications or user requirements,
allowing for dynamic resource allocation and service
customization. This research explores the potential of network
slicing to enhance quality of service and support diverse use cases
in 5G networks.
1
2
cooperation and regulatory harmonization to ensure the seamless
adoption and advancement of 5G technology on a global scale.
1.5 OBJECTIVE
This project aims to develop a robust network simulation system
using the ns- 3 framework, providing users with a versatile tool to
simulate and analyze diverse network scenarios. The primary
objective is to enable users to understand protocol behavior,
packet flows, and network performance through simulations. Key
features include Wireshark tracing for detailed packet-level
analysis,
1
3
ASCII tracing for concise event representation, and visualization
using NetAnim for graphical illustration of simulation scenarios.
Additionally, the project focuses on studying TCP congestion
control behavior within simulated
1
4
environments. Overall, this comprehensive simulation system will
serve as a valuable resource for researchers, network engineers,
and students, facilitating experimentation, analysis, and
understanding of network dynamics and protocols.
1
5
CHAPTER 2
SYSTEM ANALYSIS
10
providing various functionalities related to the transmission of user
data packets over the air interface. From a structural perspective,
the PDCP layer can be viewed in terms of its key components
and their roles within the network architecture:
12
conditions, user requirements, and quality of service (QoS)
[Link] PDCP layer configures and allocates resources for
radio bearers to ensure efficient and reliable communication
between the UE and the network.
PROPOSED SYSTEM
In the proposed system refinement, we aim to enhance the
effectiveness of 5G networks by integrating the functionality of
integrity protection and ciphering directly into the header
compression process within the UE-NGRAn and NGRan/Ue
interfaces. This integration streamlines the data transmission
process by consolidating security functions into the header
compression mechanism. Instead of performing integrity
protection and ciphering as separate operations, the proposed
system combines these functions with header compression,
thereby reducing processing overhead and improving network
efficiency.
5G Implications:
Integrating integrity protection and ciphering into header
compression in the proposed system has several implications for
13
the effectiveness of 5G networks:
14
Reduced Overhead and Latency: By combining security functions with
header compression, the proposed system reduces the number of
processing stages and associated overhead in data transmission.
This leads to lower latency, improved responsiveness, and
enhanced user experience in 5G networks, particularly for delay-
sensitive applications such as augmented reality, virtual reality,
and real-time gaming.
16
SOFTWARE REQUIREMENT SPECIFICATIONS
• Operating System: Ubuntu
• NetAnim: To simulate the packet flow in the network.
• Packages: ns3-tools, CMake.
• Languages: C/C++
• IDE: Visual Studio Code
• Wireshark
17
CHAPTER 3
SOFTWARE ENVIRONMENT
3.1 SOFTWARE
NetAnim
It is a powerful visualization tool integrated with the ns-3
(Network Simulator version 3) framework, specifically designed to
facilitate the visualization of network simulations. It provides a
graphical representation of network topologies, node movements,
packet transmissions, and other simulation events, allowing users
to visualize and analyse the behaviour of network protocols and
algorithms in a dynamic and intuitive manner. NetAnim supports
various visualization features, including node placement, link
animation, packet tracing, and event plotting, enabling users to
gain insights into the performance, scalability, and behavior of
network protocols in simulated environments.
NS3
19
In the context of 5G simulation, NetAnim and ns-3 play
complementary roles in facilitating the design, implementation,
and evaluation of 5G networks and protocols. NetAnim enables
users to visualize the behavior of 5G networks in a graphical
format, allowing for the observation of node movements, signal
propagation, handovers, and other network events. This
visualization capability is particularly valuable for understanding
the dynamics of mobility, coverage, and resource allocation in 5G
networks, which are essential aspects of 5G performance and
optimization.
C/C++
C Language Support: ns-3 offers support for programming network
simulations using the C programming language, allowing users to
11
0
write simulation models, protocols, and applications in C. While C
is less commonly used compared to C++ in ns-3 development, it
provides a lightweight and efficient option for users familiar with
the C programming language.
11
1
C-based modules and components can be seamlessly integrated
with existing ns-3 simulation environments and libraries, enabling
users to leverage the flexibility and extensibility of the ns-3
framework while programming in C.
WIRESHARK
11
3
network administrators, security professionals, developers, and
researchers. Here's an in-depth look at the features and tools
offered by Wireshark:
11
5
throughput, packet size distribution, round-trip time (RTT), and
protocol usage statistics. Users can generate various statistical
graphs and charts to visualize network performance metrics and
identify trends or anomalies.
11
6
CHAPTER 4
SYSTEM DESIGN AND UML DIAGRAMS
20
4.2 ARCHITECTURE DIAGRAM
21
4.4 SEQUENCE DIAGRAM
22
CHAPTER 5
Software Development Life Cycle
Requirement analysis
Planning
Software design such as architectural design
Software development
Testing
Deployment
24
cycle. The planning stage (also called the feasibility stage) is
exactly what it sounds like: the phase in which developers will plan
for the upcoming project. It helps to define the problem and scope
of any existing systems, as well as determine the objectives for
their new systems. By developing an effective outline for the
upcoming development cycle, they'll theoretically catch problems
before they affect development and help to secure the funding and
resources, they need to make their plan happen.
Analysis Stage
The analysis stage includes gathering all the specific details
required for a new system as well as determining the first ideas
for prototypes.
Developers may:
• Define any prototype system requirements
• Evaluate alternatives to existing prototypes
• Perform research and analysis to determine the needs of
end-users Furthermore, developers will often create a software
requirement specification or SRS document. This includes all the
specifications for software, hardware, and network requirements
for the system they plan to build. This will prevent them from
overdrawing funding or resources when working at the same place
as other development teams.
Design Stage
The design stage is a necessary precursor to the main
developer stage. Developers will first outline the details for the
overall application, alongside specific aspects, such as its:
• User interfaces
• System interfaces
• Network and network requirements
• Databases
They’ll typically turn the SRS document they created into a
more logical structure that can later be implemented in a
programming language. Operation, training, and maintenance
25
plans will all be drawn up so that developers know what they need
to do throughout every stage of the cycle moving forward.
Once complete, development managers will prepare a design
document to be referenced throughout the next phases of the
SDLC.
26
Development Stage
The development stage is the part where developers actually
write code and build the
application according to the earlier design documents and outlined
specifications. This is where Static Application Security Testing or
SAST tools come into play. Product program code is built per the
design document specifications. In theory, all of the prior planning
and outlined should make the actual development phase relatively
straightforward.
Developers will follow any coding guidelines as defined by the
organization and utilize different tools such as compilers,
debuggers, and interpreters. Programming languages can include
staples such as C++, PHP, and more. Developers will choose the
right programming code to use based on the project specifications
and requirements.
Testing Stage
Building software is not the end. Now it must be tested to
make sure that there aren’t any bugs and that the end-user
experience will not negatively be affected at any point. During the
testing stage, developers will go over their software with a fine-
tooth comb, noting any bugs or defects that need to be tracked,
fixed, and later retested. It’s important that the software overall
ends up meeting the quality standards that were previously
defined in the SRS document. Depending on the skill of the
developers, the complexity of the software, and the requirements
for the end-user, testing can either be an extremely short phase or
take a very long time. Take a look at our top 10 best practices for
software testing projects for more information.
28
Maintenance Stage
The SDLC doesn’t end when software reaches the market.
Developers must now move into a maintenance mode and begin
practicing any activities required to handle issues reported by end-
users. Furthermore, developers are responsible for implementing
any changes that the software might need after deployment.
This can include handling residual bugs that were not able to
be patched before launch or resolving new issues that crop up due
to user reports. Larger systems may require longer maintenance
stages compared to smaller systems.
29
CHAPTER 6
IMPLEMENTATION
6.1 SAMPLE
CODE
[Link]
#include "ns3/core-
module.h" #include
"ns3/network-module.h"
#include "ns3/internet-
module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
21
1
[Link] (argc, argv);
Time::SetResolution (Time::NS);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer nodes;
[Link] (2);
PointToPointHelper pointToPoint;
[Link] ("DataRate", StringValue ("5Mbps"));
[Link] ("Delay", StringValue ("2ms"));
NetDeviceContainer devices;
devices = [Link] (nodes);
21
2
InternetStackHelper stack;
21
3
[Link] (nodes);
Ipv4AddressHelper address;
[Link] ("[Link]", "[Link]");
21
5
Simulator::Destroy ();
return 0;
}
[Link]
// Default Network Topology
//
// [Link]
// n0 -------------- n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN [Link]
Header Includes:
#include "ns3/core-
module.h" #include
"ns3/network-module.h"
#include "ns3/csma-
module.h" #include
"ns3/internet-module.h"
#include "ns3/point-to-point-
module.h" #include "ns3/applications-
module.h" #include "ns3/ipv4-global-
routing-helper.h" #include
"ns3/netanim-module.h"
These lines include the necessary header files from the ns-3
module, providing access to various functionalities required for
network simulation.
Namespace:
using namespace ns3;
30
Logging:
NS_LOG_COMPONENT_DEFINE ("SecondScriptExample");
This line defines a logging component named
"SecondScriptExample", allowing for logging messages at
different verbosity levels for debugging purposes.
Main Function:
31
Logging Configuration:
if (verbose)
{
LogComponentEnable ("UdpEchoClientApplication",
LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication",
LOG_LEVEL_INFO);
}
NodeContainer p2pNodes;
[Link] (2);
NodeContainer csmaNodes;
[Link] ([Link]
(1)); [Link] (nCsma);
This section sets up the network topology by creating two node
containers: p2pNodes for the point-to-point link and csmaNodes
for the CSMA LAN.
Device Configuration:
PointToPointHelper pointToPoint;
[Link] ("DataRate", StringValue ("5Mbps"));
[Link] ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = [Link] (p2pNodes);
32
CsmaHelper csma;
[Link] ("DataRate", StringValue ("100Mbps"));
33
[Link] ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = [Link]
(csmaNodes);
This part configures the attributes of the point-to-point and CSMA
devices, such as data rate and delay, and installs them on the
respective nodes.
InternetStackHelper stack;
[Link] ([Link]
(0)); [Link]
(csmaNodes);
Ipv4AddressHelper address;
[Link] ("[Link]", "[Link]");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = [Link]
(p2pDevices);
35
UdpEchoClientHelper echoClient ([Link]
(nCsma), 9); [Link] ("MaxPackets", UintegerValue
(1)); [Link] ("Interval", TimeValue (Seconds
(1.0))); [Link] ("PacketSize", UintegerValue
(1024));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
It populates routing tables to enable proper packet forwarding in
the simulated network.
[Link] ("second");
[Link] ("second", [Link] (1),
true);
This section enables packet capture for all devices in the point-to-
point link and only for the second CSMA device.
Animation Interface:
Simulation Execution:
37
Simulator::Run ();
Simulator::Destroy
();
This part executes the simulation using Simulator::Run() and
cleans up resources using Simulator::Destroy() once the simulation
completes.
Return Statement:
return 0;
[Link]
We'll explore the setup of a wireless network topology using the
ns-3 simulation framework.
// Default Network Topology
//
// Wifi [Link]
// AP
// * * * *
// | | | | [Link]
// n5 n6 n7 n0-------------n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN [Link]
2. Required Includes
#include "ns3/core-module.h"
#include "ns3/point-to-point-
module.h" #include "ns3/network-
module.h" #include
"ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/ssid.h"
38
These lines include the necessary header files from the ns-3
library, providing functionalities related to core networking,
point-to-point communication, network topology, applications,
mobility, CSMA, Wi-Fi, etc.
39
3. Network Topology
Setup using
namespace ns3;
NS_LOG_COMPONENT_DEFINE("ThirdScriptExamp
le"); int main(int argc, char* argv[]) {
31
0
[Link]("DataRate", StringValue("5Mbps"));
[Link]("Delay", StringValue("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = [Link](p2pNodes);
31
1
// CSMA setup
NodeContainer
csmaNodes;
[Link]([Link]
(1));
[Link](nCsma);
CsmaHelper csma;
[Link]("DataRate", StringValue("100Mbps"));
[Link]("Delay", TimeValue(NanoSeconds(6560)));
NetDeviceContainer csmaDevices;
csmaDevices = [Link](csmaNodes);
// Wi-Fi setup
NodeContainer
wifiStaNodes;
[Link](nWi
fi);
NodeContainer wifiApNode = [Link](0);
YansWifiChannelHelper channel =
YansWifiChannelHelper::Default(); YansWifiPhyHelper phy;
[Link]([Link]
e()); WifiMacHelper mac;
Ssid ssid = Ssid("ns-3-ssid");
WifiHelper wifi;
NetDeviceContainer
staDevices;
[Link]("ns3::StaWifiMac
",
"Ssid", SsidValue(ssid),
"ActiveProbing",
BooleanValue(false));
staDevices = [Link](phy, mac,
wifiStaNodes); [Link]("ns3::ApWifiMac",
31
2
"Ssid",
SsidValue(ssid));
NetDeviceContainer
apDevices;
apDevices = [Link](phy, mac, wifiApNode);
31
3
6. Mobility Setup
MobilityHelper
mobility;
[Link]("ns3::GridPositionAllocator",
"MinX", DoubleValue(0.0),
"MinY", DoubleValue(0.0),
"DeltaX", DoubleValue(5.0),
"DeltaY", DoubleValue(10.0),
"GridWidth",
UintegerValue(3),
"LayoutType", StringValue("RowFirst"));
[Link]("ns3::RandomWalk2dMobilityModel",
"Bounds", RectangleValue(Rectangle(-50, 50, -50, 50)));
[Link](wifiStaNodes);
[Link]("ns3::ConstantPositionMobilityModel");
[Link](wifiApNode);
InternetStackHelper stack;
[Link](csmaNodes);
[Link](wifiApNode);
[Link](wifiStaNodes);
8. IP Address Assignment
31
4
Ipv4AddressHelper address;
[Link]("[Link]",
"[Link]");
Ipv4InterfaceContainer p2pInterfaces;
31
5
p2pInterfaces = [Link](p2pDevices);
[Link]("[Link]", "[Link]");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces =
[Link](csmaDevices);
[Link]("[Link]",
"[Link]");
[Link](staDevices);
[Link](apDevices);
31
7
12. Tracing Setup
[Link]("thirdp/third");
[Link]("thirdp/third", [Link](0));
[Link]("thirdp/third", [Link](0), true);
MyObject() {}
ns3::TracedValue<int32_t>
m_myInt;
};
40
Trace Sinks
40
A trace sink is a function that receives notifications from trace
sources when events occur or data changes. These functions, also
known as callback
62
0
CHAPTER 7
TESTING
7.1 Introduction
62
1
7.2 Sample Test Cases
62
2
CHAPTER 8
OUTPUT SCREEN
8.1 SCREENSHOTS
62
3
62
4
CHAPTER 9
CONCLUSION AND FUTURE SCOPE
CONCLUSION
FUTURE SCOPE
.
70
CHAPTER 10
REFERENCES
10.1 Websites
1. Ns3 - [Link]
2. Wireshark - [Link]
3. NetAnim - [Link]
simulation- using-netanim/
10.2 Books
1. [Link]
1TNAnVuhiDW7obXZQU65X_6b17T_7ejI7moWHPCFGVo9FZm7pYXQNjs3cP8uD1dIhnToUjQv
8CzSg
2. [Link] [5G NR
Configured Grant in ns-3 Network Simulator for Ultra-Reliable Low
Latency Communications]
3. [Link]
4wewmFzfuUlSZQMe4G6Gfa5uldleV8n4PEqXPDFFDX7jykgbCJShwSjIf0GB0nK3blh04ykNP5fA
[ importance of the simulation against encryption]
4. [Link]
EQ19GT5YzbezfQ00s43bEVnKSIA0uRkSBGq_UmS1yjYvQ0QBMRPt2aKzf6_a6V9DB7KH9xjWsC
7w [SPECTRAL TEMPORAL GRAPH NN FOR CSI PREDICITION]
5. [Link]
ccJH9hBXXsajmMvbQwG1fXeFqTiTjrA_J4twA4muYogpwyr4p01cibrDoB_u_49OzbRf0sXrKVlA
[CONTINUOUS SPECTRAL QoS TRANSFER FOR VEDIO STREAMING]
71
10.3 Publication
72