Commit c2896bf3 authored by Marvin Meiers's avatar Marvin Meiers Committed by Antoine Kaufmann
Browse files

experiments: reformat python code

parent 1ea0f3bf
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
import typing as tp import typing as tp
import simbricks.orchestration.e2e_components as e2e
import simbricks.orchestration.experiments as exp import simbricks.orchestration.experiments as exp
import simbricks.orchestration.nodeconfig as node import simbricks.orchestration.nodeconfig as node
import simbricks.orchestration.simulators as sim import simbricks.orchestration.simulators as sim
import simbricks.orchestration.e2e_components as e2e
from simbricks.orchestration.simulator_utils import create_tcp_cong_hosts
from simbricks.orchestration.e2e_helpers import E2ELinkAssigner, E2ELinkType from simbricks.orchestration.e2e_helpers import E2ELinkAssigner, E2ELinkType
from simbricks.orchestration.simulator_utils import create_tcp_cong_hosts
mtu = 1500 mtu = 1500
congestion_control = e2e.CongestionControl.CUBIC congestion_control = e2e.CongestionControl.CUBIC
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import simbricks.orchestration.e2e_components as e2e
import simbricks.orchestration.experiments as exp import simbricks.orchestration.experiments as exp
import simbricks.orchestration.nodeconfig as node import simbricks.orchestration.nodeconfig as node
import simbricks.orchestration.simulators as sim import simbricks.orchestration.simulators as sim
import simbricks.orchestration.e2e_components as e2e
from simbricks.orchestration.simulator_utils import create_tcp_cong_hosts
from simbricks.orchestration.e2e_topologies import E2EDumbbellTopology from simbricks.orchestration.e2e_topologies import E2EDumbbellTopology
from simbricks.orchestration.simulator_utils import create_tcp_cong_hosts
# iperf TCP_multi_client test # iperf TCP_multi_client test
# naming convention following host-nic-net-app # naming convention following host-nic-net-app
...@@ -48,9 +48,9 @@ num_simbricks_hosts = 1 ...@@ -48,9 +48,9 @@ num_simbricks_hosts = 1
#max_k = 199680 #max_k = 199680
#k_step = 16640 #k_step = 16640
#k_step = 33280 #k_step = 33280
link_rate = 200 # in Mbps link_rate = 200 # in Mbps
link_latency = 5 # in ms link_latency = 5 # in ms
bdp = int(link_rate * link_latency / 1000 * 10**6) # Bandwidth-delay product bdp = int(link_rate * link_latency / 1000 * 10**6) # Bandwidth-delay product
cpu_freq = '5GHz' cpu_freq = '5GHz'
cpu_freq_qemu = '2GHz' cpu_freq_qemu = '2GHz'
sys_clock = '1GHz' # if not set, default 1GHz sys_clock = '1GHz' # if not set, default 1GHz
...@@ -160,7 +160,7 @@ for congestion_control in types_of_congestion_control: ...@@ -160,7 +160,7 @@ for congestion_control in types_of_congestion_control:
freq, freq,
mtu, mtu,
congestion_control.gem5, congestion_control.gem5,
ip_start=2*num_ns3_hosts + num_simbricks_hosts + 1 ip_start=2 * num_ns3_hosts + num_simbricks_hosts + 1
) )
for i, server in enumerate(servers, 1): for i, server in enumerate(servers, 1):
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import simbricks.orchestration.e2e_components as e2e
import simbricks.orchestration.experiments as exp import simbricks.orchestration.experiments as exp
import simbricks.orchestration.nodeconfig as node import simbricks.orchestration.nodeconfig as node
import simbricks.orchestration.simulators as sim import simbricks.orchestration.simulators as sim
import simbricks.orchestration.e2e_components as e2e
from simbricks.orchestration.simulator_utils import create_tcp_cong_hosts from simbricks.orchestration.simulator_utils import create_tcp_cong_hosts
# iperf TCP_multi_client test # iperf TCP_multi_client test
......
...@@ -51,14 +51,14 @@ class E2ELinkAssigner(): ...@@ -51,14 +51,14 @@ class E2ELinkAssigner():
create_link: bool = True create_link: bool = True
): ):
if create_link and link_type is None: if create_link and link_type is None:
raise RuntimeError("Cannot create a link without link type") raise RuntimeError('Cannot create a link without link type')
if idd in self.links: if idd in self.links:
raise RuntimeError(f"Link {idd} already exists") raise RuntimeError(f'Link {idd} already exists')
link = { link = {
"left": left_switch, 'left': left_switch,
"right": right_switch, 'right': right_switch,
"type": link_type, 'type': link_type,
"created": create_link 'created': create_link
} }
if create_link: if create_link:
self._create_link(idd, link) self._create_link(idd, link)
...@@ -76,42 +76,40 @@ class E2ELinkAssigner(): ...@@ -76,42 +76,40 @@ class E2ELinkAssigner():
# TODO: set properties like latency # TODO: set properties like latency
def _create_link(self, idd: str, link): def _create_link(self, idd: str, link):
left_switch = link["left"] left_switch = link['left']
right_switch = link["right"] right_switch = link['right']
link_type = link["type"] link_type = link['type']
if link_type == E2ELinkType.SIMBRICKS: if link_type == E2ELinkType.SIMBRICKS:
left_adapter = e2e.E2ENetworkSimbricks(f"_{idd}_left_adapter") left_adapter = e2e.E2ENetworkSimbricks(f'_{idd}_left_adapter')
left_adapter.listen = False left_adapter.listen = False
left_switch.add_component(left_adapter) left_switch.add_component(left_adapter)
link["left_adapter"] = left_adapter link['left_adapter'] = left_adapter
right_adapter = e2e.E2ENetworkSimbricks( right_adapter = e2e.E2ENetworkSimbricks(f'_{idd}_right_adapter')
f"_{idd}_right_adapter"
)
right_adapter.listen = True right_adapter.listen = True
right_switch.add_component(right_adapter) right_switch.add_component(right_adapter)
link["right_adapter"] = right_adapter link['right_adapter'] = right_adapter
elif link_type == E2ELinkType.NS3_SIMPLE_CHANNEL: elif link_type == E2ELinkType.NS3_SIMPLE_CHANNEL:
ns3link = e2e.E2ESimpleChannel(f"_{idd}_link") ns3link = e2e.E2ESimpleChannel(f'_{idd}_link')
ns3link.left_node = left_switch ns3link.left_node = left_switch
ns3link.right_node = right_switch ns3link.right_node = right_switch
link["ns3link"] = ns3link link['ns3link'] = ns3link
def set_link_type(self, idd: str, link_type: E2ELinkType): def set_link_type(self, idd: str, link_type: E2ELinkType):
if idd not in self.links: if idd not in self.links:
raise RuntimeError(f"Link {idd} not found") raise RuntimeError(f'Link {idd} not found')
link = self.links[idd] link = self.links[idd]
if link["created"]: if link['created']:
raise RuntimeError("Cannot change type of already existing link") raise RuntimeError('Cannot change type of already existing link')
link["type"] = link_type link['type'] = link_type
def create_missing_links(self): def create_missing_links(self):
for idd, link in self.links.items(): for idd, link in self.links.items():
if link["created"]: if link['created']:
continue continue
if link["type"] is None: if link['type'] is None:
raise RuntimeError(f"Link {idd} has no type") raise RuntimeError(f'Link {idd} has no type')
self._create_link(idd, link) self._create_link(idd, link)
link["created"] = True link['created'] = True
def assign_networks(self) -> tp.List[NS3E2ENet]: def assign_networks(self) -> tp.List[NS3E2ENet]:
networks = [] networks = []
...@@ -119,7 +117,7 @@ class E2ELinkAssigner(): ...@@ -119,7 +117,7 @@ class E2ELinkAssigner():
while len(self.connected_switches) > 0: while len(self.connected_switches) > 0:
# create network and take next (random) switch # create network and take next (random) switch
net = NS3E2ENet() net = NS3E2ENet()
net.name = f"_network_{len(networks)}" net.name = f'_network_{len(networks)}'
networks.append(net) networks.append(net)
next_switches = set() next_switches = set()
next_switches.add(self.connected_switches.pop()) next_switches.add(self.connected_switches.pop())
...@@ -129,28 +127,28 @@ class E2ELinkAssigner(): ...@@ -129,28 +127,28 @@ class E2ELinkAssigner():
switch = next_switches.pop() switch = next_switches.pop()
net.add_component(switch) net.add_component(switch)
for link in self.switch_links[switch]: for link in self.switch_links[switch]:
if link["type"] == E2ELinkType.SIMBRICKS: if link['type'] == E2ELinkType.SIMBRICKS:
if link["left"] == switch: if link['left'] == switch:
link["right_adapter"].simbricks_component = net link['right_adapter'].simbricks_component = net
else: else:
assert link["right"] == switch assert link['right'] == switch
link["left_adapter"].simbricks_component = net link['left_adapter'].simbricks_component = net
elif link["type"] == E2ELinkType.NS3_SIMPLE_CHANNEL: elif link['type'] == E2ELinkType.NS3_SIMPLE_CHANNEL:
not_visited_switches = 0 not_visited_switches = 0
if link["left"] in self.connected_switches: if link['left'] in self.connected_switches:
next_switches.add(link["left"]) next_switches.add(link['left'])
self.connected_switches.remove(link["left"]) self.connected_switches.remove(link['left'])
not_visited_switches += 1 not_visited_switches += 1
if link["right"] in self.connected_switches: if link['right'] in self.connected_switches:
next_switches.add(link["right"]) next_switches.add(link['right'])
self.connected_switches.remove(link["right"]) self.connected_switches.remove(link['right'])
not_visited_switches += 1 not_visited_switches += 1
assert not_visited_switches < 2 assert not_visited_switches < 2
# if only one switch has been visited (namely the # if only one switch has been visited (namely the
# current switch), we see this link for the first time # current switch), we see this link for the first time
if not_visited_switches == 1: if not_visited_switches == 1:
net.add_component(link["ns3link"]) net.add_component(link['ns3link'])
else: else:
raise RuntimeError("Unknown link type") raise RuntimeError('Unknown link type')
return networks return networks
...@@ -38,9 +38,9 @@ class E2ETopology(ABC): ...@@ -38,9 +38,9 @@ class E2ETopology(ABC):
class E2EDumbbellTopology(E2ETopology): class E2EDumbbellTopology(E2ETopology):
def __init__(self): def __init__(self):
self.left_switch = e2e.E2ESwitchNode("_leftSwitch") self.left_switch = e2e.E2ESwitchNode('_leftSwitch')
self.right_switch = e2e.E2ESwitchNode("_rightSwitch") self.right_switch = e2e.E2ESwitchNode('_rightSwitch')
self.link = e2e.E2ESimpleChannel("_link") self.link = e2e.E2ESimpleChannel('_link')
self.link.left_node = self.left_switch self.link.left_node = self.left_switch
self.link.right_node = self.right_switch self.link.right_node = self.right_switch
......
...@@ -102,7 +102,9 @@ class ExpEnv(object): ...@@ -102,7 +102,9 @@ class ExpEnv(object):
return f'{self.shm_base}/dev.shm.{sim.name}' return f'{self.shm_base}/dev.shm.{sim.name}'
def n2n_eth_path( def n2n_eth_path(
self, sim_l: 'simulators.Simulator', sim_c: 'simulators.Simulator', self,
sim_l: 'simulators.Simulator',
sim_c: 'simulators.Simulator',
suffix='' suffix=''
) -> str: ) -> str:
return f'{self.workdir}/n2n.eth.{sim_l.name}.{sim_c.name}.{suffix}' return f'{self.workdir}/n2n.eth.{sim_l.name}.{sim_c.name}.{suffix}'
......
...@@ -378,8 +378,7 @@ class I40eTCPCongNode(NodeConfig): ...@@ -378,8 +378,7 @@ class I40eTCPCongNode(NodeConfig):
return super().prepare_post_cp() + [ return super().prepare_post_cp() + [
'modprobe i40e', 'modprobe i40e',
'ethtool -G eth0 rx 4096 tx 4096', 'ethtool -G eth0 rx 4096 tx 4096',
'ethtool -K eth0 tso off', 'ethtool -K eth0 tso off', # 'ip link set eth0 txqueuelen 13888',
# 'ip link set eth0 txqueuelen 13888',
f'ip link set dev eth0 mtu {self.mtu} up', f'ip link set dev eth0 mtu {self.mtu} up',
f'ip addr add {self.ip}/{self.prefix} dev eth0', f'ip addr add {self.ip}/{self.prefix} dev eth0',
] ]
......
...@@ -187,7 +187,7 @@ class ExperimentBaseRunner(ABC): ...@@ -187,7 +187,7 @@ class ExperimentBaseRunner(ABC):
assert self.profile_int assert self.profile_int
while True: while True:
await asyncio.sleep(self.profile_int) await asyncio.sleep(self.profile_int)
for (_,sc) in self.running: for (_, sc) in self.running:
await sc.sigusr1() await sc.sigusr1()
async def run(self) -> ExpOutput: async def run(self) -> ExpOutput:
......
...@@ -26,10 +26,10 @@ from __future__ import annotations ...@@ -26,10 +26,10 @@ from __future__ import annotations
import math import math
import typing as tp import typing as tp
from simbricks.orchestration import e2e_components as e2e
from simbricks.orchestration.e2e_topologies import E2ETopology
from simbricks.orchestration.experiment.experiment_environment import ExpEnv from simbricks.orchestration.experiment.experiment_environment import ExpEnv
from simbricks.orchestration.nodeconfig import NodeConfig from simbricks.orchestration.nodeconfig import NodeConfig
from simbricks.orchestration.e2e_topologies import E2ETopology
from simbricks.orchestration import e2e_components as e2e
class Simulator(object): class Simulator(object):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment