Skip to main content

Performance Analysis of 50-Node Wireless Network Using NS3 | NS3 Project 17

Performance Analysis of 50-Node Wireless Network Using NS3 

AIM:

To simulate a 50-node wireless network using the NS-3 network simulator and perform detailed performance analysis by evaluating key network metrics such as throughput, delay, packet delivery ratio (PDR), packet loss ratio (PLR), and bytes transmitted and received.

 

PROMPT USED:

LLM Used: ChatGpt, Claude

Generate NS-3 code to simulate a 50-node wireless network using the AODV routing protocol and analyse network performance metrics such as throughput, delay, packet loss ratio, packet delivery ratio and bytes transmitted and received using FlowMonitor.

 SOURCE CODE:

#include "ns3/core-module.h"

#include "ns3/network-module.h"

#include "ns3/mobility-module.h"

#include "ns3/wifi-module.h"

#include "ns3/internet-module.h"

#include "ns3/aodv-module.h"

#include "ns3/applications-module.h"

#include "ns3/flow-monitor-module.h"

#include "ns3/netanim-module.h"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("ImprovedNetworkAudit");

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

{

uint32_t numNodes = 50;

 NodeContainer nodes;

nodes.Create(numNodes);

 WifiHelper wifi;

wifi.SetStandard(WIFI_STANDARD_80211b);

 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();

YansWifiPhyHelper phy;

phy.SetChannel(channel.Create());

 WifiMacHelper mac;

mac.SetType("ns3::AdhocWifiMac");

 NetDeviceContainer devices = wifi.Install(phy, mac, nodes);

 MobilityHelper mobility;

 mobility.SetPositionAllocator("ns3::GridPositionAllocator",

"MinX", DoubleValue(0.0),

"MinY", DoubleValue(0.0),

"DeltaX", DoubleValue(20.0),

"DeltaY", DoubleValue(20.0),

"GridWidth", UintegerValue(10),

"LayoutType", StringValue("RowFirst"));

 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");

 mobility.Install(nodes);

 AodvHelper aodv;

 InternetStackHelper internet;

internet.SetRoutingHelper(aodv);

internet.Install(nodes);

 Ipv4AddressHelper address;

address.SetBase("10.1.1.0", "255.255.255.0");

 Ipv4InterfaceContainer interfaces;

interfaces = address.Assign(devices);

 /* ---------- MULTIPLE TRAFFIC FLOWS ---------- */

 uint16_t port = 9;

 for (uint32_t i = 0; i < 10; i++)

{

 uint32_t source = i;

uint32_t destination = i + 10;

 OnOffHelper onoff("ns3::UdpSocketFactory",

Address(InetSocketAddress(interfaces.GetAddress(destination), port)));

 onoff.SetConstantRate(DataRate("1Mbps"));

 ApplicationContainer app = onoff.Install(nodes.Get(source));

app.Start(Seconds(1.0 + i));

app.Stop(Seconds(20.0));

 PacketSinkHelper sink("ns3::UdpSocketFactory",

Address(InetSocketAddress(Ipv4Address::GetAny(), port)));

 ApplicationContainer sinkApp = sink.Install(nodes.Get(destination));

sinkApp.Start(Seconds(0.0));

sinkApp.Stop(Seconds(20.0));

 }

 /* ---------- FLOW MONITOR ---------- */

 FlowMonitorHelper flowmon;

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

 /* ---------- NETANIM ---------- */

 AnimationInterface anim("network50.xml");

 anim.SetMaxPktsPerTraceFile(1000000);

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

{

anim.UpdateNodeDescription(nodes.Get(i), "Node" + std::to_string(i));

anim.UpdateNodeColor(nodes.Get(i), 255, 0, 0);

}

 /* ---------- SIMULATION ---------- */

 Simulator::Stop(Seconds(20));

Simulator::Run();

 /* ---------- PERFORMANCE METRICS ---------- */

 monitor->CheckForLostPackets();

 Ptr<Ipv4FlowClassifier> classifier =

DynamicCast<Ipv4FlowClassifier>(flowmon.GetClassifier());

 std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats();

 for (auto &flow : stats)

{

 std::cout << "Flow ID: " << flow.first << std::endl;

 std::cout << "Tx Packets = " << flow.second.txPackets << std::endl;

 std::cout << "Rx Packets = " << flow.second.rxPackets << std::endl;

 std::cout << "Lost Packets = " << flow.second.lostPackets << std::endl;

 double throughput = flow.second.rxBytes * 8.0 /

(flow.second.timeLastRxPacket.GetSeconds() -

flow.second.timeFirstTxPacket.GetSeconds()) / 1024;

 std::cout << "Throughput: " << throughput << " Kbps" << std::endl;

 double delay = flow.second.delaySum.GetSeconds() /

flow.second.rxPackets;

 std::cout << "Average Delay: " << delay << std::endl;

double pdr = ((double)flow.second.rxPackets /

flow.second.txPackets) * 100;

double plr = ((double)flow.second.lostPackets /

flow.second.txPackets) * 100;

std::cout << "Packet Delivery Ratio: " << pdr << "%" << std::endl;

 std::cout << "Packet Loss Ratio: " << plr << "%" << std::endl;

 }

 Simulator::Destroy();

return 0;

 }

