auto-pelab.ns 22.6 KB
Newer Older
Mike Hibler's avatar
Mike Hibler committed
1
#
2
# Copyright (c) 2006-2007 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Mike Hibler's avatar
Mike Hibler committed
22 23
#

24 25 26 27 28
source tb_compat.tcl

set ns [new Simulator]
$ns rtproto Static

29 30 31
##########
# Beginning of user-settable options

32
#
33 34
# If set to 1, doesn't allocate any real Plab nodes (or fake ones either).
# Attributes for the elab-* machines are taken from DB data for nodes in
35 36
# the plabnodes list. This can be used to implement the Simple-Static and
# Simple-Dynamic modes
37
#
38 39 40 41
# This option requires that you have nodes listed in plabnodes and forces
# use of the dbmonitor.
#
set no_plab 0
42

43
#
44 45
# This control how many _pairs_ of PCs there are. ie. 2 gets you 2 monitors in
# Emulab, plus matching agents in PlanetLab
46 47 48
#
set num_pcs 2

49 50 51 52
#
# If set to 1, we grab real PlanetLab nodes. Both this and fake_plab can be
# set at the same time
#
53
set real_plab 1
54

55
#
56 57
# If set to 1, we create a fake PlanetLab inside Emulab, so that we can run
# the agent in an environment we have full control over
58
#
59
set fake_plab 0
60 61

#
62
# If set to 1, we do automatic tcpdumps on all nodes
63 64 65
#
set trace 1

66 67 68 69 70 71 72 73 74 75 76 77
#
# If you want to get specific real planetlab nodes, ask for them here by site
# or by emulab node ID. 
# NOTES:
#   An empty list for either selection method turns it off
#   Do not use both site and node selection at the same time!
#   The list must be at least as long as num_pcs above, It can be longer, but
#     extra elements will be ignored
#   I recommend using the sites option, rather than the nodes option, since that
#     may get you less-loaded nodes and is more robust to crashed nodes
#   You can get a list of node IDs and sites at:
#     https://www.emulab.net/nodecontrol_list.php3?showtype=widearea
78 79 80
#   You can get a list of PlanetLab nodes that are known to be fairly reliable
#     and to have data from flexmon by running the 'goodnodes.pl' script in the
#     root directory of your Flexlab source
81 82 83 84 85 86 87 88 89 90 91
#   Site names are case-sensitive!
#

# Empty list
set plabsites {}
# Example site list
#set plabsites {UCB Stanford Cornell Jerusalem Taiwan}

# Empty list
set plabnodes {}
# Example node list
92
#set plabnodes {plab518 plab541 plab628 plab736 plab360}
93
set plabnodes {plab540 plab18}
94

95 96 97 98
#
# This provides you with an easy way to skip certain hosts in the above lists
# by index number
#
99 100 101 102 103
# Empty List
set skiplist {}
# Example list
#set skiplist {2 7}

104
#
105 106
# Where to grab your tarball of flexlab software from. See the README for
# instructions. Then put the path to your tarball in this variable.
107
#
108
set pelab_tar "/proj/tbres/CHANGEME.tar.gz"
109

110
#
111 112
# Hardare type to use for PCs inside of emulab - you can set to some other
# value, like "pc3000", to get specific types of PCs
113 114
#
set hwtype "pc"
115
set do_bsd 0
116

117 118
#
# Server and client to use for automated testing. If set, will automatically
119
# be started on all elab nodes by the 'start-experiment' script
120
#
121
if {$do_bsd} {
122
    set sstr "/usr/local/etc/emulab/emulab-iperf -s "
123
    # NOTE: No client support for now, you'll have to run the client yourself
124
    set cstr "/usr/local/etc/emulab/emulab-iperf -t 60 -c "
125
} else {
126
    set sstr "/usr/bin/iperf -s "
127
    # NOTE: No client support for now, you'll have to run the client yourself
128
    set cstr "/usr/bin/iperf -t 60 -c "
129
}
130 131 132 133 134 135 136
set serverprog $sstr
set clientprog $cstr

