How to Develop RIP v2 Protocol Projects Using NS3

To develop the RIP v2 Protocol Projects in NS-3. The Routing Information Protocol version 2 (RIPv2) is distance-vector routing protocol used for dynamic routing in minimum to medium-sized networks. It supports:

  • Classless Inter-Domain Routing (CIDR)
  • Routing updates via multicast (224.0.0.9)
  • Authentication support
  • Maximum hop count of 15

Steps to Develop RIP v2 Protocol Projects Using NS3

  1. Install and Set Up NS-3

Previously open, which is assured the tool NS-3, is installed on your system.

Installation

sudo apt update

sudo apt install git g++ python3 python3-pip cmake ninja-build

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

cd ns-3-dev

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

./ns3 build

  1. Understanding RIP v2 in NS-3

RIP v2 Functionality

  • Periodic routing keep informed (in each 30 sec).
  • We used the divide horizon and route poisoning for loop prevention.
  • The performance of parameter metric terms on hop count (max 15).
  • We assist the multicast (224.0.0.9).

RIP v2 in NS-3

  • NS-3 has built-in encourage for RIPv2 through Ipv4RIPRoutingHelper.
  • We can encompass the tool NS-3 to change or examine the RIP v2 behavior.
  1. Implementing RIP v2 in NS-3

Step 1: Create a Simple RIP v2 Network Topology

We will execute a three-router network, in which every router implements the RIP v2.

Create a Simulation Script (ripv2-simulation.cc)

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

using namespace ns3;

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

CommandLine cmd;

cmd.Parse(argc, argv);

NodeContainer routers, hosts;

routers.Create(3);

hosts.Create(2);

InternetStackHelper internet;

Ipv4ListRoutingHelper listRouting;

RipHelper ripRouting;

listRouting.Add(ripRouting, 100);

internet.SetRoutingHelper(listRouting);

internet.Install(routers);

internet.Install(hosts);

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));

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

NetDeviceContainer d1, d2, d3;

d1 = p2p.Install(routers.Get(0), routers.Get(1));

d2 = p2p.Install(routers.Get(1), routers.Get(2));

d3 = p2p.Install(routers.Get(2), hosts.Get(0));

Ipv4AddressHelper address;

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

address.Assign(d1);

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

address.Assign(d2);

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

address.Assign(d3);

// Enable Routing

ripRouting.SetInterfaceMetric(routers.Get(1)->GetObject<Ipv4>(), 1, 1);

// Enable Packet Tracing

AsciiTraceHelper ascii;

p2p.EnableAsciiAll(ascii.CreateFileStream(“ripv2.tr”));

Simulator::Run();

Simulator::Destroy();

return 0;

}

  1. Compile and Run the Simulation

Step 1: Create the NS-3

./ns3 build

Step 2: Implement the replication process for this methods

./ns3 run “scratch/ripv2-simulation”

  1. Performance Analysis

Enable Logging

Alter the script to allow the recording:

LogComponentEnable(“RipRoutingProtocol”, LOG_LEVEL_INFO);

Gather the Performance Metrics of RIP v2 protocol

We calculate the Packet Delivery Ratio (PDR)

Ptr<PacketSink> sink = DynamicCast<PacketSink>(apps.Get(1));

double pdr = sink->GetTotalRx() / totalSentPackets;

Examine the Routing Table Entries

Ipv4RoutingTableEntry entry;

Ptr<Ipv4> ipv4 = routers.Get(1)->GetObject<Ipv4>();

if (ipv4->GetRoutingTableEntry(1, &entry)) {

NS_LOG_INFO(“Route to ” << entry.GetDest() << ” via ” << entry.GetGateway());

}

  1. Extend the Project
  • Associate the RIP v2 by OSPF/BGP.
  • We replicate for RIP v2 below the connection failures.
  • We increase the RIP v2 bring up-to-date for network effectiveness.

As we saw in this process, it will help you to set up the simulation network, to fine-tune the simulator and to establish the Routing Information Protocol version 2 in the ns3 by defining routing protocol that presents some samples. If needed, we can help you with another approach.