How to Implement DWDM Fiber Network in NS2

To implement the Dense Wavelength Division Multiplexing (DWDM) is an optical multiplexing technology that used to maximise bandwidth over existing fiber networks by combining numerous optical carrier signals on a single optical fiber using various wavelengths (colors) of laser light. In the simulation platform NS2, we can replicate a DWDM fiber network by set up numerous wavelength channels for communication that each channel corresponds to a distinct optical path. While NS2 doesn’t directly support DWDM, we can show it by replicating various high-speed optical links among the nodes to signify the DWDM channels. Here is a simplified guide to execute it using NS2:

Steps to Implement DWDM Fiber Network in NS2:

  1. Set up the Simulation Environment

Initially, make the fiber network nodes, which denote the DWDM system. The nodes can contain optical transmitters and receivers, and the links among these nodes will signify the DWDM optical fiber links with numerous channels.

Example TCL Script for Basic Setup:

# Create a simulator instance

set ns [new Simulator]

# Define optical link parameters

set bw_channel 10Gb         ;# Bandwidth for each DWDM channel (e.g., 10 Gbps)

set delay_fiber 5ms         ;# Delay for optical fiber communication (typical delay for fiber networks)

# Create network nodes (representing optical transmitters and receivers)

set node1 [$ns node]

set node2 [$ns node]

set node3 [$ns node]

set node4 [$ns node]

# Create DWDM channels (representing multiple optical channels on the fiber)

# Each channel is a separate duplex link between the same nodes

$ns duplex-link $node1 $node2 $bw_channel $delay_fiber DropTail  ;# Channel 1

$ns duplex-link $node1 $node2 $bw_channel $delay_fiber DropTail  ;# Channel 2 (DWDM second wavelength)

$ns duplex-link $node2 $node3 $bw_channel $delay_fiber DropTail  ;# Channel 3

$ns duplex-link $node3 $node4 $bw_channel $delay_fiber DropTail  ;# Channel 4

In this setup, Node1, Node2, Node3, and Node4 are connected through optical links, and each duplex link represents a different wavelength channel in the DWDM system. Multiple links between the same pair of nodes represent different wavelengths multiplexed on the same fiber.

  1. Configure Traffic on DWDM Channels

Next, we configure traffic to replicate data transmission over the DWDM channels. Every wavelength channel (optical link) can carry independent traffic streams.

Example of Configuring Traffic on Multiple Channels:

# Create UDP agent for traffic on Channel 1 between Node1 and Node2

set udp1 [new Agent/UDP]

$ns attach-agent $node1 $udp1

# Create CBR traffic generator for Channel 1

set cbr1 [new Application/Traffic/CBR]

$cbr1 set packet_size_ 1000

$cbr1 set rate_ 1Gb         ;# Data rate for Channel 1

$cbr1 attach-agent $udp1

# Create UDP sink for Node2 (Channel 1)

set null1 [new Agent/Null]

$ns attach-agent $node2 $null1

# Connect traffic from Node1 to Node2 on Channel 1

$ns connect $udp1 $null1

# Create UDP agent for traffic on Channel 2 between Node1 and Node2

set udp2 [new Agent/UDP]

$ns attach-agent $node1 $udp2

# Create CBR traffic generator for Channel 2

set cbr2 [new Application/Traffic/CBR]

$cbr2 set packet_size_ 1000

$cbr2 set rate_ 1Gb         ;# Data rate for Channel 2

$cbr2 attach-agent $udp2

# Create UDP sink for Node2 (Channel 2)

set null2 [new Agent/Null]

$ns attach-agent $node2 $null2

# Connect traffic from Node1 to Node2 on Channel 2

$ns connect $udp2 $null2

# Start and stop the traffic on both channels

$ns at 1.0 “$cbr1 start”

$ns at 1.0 “$cbr2 start”

$ns at 10.0 “$cbr1 stop”

$ns at 10.0 “$cbr2 stop”

In this configuration:

  • Channel 1 among the nodes Node1 and Node2 carries a 1 Gbps traffic stream.
  • Channel 2 among the similar nodes carries another independent 1 Gbps stream.
  • Both channels are used concurrently that mimicking the parallel transmission of various wavelengths in the DWDM fiber system.
  1. Simulate Multiple Channels and Path Diversity

In DWDM systems, path diversity permits for failover or load balancing. We can replicate this by setup extra optical paths among various nodes and allocating traffic to these paths.

Example of Adding Multiple Paths:

# Add an additional optical path between Node1 and Node3 via Node2 (representing another DWDM channel)

$ns duplex-link $node1 $node3 $bw_channel $delay_fiber DropTail  ;# Channel 3 (direct link Node1 -> Node3)

# Configure traffic for this path (Channel 3)

set udp3 [new Agent/UDP]

$ns attach-agent $node1 $udp3

set cbr3 [new Application/Traffic/CBR]

$cbr3 set packet_size_ 1000

$cbr3 set rate_ 1Gb

$cbr3 attach-agent $udp3

set null3 [new Agent/Null]

$ns attach-agent $node3 $null3

# Connect traffic from Node1 to Node3 on Channel 3

$ns connect $udp3 $null3

# Start and stop traffic on Channel 3

$ns at 1.0 “$cbr3 start”

$ns at 10.0 “$cbr3 stop”