#
# Application to run automatically on all nodes (planet, plab or elab)
#
set allnodesprog "/bin/true"
137

138
#
139
# Run FreeBSD 6.1 on elab_ nodes.  Forces use of dbmonitor.
140 141
#

142
#
143 144 145
# If non-zero, uses the DB-based "monitor" to control the cloud shaping. This
# implements the Simple-Static and Simple-Dynamic network models (If this is
# not set, you get the regular monitor and agent, which implement ACIM)
146 147
#
set use_dbmonitor 0
148 149 150
if {$do_bsd} {
    set use_dbmonitor 1
}
151

152 153 154 155 156
#
# Use this to set a unique port so that you don't collide with others on the
# same node. Only supported when use_magent is set
#
set stub_port 3149
157
set udp_stub_peer_port 3492
158

159
        
160 161 162 163
######
# Options for the dbmonitor (simple models)
######

164
#
165 166 167 168
# If dbmonitor is set, these are the intervals at which the latency and BW
# data are sampled by bgmon on the plab nodes (zero means use the default).
# The smaller (shorter interval) of the two, is used as the interval at which
# dbmonitor polls the DB to get data recorded by bgmon.
169
#
170 171 172 173 174 175
set dbmonitor_latinterval 10
set dbmonitor_bwinterval 0

# Get these into the environment for dbmonitor to read
set opt(DBMONITOR_LATINTERVAL) $dbmonitor_latinterval
set opt(DBMONITOR_BWINTERVAL) $dbmonitor_bwinterval
176

177 178 179 180
######
# Options for Fake PlanetLab
######

181
#
182 183 184
# When using a fake plab, these are the parameters for the fake Internet
# 'cloud' connecting the plab nodes. For now, all nodes have the same
# parameters - hopefully this will change in a later version
185
#
186 187
set cloud_delay "30ms"
set cloud_bw "1.5Mbps"
188

189
#
190 191
# When using a fake plab, these are the parameters for the 'control'
# delay (ie. the latency for the elab nodes to reach the plab nodes
192
#
193 194
set control_delay "0ms"
set control_bw "100Mbps"
195

196 197 198
######
# Deprecated / Unsupported / Internal Options
######
199

200
#
201 202
# If set to 1, we trace on all end nodes instead of (or in addition to)
# all delay nodes above.
203
#
204 205 206 207 208
# XXX this option won't do anything right now.  If there are delay nodes
# involved for local LAN/clouds it is ignored, and as long as tracing is
# enabled, plab nodes will get end_node tracing anyway.
#
set trace_end_nodes 0
209

210
#
211 212
# These are the initial conditions for the 'elabc' cloud, the Emulab side of
# a pelab experiment
213
#
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
set ecloud_delay "0ms"
set ecloud_bw "100Mbps"

#
# If non-zero, limits the number of slots in the queues for the fake PlanetLab
#
set limit_fake_queue_slots 0

# XXX for internal use only
set no_stub 0

#
# If non-zero, uses the new stub (magent) instead of the old one
# If set to 1, uses the new stub as a receiver
# If set to 2, uses a separate iperfd to receive traffic
#
230
set use_magent 1
231

232 233 234
# End of user-settable options
##########

235 236 237
set pid ${GLOBALS::pid}
set eid ${GLOBALS::eid}

238
set delay_os FBSD54-DNODE
239

240 241 242 243
if {$do_bsd} {
    set node_os FBSD61-STD
} else {
    # XXX -UPDATE for now.  Contains bug fixes (progagent command lines).
244 245
    #set node_os PLAB-DEVBOX-UPDATE
    set node_os PLAB-DEVBOX
246
}
247 248 249

tb-set-delay-os $delay_os

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
#
# Enforce no_plab requirements
#
if {$no_plab} {
    set fake_plab 0
    set real_plab 0
# XXX don't force use of dbmonitor; may want to just use init_elabnodes.
#    set use_dbmonitor 1
    set use_magent 0
    set no_stub 1
}

#
# Enforce USE_DBMONITOR requirements
#
if {$use_dbmonitor} {
    set use_magent 0
    set no_stub 1
}

