Skip to content

Simulasi pertama dengan NS2

Topology yang digunakan adalah sebagai berikut :

Berhubung masih nobitol, jadinya masih script kiddies T_T

--------------------------------------------------------------
#Create a simulator object
set ns [new Simulator]
#Create a trace file
set mytrace [open out.tr w]
$ns trace-all $mytrace

#create a NAM trace file
set myNAM [open out.nam w]
$ns namtrace-all $myNAM
#Define a procedure finish
proc finish {} {
 global ns mytrace myNAM
 $ns flush-trace
 close $mytrace
 close $myNAM
 exec nam out.nam &
exit 0
}
#Create two nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
$n0 color blue
$n0 label "cnc1"
$n1 color red
$n1 label "cnc2"
$n2 color green
$n2 label "cnc3"
#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 100Mb 5ms DropTail
$ns duplex-link $n1 $n2 54Mb 10ms DropTail
#Create a TCP agent
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n2 $sink
$ns connect $tcp $sink
$tcp set fid_ 2
#Create an FTP session
set ftp [new Application/FTP]
$ftp attach-agent $tcp
#Schedule events
$ns at 0.05 "$ftp start"
$ns at 60 "$ftp stop"
$ns at 61 "finish"
#start the Simulation
$ns run

--------------------------------------------------------------
Selamat Mencoba ^_^
One Comment leave one →
  1. 30 January 2013 6:32 AM

    Terima Kasih Pak Atas infonya ..
    artikel yang sangat bagus ..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: