How to Simulate Classful Protocol Projects Using NS3

How to Simulate Classful Protocol Projects Using NS3

To simulate the classful routing protocols (such as RIP version 1, which is a classful protocol) within NS3 that needs a same method as replicating other routing protocols, however with attention to how the network is split into classes (Class A, B, and C networks) because the classful routing protocols do not support Variable Length Subnet Masking (VLSM). Below we offer simple approach on how we can replicate classful protocols using NS3:

Steps to Simulate Classful Routing Protocols in NS3:

  1. Install NS3: Initially, make certain we have NS3 installed. Then we download and install it from nsnam.org.
  2. Understand Classful Routing: Classful protocols such as RIP version 1 do not contain the subnet mask in their routing updates. As an alternative, they depends on the IP address classes (A, B, C) to find out the network boundaries.
  3. Set Up the Network Topology: We will make a basic network with classful IP addresses and set up routing using a classful protocol such as RIP version 1 (which is already supported by NS3 as RipHelper).
  4. Assign Classful IP Addresses: Once allocating an IP addresses to the nodes, make certain we are allocating them rely on Class A, B, or C networks, like:
    • Class A: 10.x.x.x with a subnet mask of 255.0.0.0.
    • Class B: 172.16.x.x with a subnet mask of 255.255.0.0.
    • Class C: 192.168.x.x with a subnet mask of 255.255.255.0.
  5. Configure RIP (Classful Protocol): Utilise RipHelper in NS3 to set up RIP on the network nodes. NS3 supports both RIP version 1 and version 2, but to make certain classful behaviour, we should be replicated RIP version 1.
  6. Set Up Network Traffic: Install applications such as UDP Echo client-server or a TCP client-server to generate traffic on the network.
  7. Run the Simulation: After configuring everything, we run the simulation and investigate the outcomes.

Example Simulation Code for Classful Routing Protocol (RIP v1):

The following is an example of replicating a classful routing protocol (RIP version 1) using NS3.

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/rip-helper.h”

#include “ns3/ipv4-address-helper.h”

#include “ns3/point-to-point-module.h”

#include “ns3/applications-module.h”

#include “ns3/netanim-module.h”

using namespace ns3;

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

{

// Step 1: Create nodes

NodeContainer nodes;

nodes.Create (4); // Creating 4 nodes

// Step 2: Set up point-to-point links between nodes

PointToPointHelper p2p;

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

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

NetDeviceContainer devices01, devices12, devices23;

devices01 = p2p.Install (nodes.Get (0), nodes.Get (1));

devices12 = p2p.Install (nodes.Get (1), nodes.Get (2));

devices23 = p2p.Install (nodes.Get (2), nodes.Get (3));

// Step 3: Install internet stack

InternetStackHelper internet;

RipHelper ripRouting;

ripRouting.ExcludeInterface (nodes.Get (0), 1); // Exclude RIP on some interfaces if needed

internet.SetRoutingHelper (ripRouting); // Use RIP v1 for routing

internet.Install (nodes);

// Step 4: Assign IP addresses (Class A, B, and C addresses)

Ipv4AddressHelper ipv4;

// Class A network

ipv4.SetBase (“10.0.0.0”, “255.0.0.0”);

Ipv4InterfaceContainer ifc01 = ipv4.Assign (devices01);

// Class B network

ipv4.SetBase (“172.16.0.0”, “255.255.0.0”);

Ipv4InterfaceContainer ifc12 = ipv4.Assign (devices12);

// Class C network

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

Ipv4InterfaceContainer ifc23 = ipv4.Assign (devices23);

// Step 5: Set up applications (e.g., UDP Echo)

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (3)); // Echo server on node 3

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (ifc23.GetAddress (1), 9);

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

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

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

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); // Echo client on node 0

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Step 6: Enable routing and simulation visualization with NetAnim

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

AnimationInterface anim (“rip_classful_simulation.xml”);

// Step 7: Run the simulation

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Explanation of the Code:

  1. Node Creation:
    • Four nodes are made to form a small network.
  2. Point-to-Point Link Setup:
    • The PointToPointHelper is used to make a point-to-point links among the nodes.
  3. Install Internet Stack:
    • The RipHelper is utilised to install RIP version 1 for classful routing on the nodes. If we require to prevent RIP on particular interfaces, then we can use the ExcludeInterface method.
  4. IP Address Assignment:
    • IP addresses are allocated from Class A, B, and C ranges:
      • Class A (10.x.x.x) for the link among nodes 0 and 1.
      • Class B (172.16.x.x) for the link between nodes 1 and 2.
      • Class C (192.168.1.x) for the link between nodes 2 and 3.
  5. UDP Echo Application:
    • A UDP Echo server is installed on the node 3, and a UDP Echo client on node 0. It will be analysed the communication among the nodes and make certain that routing takes place using RIP.
  6. NetAnim Visualization:
    • The simulation is visualized using NetAnim by generating an XML file (rip_classful_simulation.xml).
  7. Running the Simulation:
    • The simulation is implemented using Simulator::Run(), and the simulation resources are cleaned up with Simulator::Destroy().

Running the Simulation:

  1. Build the NS3 Script: We run the below commands in the NS3 directory:

./waf configure

./waf build

./waf –run <your-script-name>

  1. Visualize the Simulation: Open the generated XML file using NetAnim to envision how RIP (classful routing) performs in the network:

netanim rip_classful_simulation.xml

Adding Mobility (Optional):

Even though RIP is frequently utilised in static networks, we can insert mobility if required:

MobilityHelper mobility;

mobility.SetMobilityModel (“ns3::RandomWalk2dMobilityModel”,

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

mobility.Install (nodes);

Analysing Performance:

To estimate the performance of RIP in this classful setup, we can calculate:

  • Packet Delivery Ratio (PDR).
  • End-to-End Delay.
  • Routing Overhead (amount of control messages exchanged by RIP).
  • Throughput (successful data transfer rate).

Key Considerations for Classful Routing Protocols:

  • No Subnetting or VLSM: Classful protocols such as RIP v1 do not support Variable Length Subnet Masking (VLSM) or CIDR, which means that subnetting is not possible, and networks are split strictly according to the Class A, B, or C addresses.
  • Automatic Summarization: In classful protocols, the routes are automatically summarized at network class boundaries.

In this brief demonstration, we had known the basic guide to replicate the classful protocol projects and analyse its performance using the NS3 simulation platform. We will also be provided in depth details on this projects depending on your requests.

All you need to do to replicate the Classful Protocol Projects Using NS3 is send us an email with all the research details you have. We will respond to you right away and provide you with the finest possible results. We will support you with your projects’ comparative analysis.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2