Wednesday 21 May 2014

OBS Network in NS2

Optical burst switching (OBS) Network:

 Optical Burst Switching (OBS) is an optical network technology that aims to improve the use of optical networks resources when compared to optical circuit switching (OCS). OBS is implemented using Wavelength Division Multiplexing (WDM), a data transmission technology that transmits data in an optical fibre by establishing several channels, each channel corresponding to a specific light wavelength.

Optical Burst Switching is used in core networks, and viewed as a feasible compromise between the existing Optical Circuit Switching (OCS) and the yet not viable Optical Packet Switching (OPS).

In OBS, packets are aggregated into data bursts at the edge of the network to form the data payload


Techopedia explains Optical Burst Switching (OBS)

Optical Burst Switching has several distinctive features: first, the packets are aggregated in the ingress (entry) node, for a very short period of time. This allows that packets that have the same
constraints, e.g., the same destination address and maybe, the same quality of service requirements are sent together as a burst of data (therefore the term Burst in the concept name). When the burst arrives at the egress (exit) node, it is disassembled and its constituent packets routed to their destination.

While the burst is being assembled in the ingress node, or possibly, after the burst has been assembled, a control packet (or header packet), containing the routing information for that burst is sent to the network, ahead of the burst. The time that separates the transmission of the control packet and the transmission of the burst is termed the offset time, and it must be long enough to allow all the routers in the predicted path the burst will take, to be configured, and only for the time needed for the burst to cross the network. When the network nodes are configured, the burst departs the ingress node and travels through the network in an all-optical form, using the circuit that was previously established by the control packet.

The second characteristic of OBS is that the routing information is transmitted in the Control Packet and is not part of the data burst itself. In fact, the burst crosses the intermediate nodes in the
network using the pre-established and pre-configured circuit in an agnostic manner, i.e., the node does not need to interpreted the data in the burst, and so, it does not need to know the format of the data in the burst. This is another special feature of OBS.

Another distinctive characteristic of OBS is that the Control Packet will undergo optical to electronic to optical conversion at each intermediate node, and also optical to electronic conversion at the egress node, as to allow these nodes to be able to configure its optical switching devices. A final characteristic of OBS networks is that there is what is called a data and control plane separation, i.e., the channel that is used to transmit the control packets is specific and different from the channels that are used to transmit the data bursts.


OBS simulator module for ns-2:

The source code of OBS (optical burst switching) extension that I created for ns-2 simulator is here. It was presented and used in "nOBS: an ns2 based simulation tool for performance evaluation of TCP traffic in OBS networks" journal paper available here. Please read readme.txt file for details



TCL script for OBS Network Topology:



proc my-duplex-link {ns n1 n2 bw delay queue_method queue_length} {
$ns optical-duplex-link $n1 $n2 $bw $delay $queue_method
$ns queue-limit $n1 $n2 $queue_length
$ns queue-limit $n2 $n1 $queue_length
}


proc my-duplex-link2 {ns n1 n2 bw delay queue_method queue_length} {
$ns optical-simplex-link $n1 $n2 $bw $delay $queue_method
$ns simplex-link $n2 $n1 $bw $delay DropTail
$ns queue-limit $n1 $n2 $queue_length
$ns queue-limit $n2 $n1 $queue_length
}


#Create a simulator object
set ns [new Simulator] 

#Variable Simulation settings: max burst size [50,100,200,300,400,500], timeout = [1:1:10] msec, simulation time: 200 sec, buffer = 2*500*1040 bytes, receive window = 500 packets.
set settings [new OpticalDefaults] 
$settings set MAX_PACKET_NUM 20
$settings set TIMEOUT 7ms
$settings set MAX_FLOW_QUEUE 5
# The following are the default values for settings, only the above have been changed.
#OpticalDefaults set MAX_PACKET_NUM 500;
#OpticalDefaults set HOP_DELAY 0.00001;
#OpticalDefaults set TIMEOUT 0.005;
#OpticalDefaults set MAX_LAMBDA 1;
#OpticalDefaults set LINKSPEED 1Gb;
#OpticalDefaults set SWITCHTIME 0.000005;
#OpticalDefaults set LIFETIME 0.1;
#OpticalDefaults set DEBUG 3;
#OpticalDefaults set MAX_DEST 40;
#OpticalDefaults set BURST_HEADER 40;
#OpticalDefaults set MAX_DELAYED_BURST 2;
#OpticalDefaults set MAX_FLOW_QUEUE 1;
$settings set MAX_DELAYED_BURST 5


$ns color 12 Red
$ns color 13 Yellow
$ns color 14 Green
$ns color 15 Purple
$ns color 16 Black
$ns color 17 Magenta
$ns color 18 Brown
$ns color 19 Orange
$ns color 20 Red
$ns color 21 Blue

