Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
f819b1f1
Commit
f819b1f1
authored
Jun 26, 2024
by
Hejing Li
Committed by
Jonas Kaufmann
Aug 20, 2024
Browse files
impl.py: add netsim base class
parent
3e72b1ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
experiments/simbricks/splitsim/impl.py
experiments/simbricks/splitsim/impl.py
+12
-5
No files found.
experiments/simbricks/splitsim/impl.py
View file @
f819b1f1
...
@@ -360,12 +360,12 @@ class QemuSim(HostSim):
...
@@ -360,12 +360,12 @@ class QemuSim(HostSim):
return
cmd
return
cmd
class
NetSim
(
Simulator
):
"""Base class for network simulators."""
class
SwitchBMSim
(
Simulator
):
def
__init__
(
self
,
e
:
exp
.
Experiment
)
->
None
:
def
__init__
(
self
,
e
:
exp
.
Experiment
):
super
().
__init__
(
e
)
super
().
__init__
(
e
)
self
.
experimen
t
=
e
self
.
op
t
=
''
self
.
switches
:
tp
.
List
[
spec
.
Switch
]
=
[]
self
.
switches
:
tp
.
List
[
spec
.
Switch
]
=
[]
self
.
nicSim
:
tp
.
List
[
I40eNicSim
]
=
[]
self
.
nicSim
:
tp
.
List
[
I40eNicSim
]
=
[]
self
.
wait
=
False
self
.
wait
=
False
...
@@ -373,11 +373,11 @@ class SwitchBMSim(Simulator):
...
@@ -373,11 +373,11 @@ class SwitchBMSim(Simulator):
def
full_name
(
self
)
->
str
:
def
full_name
(
self
)
->
str
:
return
'net.'
+
self
.
name
return
'net.'
+
self
.
name
def
add
(
self
,
switch
:
spec
.
Switch
):
def
add
(
self
,
switch
:
spec
.
Switch
):
self
.
switches
.
append
(
switch
)
self
.
switches
.
append
(
switch
)
switch
.
sim
=
self
switch
.
sim
=
self
self
.
experiment
.
add_network
(
self
)
self
.
experiment
.
add_network
(
self
)
self
.
name
=
f
'
{
switch
.
id
}
'
for
s
in
self
.
switches
:
for
s
in
self
.
switches
:
for
n
in
s
.
netdevs
:
for
n
in
s
.
netdevs
:
...
@@ -412,6 +412,13 @@ class SwitchBMSim(Simulator):
...
@@ -412,6 +412,13 @@ class SwitchBMSim(Simulator):
cleanup
=
[]
cleanup
=
[]
return
cleanup
return
cleanup
class
SwitchBMSim
(
NetSim
):
def
__init__
(
self
,
e
:
exp
.
Experiment
):
super
().
__init__
(
e
)
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
cmd
=
env
.
repodir
+
'/sims/net/switch/net_switch'
cmd
=
env
.
repodir
+
'/sims/net/switch/net_switch'
cmd
+=
f
' -S
{
self
.
switches
[
0
].
sync_period
}
-E
{
self
.
switches
[
0
].
eth_latency
}
'
cmd
+=
f
' -S
{
self
.
switches
[
0
].
sync_period
}
-E
{
self
.
switches
[
0
].
eth_latency
}
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment