How to Start Static Routing Projects Using NS2

To start a Static Routing project using NS2 that encompasses to make a routing protocol, which doesn’t modify responsively to network events such as node mobility or link failures. Routes are pre-defined or arranged, and when they are configured then does not modify within the simulation in static routing. This kind of routing is normally utilised such scenarios in which the network topology is immobile, and the routing table dynamically does not being updated.

In NS2, we need to execute the static routing is normally easier than dynamic routing protocols as the routing paths are find. Below is a structure method to start a static routing project in NS2:

Steps to Start Static Routing Projects in NS2

  1. Install NS2

We adhere to installation steps to install NS2, if is not installed earlier.

  • For Linux (Ubuntu/Debian-based):

sudo apt update

sudo apt install ns2

sudo apt install nam

  • For Windows: We want to utilise a virtual machine or tools such as Cygwin, since NS2 does not directly support Windows.

When installed then confirm that NS2 is functioning:

ns

It should go to the NS2 command-line interface.

  1. Understand Static Routing

Static routing includes to manually setting up the routes or to utilise the basic routing protocols, which do not modify over time. The crucial static routing characteristics:

  • Predefined paths: Routes are configured and it doesn’t modify.
  • No adaptation to network changes: Static routing does not modify according to the network traffic, node movement, or link failures.
  • Low overhead: While routes don’t want to compute again then the static routing utilises minimum amount of bandwidth for control messages.

In NS2, following is a few common protocols, which might deliberate “static” are:

  • Destination-Sequenced Distance-Vector (DSDV): A proactive protocol however we can be configured including static routes.
  • Manual routing: Just describing the fixed routes with the support of NS2 simulator.
  1. Set Up Your NS2 Simulation Environment

We will want to configure a simple network topology and set the nodes including static routes. It can be done with TCL scripts in NS2.

Example: Basic Network Topology with Static Routes

Below is a basic instance including 3 nodes in which the routes are predefined. The traffic will move from Node 0 to Node 2 to utilise a fixed route.

# Create a simulator object

set ns [new Simulator]

# Create nodes (3 nodes in this case)

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

# Create links between nodes

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

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

# Set up static routing manually (no dynamic changes)

# In static routing, we manually set the routing table between nodes.

# Route from node 0 to node 2 via node 1

$ns connect $n0 $n1

$ns connect $n1 $n2

# Create traffic (e.g., TCP from n0 to n2)

set tcp [new Agent/TCP]

set sink [new Agent/TCPSink]

$sink attach-agent $n2

$tcp attach-agent $n0

# Connect the agents

$ns connect $tcp $sink

# Start sending traffic at time 1.0 seconds

$ns at 1.0 “$tcp send”

# Run the simulation

$ns run

In the above instance:

  • 3 nodes are made that are n0, n1, and n2.
  • Two links are generated from n0 to n1, and n1 to n2.
  • A TCP traffic flow is configure through n1 from n0 to n2.
  1. Static Routing in NS2

The routing protocol can be immobile as we only define the routes in NS2. But, NS2 primarily supports dynamic routing protocols such as AODV, DSR, and so on, thus custom routing protocol requires to be inscribed if we need to be configured the static routes for more complex scenarios.

We can attain this by way of connecting nodes within a fixed topology and routing traffic through the predefined links for basic static routing. In this sample, the traffic will traverse n1from n0 to n2, and no dynamic routing updates will be happened.

  1. Define Static Routes Using staticRouting arise

Even though NS2 doesn’t built-in support, offered static routing protocol then we can replicate the static routing by means of describing the paths among the nodes using TCL script.

Example of static route configuration:

# Static Route Example

# A simple route setup: node 0 -> node 1 -> node 2

# Manually set the route from node 0 to node 2 via node 1.

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

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

# Static routing in NS2 is achieved by simply defining connections

# between nodes without using any dynamic protocol.

  1. Create Traffic and Monitor Behavior

When we need to configure the static routing then we can make traffic among the nodes and also monitor the behavior. For example, we have to make TCP traffic from node 0 to node 2.

Example: Generate Traffic

# Create TCP traffic from node 0 to node 2

set tcp [new Agent/TCP]

set sink [new Agent/TCPSink]

$sink attach-agent $n2

$tcp attach-agent $n0

# Connect the agents and start the traffic

$ns connect $tcp $sink

$ns at 1.0 “$tcp send”  ;# Send data at time 1.0 seconds

This configuration utilises the TCP traffic however we can use other kinds of traffic such as UDP or CBR (Constant Bit Rate).

  1. Generate Trace Files and Analyze Results

We can make trace files, which include data regarding the traffic flow, packet delivery, and routing events for observing the performance of network.

Enable Tracing:

# Enable tracing for packets and routing information

$ns trace-all “output.tr”

It will create a trace file as output.tr that can be examined to learn the performance parameters like:

  • Throughput: Estimate the volume of data which are effectively sent.
  • End-to-End Delay: Measure the duration for a packet moving from source to destination.
  • Packet Delivery Ratio: The volume of packets that are efficiently inherited and split by the total packets transmitted.
  • Routing Overhead: The control messages utilised for routing.

Also, we can envision the network with the help of NAM (Network Animator):

nam output.nam

  1. Enhancements and Extensions

When we have operating static routing simulation then we can improve it including below aspects:

  • Routing Table Configuration: Even though NS2 doesn’t support a built-in static routing protocol then we can set the routing table at each node as we need to replicate the static routes, which endure in the simulation. It is very helpful to replicate the real-world static routing in which each router contains a fixed routing table.
  • Traffic Generation: Execute various traffic sources such as TCP, UDP, and CBR for replicating diverse scenarios like file transfers or real-time applications.
  • Link Failure Simulation: Even though static routing doesn’t manage the link failure or topology modifications then we need to replicate the link failures and also we monitor how the system performs (e.g., by manually inactivating a link in the course of the simulation).

Example of link failure:

# Link failure (disable link between node 0 and node 1 at time 5.0)

$ns at 5.0 “$ns down $n0 $n1”

Since static routing doesn’t adjust to modify within the topology when the link flops then the traffic can’t attaining their destination if the simulation is adapted.

  1. References and Resources
  • NS2 Manual: It offers in-depth instruction in NS2 for network simulation with protocol set up.
  • Routing Protocols in NS2: Study, regarding the routing protocols and how they are executed using NS2 Routing Protocols Documentation within NS2.

Conclusion

To start a static routing project is comparatively straightforward using NS2. The key idea is setting up a fixed topology and predefined paths for traffic among the nodes including no dynamic route modernize. We replicate a network in which routes do not modify that is helpful for simpler network models or networks with static topology by manually specifying the links and connections.

If we need to prolong this static routing configuration, executing more complex aspects such as routing tables, performance analysis, or managing failure scenarios.

This guide will instruct you how to start and simulate the Static Routing Projects through above detailed procedure using NS2 environment. For further requirements, we will provide more insights in another simulation process.