".github/git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "6fede39bedc132e0cb08bccfcb089befe18c17d2"
Commit a530c146 authored by Antoine Kaufmann's avatar Antoine Kaufmann Committed by Hejing Li
Browse files

experiments: support for multiple simbricks links between two networks

allows callers to add a name suffix for each connection, so there are separate unix sockets.
parent f7218276
...@@ -219,10 +219,15 @@ class E2ESimbricksNetwork(E2EComponent): ...@@ -219,10 +219,15 @@ class E2ESimbricksNetwork(E2EComponent):
self.sync_delay = "" self.sync_delay = ""
self.poll_delay = "" self.poll_delay = ""
self.eth_latency = "" self.eth_latency = ""
self.peer = None
self.sync: SimbricksSyncMode = SimbricksSyncMode.SYNC_OPTIONAL self.sync: SimbricksSyncMode = SimbricksSyncMode.SYNC_OPTIONAL
self.simbricks_component = None self.simbricks_component = None
def set_peer(self, peer: E2ESimbricksNetwork):
self.peer = peer
peer.peer = self
def ns3_config(self) -> str: def ns3_config(self) -> str:
self.mapping.update({ self.mapping.update({
"UnixSocket": self.unix_socket, "UnixSocket": self.unix_socket,
......
...@@ -155,6 +155,7 @@ def partition(topology, N): ...@@ -155,6 +155,7 @@ def partition(topology, N):
con_a.eth_latency = f'{l.delay}' con_a.eth_latency = f'{l.delay}'
con_a.sync_delay = f'{l.delay}' con_a.sync_delay = f'{l.delay}'
con_a.simbricks_component = networks[lst_p] con_a.simbricks_component = networks[lst_p]
con_a.set_peer(lst_a)
con.add_component(con_a) con.add_component(con_a)
return networks return networks
...@@ -88,9 +88,10 @@ class ExpEnv(object): ...@@ -88,9 +88,10 @@ 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=''
) -> str: ) -> str:
return f'{self.workdir}/n2n.eth.{sim_l.name}.{sim_c.name}' return f'{self.workdir}/n2n.eth.{sim_l.name}.{sim_c.name}.{suffix}'
def net2host_eth_path(self, sim_n, sim_h) -> str: def net2host_eth_path(self, sim_n, sim_h) -> str:
return f'{self.workdir}/n2h.eth.{sim_n.name}.{sim_h.name}' return f'{self.workdir}/n2h.eth.{sim_n.name}.{sim_h.name}'
......
...@@ -193,8 +193,8 @@ class NetSim(Simulator): ...@@ -193,8 +193,8 @@ class NetSim(Simulator):
components.""" components."""
self.nics: list[NICSim] = [] self.nics: list[NICSim] = []
self.hosts_direct: list[HostSim] = [] self.hosts_direct: list[HostSim] = []
self.net_listen: list[NetSim] = [] self.net_listen: list[(NetSim, str)] = []
self.net_connect: list[NetSim] = [] self.net_connect: list[(NetSim, str)] = []
self.wait = False self.wait = False
def full_name(self) -> str: def full_name(self) -> str:
...@@ -203,29 +203,29 @@ class NetSim(Simulator): ...@@ -203,29 +203,29 @@ class NetSim(Simulator):
def connect_nic(self, nic: NICSim) -> None: def connect_nic(self, nic: NICSim) -> None:
self.nics.append(nic) self.nics.append(nic)
def connect_network(self, net: NetSim) -> None: def connect_network(self, net: NetSim, suffix='') -> None:
"""Connect this network to the listening peer `net`""" """Connect this network to the listening peer `net`"""
net.net_listen.append(self) net.net_listen.append((self, suffix))
self.net_connect.append(net) self.net_connect.append((net, suffix))
def connect_sockets(self, env: ExpEnv) -> tp.List[tp.Tuple[Simulator, str]]: def connect_sockets(self, env: ExpEnv) -> tp.List[tp.Tuple[Simulator, str]]:
sockets = [] sockets = []
for n in self.nics: for n in self.nics:
sockets.append((n, env.nic_eth_path(n))) sockets.append((n, env.nic_eth_path(n)))
for n in self.net_connect: for (n, suffix) in self.net_connect:
sockets.append((n, env.n2n_eth_path(n, self))) sockets.append((n, env.n2n_eth_path(n, self, suffix)))
for h in self.hosts_direct: for h in self.hosts_direct:
sockets.append((h, env.net2host_eth_path(self, h))) sockets.append((h, env.net2host_eth_path(self, h)))
return sockets return sockets
def listen_sockets(self, env: ExpEnv) -> tp.List[tp.Tuple[NetSim, str]]: def listen_sockets(self, env: ExpEnv) -> tp.List[tp.Tuple[NetSim, str]]:
listens = [] listens = []
for net in self.net_listen: for (net,suffix) in self.net_listen:
listens.append((net, env.n2n_eth_path(self, net))) listens.append((net, env.n2n_eth_path(self, net, suffix)))
return listens return listens
def dependencies(self) -> tp.List[Simulator]: def dependencies(self) -> tp.List[Simulator]:
return self.nics + self.net_connect + self.hosts_direct return self.nics + self.hosts_direct + [n for n,_ in self.net_connect]
def sockets_cleanup(self, env: ExpEnv) -> tp.List[str]: def sockets_cleanup(self, env: ExpEnv) -> tp.List[str]:
return [s for (_, s) in self.listen_sockets(env)] return [s for (_, s) in self.listen_sockets(env)]
...@@ -947,13 +947,16 @@ class NS3E2ENet(NetSim): ...@@ -947,13 +947,16 @@ class NS3E2ENet(NetSim):
if e2e_sim.adapter_type == e2e.SimbricksAdapterType.NIC: if e2e_sim.adapter_type == e2e.SimbricksAdapterType.NIC:
e2e_sim.unix_socket = env.nic_eth_path(e2e_sim.simbricks_component) e2e_sim.unix_socket = env.nic_eth_path(e2e_sim.simbricks_component)
elif e2e_sim.adapter_type == e2e.SimbricksAdapterType.NETWORK: elif e2e_sim.adapter_type == e2e.SimbricksAdapterType.NETWORK:
p_suf = ''
if e2e_sim.peer:
p_suf = min(e2e_sim.name, e2e_sim.peer.name)
if listen: if listen:
e2e_sim.unix_socket = env.n2n_eth_path( e2e_sim.unix_socket = env.n2n_eth_path(
self, e2e_sim.simbricks_component self, e2e_sim.simbricks_component, p_suf
) )
else: else:
e2e_sim.unix_socket = env.n2n_eth_path( e2e_sim.unix_socket = env.n2n_eth_path(
e2e_sim.simbricks_component, self e2e_sim.simbricks_component, self, p_suf
) )
elif e2e_sim.adapter_type == e2e.SimbricksAdapterType.HOST: elif e2e_sim.adapter_type == e2e.SimbricksAdapterType.HOST:
e2e_sim.unix_socket = env.net2host_eth_path( e2e_sim.unix_socket = env.net2host_eth_path(
...@@ -971,7 +974,10 @@ class NS3E2ENet(NetSim): ...@@ -971,7 +974,10 @@ class NS3E2ENet(NetSim):
# add all connected networks # add all connected networks
for c in component.components: for c in component.components:
if isinstance(c, e2e.E2ESimbricksNetworkNetIf): if isinstance(c, e2e.E2ESimbricksNetworkNetIf):
self.connect_network(c.simbricks_component) p_suf = ''
if c.peer:
p_suf = min(c.name, c.peer.name)
self.connect_network(c.simbricks_component, p_suf)
def run_cmd(self, env): def run_cmd(self, env):
# resolve all socket paths # resolve all socket paths
......
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