How to use Link State Routing (LS) protocol in ns2


The Link State (LS) routing protocol has two components such as routing agent and route logic. The routing agent exchanges routing packet with neighbors in the link state manner while the route logic does Dijkstra on exploiting the information gathered by the routing agents to perform the actual route computation. The test6.tcl shows the sample tcl code that runs the application with LS routing protocol.

# Filename: test6.tcl
# —————-Routing Protocol————-#

$ns rtproto LS

$ns at 0.0 "Tranmission"
proc Tranmission {} {
global C ROU R ns

set now [$ns now]
set time 10.0
set x 3
set y 4

set tcp1 [$ns create-connection TCP $C($x) TCPSink $R($y) 1]
$ns at $now "$ns trace-annotate \"Time: $now Pkt Transfer between Client($x) Receiver($y)..\""
$tcp1 set class_ 1
$tcp1 set maxcwnd_ 16
$tcp1 set packetsize_ 4000
$tcp1 set fid_ 1
set ftp1 [$tcp1 attach-app FTP]
$ftp1 set interval_ .005
$ns at $now "$ftp1 start"


Routing process

Link State Routing (LS) protocol used in ns2

Data Transmission

Link State Routing (LS) protocol used in ns2