1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#Create a simulator object
set ns [new Simulator]
#Open the ns trace file
set nf [open out.ns w]
$ns trace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exit 0
}
#Create two nodes
set n0 [$ns node]
set n1 [$ns node]
#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
#Create a TCP agent and attach it to node n0
set tcp [new Agent/TCP/Reno]
set snk [new Agent/TCPSink]
$tcp set syn_ true
$ns attach-agent $n0 $tcp
$ns attach-agent $n1 $snk
$ns connect $tcp $snk
$ns at 0.5 "$tcp advanceby 1"
$ns at 5.0 "finish"
#Run the simulation
$ns run
|