diff options
Diffstat (limited to 'libarcfire.py')
-rwxr-xr-x | libarcfire.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libarcfire.py b/libarcfire.py new file mode 100755 index 0000000..0402b30 --- /dev/null +++ b/libarcfire.py @@ -0,0 +1,62 @@ +# +# A library to manage ARCFIRE experiments +# + +# Base class for DIFs +# +# @name [string] DIF name +# @members [iterable] Nodes belonging to the DIF +# +class DIF: + def __init__(self, name, members): + self.name = name + self.members = set() if members == None else set(members) + + def __repr__(self): + return "%s: %s" % (self.name, str(sorted(self.members))) + + def node_add(node_name): + self.members.add(node_name) + + def node_del(node_name): + self.members.discard(node_name) + + +# Shim over Ethernet +# +# @link_speed [int] Speed of the Ethernet network, in Mbps +# +class ShimEthDIF(DIF): + def __init__(self, name, link_speed = 0, members = None): + 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") + + +# Base class for ARCFIRE experiments +# +# @name [string] Name of the experiment +# +class Experiment: + def __init__(self, name): + self.name = name + self.difs = dict() + + def __repr__(self): + s = "%s:" % self.name + for d in self.difs: + s += "\n %s" % self.difs[d] + + return s + + def dif_add(self, dif): + self.difs[dif.name] = dif + + def dif_del(self, dif_name): + del self.difs[dif_name] + + def run(self): + print("[experiment %s] start" % self.name) + print("[experiment %s] end" % self.name) + |