In this instance, Channel 3 is an additional optical path from the Node1 to Node3 through a direct link that could use for load balancing or path diversity in the DWDM system.

  1. Simulate Failover and Recovery

DWDM systems frequently contain the redundancy and failover capabilities. We can replicate link failure and recovery within NS2 by manually disabling and re-enabling links.

Example of Simulating Failover and Recovery:

# Fail the link between Node1 and Node2 on Channel 1 at time 5.0 seconds

$ns rtmodel-at 5.0 down $node1 $node2

# Recover the link between Node1 and Node2 on Channel 1 at time 8.0 seconds

$ns rtmodel-at 8.0 up $node1 $node2

This script mimics the failure of the optical link among the Node1 and Node2 on Channel 1 at the time 5.0 seconds and also its recovery at time 8.0 seconds. While the downtime, other channels in the DWDM system can continue functioning.

  1. Enable Tracing and Analyse Results

We can be permitted tracing to display the performance of the DWDM network, like packet transmissions, link failures, and recoveries.

Enable Trace Files:

# Enable tracing for the simulation

set tracefile [open “dwdm_fiber_trace.tr” w]

$ns trace-all $tracefile

# Define a finish procedure to end the simulation and close the trace file

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exit 0

}

# Set the simulation end time

$ns at 20.0 “finish”

The trace file will capture events like packet transmissions, link failures, and recoveries that can be examined to know the performance and reliability of the DWDM system.

  1. Run the Simulation

At the end, run the simulation to monitor the performance of the DWDM fiber network.

# Run the simulation

$ns run

Example Complete TCL Script for DWDM Fiber Network Simulation

# Create a simulator instance

set ns [new Simulator]

# Define optical link parameters

set bw_channel 10Gb

set delay_fiber 5ms

# Create network nodes (representing optical transmitters and receivers)

set node1 [$ns node]

set node2 [$ns node]

set node3 [$ns node]

set node4 [$ns node]

# Create DWDM channels (representing multiple optical channels on the fiber)

$ns duplex-link $node1 $node2 $bw_channel $delay_fiber DropTail  ;# Channel 1

$ns duplex-link $node1 $node2 $bw_channel $delay_fiber DropTail  ;# Channel 2 (DWDM second wavelength)

$ns duplex-link $node2 $node3 $bw_channel $delay_fiber DropTail  ;# Channel 3

$ns duplex-link $node3 $node4 $bw_channel $delay_fiber DropTail  ;# Channel 4

# Create UDP agent for traffic on Channel 1 between Node1 and Node2

set udp1 [new Agent/UDP]

$ns attach-agent $node1 $udp1

# Create CBR traffic generator for Channel 1

set cbr1 [new Application/Traffic/CBR]

$cbr1 set packet_size_ 1000

$cbr1 set rate_ 1Gb

$cbr1 attach-agent $udp1

# Create UDP sink for Node2 (Channel 1)

set null1 [new Agent/Null]

$ns attach-agent $node2 $null1

# Connect traffic from Node1 to Node2 on Channel 1

$ns connect $udp1 $null1

# Create UDP agent for traffic on Channel 2 between Node1 and Node2

set udp2 [new Agent/UDP]

$ns attach-agent $node1 $udp2

# Create CBR traffic generator for Channel 2

set cbr2 [new Application/Traffic/CBR]

$cbr2 set packet_size_ 1000

$cbr2 set rate_ 1Gb

$cbr2 attach-agent $udp2

# Create UDP sink for Node2 (Channel 2)

set null2 [new Agent/Null]

$ns attach-agent $node2 $null2

# Connect traffic from Node1 to Node2 on Channel 2

$ns connect $udp2 $null2

# Add an additional optical path between Node1 and Node3 (Channel 3)

$ns duplex-link $node1 $node3 $bw_channel $delay_fiber DropTail

# Configure traffic for this path (Channel 3)

set udp3 [new Agent/UDP]

$ns attach-agent $node1 $udp3

set cbr3 [new Application/Traffic/CBR]

$cbr3 set packet_size_ 1000

$cbr3 set rate_ 1Gb

$cbr3 attach-agent $udp3

set null3 [new Agent/Null]

$ns attach-agent $node3 $null3

# Connect traffic from Node1 to Node3 on Channel 3

$ns connect $udp3 $null3

# Start and stop traffic on all channels

$ns at 1.0 “$cbr1 start”

$ns at 1.0 “$cbr2 start”

$ns at 1.0 “$cbr3 start”

$ns at 10.0 “$cbr1 stop”

$ns at 10.0 “$cbr2 stop”

$ns at 10.0 “$cbr3 stop”

# Simulate failover: Fail the link between Node1 and Node2 on Channel 1 at time 5.0 seconds

$ns rtmodel-at 5.0 down $node1 $node2

# Recover the link between Node1 and Node2 on Channel 1 at time 8.0 seconds

$ns rtmodel-at 8.0 up $node1 $node2

# Enable tracing

set tracefile [open “dwdm_fiber_trace.tr” w]

$ns trace-all $tracefile

# End simulation

$ns at 20.0 “finish”

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exit 0

}

# Run the simulation

$ns run

In this procedure, we can completely understand how to configure the simulation, and also how to simulate and analyse the outcomes for DWDM fiber network via the simplified process in the platform NS2. For further requirements, we will guide you through another simulation process. Contact  ns2project.com for best implementation results in your projects.