File: simple-tcp.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,796 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (38 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (8)
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