File: D1-m-decrease.tcl

package info (click to toggle)
nam 1.15-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 29,240 kB
  • sloc: cpp: 17,338; tcl: 10,655; sh: 2,997; ansic: 1,252; makefile: 139; perl: 66
file content (80 lines) | stat: -rw-r--r-- 1,743 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# It will show how TCP adjusts its window size by multiplicative decrease
# features : labeling, annotation, nam-graph, and window size monitoring

#
#	n0 --- n1 -------------- n2 --- n3
#

set ns [new Simulator]

$ns trace-all [open D1-m-decrease.tr w]
$ns namtrace-all [open D1-m-decrease.nam w]

### build topology with 4 nodes

        foreach i " 0 1 2 3 " {
                set n$i [$ns node]
        }

        $ns at 0.0 "$n0 label TCP"
        $ns at 0.0 "$n3 label TCP"

        $ns duplex-link $n0 $n1 5Mb 20ms DropTail
        $ns duplex-link $n1 $n2 0.5Mb 100ms DropTail
        $ns duplex-link $n2 $n3 5Mb 20ms DropTail

        $ns queue-limit $n1 $n2 5

        $ns duplex-link-op $n0 $n1 orient right
        $ns duplex-link-op $n1 $n2 orient right     
        $ns duplex-link-op $n2 $n3 orient right     

        $ns duplex-link-op $n1 $n2 queuePos 0.5

### set TCP variables

Agent/TCP set nam_tracevar_ true        
Agent/TCP set window_ 20
Agent/TCP set ssthresh_ 20

### TCP between n0 and n3 (Black)

set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
        
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink

$ns connect $tcp $sink

set ftp [new Application/FTP]
$ftp attach-agent $tcp

$ns add-agent-trace $tcp tcp
$ns monitor-agent-trace $tcp
$tcp tracevar cwnd_
$tcp tracevar ssthresh_

proc finish {} {

        global ns
        $ns flush-trace

        puts "filtering..."
        exec tclsh ../bin/namfilter.tcl D1-m-decrease.nam
        puts "running nam..."
        exec nam D1-m-decrease.nam &
        exit 0
}

### set operations

$ns at 0.1 "$ftp start"
$ns at 5.0 "$ftp stop"
$ns at 5.1 "finish"

### add annotations
$ns at 0.0 "$ns trace-annotate \"TCP with multiplicative decrease\"" 

$ns run