From 1abd211bb7b58dc258570116af9403ecf0e28da9 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 19 Jul 2021 21:56:11 +0200 Subject: experiment: Move link rate setting to prototype Apparently I didn't test my final change for this feature when I moved it from the storyboard to the experiment. It didn't work, I tried to put it in the testbed class, but that was a mess, so for now it's moved to the prototype. --- rumba/elements/experimentation.py | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'rumba/elements/experimentation.py') diff --git a/rumba/elements/experimentation.py b/rumba/elements/experimentation.py index 03d90bb..efd7a3e 100644 --- a/rumba/elements/experimentation.py +++ b/rumba/elements/experimentation.py @@ -540,36 +540,22 @@ class Experiment(object): def _stop_metrics_exporter(self, nodes): raise Exception('start_metrics_exporter() method not implemented') - def set_eth_link_rate_to(self, src, dst, megabit): + @abc.abstractmethod + def _set_phy_link_rate_to(self, src, dst, megabit): + raise Exception('set_phy_k') + + def set_phy_link_rate_to(self, src, dst, megabit): """ - Sets the link rate on src NIC towards dst with ethtool - Fixme: This should be moved to the testbed class - Fixme: Test if testbed is a physical Linux server + Sets the physical link rate in the experiment """ + self._set_phy_link_rate_to(src, dst, megabit) - if megabit not in [10, 100, 1000]: - return - - self.run_command(src, "route | grep $(ping server -c 1 | head -n1 | cut -f3 -d' ' | head -c -3 | tail -c +2) | " - "grep -o '[^ ]*$' > iface ".format(dst)) - self.run_command(src, "sudo ethtool -s $(cat iface) speed {} duplex full autoneg off".format(megabit)) - self.run_command(src, "sudo ip link set $(cat iface) down") - self.run_command(src, "sudo ip link set $(cat iface) up && sleep 10") - self.run_command(src, "sudo ethtool $(cat iface) | grep '{}Mb/s'".format(megabit)) - self.run_command(src, "rm iface") - self.run_command(src, "while ! ping -c 1 {}; do sleep 1; done".format(dst)) - - def set_eth_link_rate_between(self, src, dst, megabit): + def set_phy_link_rate_between(self, src, dst, megabit): """ - Sets the link rate with ethtool - Fixme: This should be moved to the testbed class - Fixme: Test if testbed is a physical Linux server + Sets the physical link rate in the experiment """ - if megabit not in [10, 100, 1000]: - return - - self.set_eth_link_rate_to(src, dst, megabit) - self.set_eth_link_rate_to(dst, src, megabit) + self._set_phy_link_rate_to(src, dst, megabit) + self._set_phy_link_rate_to(dst, src, megabit) def swap_in(self): """ -- cgit v1.2.3