Tuesday, 29 September 2015

Otcl for NS2 (Acknowledgement Programe )

set  ns [new Simulator]
set  n1 [$ns node]
set  n2 [$ns node]

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

#Define a 'finish' procedure
proc finish {} {
        global ns nf
        $ns flush-trace
    #Close the trace file
        close $nf
    #Execute nam on the trace file
        exec nam out.nam &
        exit 0
}

$ns duplex-link $n1 $n2 5Mb 2ms DropTail


 #=== TCP connection setup starts here ===
set tcp [new Agent/TCP]
set sink [new Agent/TCPSink]
set ftp [new Application/FTP]
$ns attach-agent $n1 $tcp
$ns attach-agent $n2 $sink
$ftp attach-agent $tcp
$ns connect $tcp $sink
$ns at 0.0 "$ftp start"


$ns at 5.0 "finish"

#Run the simulation
$ns run

No comments:

Post a Comment

Grammar Mistakes in Technical Paper Writing

Let me share some experience in this post with you. I'm currently in the second year of my Ph.D. program. We are in the middle of paper...