How to Implement on Intra Domain Protocol in NS2

To implement an intra-domain routing protocol in Network Simulator 2 (NS2) has several steps to follow and it is commonly known as to mimic the routing protocols that utilized within a single autonomous system (AS), like Open Shortest Path First (OSPF), Routing Information Protocol (RIP), or even static routing configurations. NS2 has built-in support for modest protocols such as RIP, nevertheless for more complex ones such as OSPF, we might essential to physically execute or mimic their characteristics, as NS2 does not directly support these more innovative protocols.

The below are the procedures to implement an intra-domain routing protocol in NS2:

Step-by-Step Implementation:

Step 1: Install NS2

Make sure that NS2 is installed on the system.

Step 2: Choose a Protocol

For simplicity, we can initiate by executing RIP, that is a simple intra-domain routing protocol maintained by NS2.

Step 3: Create a Simulation Script

Generate a Tcl script to setup the network and mimic the routing using the chosen intra-domain protocol.

Example: Implementing RIP in NS2

  1. Create a New Tcl Script: Open a text editor and generate a new file, for example, intra_domain_rip.tcl.
  2. Set Up the Simulation Environment: Describe the simulator, configure the network topology, and setup the performance metrics specific to simulation.

# Create a simulator object

set ns [new Simulator]

# Define options for the simulation

set val(chan)   Channel/WirelessChannel    ;# Channel type

set val(prop)   Propagation/TwoRayGround   ;# Propagation model

set val(netif)  Phy/WirelessPhy            ;# Network interface type

set val(mac)    Mac/802_11                 ;# MAC type

set val(ifq)    Queue/DropTail/PriQueue    ;# Interface Queue type

set val(ll)     LL ;# Link layer type

set val(ant)    Antenna/OmniAntenna        ;# Antenna type

set val(ifqlen) 50 ;# Max packet in ifq

set val(nn)     4 ;# Number of nodes

set val(rp)     RIP ;# Routing Protocol

set val(x)      500;# X dimension of topography

set val(y)      500;# Y dimension of topography

set val(stop)   10.0 ;# Simulation time

# Initialize the topology object

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

# Create the God object

create-god $val(nn)

# Configure the nodes

$ns node-config -llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-propType $val(prop) \

-phyType $val(netif) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace ON \

-movementTrace ON \

-adhocRouting $val(rp)

# Create nodes

for {set i 0} {$i < $val(nn)} {incr i} {

set node_($i) [$ns node]

$node_($i) random-motion 0

}

# Define node positions

$node_(0) set X_ 100.0; $node_(0) set Y_ 100.0

$node_(1) set X_ 300.0; $node_(1) set Y_ 100.0

$node_(2) set X_ 100.0; $node_(2) set Y_ 300.0

$node_(3) set X_ 300.0; $node_(3) set Y_ 300.0

# Setup links

$ns duplex-link $node_(0) $node_(1) 1Mb 10ms DropTail

$ns duplex-link $node_(1) $node_(3) 1Mb 10ms DropTail

$ns duplex-link $node_(0) $node_(2) 1Mb 10ms DropTail

$ns duplex-link $node_(2) $node_(3) 1Mb 10ms DropTail

# Setup traffic sources

set udp [new Agent/UDP]

$ns attach-agent $node_(0) $udp

set null [new Agent/Null]

$ns attach-agent $node_(3) $null

$ns connect $udp $null

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set packetSize_ 512

$cbr set interval_ 0.1

$cbr start

# Setup simulation end

$ns at $val(stop) “stop”

$ns at $val(stop) “$ns nam-end-wireless $val(stop)”

$ns at $val(stop) “exit 0”

proc stop {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

}

# Run the simulation

$ns run

Step 4: Run the Simulation

  1. Save the Tcl script (intra_domain_rip.tcl).
  2. Open a terminal and navigate to the directory in which we saved the Tcl script.
  3. Execute the simulation using the following command:

ns intra_domain_rip.tcl

This command will make a trace files and optionally a network animation file (if enabled in script).

Step 5: Analyse the Results

Use trace files and the network animator (NAM) to evaluate the performance of the RIP protocol that concentrates on the parameters such as packet delivery ratio, routing efficiency, and latency.

Step 6: Visualize the Results (Optional)

If we have to permit the network animator (NAM) in script so we can visualize the simulation:

nam intra_domain_rip.nam

This will open the NAM window, in which we can see the network topology and the behaviour of the RIP protocol during the simulation.

Implementing More Advanced Intra-Domain Protocols

We need to execute more advanced intra-domain protocols such as OSPF, here are some general steps:

  1. Custom Implementation: While NS2 doesn’t support directly for OSPF, We want to expand the NS2 by writing custom C++ code that executes OSPF’s behaviour. This contains to generate a new routing agent and handling the OSPF-specific states, link-state advertisements, and the shortest-path-first algorithm.
  2. Using External Modules: Search for previous OSPF execution for NS2, if any, and incorporate them into the simulation.
  3. Consider NS3: NS3 is the successor to NS2, has better support for complex routing protocols such as OSPF. We need to deliberate using NS3 if we want an cutting-edge protocol support.

Additional Considerations

  • Network Topology: Test with diverse network topologies to see how the protocol manages numerous scenarios.
  • Mobility: Evaluate the protocol in mobile conditions if the network contains mobile nodes.
  • Performance Metrics: Evaluate and associate the parameters such as packet delivery ratio, end-to-end delay, routing overhead, and network convergence time.

In the end of the page, we utterly provide the comprehensive procedure to complete the implementation process for intra-domain routing protocol that were implemented in ns2 tool. Further details regarding the implementation of the intra-domain routing protocol in different simulations will be provided.

Engage in an extensive performance evaluation specifically designed to suit your needs. We provide exceptional outcomes for Intra Domain Protocol within the NS2 framework, supported by cutting-edge research ideas. Our team is proficient in Open Shortest Path First (OSPF), Routing Information Protocol (RIP), and static routing configurations, all tailored to align with the unique demands of your project.