#
# Set up skiplist
#
for {set i 0} {$i < [llength $skiplist]} {incr i} {
    set skip([lindex $skiplist $i]) 1
}

277
set stub_peer_port $stub_port
278
set stub_command_port 3150
279

280 281 282 283
#
# Tarballs and RPMs we install on all nodes
#
set tarfiles "/local $pelab_tar"
284 285 286 287 288 289 290
set plab_rpms "/proj/tbres/auto-pelab/libpcap-0.8.3-3.i386.rpm /proj/tbres/auto-pelab/iperf-2.0.2-1.1.fc2.rf.i386.rpm"
if {$do_bsd} {
    set elab_rpms ""
} else {
    set elab_rpms "/proj/tbres/auto-pelab/libpcap-0.8.3-3.i386.rpm /proj/tbres/auto-pelab/iperf-2.0.2-1.1.fc2.rf.i386.rpm"
}

291 292 293 294 295 296
if {$do_bsd} {
    set elabshell "/bin/sh -T"
} else {
    set elabshell "/bin/sh"
}

297
if {$use_magent} {
298
    set stubcommand "/bin/sh /local/pelab/magent/auto-magent.sh --peerserverport=$stub_peer_port --monitorserverport=$stub_command_port"
299 300 301 302
    # XXX woeful, and hopefully temporary, hack
    if {$use_magent == 2} {
	set opt(MAGENT_NORECV) 1
    }
303 304 305
} else {
    set stubcommand "/bin/sh /local/pelab/stub/auto-stub.sh"
}
306 307 308

# we don't run dbmonitor on the nodes anymore
if {0 && $use_dbmonitor} {
309
    set moncommand "$elabshell /local/pelab/dbmonitor/auto-dbmonitor.sh"
310
} else {
311
    set moncommand "$elabshell /local/pelab/monitor/auto-monitor.sh --stub-port=$stub_command_port"
312
}
313

314 315 316 317 318 319
#
# So far, nothing I tried can get the auto-* scripts to return 0
# when interrupted
#
set ecode 15

320 321
set elan_string ""
set plan_string ""
322
set inet_string ""
323 324

set stublist {}
325 326
set planetstublist {}
set plabstublist {}
327
set monitorlist {}
328 329 330
set planetservers {}
set serverlist {}
set clientlist {}
Mike Hibler's avatar
Mike Hibler committed
331
set tflist {}
332
set anlist {}
333

334 335
set sanitychecklist {}