TERMINAL OUTPUT:

The above terminal output displays the performance statistics obtained from the NS-3 simulation using the FlowMonitor module. A total of 9277 packets were transmitted during the simulation, out of which 9276 packets were successfully received, resulting in only 1 packet loss.

The network achieved a throughput of approximately 2059.86 Kbps, indicating efficient data transmission between the nodes. The average delay recorded was 0.000687 seconds, which shows that packets were delivered very quickly across the network.

The Packet Delivery Ratio (PDR) of 99.9892% indicates that almost all transmitted packets successfully reached the destination. Similarly, the Packet Loss Ratio (PLR) of 0.0107% is extremely low, demonstrating stable and reliable network communication.

Additionally, the simulation shows 5,009,580 bytes transmitted and 5,009,040 bytes received, confirming that the majority of the transmitted data was successfully delivered within the network. These results indicate that the simulated 50-node wireless network performs efficiently with minimal packet loss and low delay.

 

NETWORK ANIMATION:

The NetAnim tool is used to visualize the network topology generated by the NS-3 simulation. Each node represents a wireless device participating in network communication. The visualization helps understand the structure and connectivity of the simulated network.

 Throughput and Time graph:



Graph Explanation:

The throughput graph was plotted using gnuplot based on the simulation results obtained from the NS-3 FlowMonitor output. The graph shows the throughput performance of the 50 node network during the simulation. The values show the increasing throughput trend during the simulation before stabilizing near the measured throughput value of ~2060 Kbps.

 

RESULT ANALYSIS:
From the simulation output, the following results were observed.
Total Packets Transmitted: 9277
Total Packets Received: 9276
Packets Lost: 1

Throughput: 2059.86 Kbps
Average Delay: 0.000687 seconds
Packet Delivery Ratio: 99.9892%
Packet Loss Ratio: 0.0107%

The high packet delivery ratio indicates efficientcommunication in the network while the packet loss ratio remains extremely low, demonstrating stable network behaviour

 

ADDITIONAL OBSERVATIONS:

• An increasing number of nodes may increase network congestion.

• Wireless channel interference can affect throughput.

• Efficient routing protocols help reduce packet loss.

• FlowMonitor helps analyse real-time network performance.

Comments

Popular posts from this blog

How to Create Ubuntu 24.04 Bootable USB Using Rufus [Step-by-Step Guide]

How to Create Ubuntu 24.04 Bootable USB Using Rufus [Step-by-Step Guide] Are you planning to install or try Ubuntu 24.04 LTS ? The easiest and most reliable method is to create a bootable USB drive using Rufus on a Windows system. This detailed guide will help you create a Ubuntu 24.04 USB bootloader using Rufus with easy-to-follow steps and screenshots (optional). Here is the complete video of the bootloader creation and OS installation in Windows 11. 🧰 Requirements A USB flash drive (minimum 8GB recommended) A Windows PC Ubuntu 24.04 LTS ISO file Rufus USB creation tool 🧾 Steps to Create a Ubuntu 24.04 Bootable USB Using Rufus ✅ Step 1: Download Ubuntu 24.04 ISO Visit the official Ubuntu website and download the Ubuntu 24.04 LTS ISO file . ✅ Step 2: Download and Run Rufus Head to Rufus official site and download the latest version. Open the executable file (no installation required). ✅ Step 3: Insert USB Drive Plug in your USB drive. Rufus ...

Installing ns3 in Ubuntu 22.04 | Complete Instructions

In this post, we are going to see how to install ns-3.36.1 in Ubuntu 22.04. You can follow the video for complete details Tools used in this simulation: NS3 version ns-3.36.1  OS Used: Ubuntu 22.04 LTS Installation of NS3 (ns-3.36.1) There are some changes in the ns3 installation procedure and the dependencies. So open a terminal and issue the following commands Step 1:  Prerequisites $ sudo apt update In the following packages, all the required dependencies are taken care and you can install all these packages for the complete use of ns3. $ sudo apt install g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libc...

NS2 (NS-2.35) Installation in Ubuntu 11.10

This post will help you in installing Network Simulator 2 version NS2.35 in Ubuntu 11.10 Instructions Install Ubuntu Download NS-2.35 ( http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download ) Unzip or untar it to any folder (recommended is /home/ loginname) using the following commands one by one sudo apt-get update sudo apt-get install build-essential autoconf automake libxmu-dev tar zxvf ns-allinone-2.35.tar.gz cd ns-allinone-2.35 ./install Once installed the PATH information will be provided to you. Copy the PATH and LD_LIBRARY_PATH Variable to .bashrc (see a dot in the beginning) Input the path information in .bashrc file like this export PATH=$PATH:<Place your paths here> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH: <place the LD_LIBRARY_PATHS> here. Once done, save the file and close execute the command source .bashrc try ns or nam to see whether your installation succeeded.