Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How to Calculate Network Reliability in ns3

To calculate the network reliability in ns3, we need to evaluate the ratio of successfully delivered packets to the total packets sent. Network reliability is also known as packet delivery ratio (PDR). Furthermore, we offer a detailed explanation of how to figure Network Reliability in ns3simulation. For optimum results in terms of Network Reliability, please contact ns3simulation.com.

Here, we provide the detailed procedures to calculate the network reliability in ns3:

  1. Set up Your Simulation Environment: Create a network topology; configure nodes, links, and protocols.
  2. Install Applications: Set up applications on the nodes to generate and receive traffic.
  3. Trace the Packets: Use ns3 tracing capabilities to record the number of packets sent and received.
  4. Calculate Network Reliability: Calculate the Packet Delivery Ratio (PDR) as the measure of network reliability.

Example: Simple Network Reliability Calculation

In this sample, we generate the network topology with 2 nodes that links by point-to-point and evaluated the reliability of network.

Step 1: Set Up Your Simulation Environment

#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”

#include “ns3/flow-monitor-helper.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“NetworkReliabilityExample”);

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

{

// Create two nodes

NodeContainer nodes;

nodes.Create (2);

// Set up the point-to-point link

PointToPointHelper pointToPoint;

pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));

pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

// Install link devices on nodes

NetDeviceContainer devices;

devices = pointToPoint.Install (nodes);

// Install the internet stack

InternetStackHelper stack;

stack.Install (nodes);

// Assign IP addresses

Ipv4AddressHelper address;

address.SetBase (“10.1.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer interfaces = address.Assign (devices);

// Set up the UDP echo server on Node 1

uint16_t port = 9; // well-known echo port number

UdpEchoServerHelper echoServer (port);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

// Set up the UDP echo client on Node 0

UdpEchoClientHelper echoClient (interfaces.GetAddress (1), port);

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

echoClient.SetAttribute (“Interval”, TimeValue (Seconds (0.1))); // 10 packets per second

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

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Enable tracing

AsciiTraceHelper ascii;

pointToPoint.EnableAsciiAll (ascii.CreateFileStream (“network-reliability.tr”));

// Set up flow monitor

FlowMonitorHelper flowmon;

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

// Run the simulation

Simulator::Run ();

// Calculate network reliability

monitor->CheckForLostPackets ();

Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());

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

uint64_t totalPacketsSent = 0;

uint64_t totalPacketsReceived = 0;

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)

{

Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first);

if (t.destinationPort == port)

{

totalPacketsSent += i->second.txPackets;

totalPacketsReceived += i->second.rxPackets;

}

}

double reliability = static_cast<double>(totalPacketsReceived) / totalPacketsSent * 100;

std::cout << “Total Packets Sent: ” << totalPacketsSent << std::endl;

std::cout << “Total Packets Received: ” << totalPacketsReceived << std::endl;

std::cout << “Network Reliability: ” << reliability << ” %” << std::endl;

Simulator::Destroy ();

return 0;

}

Step 2: Install Applications

In this example, a UDP echo server is installed on Node 1, and a UDP echo client is installed on Node 0. The client sends 100 packets, each 1024 bytes in size, at an interval of 0.1 seconds.

Step 3: Trace the Packets

The FlowMonitor module is used to collect statistics such as the number of packets sent and received.

Step 4: Calculate Network Reliability

The network reliability is calculated by dividing the total number of packets received by the total number of packets sent, and then multiplying by 100 to get the percentage.

Explanation

In the present, we explained the process structurally in the below

  1. Set up Your Simulation Environment: Create two nodes and connect them with a point-to-point link.
  2. Install Applications: Install a UDP echo server on Node 1 and a UDP echo client on Node 0. Configure the client to send a specified number of packets at a specified interval.
  3. Trace the Packets: Use the FlowMonitor module to collect statistics such as the number of packets sent and received.
  4. Calculate Network Reliability: Define network reliability as the ratio of successfully delivered packets to the total packets sent. Use the collected statistics to calculate this ratio.

At the last, the network reliability can be calculate and simulated successfully by use of ns3.

We would be happy to offer you recommendations on network performance for your project from our developers. Also, we continue with an all-embracing performance analysis.