336 337 338
#
# Create all of the nodes
#
Mike Hibler's avatar
Mike Hibler committed
339
set tfix 1
340
set anix 1
341 342
for {set i 1} {$i <= $num_pcs} {incr i} {

343
    if {$real_plab && ![info exists skip($i)]} {
344
        set planet($i) [$ns node]
345
        tb-set-hardware $planet($i) pcplab
346
        append inet_string "$planet(${i}) "
347
        set planetstub($i) [$planet($i) program-agent -expected-exit-code $ecode -command $stubcommand]
348 349
        lappend stublist $planetstub($i)
        lappend planetstublist $planetstub($i)
350

351
        set plabsanitycheck($i) [$planet($i) program-agent -command "/local/pelab/run-sanity.sh vnet $planet($i) $stub_peer_port $udp_stub_peer_port"]
352 353 354

        lappend sanitychecklist $plabsanitycheck($i)

355
        tb-set-node-tarfiles $planet($i) $tarfiles
356
        tb-set-node-rpms $planet($i) $plab_rpms
357

358
        set tfupdate($tfix) [$planet($i) program-agent -command "sudo /usr/local/etc/emulab/update -it"]
Mike Hibler's avatar
Mike Hibler committed
359 360
	lappend tflist $tfupdate($tfix)
	incr tfix
361 362 363
	set allnodes($anix) [$planet($i) program-agent -command $allnodesprog]
	lappend anlist $allnodes($anix)
	incr anix
364 365 366 367 368 369 370 371

        if {[llength $plabsites] > 0} {
            set why_doesnt_tcl_have_concat "*&"
            append why_doesnt_tcl_have_concat [lindex $plabsites [expr $i - 1]]
            $planet($i) add-desire $why_doesnt_tcl_have_concat 1.0
        } elseif {[llength $plabnodes] > 0} {
            tb-fix-node $planet($i) [lindex $plabnodes [expr $i - 1]]
        }
372
    }
373

374 375
    if {$fake_plab} {
        set plab($i) [$ns node]
376
        tb-set-node-os $plab($i) $node_os
377 378
        tb-set-hardware $plab($i) $hwtype
        append plan_string "$plab(${i}) "
379
        set plabstub($i) [$plab($i) program-agent -expected-exit-code $ecode -command $stubcommand]
380 381 382 383
        lappend stublist $plabstub($i)
        lappend plabstublist $plabstub($i)

        tb-set-node-tarfiles $plab($i) $tarfiles
384
        tb-set-node-rpms $plab($i) $plab_rpms
385
        set tfupdate($tfix) [$plab($i) program-agent -command "sudo /usr/local/etc/emulab/update -it"]
Mike Hibler's avatar
Mike Hibler committed
386 387
	lappend tflist $tfupdate($tfix)
	incr tfix
388 389 390
	set allnodes($anix) [$plab($i) program-agent -command $allnodesprog]
	lappend anlist $allnodes($anix)
	incr anix
391
    }
392 393

    set elab($i) [$ns node]
394
    tb-set-node-os $elab($i) $node_os
395 396
    tb-set-hardware $elab($i) $hwtype
    append elan_string "$elab(${i}) "
397
    set monitor($i) [$elab($i) program-agent -expected-exit-code $ecode -command $moncommand]
398 399
    lappend monitorlist $monitor($i)

400 401
    set server($i) [$elab($i) program-agent -expected-exit-code $ecode -command $serverprog]
    set client($i) [$elab($i) program-agent -expected-exit-code $ecode -command $clientprog]
402 403 404
    lappend serverlist $server($i)
    lappend clientlist $client($i)

405
    set elabsanitycheck($i) [$elab($i) program-agent -command "/local/pelab/run-sanity.sh any $elab($i) "]
406 407 408

    lappend sanitychecklist $elabsanitycheck($i)

409
    tb-set-node-tarfiles $elab($i) $tarfiles
410 411 412
    if {$elab_rpms != ""} {
        tb-set-node-rpms $elab($i) $elab_rpms
    }
413
    set tfupdate($tfix) [$elab($i) program-agent -command "sudo /usr/local/etc/emulab/update -it"]
Mike Hibler's avatar
Mike Hibler committed
414 415
    lappend tflist $tfupdate($tfix)
    incr tfix
416 417 418
    set allnodes($anix) [$elab($i) program-agent -command $allnodesprog]
    lappend anlist $allnodes($anix)
    incr anix
419

420 421 422 423 424
    #
    # If the user has given a plabnodes list, we set up $opt variables so that
    # even if they are not actually using PlanetLab nodes, the simple model can
    # still see the mapping between elab and plab nodes
    #
425
    if {[llength $plabnodes] > 0 && ![info exists skip($i)]} {
426
        set opt(pelab-elab-$i-mapping) [lindex $plabnodes [expr $i - 1]]
427
    }
428 429
}

430 431
#
# Run the DB monitor on ops
432
# Intervals are passed via the environment.
433 434 435 436
#
if {$use_dbmonitor} {
    set dbmonitor [new Program $ns]
    $dbmonitor set node "ops"
437
    $dbmonitor set command "/usr/testbed/sbin/dbmonitor.pl $pid $eid"
438 439 440 441
    $dbmonitor set expected-exit-code $ecode
    set monitorlist $dbmonitor
}

442 443 444
#
# Set up groups to make it easy for us to start/stop program agents
#
445 446 447 448 449 450 451 452
if {$stublist != {}} {
    set stubgroup [$ns event-group $stublist]
    if {$real_plab} {
        set planetstubs [$ns event-group $planetstublist]
    }
    if {$fake_plab} {
        set plabstubs [$ns event-group $plabstublist]
    }
453
}
454
set monitorgroup [$ns event-group $monitorlist]
455 456 457

