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
|
#
# A library to manage ARCFIRE experiments
#
# Sander Vrijders <sander.vrijders@intec.ugent.be>
# Vincenzo Maffione <v.maffione@nextworks.it>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA
import emulab_support as es
import jfed_support as js
import abc
import getpass
import ouroboros_support as our
# Represents generic testbed info
#
# @username [string] user name
# @password [string] password
# @proj_name [string] project name
# @exp_name [string] experiment name
#
class Testbed:
def __init__(self, exp_name, username, password, proj_name):
self.username = username
self.password = password
self.proj_name = proj_name
self.exp_name = exp_name
@abc.abstractmethod
def create_experiment(self, nodes, links):
return
# Represents an emulab testbed info
#
# @url [string] URL of the testbed
# @image [string] specific image to use
#
class EmulabTestbed:
def __init__(self, exp_name, username, password = "",
proj_name = "ARCFIRE", url = "wall1.ilabt.iminds.be",
image = "UBUNTU14-64-STD"):
Testbed.__init__(self, exp_name, username, password, proj_name)
self.url = url
self.image = image
def create_experiment(self, nodes, links):
es.create_experiment(self, nodes, links)
es.swap_exp_in(self)
es.wait_until_nodes_up(self)
es.complete_experiment_graph(self, nodes, links)
class jFedTestbed:
def __init__(self, exp_name, username, cert_file, jfed_jar, exp_hours = "2",
proj_name = "ARCFIRE", authority = "wall2.ilabt.iminds.be"):
passwd = getpass.getpass(prompt = "Password for certificate file: ")
Testbed.__init__(self, exp_name, username, passwd, proj_name)
self.authority = "urn:publicid:IDN+" + authority + "+authority+cm"
self.auth_name = authority
self.cert_file = cert_file
self.jfed_jar = jfed_jar
self.exp_hours = exp_hours
def create_experiment(self, nodes, links):
js.create_experiment(self, nodes, links)
# Represents an interface on a node
#
# @name [string] interface name
# @ip [int] IP address of that interface
#
class Interface:
def __init__(self, name = "", ip = ""):
self.name = name
self.ip = ip
# Represents a link in the physical graph
#
# @name [string] Link name
#
class Link:
def __init__(self, name):
self.name = name
# Represents a point-to-point link in the physical graph
#
# @name [string] DIF name
#
class P2PLink(Link):
def __init__(self, name, node_a, node_b,
int_a = Interface(),
int_b = Interface()):
Link.__init__(self, name)
self.node_a = node_a
self.node_b = node_b
self.int_a = int_a
self.int_b = int_b
def get_links(nodes):
difs = set()
links = list()
for node in nodes:
for dif in node.difs:
if type(dif) is ShimEthDIF:
difs.add(dif)
for dif in difs:
# Point-to-point link
if len(dif.members) == 2:
node_a = dif.members[0]
node_b = dif.members[1]
link = P2PLink(node_a.name + "-" + node_b.name,
node_a, node_b)
links.append(link)
return links
# Base class for DIFs
#
# @name [string] DIF name
#
class DIF:
def __init__(self, name, members = list()):
self.name = name
self.members = members
def __repr__(self):
s = "DIF %s" % self.name
return s
def add_member(self, node):
self.members.append(node)
def del_member(self, node):
self.members.remove(node)
# Shim over UDP
#
class ShimUDPDIF(DIF):
def __init__(self, name, members = list()):
DIF.__init__(self, name, members)
# Shim over Ethernet
#
# @link_speed [int] Speed of the Ethernet network, in Mbps
#
class ShimEthDIF(DIF):
def __init__(self, name, members = list(), link_speed = 0):
DIF.__init__(self, name, members)
self.link_speed = int(link_speed)
if self.link_speed < 0:
raise ValueError("link_speed must be a non-negative number")
# Normal DIF
#
# @policies [dict] Policies of the normal DIF
#
class NormalDIF(DIF):
def __init__(self, name, members = list(), policies = dict()):
DIF.__init__(self, name, members)
self.policies = policies
def add_policy(self, comp, pol):
self.policies[comp] = pol
def del_policy(self, comp):
del self.policies[comp]
def __repr__(self):
s = DIF.__repr__(self)
for comp, pol in self.policies.items():
s += "\n Component %s has policy %s" % (comp, pol)
return s
# A node in the experiment
#
# @difs: DIFs the node will have an IPCP in
# @dif_registrations: Which DIF is registered in which DIF
# @registrations: Registrations of names in DIFs
# @bindings: Binding of names on the processing system
#
class Node:
def __init__(self, name, difs = list(),
dif_registrations = dict(),
registrations = dict(),
bindings = dict()):
self.name = name
self.difs = difs
for dif in difs:
dif.add_member(self)
self.dif_registrations = dif_registrations
self.registrations = registrations
self.bindings = bindings
self.full_name = name
def __repr__(self):
s = "Node " + self.name + ":\n"
s += " IPCPs in DIFs: ["
for d in self.difs:
s += " %s" % d.name
s += " ]\n"
s += " DIF registrations: [ "
for dif_a, difs in self.dif_registrations.items():
s += "%s => [" % dif_a.name
for dif_b in difs:
s += " %s" % dif_b.name
s += " ]"
s += " ]\n"
s += " Name registrations: [ "
for name, difs in self.registrations.items():
s += "%s => [" % name
for dif in difs:
s += " %s" % dif.name
s += " ]"
s += " ]\n"
s += " Bindings: [ "
for ap, name in self.bindings.items():
s += "'%s' => '%s'" % (ap, name)
s += " ]\n"
return s
def add_dif(self, dif):
self.difs.append(dif)
dif.add_member(self)
def del_dif(self, dif):
self.difs.remove(dif)
dif.del_member(self)
def add_dif_registration(self, dif_a, dif_b):
self.dif_registrations[dif_a].append(dif_b)
def del_dif_registration(self, dif_a, dif_b):
self.dif_registrations[dif_a].remove(dif_b)
def add_registration(self, name, dif):
self.dif_registrations[name].append(dif)
def del_registration(self, name, dif):
self.dif_registrations[name].remove(dif)
def add_binding(self, name, ap):
self.dif_bindings[name] = ap
def del_binding(self, name):
del self.dif_bindings[name]
# Base class for ARCFIRE experiments
#
# @name [string] Name of the experiment
# @nodes: Nodes in the experiment
#
class Experiment:
def __init__(self, testbed, nodes = list()):
self.nodes = nodes
self.testbed = testbed
def __repr__(self):
s = ""
for n in self.nodes:
s += "\n" + str(n)
return s
def add_node(self, node):
self.nodes.append(node)
def add_node(self, node):
self.nodes.remove(node)
# Realize the experiment topology, using a testbed-specific setup
def realize(self):
self.links = get_links(self.nodes)
self.testbed.create_experiment(self.nodes, self.links)
@abc.abstractmethod
def run(self):
raise Exception('run() method not implemented')
# An experiment over the IRATI implementation
class IRATIExperiment(Experiment):
def __init__(self, testbed, nodes = list()):
Experiment.__init__(self, testbed, nodes)
def run(self):
print("[IRATI experiment] start")
self.realize()
print("[IRATI experiment] end")
# An experiment over the RLITE implementation
class RLITEExperiment(Experiment):
def __init__(self, testbed, nodes = list()):
Experiment.__init__(self, testbed, nodes)
def run(self):
print("[RLITE experiment] start")
self.realize()
print("[RLITE experiment] end")
# An experiment over the Ouroboros implementation
class OuroborosExperiment(Experiment):
def __init__(self, testbed, nodes = list()):
Experiment.__init__(self, testbed, nodes)
def run(self):
print("[Ouroboros experiment] start")
print("Creating resources...")
self.realize()
print("Setting up Ouroboros...")
our.setup_ouroboros(self.testbed, self.nodes)
print("Binding names...")
our.bind_names(self.testbed, self.nodes)
print("[Ouroboros experiment] end")
|