forked from neuwin1216548787/inetmanet
/
rundemo
executable file
·430 lines (369 loc) · 15.3 KB
/
rundemo
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
#!/bin/sh
# the next line restarts using wish (on cygwin, use wish84 or the like) \
exec wish "$0" "$@"
#==========================================================================
# DEMO
# part of OMNeT++
#==========================================================================
#--------------------------------------------------------------
# Copyright (C) 1992-2003 Andras Varga
# 2009 Thomas Reschka
# This file is distributed WITHOUT ANY WARRANTY. See the file
# `license' for details on this and other legal matters.
#--------------------------------------------------------------
#
# Configuration
#
set wantScrollbar 1
set unixbrowser "firefox"
#set unixbrowser "mozilla"
#set unixbrowser "konqueror"
#set unixbrowser "netscape"
#
# title line: {"title"}
# program line: {"name" "directory" "unix-command" "windows-command"}
# readme line: {"name" "readme-file"}
# docu line: {"name" "readme-file" "html-file"}
# separator: {}
#
set i 0
set first ""
foreach line {
{"INET Framework"}
{"About..." "README" "../doc/index.html"}
{"Ethernet"}
{"ARP Test" "ethernet/arptest" "./run" "run"}
{"ARP Test 2" "ethernet/arptest2" "./run" "run"}
{"LANs: mixed Ethernet" "ethernet/lans" "./run mixed.ini" "run mixed.ini"}
{"LANs: Ethernet bus" "ethernet/lans" "./run bus.ini" "run bus.ini"}
{"LANs: hub" "ethernet/lans" "./run hub.ini" "run hub.ini"}
{"LANs: switch" "ethernet/lans" "./run switch.ini" "run switch.ini"}
{"LANs: duplexswitch" "ethernet/lans" "./run duplexswitch.ini" "run duplexswitch.ini"}
{"LANs: two hosts" "ethernet/lans" "./run twoHosts.ini" "run twoHosts.ini"}
{"LANs: very large LAN" "ethernet/lans" "./run largeNet.ini" "run largeNet.ini"}
{"INET"}
{"NClients/Telnet" "inet/nclients" "./run" "run"}
{"NClients/HTTP" "inet/nclients" "./run basicHTTP.ini" "run basicHTTP.ini"}
{"NClients/file transfer" "inet/nclients" "./run filetransfer.ini" "run filetransfer.ini"}
{"FlatNet" "inet/flatnet" "./run" "run"}
{"KIDSNw1" "inet/kidsnw1" "./run" "run"}
{"Multicast" "inet/multicast" "./run" "run"}
{"RouterPerf" "inet/routerperf" "./run" "run"}
{"BulkTransfer" "inet/bulktransfer" "./run" "run"}
{"TcpSack" "inet/tcpsack" "./run" "run"}
{"Ber" "inet/ber" "./run" "run"}
{"IPv6 (work in progress)"}
{"NClients" "ipv6/nclients" "./run" "run"}
{"DemoNetworkEth" "ipv6/demonetworketh" "./run" "run"}
{"SCTP"}
{"NClients" "sctp/nclients" "./run" "run"}
{"Multi-homing" "sctp/multihomed" "./run" "run"}
{"Emulation"}
{"Traceroute" "emulation/traceroute" "./run" "run"}
{"ExtClient" "emulation/extclient" "./run" "run"}
{"ExtServer" "emulation/extserver" "./run" "run"}
{"Ad-hoc"}
{"Mobility models" "adhoc/mobility" "./run" "run"}
{"802.11b ad-hoc" "adhoc/ieee80211" "./run" "run"}
{"802.11b ad-hoc (MF impl.)" "adhoc/mf80211" "./run" "run"}
{"Wireless"}
{"802.11 AP and hosts" "wireless/lan80211" "./run" "run"}
{"802.11 handover" "wireless/handover" "./run" "run"}
{"802.11 thruput test" "wireless/throughput" "./run" "run"}
{"802.11 thruput test 2" "wireless/hosttohost" "./run" "run"}
{"MPLS/RSVP-TE"}
{"TestTE/failure" "mpls/testte_failure" "./run" "run"}
{"TestTE/reroute" "mpls/testte_reroute" "./run" "run"}
{"TestTE/routing" "mpls/testte_routing" "./run" "run"}
{"TestTE/tunnel " "mpls/testte_tunnel" "./run" "run"}
{"LDP/test" "mpls/ldp" "./run" "run"}
{"Net37" "mpls/net37" "./run" "run"}
{"OSPFv2"}
{"SimpleTest" "ospfv2/simpletest" "./run" "run"}
{"Areas" "ospfv2/areas" "./run" "run"}
{"Backbone" "ospfv2/backbone" "./run" "run"}
{"FullTest" "ospfv2/fulltest" "./run" "run"}
} {
lappend samples $i
if {[llength $line]==0} {
set db($i,type) "spacer"
} elseif {[llength $line]==1} {
set db($i,type) "heading"
set db($i,title) [lindex $line 0]
} elseif {[llength $line]==2} {
set db($i,type) "readme"
set db($i,title) [lindex $line 0]
set db($i,readme) [lindex $line 1]
if {$first==""} {set first $i}
} elseif {[llength $line]==3} {
set db($i,type) "docu"
set db($i,title) [lindex $line 0]
set db($i,readme) [lindex $line 1]
set db($i,docu) [lindex $line 2]
if {$first==""} {set first $i}
} elseif {[llength $line]==4} {
set db($i,type) "program"
set db($i,title) [lindex $line 0]
set db($i,dir) [lindex $line 1]
set db($i,uprog) [lindex $line 2]
set db($i,wprog) [lindex $line 3]
if {$first==""} {set first $i}
} else {
tk_messageBox -title {Error} -type ok -icon error -message "Error in table: wrong #items in {$line}"
exit
}
incr i
}
proc createWindow {} {
global wantScrollbar samples first db fonts colors
wm focusmodel . passive
wm minsize . 1 1
wm overrideredirect . 0
wm resizable . 1 1
wm deiconify .
wm title . "OMNeT++ Demo Simulations"
wm protocol . WM_DELETE_WINDOW {exit}
wm geometry . "650x400"
#################################
# Menu bar
#################################
menu .menubar
. config -menu .menubar
# Create menus
foreach i {
{filemenu -label File -underline 0}
{helpmenu -label Help -underline 0}
} {
eval .menubar add cascade -menu .menubar.$i
menu ".menubar.[lindex $i 0]" -tearoff 0
}
# File menu
foreach i {
{command -command exit -label Exit -underline 1}
} {
eval .menubar.filemenu add $i
}
# Help menu
foreach i {
{command -command helpAbout -label {About OMNeT++} -underline 0}
} {
eval .menubar.helpmenu add $i
}
#################################
# Create main display area
#################################
frame .sel -bd 2 -relief groove
frame .main -bd 2 -relief groove
pack .sel -expand 0 -fill y -side left -padx 2
pack .main -expand 1 -fill both -side right -padx 2
frame .main.up
frame .main.lo
frame .main.mid
pack .main.up -expand 0 -fill x -side top
pack .main.lo -expand 0 -fill x -side bottom
pack .main.mid -expand 1 -fill both -side top
label .main.up.banner -bg $colors(banner) -relief groove -font $fonts(bold)
pack .main.up.banner -fill x -side top
text .main.mid.text -yscrollcommand ".main.mid.sb set" -width 80 -height 20 -wrap none
scrollbar .main.mid.sb -command ".main.mid.text yview"
pack .main.mid.sb -anchor center -expand 0 -fill y -side right
pack .main.mid.text -anchor center -expand 1 -fill both -side left
button .main.lo.start -font $fonts(bold) -bg $colors(startbutton)
pack .main.lo.start -expand 1 -fill x -padx 10 -pady 6
canvas .sel.c -width 200
pack .sel.c -side left -expand yes -fill both
if {$wantScrollbar} {
.sel.c config -yscrollcommand ".sel.s set"
scrollbar .sel.s -command ".sel.c yview"
pack .sel.s -side right -fill y
}
frame .sel.c.f
.sel.c create window 0 0 -anchor nw -window .sel.c.f
set f .sel.c.f
#label $f.banner -text "Sample simulations:" -bg $colors(banner) -relief groove -font $fonts(bold)
#pack $f.banner -fill x -side top
foreach i $samples {
if {$db($i,type)=="spacer"} {
frame $f.$i -relief flat
pack $f.$i -fill x -side top -pady 5
} elseif {$db($i,type)=="heading"} {
label $f.$i -text $db($i,title) -bg $colors(banner) -relief groove -font $fonts(bold)
pack $f.$i -fill x -side top -padx 5 -pady 5
} elseif {$db($i,type)=="readme" || $db($i,type)=="docu" || $db($i,type)=="program"} {
button $f.$i -text $db($i,title) -bd 1 -command "showDemo $i"
pack $f.$i -fill x -side top -padx 5 -pady 2
} else {
tk_messageBox -title {Error} -type ok -icon error -message "internal error: wrong type '$db($i,type)'"
exit
}
}
update
.sel.c config -width [winfo width .sel.c.f]
.sel.c config -scrollregion "0 0 0 [winfo height .sel.c.f]"
showDemo $first
}
proc helpAbout {} {
tk_messageBox -title {About} -type ok -icon info -message {Demo simulations for OMNEST/OMNeT++.}
}
proc showDemo {sample} {
global samples db colors tcl_platform
set f .sel.c.f
foreach i $samples {
if {$db($i,type)=="readme" || $db($i,type)=="docu" || $db($i,type)=="program"} {
$f.$i config -relief raised -bg $colors(unselbutton)
}
}
$f.$sample config -relief sunken -bg $colors(selbutton)
if {$db($sample,type)=="readme"} {
.main.up.banner config -text "$db($sample,title)"
pack forget .main.lo
loadFile .main.mid.text $db($sample,readme)
} elseif {$db($sample,type)=="docu"} {
.main.up.banner config -text "$db($sample,title)"
.main.lo.start config -text "Open documentation\n($db($sample,docu))"
.main.lo.start config -command "openDocu $sample"
pack forget .main.lo
pack .main.lo -expand 0 -fill x -side bottom -before .main.mid
loadFile .main.mid.text $db($sample,readme)
} elseif {$db($sample,type)=="program"} {
if {$tcl_platform(platform)=="unix"} {
set cmd "cd $db($sample,dir); $db($sample,uprog)"
} else {
set cmd "cd $db($sample,dir); $db($sample,wprog)"
}
.main.up.banner config -text "$db($sample,title) README"
.main.lo.start config -text "Launch $db($sample,title)\n($cmd)"
.main.lo.start config -command "runSample $sample"
pack forget .main.lo
pack .main.lo -expand 0 -fill x -side bottom -before .main.mid
loadFile .main.mid.text "$db($sample,dir)/README"
} else {
tk_messageBox -title {Error} -type ok -icon error -message "internal error: wrong type '$db($sample,type)'"
exit
}
}
proc loadFile {t filename} {
$t delete 1.0 end
if [catch {
# try with ".txt" suffix as well
if [catch {set f [open $filename r]}] {set f [open "$filename.txt" r]}
set contents [read $f]
close $f
} err] {
#tk_messageBox -title {OMNeT++ Demo} -type ok -icon error -message "Cannot display README: $err"
return
}
$t insert end $contents
$t mark set insert 1.0
}
proc runSample {sample} {
global samples db tcl_platform
if {$tcl_platform(platform) == "unix"} {
set prog $db($sample,uprog)
} else {
set prog "cmd /c $db($sample,wprog)"
}
set pwd [pwd]
if [catch {
cd $db($sample,dir)
#exec $prog &
#exec [lindex $prog 0] [lindex $prog 1] [lrange $prog 2 end] &
eval exec $prog &
} err] {
tk_messageBox -title {OMNeT++ Demo} -type ok -icon error -message "Error running the simulation program: $err"
}
cd $pwd
}
proc openDocu {sample} {
global samples db tcl_platform unixbrowser
if [catch {
if {$tcl_platform(platform) == "windows"} {
exec cmd.exe /c start $db($sample,docu)
} else {
exec $unixbrowser $db($sample,docu) &
}
} err] {
tk_messageBox -title {OMNeT++ Demo} -type ok -icon error -message "Error running the simulation program: $err"
}
}
#===================================================================
# GENERIC BINDINGS
#===================================================================
proc generic_bindings {} {
bind Button <Return> {tkButtonInvoke %W}
}
#===================================================================
# FONT BINDINGS
#===================================================================
proc font_bindings {} {
global fonts tcl_platform colors
set colors(banner) #e0e0a0
set colors(unselbutton) #c0c0c0
set colors(selbutton) #ffffff
set colors(startbutton) #e0e0a0
#
# fonts() array elements:
# normal: menus, labels etc
# bold: buttons
# icon: toolbar 'icons'
# big: STOP button
# msgname: message name during animation
# fixed: text windows and listboxes
#
if {$tcl_platform(platform) == "unix"} {
set fonts(normal) -Adobe-Helvetica-Medium-R-Normal-*-12-*-*-*-*-*-*-*
set fonts(bold) -Adobe-Helvetica-Bold-R-Normal-*-12-*-*-*-*-*-*-*
set fonts(icon) -Adobe-Times-Bold-I-Normal-*-12-*-*-*-*-*-*-*
set fonts(big) -Adobe-Helvetica-Medium-R-Normal-*-18-*-*-*-*-*-*-*
set fonts(msgname) -Adobe-Helvetica-Medium-R-Normal-*-12-*-*-*-*-*-*-*
set fonts(fixed) fixed
set fonts(balloon) -Adobe-Helvetica-Medium-R-Normal-*-12-*-*-*-*-*-*-*
} else {
# Windows, Mac
set fonts(normal) -Adobe-Helvetica-Medium-R-Normal-*-*-140-*-*-*-*-*-*
set fonts(bold) -Adobe-Helvetica-Bold-R-Normal-*-*-140-*-*-*-*-*-*
set fonts(icon) -Adobe-Helvetica-Bold-R-Normal-*-*-140-*-*-*-*-*-*
set fonts(big) -Adobe-Helvetica-Medium-R-Normal-*-*-180-*-*-*-*-*-*
set fonts(msgname) -Adobe-Helvetica-Medium-R-Normal-*-*-140-*-*-*-*-*-*
set fonts(fixed) FixedSys
set fonts(balloon) -Adobe-Helvetica-Medium-R-Normal-*-*-140-*-*-*-*-*-*
}
if {$tcl_platform(platform) == "unix"} {
option add *Scrollbar.width 12
option add *Menubutton.font $fonts(normal)
option add *Menu.font $fonts(normal)
option add *Label.font $fonts(normal)
option add *Entry.font $fonts(normal)
option add *Listbox.font $fonts(fixed)
option add *Text.font $fonts(fixed)
option add *Button.font $fonts(bold)
}
}
proc checkVersion {} {
global tk_version tk_patchLevel
catch {package require Tk}
if {$tk_version<8.0} {
wm deiconify .
wm title . "Bad news..."
frame .f
pack .f -expand 1 -fill both -padx 2 -pady 2
label .f.l1 -text "Your version of Tcl/Tk is too old!"
label .f.l2 -text "Tcl/Tk 8.0 or later required."
button .f.b -text "OK" -command {exit}
pack .f.l1 .f.l2 -side top -padx 5
pack .f.b -side top -pady 5
focus .f.b
wm protocol . WM_DELETE_WINDOW {exit}
tkwait variable ok
}
if {[string compare $tk_patchLevel "8.0p1"]<0} {
tk_messageBox -title {Warning} -type ok -icon warning \
-message {Old Tcl/Tk version. At least 8.0p1 is strongly recommended!}
}
}
set tk_strictMotif 1
cd [file dirname [info script]]
checkVersion
generic_bindings
font_bindings
createWindow