How to Begin Implement a CCNA Protocols in NS3

To implement the CCNA protocols like RIP, OSPF, EIGRP, and so on are generally focused on routing protocols which can be utilized within computer networks. To execute the CCNA protocols leveraging NS3 has needs to replicate its behavior in network situations. NS3 directly have support for some of these protocols, but others such as EIGRP wants integration with external tools like Quagga or a custom execution.

We can see how to start executing the CCNA protocols in ns3:

Steps to Begin Implement a CCNA Protocols in NS3

  1. Understand the Protocols

CCNA includes a wide range of protocols:

  • RIP v2: It is a classless distance-vector routing protocol.
  • OSPF: A link-state routing protocol.
  • EIGRP: Cisco’s hybrid routing protocol to integrate both distance-vector and link-state aspects.
  • BGP: A path-vector protocol is often utilized for inter-domain routing.
  1. Set Up ns3 Environment
  1. Install ns3:

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

cd ns-3-dev

./build.py

  1. Confirm the installation:

./ns3 run hello-simulator

  1. Plan the Network Topology
  • Components:
    • Routers are executing the CCNA protocols.
    • Hosts linked to the routers.
    • Connections among the routers and subnets.
  • Topology:
    • Make use of point-to-point or LAN connections.
  1. Implementation Steps for Specific Protocols
  2. RIP v2 (Built-in Support in ns3)
  1. Include Necessary Headers

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

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

#include “ns3/rip-helper.h”

  1. Define Nodes

ns3::NodeContainer routers, hosts;

routers.Create(3);  // Three routers

hosts.Create(2);    // Two hosts

  1. Set Up Links

ns3::PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, ns3::StringValue(“1Gbps”));

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

ns3::NetDeviceContainer devices;

devices.Add(p2p.Install(routers.Get(0), routers.Get(1)));  // R1-R2

devices.Add(p2p.Install(routers.Get(1), routers.Get(2)));  // R2-R3

devices.Add(p2p.Install(routers.Get(0), hosts.Get(0)));    // R1-Host1

devices.Add(p2p.Install(routers.Get(2), hosts.Get(1)));    // R3-Host2

  1. Install Internet Stack with RIP

ns3::RipHelper rip;

ns3::InternetStackHelper stack;

stack.SetRoutingHelper(rip);  // Use RIP as the routing protocol

stack.Install(routers);

stack.Install(hosts);

  1. Assign IP Addresses

ns3::Ipv4AddressHelper address;

// Subnet 1: Between R1 and R2

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

address.Assign(devices.Get(0));

// Subnet 2: Between R2 and R3

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

address.Assign(devices.Get(1));

// Subnet 3: R1 to Host1

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

address.Assign(devices.Get(2));

// Subnet 4: R3 to Host2

address.SetBase(“172.16.1.0”, “255.255.0.0”);

address.Assign(devices.Get(3));

  1. Generate Traffic

ns3::UdpEchoServerHelper echoServer(9);

ns3::ApplicationContainer serverApp = echoServer.Install(hosts.Get(1));

serverApp.Start(ns3::Seconds(1.0));

serverApp.Stop(ns3::Seconds(20.0));

ns3::UdpEchoClientHelper echoClient(address.Assign(devices.Get(1)).GetAddress(1), 9);

echoClient.SetAttribute(“MaxPackets”, ns3::UintegerValue(10));

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

echoClient.SetAttribute(“PacketSize”, ns3::UintegerValue(512));

ns3::ApplicationContainer clientApp = echoClient.Install(hosts.Get(0));

clientApp.Start(ns3::Seconds(2.0));

clientApp.Stop(ns3::Seconds(20.0));

  1. Run the Simulation

ns3::Simulator::Run();

ns3::Simulator::Destroy();

  1. OSPF and EIGRP

OSPF and EIGRP are not directly executed using ns3. To replicate these protocols, we can:

  1. Install Quagga:

sudo apt install quagga

  1. Configure Quagga:
    • Make configuration files as ospfd.conf, zebra.conf for OSPF; eigrpd.conf for EIGRP.
    • Instance ospfd.conf:

router ospf

network 10.0.0.0/8 area 0

  1. Integrate Quagga with ns3:
    • Associate ns3 nodes including Quagga routers applying TapBridgeHelper.

ns3::TapBridgeHelper tapBridge;

tapBridge.SetAttribute(“Mode”, ns3::StringValue(“UseLocal”));

tapBridge.Install(routers.Get(0), devices.Get(0));

  1. Generate Traffic and Run Simulation:
    • Adhere to the similar simulation steps by way of RIP for making traffic and estimating the performance.
  1. BGP (External Tool Integration)
  1. Install FRRouting or Quagga:
    • FRRouting or Quagga can be performed like BGP routers.
    • Set up BGP peers within bgpd.conf.
  2. Set Up Peering:
    • Describe the peers and publicise prefixes.
  3. Integrate with ns3:
    • Leverage TapBridgeHelper for connectivity among the ns3 and FRRouting/Quagga.
  1. Analyze Results

Metrics:

  • Packet Delivery Ratio (PDR):
    • Compute the rate of packets which are effectively transmitted to entire forwarded packets.
  • Routing Overhead:
    • During the simulation, count the volume of control packets that are swapped.
  • Convergence Time:
    • Measure duration to become stable after topology changes for routing tables.

Tracing and Visualization:

  • Allow .pcap tracing:

ns3::AsciiTraceHelper ascii;

p2p.EnableAsciiAll(ascii.CreateFileStream(“ccna-protocols.tr”));

p2p.EnablePcapAll(“ccna-protocols”);

  • Apply NetAnim for envisioning the simulation outcomes:

./waf –run “ccna-protocols-simulation –vis”

  1. Iterate and Enhance
  • Advanced Scenarios:
    • Mimic link failures or high traffic loads to experiment the resilience of protocol.
    • Launch mobility for OSPF/EIGRP within MANET-like situations.
  • Compare Protocols:
    • Measure the RIP, OSPF, and EIGRP’s performance within same topologies.
  • Custom Protocol Extensions:
    • Fine-tune existing protocol logic in ns3 or Quagga tools for integrating advanced aspects.

We had successfully executed the common procedure of CCNA Protocol that were implemented and analysed the outcomes using the tool of ns3 and extended the protocols for advanced uses. If you need more information about the CCNA Protocol we will provide it.