Skip to content

WDM Mesh Network Simulation Under ns-2 using OWns

 

Some Important Sections of the WDM Network Simulation Script

Setting some Important Parameters

 
set val(wvlen_routing) WDMSession ;# wvlen routing protocol
set val(wvlen_assign) FirstFit ;# wvlen assignment protocol
 
set val(node_num) 9 ;# total node number in network
set val(conn_prob) 0.4 ;# nodes connection prob.
set val(topo_seed) 99 ;# seed to create the topology
 
set val(link_bw) 8Mb ;# all links have the same bandwidth 
 
set val(link_wvlen_num) 16 ;# all links have the same wvlen number
set val(link_delay) 10ms ;# all links have the same delay
set val(wvlen_conv_factor) 1 ;# wvlen conversion factor, between 0 and 1
set val(wvlen_conv_dist) 8 ;# wvlen conversion distance, <= wvlen num
set val(wvlen_conv_time) 0.024 ;# wvlen conversion time (relative time)
 ;# pkts trasmission time * 3
 
set val(util_sample_interval) 0.5 ;# link utilization sample interval
set val(wvlen_alloc_path2) 1 ;# wvlen alloc on path2? 0, disable; 1, enable
 
set val(traf_num) 18 ;# total session-traffics in network

set val(traf_arrival_rate) 0.5 ;# each traffic arrival rate
set val(traf_holding_time) 10.0 ;# each traffic holdingtime 
 ;#[for graph change it to 1 2 ... 10]

set val(traf_pkt_size) 2000 ;# session-traffic packet size
set val(traf_pkt_rate) 2Mb ;# session-traffic packet arrival rate
 
set val(traf_type) Exponential ;# session-traffic type in network

set val(traf_exp_burst_time) 0.7 ;# expoo traffic average burst time 
set val(traf_exp_idle_time) 0.1 ;# expoo traffic average idle time 

set val(traf_max_req) 50 ;# max requests number
set val(traf_start_time) 0.0 ;# session-traffic starting time
set val(traf_stop_time) 0.0 ;# session-traffic stoping time
 ;# if 0, doesn't stop until reach
 ;# the max requests number 
 

set nshome "/root/ns-allinone-2.1b6/ns-2.1b6"

source $nshome/OWNS/tcl/ns-wdm-trafgen.tcl
source $nshome/OWNS/tcl/ns-wdm-stat.tcl

 

Creating a WDM Mesh Network

#3x3Mesh topology 

#
# Define different colors for traffics
# 
for { set i 0 } { $i < $val(traf_num) } { incr i } {
 eval $ns color $i $color([expr $i % $color_num])
}

#
# Wvlen routing protocol and assigning mechanism
#
$ns wrouting-proto $val(wvlen_routing)
$ns wassign-proto $val(wvlen_assign)

#
# Create random topology
#
eval create-topology ns WDMNode SessionTrafficRcvr $val(link_bw) $val(link_wvlen_num) \
 $val(wvlen_conv_factor) $val(wvlen_conv_dist) $val(wvlen_conv_time) \
 $val(wvlen_alloc_path2) $val(util_sample_interval) $val(traf_max_req)

#
# Create random traffics
#
create-traffic ns traffic WDMNode SessionTrafficRcvr $val(node_num) $val(traf_num) \
 $val(traf_pkt_size) $val(traf_pkt_rate) \
 $val(traf_arrival_rate) $val(traf_holding_time) \
 $val(traf_exp_burst_time) $val(traf_exp_idle_time)

#
# Schedule session-traffic for WDM network
#
for { set i 0 } { $i < $val(traf_num) } { incr i } {
 $ns schedule-sessiontraffic $traffic($i) \
 $val(traf_start_time) $val(traf_stop_time)
}

 

 Some Important Procedures

proc create-topology {nsns node sinker linkBW wvlens conv_f conv_d conv_t path2 interval maxreq } {
 upvar $node n
 upvar $nsns ns
 upvar $sinker sink

 set verbose 1

 if {$verbose} { 
 puts "Creating WDMNodes..." 
 }
 for {set i 0} {$i < 9} {incr i} {
 set n($i) [$ns $node]

 # create a session-traffic receiver for each node
 set sink($i) [new Agent/$sinker]
 $ns attach-agent $n($i) $sink($i)
 }

 $ns start-config-wassignlogic

 $ns wvlen-conversion $conv_f $conv_d $conv_t

 $ns alloc-wvlen-path2 $path2

 $ns util-sample-interval $interval

 $ns max-req $maxreq

 # EDGES (from-node to-node length a b):
 if {$verbose} { 
 puts -nonewline "Creating links 0..."
 flush stdout 
 }
 set i 0 
 foreach t { 
 {0 1 20ms} 
 {1 2 20ms} 
 {0 3 20ms} 
 {1 4 20ms} 
 {2 5 20ms} 
 {3 4 20ms} 
 {4 5 20ms} 
 {3 6 20ms} 
 {6 7 20ms} 
 {4 7 20ms} 
 {7 8 20ms} 
 {5 8 20ms} 
 } { 
 $ns duplex-FiberLink $n([lindex $t 0]) $n([lindex $t 1]) $linkBW [lindex $t 2] Null $wvlens
 incr i 
 if {[expr $i % 100] == 0} { 
 puts "creating link $i..." 
 } 
 } 
 return 9
}




proc create-traffic { sim trafsrc node sinker nodenum trafnum pktsize rate traf_arrival_rate traf_holding_time arg1 arg2} {
 upvar $sim ns
 upvar $trafsrc src
 upvar $node n
 upvar $sinker sink

 set i 0
 foreach pair {
 { 0 5 }
 { 3 1 }
 { 0 4 }
 { 4 6 }
 { 2 3 }
 { 5 0 }
 { 0 3 }
 { 4 0 }
 { 2 0 }
 { 2 4 }
 { 0 7 }
 { 3 6 }
 { 0 1 }
 { 4 2 }
 { 2 8 }
 { 5 0 }
 { 8 3 }
 { 4 7 }
 { 2 8 }
 { 8 4 }
 } {
 set sid [lindex $pair 0] 
 set did [lindex $pair 1] 

 set src($i) [create-Exponential-traffic $n($sid) $sink($did) $pktsize $rate $traf_arrival_rate $traf_holding_time $i $arg1 $arg2]
 incr i
 }
}

 

The Statistical Results for the Initial Parameters

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Blocking prob. = 0.31372549
total requests = 51, rejected requests = 16
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Average hops = 2.31428571
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Average pkt delay = 0.07549846
total pkts = 44694, total delay = 3374.32800000
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Link utilization = 0.52569400
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

The Nam output of the 3×3 WDM  Mesh Topology

 

The Simulation Results

To Get the Graph, the Parameter val(traf_holding_time) was changed from 1 to 10 and the simulation was repeated for 10 times.

The Values will be recorded in the files

“3x3Mesh-LoadVsBp.dat”
“3x3Mesh-LoadVsAvgDelay.dat”
“3x3Mesh-LoadVsAvgHops.dat” and
“3x3Mesh-LoadVsAvgUtil.dat”

After Running the Simulation for 10 times, there will be 10 records in the data files. (since we are using the files in append mode in the tcl script).

 

Average Delay over Different Traffic Load

 

 

The Blocking Probability over Different Traffic Load

 

The Average Utilization over Different Traffic Load

 

The Average hops of Different Traffic Load

 

 

WhatsApp Discuss Through WhatsApp