nstb_compat.tcl 9.28 KB
Newer Older
1
# -*- tcl -*-
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{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/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23 24
#

25 26 27
# This is a nop tb_compact.tcl file that should be used when running scripts
# under ns.

28
namespace eval GLOBALS {
29
    variable elabinelab_fw_type "ipfw2-vlan"
30
    variable security_level 0
31 32 33
    variable pid {}
    variable gid {}
    variable eid {}
34 35
}

36 37 38 39
proc tb-set-ip {node ip} {}
proc tb-set-ip-interface {src dst ip} {}
proc tb-set-ip-link {src link ip} {}
proc tb-set-ip-lan {src lan ip} {}
40
proc tb-set-netmask {lanlink netmask} {}
41 42
proc tb-set-node-service {service args} {}
proc tb-add-node-service-hook {service args} {}
43
proc tb-set-hardware {node type args} {}
44
proc tb-set-node-os {node os {parentos 0}} {}
45
proc tb-set-node-loadlist {node loadlist} {}
46 47 48 49 50 51
proc tb-set-link-loss {src args} {}
proc tb-set-lan-loss {lan rate} {}
proc tb-set-node-rpms {node args} {}
proc tb-set-node-startup {node cmd} {}
proc tb-set-node-cmdline {node cmd} {}
proc tb-set-node-tarfiles {node args} {}
52
proc tb-set-tarfiles {args} {}
53 54 55 56 57 58 59 60 61 62 63 64
proc tb-set-node-lan-delay {node lan delay} {}
proc tb-set-node-lan-bandwidth {node lan bw} {}
proc tb-set-node-lan-loss {node lan loss} {}
proc tb-set-node-lan-params {node lan delay bw loss} {}
proc tb-set-node-failure-action {node type} {}
proc tb-set-ip-routing {type} {}
proc tb-fix-node {v p} {}
proc tb-make-weighted-vtype {name weight types} {}
proc tb-make-soft-vtype {name types} {}
proc tb-make-hard-vtype {name types} {}
proc tb-set-lan-simplex-params {lan node todelay tobw toloss fromdelay frombw fromloss} {}
proc tb-set-link-simplex-params {link src delay bw loss} {}
65
proc tb-set-uselatestwadata {onoff} {}
66
proc tb-set-usewatunnels {onoff} {}
67
proc tb-set-wasolver-weights {delay bw plr} {}
68 69
proc tb-use-endnodeshaping {onoff} {}
proc tb-force-endnodeshaping {onoff} {}
70
proc tb-set-node-memory-size {node mem} {}
71 72 73
proc tb-set-multiplexed {link onoff} {}
proc tb-set-endnodeshaping {link onoff} {}
proc tb-set-noshaping {link onoff} {}
74
proc tb-set-useveth {link onoff} {}
75
proc tb-set-link-encap {link style} {}
76
proc tb-set-fw-style {vnode style} {}
77 78
proc tb-set-allowcolocate {lanlink onoff} {}
proc tb-set-colocate-factor {factor} {}
79
proc tb-set-sync-server {node} {}
Leigh Stoller's avatar
Leigh Stoller committed
80
proc tb-set-node-usesharednode {node} {}
81 82 83 84
proc tb-set-mem-usage {usage} {}
proc tb-set-cpu-usage {usage} {}
proc tb-bind-parent {sub phys} {}
proc tb-fix-current-resources {onoff} {}
85
proc tb-set-encapsulate {onoff} {}
86
proc tb-set-vlink-emulation {style} {}
87
proc tb-set-sim-os {os} {}
88
proc tb-set-jail-os {os} {}
89
proc tb-set-link-layer {link layer} {}
90
proc tb-set-delay-os {os} {}
91
proc tb-set-delay-capacity {cap} {}
92 93
proc tb-use-ipassign {onoff} {}
proc tb-set-ipassign-args {args} {}
94
proc tb-set-lan-protocol {lanlink protocol} {}
95
proc tb-set-link-protocol {lanlink protocol} {}
96
proc tb-set-switch-fabric {lanlink fabric} {}
97 98 99
proc tb-set-lan-accesspoint {lanlink node} {}
proc tb-set-lan-setting {lanlink capkey capval} {}
proc tb-set-node-lan-setting {lanlink node capkey capval} {}
100 101 102 103
proc tb-use-physnaming {onoff} {}
proc tb-feedback-vnode {vnode hardware args} {}
proc tb-feedback-vlan {vnode lan args} {}
proc tb-feedback-vlink {link args} {}
104
proc tb-elab-in-elab {onoff} {}
105 106 107
proc tb-elab-in-elab-topology {topo} {}
proc tb-set-inner-elab-eid {eid} {}
proc tb-set-elabinelab-cvstag {cvstag} {}
108
proc tb-elabinelab-singlenet {{onoff 1}} {}
109 110 111 112
proc tb-set-elabinelab-attribute {key val {order 0}} {}
proc tb-unset-elabinelab-attribute {key} {}
proc tb-set-elabinelab-role-attribute {role key val {order 0}} {}
proc tb-unset-elabinelab-role-attribute {role key} {}
113 114 115 116 117
proc tb-set-node-inner-elab-role {node role} {}
proc tb-set-node-id {vnode myid} {}
proc tb-set-link-est-bandwidth {srclink args} {}
proc tb-set-lan-est-bandwidth {lan bw} {}
proc tb-set-node-lan-est-bandwidth {node lan bw} {}
118 119 120 121 122
proc tb-set-link-backfill {srclink args} {}
proc tb-set-link-simplex-backfill {link src bw} {}
proc tb-set-lan-backfill {lan bw} {}
proc tb-set-node-lan-backfill {node lan bw} {}
proc tb-set-lan-simplex-backfill {lan node tobw frombw} {}
123
proc tb-set-node-plab-role {node role} {}
124
proc tb-set-node-plab-plcnet {node lanlink} {}
125
proc tb-set-nonfs {onoff} {}
126
proc tb-set-dpdb {onoff} {}
127
proc tb-fix-interface {vnode lanlink iface} {}
Leigh Stoller's avatar
Leigh Stoller committed
128 129
proc tb-set-node-usesharednode {node weight} {}
proc tb-set-node-sharingmode {node sharemode} {}
130
proc tb-set-node-routable-ip {node onoff} {}
131

Xing Lin's avatar
Xing Lin committed
132 133 134 135 136 137
#add for OML
proc tb-set-use-oml {args} {}
proc tb-set-oml-server {node} {}
proc tb-set-oml-mp {args} {}
proc tb-set-oml-use-control {args} {}

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
proc tb-set-security-level {level} {

    switch -- $level {
	"Green" {
	    set level 0
	}
	"Blue" {
	    set level 1
	}
	"Yellow" {
	    set level 2
	}
	"Orange" {
	    set level 3
	}
	"Red" {
	    perror "\[tb-set-security-level] Red security not implemented yet"
	    return
	}
	unknown {
	    perror "\[tb-set-security-level] $level is not a valid level"
	    return
	}
    }
    set ::GLOBALS::security_level $level
}

165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
#
# Set firewall type for firewalled elabinelab experiments
#
proc tb-set-elabinelab-fw-type {type} {

    switch -- $type {
        "ipfw2-vlan" {
            set type "ipfw2-vlan"
        }
        "iptables-vlan" {
            set type "iptables-vlan"
        }
        unknown  {
            perror "\[tb-set-elabinelab-fw-type] $type is not a valid type"
            return
        }
    }
    set ::GLOBALS::elabinelab_fw_type $type
}

Timothy Stack's avatar
Timothy Stack committed
185 186 187 188 189 190 191 192 193 194
#
# Set the startup command for a node. Replaces the tb-set-node-startup
# command above, but we have to keep that one around for a while. This
# new version dispatched to the node object, which uses a program object.
# 
proc tb-set-node-startcmd {node command} {
    if {[$node info class] != "Node"} {
	perror "\[tb-set-node-startcmd] $node is not a node."
	return
    }
195
    set command "($command ; /usr/local/etc/emulab/startcmddone \$?)"
Timothy Stack's avatar
Timothy Stack committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
    set newprog [$node start-command $command]

    return $newprog
}

#
# Create a program object to run on the node when the experiment starts.
#
Node instproc start-command {command} {
    global hosts

    $self instvar sim
    set newname "$hosts($self)_startcmd"

    set newprog [uplevel 2 "set $newname [new Program]"]
    $newprog set node $self
    $newprog set command $command

    return $newprog
}

217 218
Class Program

219 220 221
Program instproc init {args} {
}

222 223 224
Program instproc unknown {m args} {
}

225 226 227 228 229 230 231 232
Class Disk

Disk instproc init {args} {
}

Disk instproc unknown {m args} {
}

233 234
Class Firewall

235
Firewall instproc init {sim args} {
236
    global last_fw
237 238 239 240
    global last_fw_node
    real_set tmp [$sim node]
    real_set last_fw $self
    real_set last_fw_node $tmp
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
}

Firewall instproc unknown {m args} {
}

Class EventSequence

EventSequence instproc init {args} {
}

EventSequence instproc unknown {m args} {
}

Class EventTimeline

EventTimeline instproc init {args} {
}

EventTimeline instproc unknown {m args} {
}

Class EventGroup

EventGroup instproc init {args} {
}

EventGroup instproc unknown {m args} {
}

Class Console -superclass Agent

Console instproc init {args} {
}

Console instproc unknown {m args} {
}

Topography instproc load_area {args} {
}

Topography instproc checkdest {args} {
    return 1
}

285 286 287 288 289 290
Class Bridge -superclass Node

Simulator instproc bridge {args} {
    return [new Bridge]
}

291 292 293 294 295 296 297 298 299 300 301 302 303
Class NSENode -superclass Node

NSENode instproc make-simulated {args} {
    uplevel 1 eval $args
}

# We are just syntax checking the NS file
Simulator instproc run {args} {
}

Simulator instproc nsenode {args} {
    return [new NSENode]
}
Shashi Guruprasad's avatar
Shashi Guruprasad committed
304 305 306 307

Simulator instproc make-simulated {args} {
    uplevel 1 eval $args
}
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326

Simulator instproc event-sequence {args} {
    $self instvar id_counter

    incr id_counter
    return [new EventSequence]
}

Simulator instproc event-timeline {args} {
    $self instvar id_counter

    incr id_counter
    return [new EventTimeline]
}

Simulator instproc event-group {args} {
    return [new EventGroup]
}

327 328
Simulator instproc make-cloud {nodes bw delay args} {
    return [$self make-lan $nodes $bw $delay]
329 330
}

331 332 333
Simulator instproc make-path {linklist} {
}

334 335 336
Simulator instproc make-portinvlan {node token} {
}

337 338 339 340
Simulator instproc make-san {nodelist} {
    return [$self make-lan $nodelist ~ 0ms]
}

341 342 343 344
Simulator instproc blockstore {args} {
    return [$self node]
}

345 346 347 348 349 350 351 352 353 354
Node instproc program-agent {args} {
}

Node instproc topography {args} {
}

Node instproc console {} {
    return [new Console]
}

355 356 357
Node instproc unknown {m args} {
}

358 359 360
Simulator instproc connect {src dst} {
}

361
Simulator instproc define-template-parameter {name args} {
362
    # install the name/value in the outer environment.
363
    set value [lindex $args 0]    
364
    uplevel 1 set \{$name\} \{$value\}
365 366
}

367 368 369 370 371
LanNode instproc trace {args} {
}

LanNode instproc trace_endnode {args} {
}
Timothy Stack's avatar
Timothy Stack committed
372

373 374 375
LanNode instproc implemented_by {args} {
}

Timothy Stack's avatar
Timothy Stack committed
376 377
LanNode instproc unknown {m args} {
}