"docs/license.rst" did not exist on "642d5e9155a16c96b01eee7b8ef0e9d558fc2e16"
Commit f819b1f1 authored by Hejing Li's avatar Hejing Li Committed by Jonas Kaufmann
Browse files

impl.py: add netsim base class

parent 3e72b1ca
......@@ -360,12 +360,12 @@ class QemuSim(HostSim):
return cmd
class NetSim(Simulator):
"""Base class for network simulators."""
class SwitchBMSim(Simulator):
def __init__(self, e: exp.Experiment):
def __init__(self, e: exp.Experiment) -> None:
super().__init__(e)
self.experiment = e
self.opt = ''
self.switches: tp.List[spec.Switch] = []
self.nicSim: tp.List[I40eNicSim] = []
self.wait = False
......@@ -373,11 +373,11 @@ class SwitchBMSim(Simulator):
def full_name(self) -> str:
return 'net.' + self.name
def add(self, switch: spec.Switch):
self.switches.append(switch)
switch.sim = self
self.experiment.add_network(self)
self.name = f'{switch.id}'
for s in self.switches:
for n in s.netdevs:
......@@ -412,6 +412,13 @@ class SwitchBMSim(Simulator):
cleanup = []
return cleanup
class SwitchBMSim(NetSim):
def __init__(self, e: exp.Experiment):
super().__init__(e)
def run_cmd(self, env: ExpEnv) -> str:
cmd = env.repodir + '/sims/net/switch/net_switch'
cmd += f' -S {self.switches[0].sync_period} -E {self.switches[0].eth_latency}'
......
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