How to Implement Wide Area Networks in ns2

To implement a Wide Area Network (WAN) in ns2 (Network Simulator 2) has needs to encompass to emulate a network that spans a large geographic area, usually associating multiple smaller networks like Local Area Networks or Metropolitan Area Networks. A WAN usually uses the numerous networking technologies and protocols to associate nodes that are physically distant from each other. The given below is the overview to implement the wide area network using ns2:

Step-by-Step Implementation:

Conceptual Overview

In a Wide Area Network:

  1. Core Nodes (Routers/Switches): These nodes form the backbone of the WAN, associating numerous subnetworks or other WAN segments.
  2. Edge Nodes (Gateways): These nodes denote the entry points to the WAN from smaller networks such as LANs or MANs.
  3. Communication Links: These links interconnect the core and edge nodes that usually using long-distance interaction technologies such as leased lines, MPLS, or satellite links.

Step 1: Conceptualize the WAN Simulation

In this simulation, we will generate a scenario in which the multiple edge networks (representing LANs or MANs) are interconnected via core nodes, which form the WAN backbone. Traffic will be transmitted via these nodes, and we can evaluate on how numerous routing protocols or traffic patterns effects the network’s performance.

Step 2: Create the Tcl Script

The given below are the sample Tcl script that emulates a basic Wide Area Network in ns2.

Example Tcl Script for Simulating a WAN in ns2

# Create a simulator object

set ns [new Simulator]

# Define the topography object (for a very large area)

set topo [new Topography]

$topo load_flatgrid 5000 5000  # 5km x 5km area

# Create the General Operations Director (GOD) for the WAN simulation

create-god 10  # Number of nodes (6 edge nodes + 4 core nodes)

# Configure the nodes for the WAN using static routing

$ns node-config -llType LL \

-macType Mac/802_3 \

-ifqType Queue/DropTail/PriQueue \

-ifqLen 50 \

-antType Antenna/OmniAntenna \

-propType Propagation/FreeSpace \

-phyType Phy/WirelessPhy \

-channelType Channel/WirelessChannel \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace ON \

-movementTrace OFF

# Open trace and NAM files for recording the simulation

set tracefile [open wan_out.tr w]

$ns trace-all $tracefile

set namfile [open wan_out.nam w]

$ns namtrace-all-wireless $namfile 5000 5000

# Define a finish procedure to close files and end the simulation

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam wan_out.nam &

exit 0

}

# Create core nodes (WAN backbone routers)

set core1 [$ns node]

set core2 [$ns node]

set core3 [$ns node]

set core4 [$ns node]

# Create edge nodes (representing LANs or local networks connected to the WAN)

set edge1 [$ns node]

set edge2 [$ns node]

set edge3 [$ns node]

set edge4 [$ns node]

set edge5 [$ns node]

set edge6 [$ns node]

# Set initial positions for core and edge nodes

$core1 set X_ 1500.0

$core1 set Y_ 2500.0

$core2 set X_ 2500.0

$core2 set Y_ 2500.0

$core3 set X_ 3500.0

$core3 set Y_ 2500.0

$core4 set X_ 4500.0

$core4 set Y_ 2500.0

$edge1 set X_ 1000.0

$edge1 set Y_ 1000.0

$edge2 set X_ 2000.0

$edge2 set Y_ 1000.0

$edge3 set X_ 3000.0

$edge3 set Y_ 1000.0

$edge4 set X_ 4000.0

$edge4 set Y_ 1000.0

$edge5 set X_ 1000.0

$edge5 set Y_ 4000.0

$edge6 set X_ 4000.0

$edge6 set Y_ 4000.0

# Create high-speed backbone links between core nodes

$ns duplex-link $core1 $core2 100Mb 20ms DropTail

$ns duplex-link $core2 $core3 100Mb 20ms DropTail

$ns duplex-link $core3 $core4 100Mb 20ms DropTail

# Create links between edge nodes and core nodes (lower speed links)

$ns duplex-link $edge1 $core1 10Mb 50ms DropTail

$ns duplex-link $edge2 $core2 10Mb 50ms DropTail

$ns duplex-link $edge3 $core3 10Mb 50ms DropTail

$ns duplex-link $edge4 $core4 10Mb 50ms DropTail

$ns duplex-link $edge5 $core1 10Mb 50ms DropTail

$ns duplex-link $edge6 $core4 10Mb 50ms DropTail

# Define a custom procedure for simulating data transmission between edge nodes

proc send_data {src dst packetSize rate} {

global ns

# Create a TCP agent to simulate data traffic

set tcp [new Agent/TCP]

$ns attach-agent $src $tcp

set sink [new Agent/TCPSink]

$ns attach-agent $dst $sink

$ns connect $tcp $sink

# Generate traffic using an FTP application

set ftp [new Application/FTP]

$ftp attach-agent $tcp

$ftp start

}

# Simulate data transmission between various edge nodes

$ns at 1.0 “send_data $edge1 $edge6 1024 100Kb”

$ns at 2.0 “send_data $edge2 $edge5 1024 100Kb”

$ns at 3.0 “send_data $edge3 $edge4 1024 100Kb”

# Schedule the end of the simulation

$ns at 30.0 “finish”

# Run the simulation

$ns run

Step 3: Run the Tcl Script

Save the script with a .tcl extension, for instance, wan_simulation.tcl. In the terminal execute the following command.

ns wan_simulation.tcl

Step 4: Visualize the Simulation

To visualize the simulation, open the generated NAM file using:

nam wan_out.nam

Script Explanation

  • Core Nodes: The nodes core1, core2, core3, and core4 denote the WAN backbone routers that interconnect numerous edge networks. These nodes are interconnected by high-speed links.
  • Edge Nodes: The nodes edge1 to edge6 denotes numerous LANs or local networks that interconnected to the WAN. These nodes are associated to the core nodes through lower-speed links.
  • Data Transmission: The send_data procedure emulates the data transmission among the edge nodes using TCP, which is common in WANs for reliable data transfer.
  • Traffic Generation: The FTP application emulates the file transfers that denote the common data communication in a WAN.

Customization

  • Different Routing Protocols: Test with numerous routing protocols such as OSPF or BGP to see how they impact the performance of the WAN.
  • Varying Link Capacities: Adapts the bandwidth and latency of the links to emulate the numerous network conditions like congestion, high-latency environments, or changing link qualities.
  • Mobility: Execute mobility models that emulate the scenarios in which the some edge nodes or users are mobile within the WAN.
  • Security: Add security mechanisms like firewalls or encryption, to mimic secure WAN environments.

Limitations

  • Simplified WAN Model: This script delivers a basic design of a WAN and does not account for the full complexity of real-world WAN environments, like multi-homing, redundancy, or advanced QoS mechanisms.
  • No Physical Layer Simulation: The script does not emulate the physical layer features that particulars to WANs, like fiber optic properties, satellite communication delays, or signal degradation over long distances.
  • Limited Protocol Support: ns2 is not intended for modern WAN protocols, so the emulation is limited to similar to WAN interactions using existing network models.

In this simulation, we clearly show the overview of implementing procedures for wide area network that were executed using the tool of ns2. We plan to elaborate more information regarding the wide area network.

Our team ns2projects.com specializes in Wide Area Network project ideas that are perfectly tailored to your needs. If you’re looking to enhance your network performance, share your details with us, and we’ll deliver outstanding results along with a comprehensive analysis.