How to Start Non Adaptive Routing Projects Using NS2
The Non-Adaptive Routing denotes the routing protocols that do not alter their routes according to the real-time network environments such as link failures, congestion, etc. These protocols are typically used the fixed routing tables or pre-determined routes which are not updated dynamically during the network operation.
Steps to Start Non Adaptive Routing Projects Using NS2
Examples of non-adaptive routing protocols include:
- Static Routing: Where the routes are static and do not modify, regardless for the network environments.
- Distance Vector Routing: In which the routers periodically modify the routing data, nevertheless after the routing tables are configure, they don’t adjust the variations unless for explicitly triggered.
In NS2, we can replicate the non-adaptive routing through either apply a custom static routing protocol or using previous protocols that do not adjust routes dynamically such as Distance Vector Routing.
Steps to Start a Non-Adaptive Routing Project in NS2
- Install NS2
Enable which NS2 is installed on your system:
- For Linux (Ubuntu/Debian-based):
sudo apt update
sudo apt install ns2
sudo apt install nam
- For Windows: We may essential to use a virtual machine or Cygwin, as NS2 is not natively helps for the Windows.
We validate the installation:
ns
- Understand Non-Adaptive Routing
In non-adaptive routing, routers do not adapt their routes according to the variation in the network. General features are non-adaptive routing protocols they are:
- Static Routing: The routes are manually setting and do not change during the operation.
- Distance Vector Routing: In this technique, routers direct periodic bring up-to-date to their neighbours by their distance information, nevertheless they do not response to real-time conditions for sample changes in link quality or failures.
- Create the Network Topology
In non-adaptive routing, the network topology remains fixed and does not change the dynamically. We require to describe a simple static network topology in which routing decisions are pre-configured and do not adapt to variations.
For sample, in a static routing environment, routes among the source and destination nodes are manually stated.
- Choose a Non-Adaptive Routing Protocol
There are two main methods to apply the non-adaptive routing in NS2:
- Static Routing:
- Routes are predefined and do not alter during the replication.
- Used the staticRouting setting or manually state the way for packet delivery.
- Distance Vector Routing (with no real-time adaptations):
- Nodes are used in the distance vector tables we sending the packets. These tables are updated periodically according to the routing advertisements; nevertheless there is no instantaneous adaptation for connection failure or congestion.
- Create the TCL Script for Non-Adaptive Routing
Let’s look at a sample on how to replicate the non-adaptive routing using static routing in NS2.
Example TCL Script: Non-Adaptive Static Routing
This sample will replicate the static routing environment in which the routes are predefined among the nodes.
# Create a simulator object
set ns [new Simulator]
# Create nodes (routers) for the network
set n0 [$ns node] ;# Source
set n1 [$ns node] ;# Intermediate node 1
set n2 [$ns node] ;# Intermediate node 2
set n3 [$ns node] ;# Destination
# Create links between the nodes (Router links)
$ns duplex-link $n0 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n2 10Mb 10ms DropTail
$ns duplex-link $n2 $n3 10Mb 10ms DropTail
# Manually define static routes between the source and destination
# Static routing (source n0 to destination n3 via n1 and n2)
$ns route $n0 $n3 10 ;# Route from n0 to n3 (using nodes n1 and n2)
$ns route $n1 $n3 10 ;# Route from n1 to n3 (direct route)
$ns route $n2 $n3 10 ;# Route from n2 to n3 (direct route)
# Setup traffic flow (CBR from n0 to n3)
set udp1 [new Agent/UDP]
set sink1 [new Agent/Null]
$sink1 attach-agent $n3
$udp1 attach-agent $n0
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 512
$cbr1 set interval_ 0.1 ;# Set rate for CBR traffic
$cbr1 attach-agent $n0
$ns connect $udp1 $sink1
# Set traffic start and stop times
$ns at 1.0 “$cbr1 start”
$ns at 5.0 “$cbr1 stop”
# Enable trace output to monitor the packet flow
$ns trace-all “non_adaptive_output.tr”
$ns namtrace-all “non_adaptive_output.nam”
# Run the simulation
$ns run
- Explanation of the TCL Script
- Network Topology:
- The network contains for four nodes such as n0, n1, n2, n3, where n0 is the source and n3 is the destination.
- The nodes are connected through duplex connection having a bandwidth for 10Mb and a delay of 10ms.
- Static Routing:
- The fixed routing set up describes the routes among the nodes.
- The route is manually setting using the $ns route direct the congestion from n0 to n3 via nodes n1 and n2.
- This route are static and do not modify during the replication.
- Traffic Flow:
- A CBR (Constant Bit Rate) congestion flow is starts from n0 to n3 we replicate a simultaneous for the data stream.
- The congestion flow is setting by a packet size of 512 bytes and an interval of 0.1 seconds.
- Trace and NAM:
- trace-all: Traces packet action for the network and save the outcomes in a non_adaptive_output.tr file.
- namtrace-all: Generates the animation file such as non_adaptive_output.nam to envision for the replication.
- Simulate and Analyze the Results
After running the simulation, you can analyze the output using NAM and trace files.
- NAM Visualization: Process for the NAM tool to show the replication and follow on how the traffic flows along the pre-configured static routes:
nam non_adaptive_output.nam
The NAM animation will view the nodes and connection, and we can follow the packet actions according to the static routing paths.
- Trace File Analysis: Used the trace file such as non_adaptive_output.tr to examine the packet transmission. We can use awk or other tools to examine the trace data:
awk ‘{print $1, $2, $3, $4}’ non_adaptive_output.tr
This will offers the insights of packet flow, involves the routing decisions such as although static, the packet will follow the manually configured path.
- Extending the Non-Adaptive Routing Project
We can improve this project through adding further features, such as:
- Distance Vector Routing:
- Apply Distance Vector Routing techniques which does not adjust the network variations in real-time. The nodes will be periodically modify their routing tables nevertheless would not be response for the connection failures or traffic.
- Multiple Traffic Flows:
- Enhance the several congestion flows among alter the source-destination pairs to view on how the static routes has maintain the different instantaneous flows.
- Failure Simulation:
- Replicate the link failures or node crashes, nevertheless the routing is non-adaptive, the network will not bring up-to-date its routing tables are dynamically. We can follow for the significances of the loss of adaptation.
- Static vs. Dynamic Comparison:
- Associate the non-adaptive routing with adaptive routing protocols through build a same replication using protocols such as Dijkstra or OSPF. This will be support we recognize the advantages and disadvantages of non-adaptive routing.
- Performance Metrics:
- Calculate the end-to-end delay, throughput, and packet loss in a non-adaptive routing environment, and associate this parameter metrics through adaptive routing protocols.
Finally, we all discussed and get knowledge about Non-Adaptive Routing in ns2 environment and also we support all kinds of Non-Adaptive Routing environment.