How to Start WAN Protocols Projects Using NS2
To start Wide Area Network (WAN) protocol projects in NS2, we can replicate the long-distance networks including suitable routing protocols, traffic models, and link properties in terms of latency and bandwidth. Here’s a basic method to get started:
Steps to Start WAN Protocol Projects in NS2
- Set Up NS2 Environment
Make sure we have installed the NS2 and correctly functioning on the machine.
- Install NS2:
sudo apt-get update
sudo apt-get install ns2
- Verify Installation:
ns
We should see the NS2 command-line prompt (%) as it functional.
- Understand WAN Characteristics
Wide Area Networks (WANs) associate geographically remote nodes and its crucial features including:
- High Latency: Longer delays by reason of distance.
- Variable Bandwidth: Various connections may require distinct bandwidth capabilities.
- Packet Loss: Congestion and distance can be triggered by packet loss.
- Routing Protocols:
- RIP (Routing Information Protocol)
- MPLS for optimized WAN routing
- BGP (Border Gateway Protocol)
- OSPF (Open Shortest Path First)
- Write a Basic WAN Simulation TCL Script
Below is a simple script of WAN simulation using RIP routing and numerous nodes are linked by high-latency connections.
WAN TCL Script Example:
# Initialize NS2 simulator
set ns [new Simulator]
# Define output files
set nf [open wan-output.nam w]
$ns namtrace-all $nf
set tr [open wan-output.tr w]
$ns trace-all $tr
# Create Nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
# Define WAN Links with High Latency
$ns duplex-link $n0 $n1 10Mb 100ms DropTail
$ns duplex-link $n1 $n2 10Mb 200ms DropTail
$ns duplex-link $n2 $n3 10Mb 300ms DropTail
$ns duplex-link $n3 $n4 10Mb 150ms DropTail
# Enable Routing Protocol (RIP)
$ns rtproto RIP
# Attach Traffic Sources
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $n0 $udp
$ns attach-agent $n4 $null
$ns connect $udp $null
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 1000
$cbr set rate_ 5Mbps
# Schedule Traffic
$ns at 0.5 “$cbr start”
$ns at 4.5 “$cbr stop”
# Finish Simulation
$ns at 5.0 “finish”
proc finish {} {
global ns nf tr
$ns flush-trace
close $nf
close $tr
exec nam wan-output.nam &
exit 0
}
$ns run
- Run the Simulation
- We will need to store the script like wan_simulation.tcl.
- Execute it to follow the NS2 command:
ns wan_simulation.tcl
- Outputs:
- NAM File: It helps to envision the network animation.
- Trace File: Examine the performance parameters using trace file.
- Analyze the Simulation Results
- Examine primary simulation parameters to apply the trace file as wan-output.tr:
- Packet Delivery Ratio (PDR)
- Latency/End-to-End Delay
- Throughput
- Packet Loss Rate
Example AWK Script for Latency:
awk ‘{if ($1==”r” && $4==”tcp”) {end[$3]=$2} if ($1==”s” && $4==”tcp”) {start[$3]=$2}}
END {for (i in start) print “Packet:”, i, “Delay:”, end[i]-start[i]}’ wan-output.tr
- Enhance the Simulation
- Advanced Routing Protocols:
- For dynamic routing decisions in WAN to leverage the OSPF or BGP protocols.
- Example: Substitute RIP including OSPF using script:
$ns rtproto OSPF
- Traffic Variations:
- Integrate the traffic differences to TCP, FTP, or mixed traffic sources for real-world WAN circumstances.
- Instance for FTP over TCP:
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp start
- Link Failures:
- Launch link failures to experiment the resilience of protocol:
$ns rtmodel-at 2.0 down $n1 $n2
$ns rtmodel-at 3.0 up $n1 $n2
- Performance Comparison:
- We can equate the performance of protocols RIP, OSPF, and BGP for latency and throughput.
- Tools for Result Analysis
- We can utilise AWK scripts to analyse the trace files.
- NAM: Envision the topology and packet flow using NAM files.
- Graph Plotting: Analyse the performance parameters with the support of Python/Matplotlib or gnuplot:
- End-to-End Delay
- Throughput vs. Time
- Packet Delivery Ratio
Example Project Ideas:
- WAN Routing Protocol Performance Comparison: Equate the performance of routing protocol like RIP, OSPF, and BGP on large topologies.
- MPLS for WAN Traffic Optimization: Execute the MPLS within a WAN situation for label-based forwarding.
- QoS in WANs: We will replicate the quality of service for instance priority queues in diverse traffic types.
- Fault Tolerance in WANs: Replicate the link/node failures and then examine the retrieval time by leveraging dynamic routing protocols.
In this module, we had expounded the information through the simulation instruction for WAN Protocols Projects that were executed using NS2 environment. Additional details regarding this subject will also be provided.