Debian Codegraph @

tcl/ex/scuba/noscuba-equal/demo.tcl

raw
1 #
2 # Copyright (c) @ Regents of the University of California.
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # 3. All advertising materials mentioning features or use of this software
14 # must display the following acknowledgement:
15 # This product includes software developed by the MASH Research
16 # Group at the University of California Berkeley.
17 # 4. Neither the name of the University nor of the Research Group may be
18 # used to endorse or promote products derived from this software without
19 # specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 # SUCH DAMAGE.
32 #
33 # @(#) $Header: /cvsroot/nsnam/ns-2/tcl/ex/scuba/noscuba-equal/demo.tcl,v 1.1 1997/06/14 00:16:02 elan Exp $
34 #
35
36 set tcldir ../../../
37
38 source $tcldir/rtp/session-scuba.tcl
39 source $tcldir/rtp/session-rtp.tcl
40
41 proc trace_annotate { s } {
42 global ns
43 set f [$ns set traceAllFile_]
44
45 puts $f [format "v %s %s {set sim_annotation {%s}}" [$ns now] eval $s]
46 }
47
48 set ns [new MultiSim]
49
50 for { set i 0 } { $i < 8 } { incr i } {
51 set node($i) [$ns node]
52 }
53
54 set f [open out.tr w]
55 $ns trace-all $f
56
57 Queue set limit_ 10
58
59 proc makelinks { bw delay pairs } {
60 global ns node
61 foreach p $pairs {
62 set src $node([lindex $p 0])
63 set dst $node([lindex $p 1])
64 $ns duplex-link $src $dst $bw $delay DropTail
65 }
66 }
67
68 makelinks 1.5Mb 10ms {
69 { 0 3 }
70 { 1 3 }
71 { 2 3 }
72 { 4 7 }
73 { 5 7 }
74 { 6 7 }
75 }
76
77 makelinks 400kb 50ms {
78 { 3 7 }
79 }
80
81 for { set i 0 } { $i < 8 } { incr i } {
82 set dm($i) [new DM $ns $node($i)]
83 }
84
85 $ns at 0.0 "$ns run-mcast"
86
87 set sessbw 400kb/s
88
89 foreach n { 0 1 2 4 5 6 } {
90 set sess($n) [new Session/RTP]
91 $sess($n) session_bw $sessbw
92 $sess($n) attach-node $node($n)
93 }
94
95 $ns at 1.0 {
96 global sess
97 foreach n { 0 1 2 4 5 6 } {
98 $sess($n) join-group 0x8000
99 }
100 }
101
102 foreach n { 0 1 2 } {
103 set d [$sess($n) set dchan_]
104 $d set class_ [expr $n]
105 }
106
107 $ns at 1.0 "trace_annotate {Starting receivers...}"
108 # start receivers
109 $ns at 1.0 {
110 global sess
111 $sess(4) start
112 $sess(5) start
113 $sess(6) start
114 }
115
116 # start senders
117 $ns at 1.0 "trace_annotate {Starting sender 1 at 130kb/s...}"
118 $ns at 1.0 "$sess(0) start"
119 $ns at 1.0 "$sess(0) transmit 130kb/s"
120
121 $ns at 2.0 "trace_annotate {Starting sender 2 at 130kb/s...}"
122 $ns at 2.0 "$sess(1) start"
123 $ns at 2.0 "$sess(1) transmit 130kb/s
124 "
125 $ns at 3.0 "trace_annotate {Starting sender 3 at 130kb/s...}"
126 $ns at 3.0 "$sess(2) start"
127 $ns at 3.0 "$sess(2) transmit 130kb/s"
128
129 $ns at 5.0 "finish"
130
131 proc finish {} {
132 global tcldir
133 puts "converting output to nam format..."
134 global ns
135 $ns flush-trace
136 exec awk -f $tcldir/nam-demo/nstonam.awk out.tr > demo-nam.tr
137 exec rm -f out
138 #XXX
139 puts "running nam..."
140 exec /usr/local/src/nam/nam demo-nam &
141 exit 0
142 }
143
144 $ns run
145