set allservers [$ns event-group $serverlist]
set allclients [$ns event-group $clientlist]
458

Mike Hibler's avatar
Mike Hibler committed
459
set tfhosts [$ns event-group $tflist]
460
set anhosts [$ns event-group $anlist]
461

462 463
set sanityCheckDumps [$ns event-group $sanitychecklist]

464
set tracelist {}
Mike Hibler's avatar
Mike Hibler committed
465

466 467 468 469
#
# Real Internet cloud for real plab nodes
#
if {$real_plab} {
470
    set realinternet [$ns make-lan "$inet_string" 100Mbps 0ms]
471
    tb-set-lan-protocol $realinternet ipv4
472
    if {$trace} {
473
	$realinternet trace header "tcp and port $stub_peer_port"
474 475 476 477 478
	if {$trace_end_nodes} {
	    $realinternet trace_endnode 1
	}
	lappend tracelist $realinternet
    }
479 480
}

481
#
482
# Fake 'Internet' cloud for fake plab nodes
483 484
#
if {$fake_plab} {
Robert Ricci's avatar
Robert Ricci committed
485
    set plabc [$ns make-cloud "$plan_string" $cloud_bw $cloud_delay]
486
    tb-set-ip-lan $plab(1) $plabc 10.1.0.1
487 488 489 490 491 492 493
    if {$trace} {
	$plabc trace
	if {$trace_end_nodes} {
	    $plabc trace_endnode 1
	}
	lappend tracelist $plabc
    }
494 495 496 497 498 499
    if {$limit_fake_queue_slots} {
        for {set i 1} {$i <= $num_pcs} {incr i} {
            set fakequeues($i) [[$ns lanlink $plabc $plab($i)] queue]
            $fakequeues($i) set limit_ $limit_fake_queue_slots
        }
    }
500 501 502 503 504
}

#
# Lan which will be controlled by the monitor
#
505
set elabc [$ns make-cloud "$elan_string" $ecloud_bw $ecloud_delay]
506
tb-set-ip-lan $elab(1) $elabc 10.0.0.1
507 508 509 510 511 512 513
if {$trace} {
    $elabc trace
    if {$trace_end_nodes} {
	$elabc trace_endnode 1
    }
    lappend tracelist $elabc
}
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528

#
# We don't want the sync server to end up out there on some plab node
#
tb-set-sync-server $elab(1)

#
# Set up a fake Internet link between the PlanetLab and Emulab sides
# when using fake plab nodes
#
if {$fake_plab} {
    set erouter [$ns node]
    set prouter [$ns node]

    set elabcontrol [$ns make-lan "$elan_string $erouter" 100Mbps 0ms]
529
    set plabcontrol [$ns make-lan "$plan_string $prouter" 100Mbps 0ms]
530 531

    set internet [$ns duplex-link $erouter $prouter $control_bw $control_delay DropTail]
532 533 534 535 536 537 538
    if {$trace} {
	$internet trace
	if {$trace_end_nodes} {
	    $internet trace_endnode 1
	}
	lappend tracelist $internet
    }
539 540

    tb-set-ip-lan $elab(1) $elabcontrol 192.168.0.1
541
    tb-set-ip-lan $plab(1) $plabcontrol 192.168.1.1
542 543 544 545 546

    tb-set-ip-link $erouter $internet 192.168.254.1
    tb-set-ip-link $prouter $internet 192.168.254.2
}

547
# for one-off ops commands
548 549 550 551 552 553 554 555 556 557 558 559 560
set opsagent [new Program $ns]
$opsagent set node "ops"
$opsagent set command "/bin/true"

#
# The set of traced links
# XXX still cannot use an event-group of link tracing events in a sequence
#
#set tracegroup [$ns event-group $tracelist]

