1 # application-hmsim.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1997-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/sim/hm/application-hmsim.tcl,v 1.7 2002/02/03 04:16:36 lim Exp $ (UCB)
32
33 Class HMSimApplication -superclass Application
34
35 HMSimApplication instproc init { argv } {
36 set config [new Configuration]
37 $self set options_ $config
38
39 $self next hm
40
41 $self init_args $config
42 $self init_resources $config
43 $config parse_args $argv
44 $self init_local
45
46 $self init_sim
47 }
48
49 HMSimApplication instproc init_args o {
50 $o register_boolean_option -lb loadBalance
51
52 $o register_option -target targetNum
53 $o register_option -hostnum hostNum
54 $o register_option -int checkInterval
55 $o register_option -end endTime
56 $o register_option -log logFile
57 $o register_option -ckfact checkFactor
58 }
59
60 HMSimApplication instproc init_resources o {
61
62 $o add_default megaCtrl 224.4.5.24/50000/31
63 $o add_default megaCtrlBW 20000
64 # 60 seconds max startup wait for first message
65 $o add_default megaStartupWait 60
66
67 $o add_default unicastOutput 1
68
69 $o add_default maxWait 2500
70
71 $o add_default minPort 10000
72 $o add_default maxPorts 10000
73
74 $o add_default checkFactor 4
75 $o add_default checkInterval 20000
76 $o add_default deathInterval 10000
77 $o add_default minDeathWait 60000
78
79 $o add_default highLoad 85
80 $o add_default lowLoad 15
81 $o add_default execPath /a/center/src/mash/bin
82 $o add_default minHmNum 1
83 $o add_default loadSamples 2
84 $o add_default logFile stdout
85
86 $o add_default hostNum 4
87 $o add_default endTime 10
88 }
89
90 HMSimApplication instproc init_sim {} {
91 global ns
92 $ns at [$self get_option endTime] "$self finish"
93
94 # ns-random 1239871
95 ns-random 0
96 set log [$self get_option logFile]
97 if { $log != "stdout" } {
98 set log [open $log a+]
99 }
100 set hm [new HMSimAgent 0 $self $log]
101 $hm set alice_ 1
102 }
103
104 HMSimApplication instproc finish {} {
105 global hmrec
106
107 set max -1
108 foreach x $hmrec {
109 # puts "[lindex $x 0] [lindex $x 1]"
110 set cur [lindex $x 0]
111 if { $cur > $max } {
112 set max $cur
113 }
114 }
115 puts "$max [$self get_option checkInterval]"
116 exit 0
117 }
118
119
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.