How to Implement Metropolitan Area Networks in ns2

To implement the Metropolitan Area Network (MAN) in ns2 (Network Simulator 2), we have to simulate a network that extents a large geographic area, usually a city or large campus. These networks mainly integrate several Local Area Networks (LANs) using high-speed backbone links. The intent of the simulation might be to evaluate the performance of various routing protocols, network topologies or data traffic patterns inside the MAN.

In the following below, we delivered the procedure to implement MAN using ns2:

Step-by-Step Implementation:

Conceptual Overview

In a Metropolitan Area Network:

  1. Core Nodes (Backbone Routers): These are high-speed routers that form the backbone of the MAN, incorporating different sub-networks.
  2. Access Nodes: These nodes indicate LANs or other local networks linked to the MAN through the core nodes.
  3. Communication Links: High-speed links (like fiber optic) connect the core nodes, as they access nodes connect to core nodes across relatively slower links.

Step 1: Conceptualize the MAN Simulation

In this simulation, we will generate a situation in which numerous access nodes (indicating LANs) are linked over core nodes (denoting backbone routers). Traffic will be directed via these nodes and can evaluate how various traffic patterns or routing protocols influence the network’s performance.

Step 2: Create the Tcl Script

Below, we generate a sample Tcl script that simulates a basic Metropolitan Area Network in ns2.

Example Tcl Script for Simulating a MAN in ns2

# Create a simulator object

set ns [new Simulator]

# Define the topography object (for a large area)

set topo [new Topography]

$topo load_flatgrid 3000 3000  # 3km x 3km area

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

create-god 9  # Number of nodes (6 access nodes + 3 core nodes)

# Configure the nodes for the MAN 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 man_out.tr w]

$ns trace-all $tracefile

set namfile [open man_out.nam w]

$ns namtrace-all-wireless $namfile 3000 3000

# 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 man_out.nam &

exit 0

}

# Create core nodes (backbone routers)

set core1 [$ns node]

set core2 [$ns node]

set core3 [$ns node]

# Create access nodes (representing LANs or local networks)

set access1 [$ns node]

set access2 [$ns node]

set access3 [$ns node]

set access4 [$ns node]

set access5 [$ns node]

set access6 [$ns node]

# Set initial positions for core and access nodes

$core1 set X_ 1000.0

$core1 set Y_ 1500.0

$core2 set X_ 1500.0

$core2 set Y_ 1500.0

$core3 set X_ 2000.0

$core3 set Y_ 1500.0

$access1 set X_ 500.0

$access1 set Y_ 1000.0

$access2 set X_ 1500.0

$access2 set Y_ 1000.0

$access3 set X_ 2500.0

$access3 set Y_ 1000.0

$access4 set X_ 500.0

$access4 set Y_ 2000.0

$access5 set X_ 1500.0

$access5 set Y_ 2000.0

$access6 set X_ 2500.0

$access6 set Y_ 2000.0

# Create links between core nodes (high-speed backbone links)

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

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

# Create links between access nodes and core nodes (relatively slower links)

$ns duplex-link $access1 $core1 10Mb 20ms DropTail

$ns duplex-link $access2 $core1 10Mb 20ms DropTail

$ns duplex-link $access3 $core3 10Mb 20ms DropTail

$ns duplex-link $access4 $core1 10Mb 20ms DropTail

$ns duplex-link $access5 $core2 10Mb 20ms DropTail

$ns duplex-link $access6 $core3 10Mb 20ms DropTail

# Define a custom procedure for simulating data transmission between access 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 access nodes

$ns at 1.0 “send_data $access1 $access6 1024 100Kb”

$ns at 2.0 “send_data $access2 $access4 1024 100Kb”

$ns at 3.0 “send_data $access3 $access5 1024 100Kb”

# Schedule the end of the simulation

$ns at 20.0 “finish”

# Run the simulation

$ns run

Step 3: Run the Tcl Script

Save the script with a .tcl extension, for instance, man_simulation.tcl. Then, use the below command in your terminal to execute the script:

ns man_simulation.tcl

Step 4: Visualize the Simulation

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

nam man_out.nam

Script Explanation

  • Core Nodes: The nodes core1, core2, and core3 indicate the backbone routers that form the core of the MAN. These nodes are interrelated using high-speed links.
  • Access Nodes: The nodes access1 to access6 denote various LANs or local networks connected to the MAN. These nodes are linked to the core nodes through relatively slower links.
  • Data Transmission: The send_data process replicates data transfers amongst access nodes using TCP that is frequent in MANs for consistent data transfer.
  • Traffic Generation: The FTP application recreates file transfers, signifying typical data communication in a MAN.

Customization

  • Routing Protocols: Test with various routing protocols like OSPF (if backs) or execute custom routing to see how they impact the performance of the MAN.
  • Varying Link Capacities: Replicate the various network conditions include jamming or high-latency environments by altering the bandwidth and delay of the links.
  • Mobility: Execute mobility models if simulating environment where some access nodes or users travel inside the MAN.
  • Multiple Data Centers: Simulate multiple data centers into the MAN by attaching more core nodes and connections to indicate various network parts.

Limitations

  • Simplified MAN Model:  It offers a simple model of a MAN and does not responsible for the full involvedness of realistic MAN situations like multi-homing, redundancy, or advanced QoS mechanisms.
  • No Physical Layer Simulation: The script does not replicate the physical layer characteristics certain to MANs involves fiber optic properties or signal degradation over long distances.
  • Limited Protocol Support: ns2 is not configured for earlier MAN protocols, so the simulation is restricted to fairly precise the MAN interactions using available network models.

Through this procedure, you can completely learned the concepts and the connection of core nodes, access nodes and communication links which are required to accomplish the MAN with the help of Network Simulator 2 (ns2). If needed, we will present any details regarding these networks or ns2 simulation process. If you are interested in implementing Metropolitan Area Networks using the ns2 tool, please feel free to contact us. We are available to provide support with a variety of topics and ideas. Additionally, we offer assistance to researchers in conducting performance analysis.