How to Start Global Routing Projects Using NS2
To stimulate the Global Routing denotes the routing method used in the large-scale networks, in which the routers have a done to display for the network topology and can create the routing decisions according to the global knowledge such as in Link State Routing or OSPF). In Global Routing, the complete network topology is typically distributed through every router, to calculate the permits for optimize the available routes in all destinations.
In NS2, global routing can be replicated using protocols like OSPF (Open Shortest Path First) or through using the alter execution for the link-state routing. This will need to replicate the large-scale networks, in which all routers are modifying the full topology data and calculate routes according to the global network state.
Steps to Start a Global Routing Project in NS2
- Install NS2
Assure you have NS2 installed on your system:
- For Linux (Ubuntu/Debian-based):
sudo apt update
sudo apt install ns2
sudo apt install nam
- For Windows: We will require the virtual machine or Cygwin as NS2 is not natively helps for the Windows.
Validate the installation through processing:
ns
- Understand the Concept of Global Routing
Global Routing has includes the procedures in which the routers are handle in a complete vision for the network’s topology and make decisions according to this idea. In real-world networks, Link State Routing protocols like OSPF are general sample, in which the routers used a global network topology data we measure the shortest path to every other node.
In NS2, replicating a global routing can be complete using:
- Link-State Routing protocols like OSPF.
- Custom routing algorithms in which the routers can modify the full topological data and calculate the paths accordingly.
- Create the Network Topology
Designed for the Global Routing replicate, it starts for describing a network topology. A simple sample might be a network through 5-10 routers associated in different path, in which the every router has global information about the complete network.
- Choose or Implement a Global Routing Protocol
We can replicate the global routing in NS2 using the previous routing protocols such as OSPF or a link-state-based protocol.
Designed for the instance, in OSPF, every router has periodically transmits the LSA (Link-State Advertisements) to all other routers, distribute the data about its neighbours. Routers before recomputed the optimize path according to the complete topology.
Option 1: Use OSPF (Open Shortest Path First)
- OSPF is a global routing protocol in which every router distributes the local connection and defines the information by all other routers. This assigns the each router to build a similar global network vision and measure the minimum pathu using the Dijkstra’s algorithm.
If OSPF is accessible in your version of NS2, it can be directly used.
Option 2: Custom Link-State Routing Implementation
If OSPF isn’t accessible or you’d like we build alter a global routing protocol, we can apply the basic link-state protocol in which the nodes modification LSAs and calculate the routes according to the global state.
- Create the TCL Script for Global Routing
Here’s a sample TCL script replicating a Global Routing project using Link-State Routing in NS2. The script describes a simple network by several routers and uses a basic link-state routing protocol for global routing.
Example TCL Script: Global Routing Using Link-State Protocol
# Create the simulator object
set ns [new Simulator]
# Create nodes (routers) for the network (e.g., 5 nodes)
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
# 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
$ns duplex-link $n3 $n4 10Mb 10ms DropTail
$ns duplex-link $n0 $n4 10Mb 10ms DropTail
# Define the Link-State Routing Protocol
$ns node-config -routing-protocol OSPF
# Setup traffic flow (CBR from n0 to n4)
set udp1 [new Agent/UDP]
set sink1 [new Agent/Null]
$sink1 attach-agent $n4
$udp1 attach-agent $n0
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 512
$cbr1 set interval_ 0.1
$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 routing and packet flow
$ns trace-all “global_routing_output.tr”
$ns namtrace-all “global_routing_output.nam”
# Run the simulation
$ns run
- Explanation of the TCL Script
- Network Topology:
- The replication uses 5 nodes such as n0, n1, n2, n3, n4, and connection are introduce among the nodes by duplex-link. Every connection is set up by bandwidth for 10Mb and delay of 10ms.
- Routing Protocol:
- The -routing-protocol OSPF setting the OSPF (Open Shortest Path First) protocol, replicate that global routing. Every router has used a link-state database we calculate the minimum path to other routers.
- Traffic Flow:
- The CBR (Constant Bit Rate) congestion flow is setting from the node n0 such as source to node n4 like as destination. This replicates the constant UDP congestion over the network.
- Traces:
- Trace-all: Traces are gathered into the global_routing_output.tr file we track the routing and packet flow.
- namtrace-all: Generate a .nam file for visualizing the replication in NAM (Network Animator).
- Simulate and Analyze the Results
After you process the script, we can analyze the outcomes using NAM and trace files.
- NAM Visualization: Process the NAM tool for envision the animation:
nam global_routing_output.nam
This will display the network topology on how the packets flow based on global routing decisions complete through OSPF.
- Trace File Analysis: Used the suggest file such as global_routing_output.tr we examine the routing decisions create during the replication. We can use the tools such as awk to extract related data:
awk ‘{print $1, $2, $3, $4, $5}’ global_routing_output.tr
This will help you understand how the OSPF protocol is creation of routing decisions on how the traffic is routed according to the global network topology.
- Extending the Global Routing Project
We can improve your global routing project in multiple paths:
- Multiple Traffic Flows:
- Increase for several traffic flows among multiple pairs of source and destination nodes we examine on how OSPF routes congestion when different paths are available.
- Dynamic Changes in the Network:
- Replicate the connection failure, node crashes, or congestion and view on how OSPF bring up-to-date its routing tables to accommodate this variation. This would need to apply the link-state advertisements (LSAs) and making nodes re-compute their minimum path when the topology are changed.
- Real-World Protocols:
- Encompass the project through using a more realistic execution of OSPF or another global routing protocol. NS2 has helps for OSPF and other protocols; nevertheless we may require extending or modifying the previous execution to ensemble you’re necessary.
- Mobility:
- Designed for mobile networks, replicate the MANETs (Mobile Ad hoc Networks) in which the nodes are mobile, and the global topology continuously vary. This can be accomplished through using the Mobile Ad hoc Network (MANET) and altering the global routing protocol we put up the mobility.
- Advanced Routing Metrics:
- In its place of using the just hop count as a metric; consider using delay, link quality, or bandwidth as section of the routing decision we replicate the further sophisticated global routing.
- Visualize Routing Updates:
- Used a further advanced visual tool we track on how LSAs are spread through the network, view the modification in routing tables as their network topology evolves.
In this manual, we entirely understood the concept of Global Routing that were executed in ns2 simulation that has generate the topology and then establish the routing decision to mimic and then run the execution to analyse the outcome. You can also consider the future enhancement features to accomplish it as per your requirements.