How to Start Internal Protocols Project Using NS2

To create a project has including the internal protocols in NS2 (Network Simulator 2) typically it replicates the routing protocols used in a single autonomous system (AS). This coordinates through Interior Gateway Protocols (IGPs), such as RIP (Routing Information Protocol), OSPF (Open Shortest Path First), or internal routing schemes level for the custom.

Here’s a step-by-step guide:

Steps to Start Internal Protocol Project Using NS2

  1. Understand Internal Protocols and NS2 Capabilities
  • Internal Protocols Overview:
    • Protocols are modeled for routing in a network or AS.
    • Examples:
      • RIP: A distance-vector protocol.
      • OSPF: A link-state protocol.
      • Internal protocols are custom, like as company-specific routing techniques.
  • NS2 Features:
    • It helps for the built-in routing protocols such as RIP.
    • Extendable for custom protocol execution for instance OSPF.
  1. Set Up NS2 Environment
  • Install NS2:

sudo apt-get install ns2

  • Validate the installation by a sample script:

ns example.tcl

  1. Define the Project Scope
  • Objective Examples:
    • It replicates the RIP or OSPF in dynamic or static network scenarios.
    • It associates the performance parameter metrics for sample convergence time, throughput of RIP vs OSPF.
    • Model in a custom internal routing protocol for a specific environment.
  • Scenarios:
    • During the topology changes are network stability.
    • Routing performance is affecting the node failures.
  1. Design the Network Topology
  • Topology Elements:
    • Nodes: Represent routers or hosts.
    • Links: It replicates the connection for physical or logical link by bandwidth, delay, and queue settings.
  • Example Topology:
    • The six nodes are connected in the mesh or tree structure, forming a single AS.
  1. Write the TCL Script
  • Use the tool helps for NS2’s built-in the RIP or generates the custom extensions for protocols like OSPF.

Example TCL Script for RIP Simulation:

# Initialize the simulator

set ns [new Simulator]

# Define trace and NAM files

set tracefile [open internal_protocol_trace.tr w]

$ns trace-all $tracefile

set namfile [open internal_protocol_simulation.nam w]

$ns namtrace-all $namfile

# Create nodes

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

set n5 [$ns node]

# Connect nodes

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

$ns duplex-link $n1 $n2 1Mb 10ms DropTail

$ns duplex-link $n2 $n3 1Mb 10ms DropTail

$ns duplex-link $n3 $n4 1Mb 10ms DropTail

$ns duplex-link $n4 $n5 1Mb 10ms DropTail

$ns duplex-link $n0 $n5 1Mb 10ms DropTail

# Configure routing protocol (RIP)

$ns rtproto RIP

# Add traffic

set udp [new Agent/UDP]

$ns attach-agent $n0 $udp

set null [new Agent/Null]

$ns attach-agent $n5 $null

$ns connect $udp $null

set cbr [new Application/Traffic/CBR]

$cbr set packetSize_ 512

$cbr set interval_ 0.1

$cbr attach-agent $udp

# Start traffic

$ns at 1.0 “$cbr start”

$ns at 10.0 “$cbr stop”

# Terminate simulation

$ns at 15.0 “finish”

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam internal_protocol_simulation.nam &

exit 0

}

$ns run

  1. Extend for OSPF or Custom Protocols
  • OSPF Implementation:
    • It needs a custom extension and replicates the link-state advertisements (LSAs) and Dijkstra’s procedures.
    • Alter the Agent class in NS2’s C++ help for important in OSPF-like behavior.
  • Custom Protocol:
    • Build a new routing agent in C++.
    • Incorporate through NS2’s network layer and handle the routing tables and packet sending.
  1. Simulate Network Dynamics
  • Link Failures:

$ns rtmodel-at 5.0 down $n2 $n3

$ns rtmodel-at 7.0 up $n2 $n3

  • Traffic Variation:
    • Establish for several congestion sources by different patterns.
  1. Run the Simulation
  • Implement the TCL script:

ns internal_protocol_simulation.tcl

  • Envision for the network using NAM:

nam internal_protocol_simulation.nam

  1. Analyze Performance
  • Extract metrics from the trace file (internal_protocol_trace.tr):
    • Packet Delivery Ratio (PDR): Ratio of packets is delivered successfully.
    • Routing Overhead: Number of control messages is altered.
    • Convergence Time: The network takes duration for stabilize the topology after modified.

Example AWK Script for PDR:

BEGIN {sent=0; received=0;}

{

if ($1 == “s” && $4 == “UDP”) {

sent++;

} else if ($1 == “r” && $4 == “UDP”) {

received++;

}

}

END {

print “Packet Delivery Ratio:”, received/sent;

}

  1. Enhance Protocol Functionality
  • QoS Extensions:
    • It improves the helps for prioritizing the certain kinds of congestion.
  • Energy Efficiency:
    • Evaluate protocols in energy-constrained environments for instance IoT.
  • Security:
    • Execute encode or verification for routing updates.
  1. Document the Project
  • Include:
    • Objectives and problem statement has prepare the beginning of document.
    • Network topology and setting are based on the problem statement of the document.
    • Then gives the parameter simulation results for sample graphs and tables.
    • Finally it observations and recommendations of the document.

Suggested Enhancements

  • Compare Protocols:
    • Estimate the RIP vs OSPF in based on the overhead, delay, and scalability.
  • Scalability Testing:
    • Internal protocols are replicates in networks through hundreds of nodes.
  • Realistic Traffic Patterns:
    • Replicates the congestion patterns are web browsing, video streaming, or other real-world scenarios.

Now, you can clearly understand the approach and be able to implement the internal routing protocols by referring the given structured procedure and the examples using ns2 tool. You can also expand the simulation according to the requirements.