#Open the win size file
set winfile [open windows.txt w]
set goodfile [open goodput.txt w]


#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf

# enable source routing

$ns op_src_rting 1



#Open the nam trace file
set nf [open out.tr w]
$ns trace-all $nf
set f [open out.nam w]
$ns namtrace-all $f

#Start from zero when numbering the nodes. 

#Create 2 optical nodes
for {set i 0} {$i < 2} {incr i} {
            set n($i) [$ns OpNode]
   #define optical nodes
   set temp [$n($i) set src_agent_]
   $temp optic_nodes 0 1
   $temp set nodetype_ 0
   $temp set conversiontype_ 1
   $temp create
   #whether acks are burstified
   $temp set ackdontburst 1

   set temp [$n($i) set burst_agent_]
   $temp optic_nodes 0 1
   #whether acks are burstified
   $temp set ackdontburst 1

   set temp [$n($i) set classifier_]
   $temp optic_nodes 0 1

}



#Create 20 electronic nodes
for {set i 2} {$i < 22} {incr i} {
            set n($i) [$ns node]
   
   #define optical nodes
   set temp [$n($i) set src_agent_]
   $temp optic_nodes 0 1
   

   
   set temp [$n($i) set classifier_]
   $temp optic_nodes 0 1
   
}

set queue_length 100000

#Create links between the nodes
 my-duplex-link2 $ns $n(0) $n(1) 1000Mb 10ms OpQueue $queue_length

#creating the error model
set loss_module [new ErrorModel]
$loss_module set rate_ 0.01
$loss_module unit pkt
$loss_module ranvar [new RandomVariable/Uniform]
$loss_module drop-target [new ONA]
#set whether burst or control packet will be dropped
$loss_module set opticaldrop_ 2
#Inserting Error Module
$ns lossmodel $loss_module $n(0) $n(1)
for {set i 2} {$i < 12} {incr i} {
$ns duplex-link $n($i) $n(0) 155Mb 1ms DropTail
$ns queue-limit $n($i) $n(0) $queue_length
$ns queue-limit $n(0) $n($i) $queue_length
}


for {set i 12} {$i < 22} {incr i} { 
$ns duplex-link $n($i) $n(1) 155Mb 1ms DropTail
$ns queue-limit $n($i) $n(1) $queue_length
$ns queue-limit $n(1) $n($i) $queue_length
}




 set flow 0

 for {set i 2} {$i < 12} {incr i} {

  set d [expr $i + 10]

  #Create a TCP agent and attach it to node n0
set cbr($i) [new Agent/TCP/Reno]
$ns attach-agent $n($i) $cbr($i)
$cbr($i) set fid_ $d
$cbr($i) set fid2_ $flow
$cbr($i) set window_ 10000

$cbr($i) target [$n($i) set src_agent_]

set ftp($i) [$cbr($i) attach-source FTP]


set null($i) [new Agent/TCPSink]
$ns attach-agent $n($d) $null($i)
#$null($i) set fid_ $s  #This part is not working. Hard coded in tcp sink.cc
$null($i) set fid2_ $flow

$null($i) target [$n($d) set src_agent_]

$ns connect $cbr($i) $null($i)

incr flow


  set temp [$n($i) set src_agent_]
$temp install_connection $d         $i $d   $i 0 1 $d
set temp [$n($d) set src_agent_]
$temp install_connection $i         $d $i   $d 1 0 $i

 $ns at [expr $i] "$ftp($i) start" 

 }
  set temp [$n(0) set src_agent_]
$temp install_connection 1         0 1   0 1 
set temp [$n(1) set src_agent_]
$temp install_connection 0         1 0   1 0



proc plotWindow {file} {
global goodfile
global ns
global cbr
set time 0.01
set now [$ns now]
puts -nonewline $file "$now"
puts -nonewline $goodfile "$now"
for {set i 2} {$i < 12} {incr i} {
set cwnd($i) [$cbr($i) set cwnd_]
puts -nonewline $file " $cwnd($i)"
puts -nonewline $goodfile " "
puts -nonewline  $goodfile [$cbr($i) set ack_]
#puts -nonewline  $goodfile [expr  [$cbr($i) set ack_]/[expr $now-$i]]
}
puts $file ""
puts $goodfile ""
$ns at [expr $now+$time] "plotWindow $file"
}

proc finish {} {
        #global ns nf
#global f
global winfile
global goodfile
        #$ns flush-trace
#Close the trace file
        #close $f
close $winfile
#Execute nam on the trace file
        #exec ./nam out.nam 
close $goodfile
        exit 0
}


#$ns at 1 "plotWindow $winfile"
$ns at 10 "finish"
$ns run

NAM and Trace Output: