BCA / B.Tech 16 min read

Routing Protocol Support of NS2

Routing Protocol Support of NS2 in Hindi | Routing Protocol Support in NS2 in Hindi:


  • NS2 is a powerful tool for networking research and simulation with its extensive support for routing protocols. From static routing to dynamic and on-demand routing, NS2 is capable of accurately simulating the complex functions of routing in various networking environments.
  • By simulating these protocols, researchers can test various routing strategies, which can prove to be extremely important for real-world networks.
  • NS2 (Network Simulator 2) is an extremely useful network simulator that is used to simulate various types of network protocols. Support for routing protocols is particularly important in it,
  • because these protocols determine the path of data packets in the network. Routing protocols decide which path (route) is most suitable for sending packets from the source to the destination.

In this article, we will discuss in detail the routing protocol support in NS2, various types of routing protocols, and the simulation process.

1. Introduction to Routing Protocols

Routing protocols are responsible for sending data packets between different nodes of a network. The main function of routing protocols is to select the best path for the packets. Routing can be of two types:

  • Static Routing: In this, the routes are predetermined and these routes do not change when there is any change in the network.
  • Dynamic Routing: In this, the routes change automatically according to the condition of the network. Routing protocols are used between nodes so that the best path can be chosen according to different situations in the network.
  • A wide range of routing protocols are available in NS2, which can be used for different types of networks (both wired and wireless).

2. Types of Routing Protocols

The commonly used routing protocols in NS2 are as follows:

a. Static Routing

This is a simple type of routing protocol, in which the routes between the nodes of the network are predetermined and they remain stable. In this, the routes do not change based on the conditions of the network.

b. Dynamic Routing

In dynamic routing protocols, the nodes themselves determine the routes based on the conditions of the network. There are many protocols under dynamic routing, some of the main ones are:

i. Distance Vector (DV) Routing Protocol

  • In this protocol, each node sends the "distance" of its network to its neighboring nodes. Based on this information, the nodes decide which route is the shortest and most suitable. Example:

RIP (Routing Information Protocol): This is one of the simplest distance vector protocols, which determines the distance between nodes.

ii. Link-State Routing Protocol

  • In link-state routing, nodes try to know the entire state of the network (the state of the links). This routing protocol is more complex, but it provides a better understanding of the network.

Example:

OSPF (Open Shortest Path First): This is a popular link-state protocol that gives each node in the network the lowest cost path to reach other nodes.

iii. Ad-Hoc Routing Protocols

These protocols are specially used for wireless networks and mobile networks, where nodes are constantly changing their position. Some of the main ad-hoc routing protocols are as follows:

  • AODV (Ad-Hoc On-Demand Distance Vector): This is an on-demand protocol, in which a route is searched for only when a node feels the need to send data.
  • DSDV (Destination-Sequenced Distance-Vector): This is a protocol based on distance vector, which is used for dynamic routing.
  • DSR (Dynamic Source Routing): This is a source-routing protocol, in which the routing decision is made by the sending node.

3. Setup of Routing Protocols in NS2

Setting up routing protocols in NS2 is easy. For each protocol, you need to select the correct protocol after setting up the network topology (nodes, links). Let's see how to set it up:

a. Example of Static Routing

# Creation of simulator object
set ns [new Simulator]

# Trace file for tracing
set tracefile [open out.tr w]
$ns trace-all $tracefile

# Creation of nodes
set node1 [$ns node]
set node2 [$ns node]

# Creating a link between nodes
$ns duplex-link $node1 $node2 1Mb 10ms DropTail

# Setting a static route
$node1 add-route-to-node $node2 1
$node2 add-route-to-node $node1 1

# Running the simulation
$ns run
In this example, we have established a fixed path between the nodes for static routing.

b. Example of AODV (On-demand routing)

AODV is a popular dynamic routing protocol that is used for on-demand routing. The following commands can be used to set it up in NS2:

# Setting up the AODV protocol
Agent/DSDV set routingAgent_ true

# Creation of simulation object
set ns [new Simulator]

# Creation of nodes
set node1 [$ns node]
set node2 [$ns node]

# Creating a link between nodes
$ns duplex-link $node1 $node2 1Mb 10ms DropTail

# Creating and attaching traffic
set tcp [new Agent/TCP]
set sink [new Agent/TCPSink]
$ns attach-agent $node1 $tcp
$ns attach-agent $node2 $sink
$ns connect $tcp $sink

# Running the simulation
$ns run
In this example, we have set up the AODV routing protocol, which is activated when the nodes start sending data.


4. Observation of the functioning of routing protocols

  • To observe the functioning of routing protocols, you can use a trace file, which contains information about each routing decision, sending and receiving of packets. You can also see a graphical animation of the simulation using NAM (Network Animator), which clearly shows the routing and transfer of packets between the nodes.

nam out.nam

5. Advantages and Challenges of Routing Protocols

Advantages of Routing Protocols in Hindi | Advantages:

  • Dynamic Routing protocols automatically update the route according to the changing conditions of the network.
  • On-demand protocols (like AODV) save energy and bandwidth because they set a route only when data needs to be sent.
  • Link-state protocols like OSPF are capable of determining accurate and minimum latency paths for all nodes in the network.

Objectives of Routing Protocols in Hindi | Challenges:

  • Dynamic routing requires more resources because the routes have to be constantly updated.
  • Routing becomes more complex in mobile networks due to the constantly changing position of the nodes.
  • In case of a link failure, routing protocols should have the ability to find a quick and accurate route.

In this Chapter

Routing Protocol Support of NS2
Auto-Configuration and Anycast
Modified EUI-64 | What is Modified EUI-64?
Architecture of Mobile Computing
Wireless LAN in Hindi | What is Wireless LAN?
Wireless User Devices
MAC Protocol | What is MAC Protocol?
IEEE 802.11 | What is IEEE 802.11
Mobile IP | What is Mobile IP
Wireless TCP/IP
Unicast & Multicast Communication
Bluetooth | What is Bluetooth?
NS2 & NAM | What are NS2 and NAM?
Purpose & installation of NS2 & NAM
Background of NS2 & NAM
Architecture of NS2 & NAM
Interface of OTcl & C++
Trace Files & Formats
Protocol Support of NS2
Simulation Object of NS2 & NAM
Basic Syntax of NS2 & NAM
Node Creation of NS2 & NAM
Running NS2 & NAM
Finish Procedure NS2 & NAM
Invoking external commands within NS2
Nodes & Agents of NS2 & NAM
NS2 Commands
Creating Links in Wired Network
Setting Link Parameters
Sending Traffics Through NS2 Links
Scenarios in Wired Networks
Additional Parameters
Setting node positions
God object & topography
Protocol Support
Scenarios in Wireless Networks
What is the Internet? Difference Between Intranet and Extranet
Types of Internet
OSI Model and its Layers
Computer Network (CN) All Important Questions and Answers in English (MDSU)
BCA | Computer Network | 2025 Paper | MDSU Exam Paper
Importance of the Layer Model in Computer Networks
Network Classification
Network Topology
Network Switching & Components
Ethernet
Token Ring
Basic Networking Concepts & Cabling
What is a Computer in English?
Bridges in Computer Networks
Routers in Computer Networks
Gateways in Computer Networks
Public & Private Networks
FDMA (Frequency Division Multiple Access)
BCA | CN(Computer Network) Paper | 2023 MDSU Exam Paper
What is World Wide Web (WWW)
TDMA, SDMA, CDMA
Personal Communication System | What is PCS
IPv4 | What is IPv4?
Subnetting IPv4 Address
Casting in IPv4
Private IPv4 Addressing
IPv4 Address Scheme
IPv6 Addressing Scheme
Types of IPv6 Addressing