#
# Build up the event sequences to start and stop an actual run.
#
561
if {$no_plab || $real_plab} {
562 563 564 565 566
  set start [$ns event-sequence]
    $start append "$ns log \"Starting REAL plab experiment\""

    # stop stubs and monitors
    $start append "$ns log \"##### Stopping stubs and monitors...\""
567
    if {!$no_stub && $real_plab} {
568 569
	$start append "$planetstubs stop"
    }
570 571 572
    $start append "$monitorgroup stop"

    # stop servers
573 574 575 576
    if {$serverprog != ""} {
	$start append "$ns log \"##### Stopping servers...\""
	$start append "$allservers stop"
    }
577 578 579 580 581 582 583 584

    # stop link logging
    $start append "$ns log \"##### Roll link trace logs...\""
    foreach link $tracelist {
        $start append "$link trace snapshot"
        $start append "$link trace stop"
    }

585 586
    $start append "$sanityCheckDumps stop"

587 588 589 590 591 592 593 594 595 596
    # clean out log files
    # XXX original script passed --root, cleanlogs does not--may be a problem.
    $start append "$ns log \"##### Cleaning logs...\""
    $start append "$ns cleanlogs"

    # reset shaping characteristics for all nodes
    $start append "$ns log \"##### Resetting links...\""
    $start append "$elabc clear"
    $start append "$elabc reset"

597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
    if {$real_plab} {
	# distinguish between real/fake runs
	# XXX I'm thinkin...we can do better than this!
	$start append "$opsagent run -command \"cp /dev/null /proj/$pid/exp/$eid/tmp/real_plab\""

	# save off node list
	$start append "$ns log \"##### Creating node list...\""
	$start append "$opsagent run -command \"/usr/testbed/bin/node_list -m -e $pid,$eid > /proj/$pid/exp/$eid/tmp/node_list\""

	# initialize path characteristics
	$start append "$ns log \"##### Initialize emulation node path characteristics...\""
	$start append "$elabc create"
	$start append "$opsagent run -command \"/usr/testbed/bin/init-elabnodes.pl  -o /proj/$pid/exp/$eid/tmp/initial-conditions.txt $pid $eid\""
    } else {
	$start append "$elabc create"
    }
613 614 615 616 617 618 619 620 621 622 623

    # restart link tracing
    # XXX cleanlogs has unlinked the current trace log, so we have to
    # snapshot to bring it back into existence
    $start append "$ns log \"##### Starting link tracing...\""
    foreach link $tracelist {
        $start append "$link trace snapshot"
        $start append "$link trace start"
    }

    # restart servers
624 625 626 627
    if {$serverprog != ""} {
	$start append "$ns log \"##### Starting server...\""
	$start append "$allservers start"
    }
628 629 630

    # restart stubs and monitors
    $start append "$ns log \"##### Starting stubs and monitors...\""
631
    if {!$no_stub && $real_plab} {
632 633
	$start append "$planetstubs start"
    }
634 635 636 637 638 639 640 641 642 643 644 645
    $start append "$monitorgroup start"

    # gather up the data and inform the user
    $start append "$ns log \"##### Experiment run started!\""
    # XXX cannot do a report here as that will cause the logs to be
    #     deleted before the next loghole sync

  set stop [$ns event-sequence]
    $stop append "$ns log \"Stopping REAL plab experiment\""

    # stop stubs and monitors
    $stop append "$ns log \"##### Stopping stubs and monitors...\""
646
    if {!$no_stub && $real_plab} {
647 648
	$stop append "$planetstubs stop"
    }
649 650 651
    $stop append "$monitorgroup stop"

    # stop servers
652 653 654 655
    if {$serverprog != ""} {
	$stop append "$ns log \"##### Stopping servers...\""
	$stop append "$allservers stop"
    }
656

657 658
    $stop append "$sanityCheckDumps stop"

659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
    # stop link logging and save logs
    $stop append "$ns log \"##### Stop link tracing...\""
    foreach link $tracelist {
        $stop append "$link trace snapshot"
        $stop append "$link trace stop"
    }

    # reset shaping characteristics for all nodes
    $stop append "$ns log \"##### Resetting links...\""
    $stop append "$elabc clear"
    $stop append "$elabc reset"

    # gather up the data and inform the user
    $stop append "$ns log \"##### Experiment run stopped!\""
    $stop append "$ns report"
}

