From 05a6aae466d9e014d2b7b7b4835360eb808e5e1f Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 11 Apr 2017 16:38:41 +0200 Subject: prototypes: ouroboros: Implement all commands This will implement all the commands necessary for bootstrapping a network that runs Ouroboros. APs are be bound to a name, IPCPs either bootstrapped or enrolled, and names registered in DIFs. --- rumba/prototypes/ouroboros.py | 96 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py index 4f78361..00fdb6b 100644 --- a/rumba/prototypes/ouroboros.py +++ b/rumba/prototypes/ouroboros.py @@ -20,6 +20,7 @@ import rumba.ssh_support as ssh import rumba.model as mod +import time # An experiment over the Ouroboros implementation class Experiment(mod.Experiment): @@ -32,7 +33,7 @@ class Experiment(mod.Experiment): cmds.append("sudo apt-get update") cmds.append("sudo apt-get install cmake protobuf-c-compiler git --yes") cmds.append("sudo rm -r ~/ouroboros/build") - cmds.append("cd ~/ouroboros; sudo ./install_release.sh") + cmds.append("cd ~/ouroboros; sudo ./install_debug.sh /") cmds.append("sudo nohup irmd > /dev/null &") for node in self.nodes: @@ -47,13 +48,98 @@ class Experiment(mod.Experiment): cmds.append("irm b ap " + ap + " n " + name) ssh.execute_commands(self.testbed, node.full_name, - cmds, time_out=None) + cmds, time_out = None) + + def reg_names(self): + for node in self.nodes: + cmds = list() + for name, difs in node.registrations.items(): + cmd = "irm r n " + name + for dif in difs: + cmd += " dif " + dif.name + cmds.append(cmd) + + ssh.execute_commands(self.testbed, node.full_name, cmds, + time_out = None) + + def create_ipcps(self): + for node in self.nodes: + cmds = list() + for ipcp in node.ipcps: + cmds2 = list() + if ipcp.dif_bootstrapper == True: + cmd = "irm i b n " + ipcp.name + else: + cmd = "irm i c n " + ipcp.name + + if type(ipcp.dif) is mod.ShimEthDIF: + # NOTE: Here to test with fake testbed + if ipcp.ifname is None: + ipcp.ifname = "eth0" + cmd += " type shim-eth-llc if_name " + ipcp.ifname + cmd += " dif " + ipcp.dif.name + elif type(ipcp.dif) is mod.NormalDIF: + cmd += " type normal" + if ipcp.dif_bootstrapper == True: + cmd += " dif " + ipcp.dif.name + cmd2 = "irm b i " + ipcp.name + " name " + ipcp.dif.name + cmds2.append(cmd2) + cmd2 = "irm r n " + ipcp.name + for dif_b in node.dif_registrations[ipcp.dif]: + cmd2 += " dif " + dif_b.name + cmds2.append(cmd2) + cmd2 = "irm r n " + ipcp.dif.name + for dif_b in node.dif_registrations[ipcp.dif]: + cmd2 += " dif " + dif_b.name + cmds2.append(cmd2) + elif type(ipcp.dif) is mod.ShimUDPDIF: + # FIXME: Will fail, since we don't keep IPs yet + cmd += " type shim-udp" + cmd += " dif " + ipcp.dif.name + else: + print("Unsupported IPCP type") + continue + + cmds.append(cmd) + for cmd in cmds2: + cmds.append(cmd) + + ssh.execute_commands(self.testbed, node.full_name, cmds, + time_out = None) + + def enroll_ipcps(self): + for el in self.enrollments: + for e in el: + for ipcp in e['enrollee'].ipcps: + if ipcp.dif == e['dif']: + cmds = list() + cmd = "irm i e n " + ipcp.name + " dif " + e['dif'].name + cmds.append(cmd) + cmd = "irm b i " + ipcp.name + " name " + ipcp.dif.name + cmds.append(cmd) + cmd = "irm r n " + ipcp.name + for dif_b in e['enrollee'].dif_registrations[ipcp.dif]: + cmd += " dif " + dif_b.name + cmds.append(cmd) + cmd = "irm r n " + ipcp.dif.name + for dif_b in e['enrollee'].dif_registrations[ipcp.dif]: + cmd += " dif " + dif_b.name + cmds.append(cmd) + + ssh.execute_commands(self.testbed, + e['enrollee'].full_name, + cmds, time_out = None) + time.sleep(2) def run_prototype(self): - print("[Ouroboros experiment] start") - print("Creating resources...") print("Setting up Ouroboros...") self.setup_ouroboros() print("Binding names...") self.bind_names() - print("[Ouroboros experiment] end") + print("Creating IPCPs") + self.create_ipcps() + print("Enrolling IPCPs...") + self.enroll_ipcps() + print("Registering names...") + self.reg_names() + print("All done, have fun!") -- cgit v1.2.3