Networks



In Networks, simulation tools play an important role for carrying out simulations. Below is the code for simulation of nodes on NS2 platform.
The below tcl script shows the code for creation of six nodes in the network. The code to create global simulator object, open trace file, nam file required for the simulation is available on https://sandip9334.blogspot.in/. These lines of code mentioned in the above link has to be placed before the below mentioned code in a single tcl file.
#Creation of six nodes
set na [$sn node]
set nb [$sn node]
set nc [$sn node]
set nd [$sn node]
set ne [$sn node]
set nf [$sn node]

#Creating links between the nodes
$sn duplex-link $na $nc 2Mb 10ms DropTail
$sn duplex-link $nb $nc 2Mb 10ms DropTail
$sn duplex-link $nc $nd 1.7Mb 20ms DropTail
$sn duplex-link $nd $ne 2Mb 20ms DropTail
$sn duplex-link $nd $nf 2Mb 20ms DropTail


#Setting Queue Size of link (nc-nd) to 10
$sn queue-limit $nc $nd 10

#Provide node positions to visualize in NAM window
$sn duplex-link-op $na $nc orient right-down
$sn duplex-link-op $nb $nc orient right-up
$sn duplex-link-op $nc $nd orient right
$sn duplex-link-op $nd $ne orient right-up
$sn duplex-link-op $nd $nf orient right-down

#Monitoring the queue for link (nc-nd) (nd-ne). (for NAM)
$sn duplex-link-op $nc $nd queuePos 0.5
$sn duplex-link-op $nd $ne queuePos 0.5

#Set a TCP connection
set tcp [new Agent/TCP]
$tcp set class_ 1
$sn attach-agent $na $tcp 


#Setup of tcp traffic source and connection with tcp sink 
set sink [new Agent/TCPSink]
$sn attach-agent $ne $sink
$sn connect $tcp $sink
$tcp set fid_ 2 



#Setting a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP 


#Setting up a UDP connection
set udp [new Agent/UDP]
$sn attach-agent $nb $udp 


#Setting of udp traffic source and its connection with null
set null [new Agent/Null]
$sn attach-agent $nf $null
$sn connect $udp $null
$udp set fid_ 1 


#Setting up a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 1mb
$cbr set random_ false 


#Scheduling events for the CBR and FTP agents
$sn at 0.1 "$cbr start"
$sn at 1.0 "$ftp start"
$sn at 4.0 "$ftp stop"
$sn at 4.5 "$cbr stop" 

$sn at 5.0 "finish" 

#Run the simulation
$sn run

Comments

  1. Great article you always put very nice article Keep it up and provide some tips that how can I get more traffic on Allbet Apk Free Download Games As I thinks you have very good known of SEO

    ReplyDelete
  2. Nice post. I was checking constantly this blog and I am impressed!
    Big Gaming Jackpot casino

    ReplyDelete

Post a Comment