#
# Build up the event sequences to start and stop an actual run on FAKE
# plab nodes.  The only difference here (besides the names) is that these
# sequences use plabstubs rather than planetstubs.
#
if {$fake_plab} {
  set start_fake [$ns event-sequence]
    $start_fake append "$ns log \"Starting FAKE plab experiment\""

    # stop stubs and monitors
    $start_fake append "$ns log \"##### Stopping stubs and monitors...\""
687 688 689
    if {!$no_stub} {
	$start_fake append "$plabstubs stop"
    }
690 691 692
    $start_fake append "$monitorgroup stop"

    # stop servers
693 694 695 696
    if {$serverprog != ""} {
	$start_fake append "$ns log \"##### Stopping servers...\""
	$start_fake append "$allservers stop"
    }
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732

    # stop link logging
    $start_fake append "$ns log \"##### Roll link trace logs...\""
    foreach link $tracelist {
        $start_fake append "$link trace snapshot"
        $start_fake append "$link trace stop"
    }

    # clean out log files
    # XXX original script passed --root, cleanlogs does not--may be a problem.
    $start_fake append "$ns log \"##### Cleaning logs...\""
    $start_fake append "$ns cleanlogs"

    # reset shaping characteristics for all nodes
    $start_fake append "$ns log \"##### Resetting links...\""
    $start_fake append "$elabc clear"
    $start_fake append "$elabc reset"

    # distinguish between real/fake runs
    # XXX I'm thinkin...we can do better than this!
    $start_fake append "$opsagent run -command \"rm -f /proj/$pid/exp/$eid/tmp/real_plab\""

    # save off node list
    $start_fake append "$ns log \"##### Creating node list...\""
    $start_fake append "$opsagent run -command \"/usr/testbed/bin/node_list -m -e $pid,$eid > /proj/$pid/exp/$eid/tmp/node_list\""

    # restart link tracing
    # XXX cleanlogs has unlinked the current trace log, so we have to
    # snapshot to bring it back into existence
    $start_fake append "$ns log \"##### Starting link tracing...\""
    foreach link $tracelist {
        $start_fake append "$link trace snapshot"
        $start_fake append "$link trace start"
    }

    # restart servers
733 734 735 736
    if {$serverprog != ""} {
	$start_fake append "$ns log \"##### Starting server...\""
	$start_fake append "$allservers start"
    }
737 738 739

    # restart stubs and monitors
    $start_fake append "$ns log \"##### Starting stubs and monitors...\""
740 741 742
    if {!$no_stub} {
	$start_fake append "$plabstubs start"
    }
743 744 745 746 747 748 749 750 751 752 753 754
    $start_fake append "$monitorgroup start"

    # gather up the data and inform the user
    $start_fake append "$ns log \"##### Experiment run started!\""
    # XXX cannot do a report here as that will cause the logs to be
    #     deleted before the next loghole sync

  set stop_fake [$ns event-sequence]
    $stop_fake append "$ns log \"Stopping FAKE plab experiment\""

    # stop stubs and monitors
    $stop_fake append "$ns log \"##### Stopping stubs and monitors...\""
755 756 757
    if {!$no_stub} {
	$stop_fake append "$plabstubs stop"
    }
758 759 760
    $stop_fake append "$monitorgroup stop"

    # stop servers
761 762 763 764
    if {$serverprog != ""} {
	$stop_fake append "$ns log \"##### Stopping servers...\""
	$stop_fake append "$allservers stop"
    }
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782

    # stop link logging and save logs
    $stop_fake append "$ns log \"##### Stop link tracing...\""
    foreach link $tracelist {
        $stop_fake append "$link trace snapshot"
        $stop_fake append "$link trace stop"
    }

    # reset shaping characteristics for all nodes
    $stop_fake append "$ns log \"##### Resetting links...\""
    $stop_fake append "$elabc clear"
    $stop_fake append "$elabc reset"

    # gather up the data and inform the user
    $stop_fake append "$ns log \"##### Experiment run stopped!\""
    $stop_fake append "$ns report"
}

783
$ns run