How to Simulate WAN Protocols Projects Using NS2

To simulate Wide Area Network (WAN) protocols using NS2, we will usually concentrate on replicating networks that uncover large geographic areas, like those including multiple nodes spread via diverse regions. WAN protocols handle routing, congestion control, and communication effectiveness over long distances. Some of the protocols need to replicate that have TCP/IP, MPLS, and other protocols intended for WAN efficiency.

Here’s a step-by-step guide to help you simulate WAN protocols using NS2:

Steps to Simulate WAN Protocols Projects in NS2

  1. Install NS2

Make sure that we have NS2 installed.

  1. Define a Wide Area Network Topology

WAN networks usually contain multiple subnets, long-distance links, and high delay among nodes. Here’s how we can configure a simple WAN topology:

Example TCL Script for WAN Topology:

# Create a new simulator instance

set ns [new Simulator]

# Define trace and nam files for logging and visualization

set tracefile [open wan_simulation.tr w]

$ns trace-all $tracefile

set namfile [open wan_simulation.nam w]

$ns namtrace-all $namfile

# Create WAN nodes

set n0 [$ns node]  ;# Node 0 in region 1

set n1 [$ns node]  ;# Node 1 in region 1

set n2 [$ns node]  ;# Node 2 in region 2

set n3 [$ns node]  ;# Node 3 in region 2

set n4 [$ns node]  ;# Node 4 in region 3

# Create links within regions (shorter delays)

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

$ns duplex-link $n2 $n3 10Mb 10ms DropTail

# Create links between regions (WAN links with higher delay)

$ns duplex-link $n1 $n2 1Mb 100ms DropTail  ;# Between region 1 and 2

$ns duplex-link $n3 $n4 1Mb 150ms DropTail  ;# Between region 2 and 3

In this topology:

  • n0 and n1 are in the same region.
  • n2 and n3 are in another region, and the connection among the regions has higher delay.
  • n4 is in a different region entirely, associated through WAN links.
  1. Configure Routing Protocols

WANs usually depend on standard routing protocols such as RIP, OSPF, or BGP (if available). For simplicity, we need to utilize Static routing or RIP in NS2.

Example for Static Routing:

# Enable hierarchical routing

$ns rtproto Static

# Define routing for nodes (static routes for WAN)

$n0 add-route $n4 via $n1

$n1 add-route $n4 via $n2

$n2 add-route $n0 via $n1

$n3 add-route $n0 via $n2

  1. Set up WAN Traffic

WANs usually manage numerous kinds of traffic that involves TCP and UDP. Here’s how to configure both traffic types.

Example for TCP Traffic:

# Create TCP connection from node 0 to node 4

set tcp0 [new Agent/TCP]

set sink0 [new Agent/TCPSink]

$ns attach-agent $n0 $tcp0

$ns attach-agent $n4 $sink0

$ns connect $tcp0 $sink0

# Create FTP application over TCP

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

$ns at 2.0 “$ftp0 start”

$ns at 10.0 “$ftp0 stop”

Example for UDP Traffic:

# Create UDP communication from node 1 to node 3

set udp0 [new Agent/UDP]

set null0 [new Agent/Null]

$ns attach-agent $n1 $udp0

$ns attach-agent $n3 $null0

$ns connect $udp0 $null0

# Create CBR traffic over UDP

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set interval_ 0.1

$cbr0 attach-agent $udp0

$ns at 3.0 “$cbr0 start”

$ns at 12.0 “$cbr0 stop”

  1. Simulate WAN Congestion

WAN links can easily get congested because of limited bandwidth and long latency. To replicate WAN congestion, we can configure multiple traffic flows to pass via the same WAN links.

# Create additional traffic for congestion

set tcp1 [new Agent/TCP]

set sink1 [new Agent/TCPSink]

$ns attach-agent $n0 $tcp1

$ns attach-agent $n4 $sink1

$ns connect $tcp1 $sink1

# Generate FTP traffic for the second connection

set ftp1 [new Application/FTP]

$ftp1 attach-agent $tcp1

$ns at 4.0 “$ftp1 start”

$ns at 10.0 “$ftp1 stop”

By generating traffic that competes for the WAN link, we need to replicate congestion and observe how it impact throughput, delay, and packet loss.

  1. Run the Simulation

After configuring the WAN topology and traffic, save TCL script (e.g., wan_simulation.tcl) and execute it:

ns wan_simulation.tcl

  1. Analyse the Results

We need to evaluate the performance of WAN simulation by using the trace file (.tr). Important key metrics to measure that include:

  • Throughput: How much data is being successfully routed over the WAN?
  • End-to-End Delay: The total time it takes for packets to travel from the source to the destination via WAN links.
  • Packet Loss: How many packets are dropped because of congestion on the WAN links?

Example AWK Script to Calculate Throughput:

BEGIN { recvBytes = 0; startTime = 0; endTime = 0; }

{

if ($1 == “r” && $4 == “AGT”) {

recvBytes += $7;

if (startTime == 0) startTime = $2;

endTime = $2;

}

}

END { throughput = (recvBytes * 8) / (endTime – startTime) / 1024; print “Throughput = “, throughput, “Kbps”; }

  1. Simulating WAN-Specific Protocols

Some protocols intended for WAN efficiency that involves:

  • MPLS (Multiprotocol Label Switching): Implement MPLS can enhance packet forwarding in WANs.
  • TCP Variants: we replicate different TCP congestion control mechanisms like TCP Reno, TCP Vegas and see how they act as in WAN environment.
  1. Example WAN Project Ideas
  1. Comparison of TCP Variants in WAN:
    • mimic different TCP variants such as TCP Reno, TCP Tahoe and relate their performance (throughput, delay) in a WAN environment with high latency.
  2. Impact of Congestion on WAN Traffic:
    • Replicate heavy traffic on WAN links and measure on how congestion impacts packet delivery, latency, and throughput.
  3. WAN Traffic Engineering Using MPLS:
    • Replicate MPLS-based routing in a WAN and relate its efficiency against traditional IP routing based on delay and resource utilization.
  4. WAN Performance Under Link Failures:
    • Replicate a WAN in which certain links fail, and learn on how different routing protocols manage rerouting and recovery.

From the demonstration, we illustrate the complete simulation setup that will help you to execute and simulate the Wide Area Network using ns2 tool and also we provide the procedures, example snippets and their explanation. If you need to know more details regarding this process we will provide it. Stay connected with us for top-notch results in your WAN Protocols Projects!

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2