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
|
#!/usr/bin/env python
"""
Example using the Ouroboros-aligned layer-centric API.
Shows the naming conventions: Layer, UnicastLayer, EthDixLayer, etc.
"""
from rumba.model import *
from rumba.utils import ExperimentManager
# import testbed plugins
import rumba.testbeds.local as local
# import prototype plugins
import rumba.prototypes.ouroboros as our
import rumba.log as log
log.set_logging_level('DEBUG')
# -----------------------------------------------------------------------
# Layer-centric syntax
# -----------------------------------------------------------------------
# Define layers
top = UnicastLayer("top")
mid = UnicastLayer("mid")
top.add_policy("rmt.pff", "lfa")
# Ethernet layers model point-to-point links
e1 = EthDixLayer("e1")
e2 = EthDixLayer("e2")
e3 = EthDixLayer("e3")
# Define nodes and their layer memberships + registrations
a = Node("a",
layers=[top, mid, e1, e2],
registrations={mid: [e1, e2],
top: [mid]})
b = Node("b",
layers=[mid, e1, e3],
registrations={mid: [e1, e3],
})
c = Node("c",
layers=[top, mid, e2, e3],
registrations={mid: [e2, e3],
top: [mid]})
# Create testbed and experiment
tb = local.Testbed(exp_name="layer-example")
exp = our.Experiment(tb, nodes=[a, b, c])
print(exp)
# Use properties from the API
for layer in exp.layer_ordering:
print("Layer: %s (type=%s, is_eth=%s, is_shim=%s)" % (
layer.name, layer.layer_type.value, layer.is_eth, layer.is_shim))
with ExperimentManager(exp):
exp.swap_in()
exp.install_prototype()
exp.bootstrap_prototype()
|