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
74a9f167
Commit
74a9f167
authored
Jul 22, 2022
by
Jonas Kaufmann
Committed by
Antoine Kaufmann
Jul 29, 2022
Browse files
move all class attributes to __init__
parent
f08c4bc2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
337 additions
and
217 deletions
+337
-217
experiments/simbricks/exectools.py
experiments/simbricks/exectools.py
+34
-26
experiments/simbricks/experiments.py
experiments/simbricks/experiments.py
+33
-35
experiments/simbricks/nodeconfig.py
experiments/simbricks/nodeconfig.py
+167
-90
experiments/simbricks/proxy.py
experiments/simbricks/proxy.py
+23
-19
experiments/simbricks/simulators.py
experiments/simbricks/simulators.py
+80
-47
No files found.
experiments/simbricks/exectools.py
View file @
74a9f167
...
...
@@ -27,6 +27,7 @@ import re
import
shlex
import
shutil
import
signal
import
typing
as
tp
from
asyncio.subprocess
import
Process
...
...
@@ -45,8 +46,6 @@ class HostConfig(object):
class
Component
(
object
):
proc
:
Process
terminate_future
:
asyncio
.
Task
[
int
]
def
__init__
(
self
,
cmd_parts
,
with_stdin
=
False
):
self
.
is_ready
=
False
...
...
@@ -58,6 +57,9 @@ class Component(object):
#print(cmd_parts)
self
.
with_stdin
=
with_stdin
self
.
_proc
:
tp
.
Optional
[
Process
]
=
None
self
.
_terminate_future
:
tp
.
Optional
[
asyncio
.
Task
[
int
]]
=
None
def
_parse_buf
(
self
,
buf
,
data
):
if
data
is
not
None
:
buf
.
extend
(
data
)
...
...
@@ -100,19 +102,19 @@ class Component(object):
async
def
_waiter
(
self
):
out_handlers
=
asyncio
.
ensure_future
(
asyncio
.
wait
([
self
.
_read_stream
(
self
.
proc
.
stdout
,
self
.
_consume_out
),
self
.
_read_stream
(
self
.
proc
.
stderr
,
self
.
_consume_err
)
self
.
_read_stream
(
self
.
_
proc
.
stdout
,
self
.
_consume_out
),
self
.
_read_stream
(
self
.
_
proc
.
stderr
,
self
.
_consume_err
)
])
)
rc
=
await
self
.
proc
.
wait
()
rc
=
await
self
.
_
proc
.
wait
()
await
out_handlers
await
self
.
terminated
(
rc
)
return
rc
async
def
send_input
(
self
,
bs
,
eof
=
False
):
self
.
proc
.
stdin
.
write
(
bs
)
self
.
_
proc
.
stdin
.
write
(
bs
)
if
eof
:
self
.
proc
.
stdin
.
close
()
self
.
_
proc
.
stdin
.
close
()
async
def
start
(
self
):
if
self
.
with_stdin
:
...
...
@@ -120,38 +122,38 @@ class Component(object):
else
:
stdin
=
None
self
.
proc
=
await
asyncio
.
create_subprocess_exec
(
self
.
_
proc
=
await
asyncio
.
create_subprocess_exec
(
*
self
.
cmd_parts
,
stdout
=
asyncio
.
subprocess
.
PIPE
,
stderr
=
asyncio
.
subprocess
.
PIPE
,
stdin
=
stdin
,
)
self
.
terminate_future
=
asyncio
.
ensure_future
(
self
.
_waiter
())
self
.
_
terminate_future
=
asyncio
.
ensure_future
(
self
.
_waiter
())
await
self
.
started
()
async
def
wait
(
self
):
await
self
.
terminate_future
await
self
.
_
terminate_future
async
def
interrupt
(
self
):
if
self
.
terminate_future
.
done
():
if
self
.
_
terminate_future
.
done
():
return
self
.
proc
.
send_signal
(
signal
.
SIGINT
)
self
.
_
proc
.
send_signal
(
signal
.
SIGINT
)
async
def
terminate
(
self
):
if
self
.
terminate_future
.
done
():
if
self
.
_
terminate_future
.
done
():
return
self
.
proc
.
terminate
()
self
.
_
proc
.
terminate
()
async
def
kill
(
self
):
self
.
proc
.
kill
()
self
.
_
proc
.
kill
()
async
def
int_term_kill
(
self
,
delay
=
5
):
await
self
.
interrupt
()
_
,
pending
=
await
asyncio
.
wait
([
self
.
terminate_future
],
timeout
=
delay
)
_
,
pending
=
await
asyncio
.
wait
([
self
.
_
terminate_future
],
timeout
=
delay
)
if
len
(
pending
)
!=
0
:
print
(
'terminating'
)
await
self
.
terminate
()
_
,
pending
=
await
asyncio
.
wait
([
self
.
terminate_future
],
_
,
pending
=
await
asyncio
.
wait
([
self
.
_
terminate_future
],
timeout
=
delay
)
if
len
(
pending
)
!=
0
:
print
(
'killing'
)
...
...
@@ -199,7 +201,6 @@ class SimpleComponent(Component):
class
SimpleRemoteComponent
(
SimpleComponent
):
pid_fut
:
asyncio
.
Future
def
__init__
(
self
,
...
...
@@ -231,8 +232,11 @@ class SimpleRemoteComponent(SimpleComponent):
# wrap up command in ssh invocation
parts
=
self
.
_ssh_cmd
(
remote_parts
)
super
().
__init__
(
label
,
parts
,
*
args
,
**
kwargs
)
self
.
_pid_fut
:
tp
.
Optional
[
asyncio
.
Future
]
=
None
def
_ssh_cmd
(
self
,
parts
):
"""SSH invocation of command for this host."""
return
[
...
...
@@ -245,34 +249,34 @@ class SimpleRemoteComponent(SimpleComponent):
async
def
start
(
self
):
"""Start this command (includes waiting for its pid."""
self
.
pid_fut
=
asyncio
.
get_running_loop
().
create_future
()
self
.
_
pid_fut
=
asyncio
.
get_running_loop
().
create_future
()
await
super
().
start
()
await
self
.
pid_fut
await
self
.
_
pid_fut
async
def
process_out
(
self
,
lines
,
eof
):
"""Scans output and set PID future once PID line found."""
if
not
self
.
pid_fut
.
done
():
if
not
self
.
_
pid_fut
.
done
():
newlines
=
[]
pid_re
=
re
.
compile
(
r
'^PID\s+(\d+)\s*$'
)
for
l
in
lines
:
m
=
pid_re
.
match
(
l
)
if
m
:
pid
=
int
(
m
.
group
(
1
))
self
.
pid_fut
.
set_result
(
pid
)
self
.
_
pid_fut
.
set_result
(
pid
)
else
:
newlines
.
append
(
l
)
lines
=
newlines
if
eof
and
not
self
.
pid_fut
.
done
():
if
eof
and
not
self
.
_
pid_fut
.
done
():
# cancel PID future if it's not going to happen
print
(
'PID not found but EOF already found:'
,
self
.
label
)
self
.
pid_fut
.
cancel
()
self
.
_
pid_fut
.
cancel
()
await
super
().
process_out
(
lines
,
eof
)
async
def
_kill_cmd
(
self
,
sig
):
"""Send signal to command by running ssh kill -$sig $PID."""
cmd_parts
=
self
.
_ssh_cmd
([
'kill'
,
'-'
+
sig
,
str
(
self
.
pid_fut
.
result
())
'kill'
,
'-'
+
sig
,
str
(
self
.
_
pid_fut
.
result
())
])
proc
=
await
asyncio
.
create_subprocess_exec
(
*
cmd_parts
)
await
proc
.
wait
()
...
...
@@ -288,7 +292,9 @@ class SimpleRemoteComponent(SimpleComponent):
class
Executor
(
object
):
ip
=
None
def
__init__
(
self
):
self
.
ip
=
None
def
create_component
(
self
,
label
,
parts
,
**
kwargs
)
->
SimpleComponent
:
raise
NotImplementedError
(
'Please Implement this method'
)
...
...
@@ -354,6 +360,8 @@ class LocalExecutor(Executor):
class
RemoteExecutor
(
Executor
):
def
__init__
(
self
,
host_name
,
workdir
):
super
().
__init__
()
self
.
host_name
=
host_name
self
.
cwd
=
workdir
self
.
ssh_extra_args
=
[]
...
...
experiments/simbricks/experiments.py
View file @
74a9f167
...
...
@@ -29,7 +29,7 @@ import typing as tp
from
simbricks.exectools
import
Executor
,
SimpleComponent
from
simbricks.experiment.experiment_environment
import
ExpEnv
from
simbricks.experiment.experiment_output
import
ExpOutput
from
simbricks.proxy
import
NetProxyConnecter
,
NetProxyListener
,
SimProxy
from
simbricks.proxy
import
NetProxyConnecter
,
NetProxyListener
from
simbricks.simulators
import
(
HostSim
,
I40eMultiNIC
,
NetSim
,
NICSim
,
PCIDevSim
,
Simulator
)
...
...
@@ -43,27 +43,29 @@ class Experiment(object):
Holds information about the simulators to run and paramaters to configure
the experiment.
"""
name
:
str
"""This experiment's name. Can be used to filter multiple experiments to be
run."""
timeout
:
int
def
__init__
(
self
,
name
:
str
,
timeout
:
int
=
0
):
self
.
name
=
name
"""
This experiment's name. Can be used to filter multiple experiments to be
run.
"""
self
.
timeout
=
timeout
"""Timeout for experiment in seconds."""
checkpoint
=
False
self
.
checkpoint
=
False
"""Whether to use checkpoints in experiment.
Can for example be used to speed up booting a host simulator by first
running in a less accurate mode. Before we then start the application we are
interested in, a checkpoint is taken and the simulator shut down. Then, the
simulator is restored in the accurate mode using this checkpoint."""
no_simbricks
=
False
running in a less accurate mode. Before we then start the application we
are interested in, a checkpoint is taken and the simulator shut down.
Then, the simulator is restored in the accurate mode using this
checkpoint."""
self
.
no_simbricks
=
False
"""`true` - No simbricks adapters are used in the simulators."""
hosts
:
tp
.
List
[
HostSim
]
=
[]
pcidevs
:
tp
.
List
[
PCIDevSim
]
=
[]
networks
:
tp
.
List
[
NetSim
]
=
[]
metadata
=
{}
def
__init__
(
self
,
name
:
str
):
self
.
name
=
name
self
.
hosts
:
tp
.
List
[
HostSim
]
=
[]
self
.
pcidevs
:
tp
.
List
[
PCIDevSim
]
=
[]
self
.
networks
:
tp
.
List
[
NetSim
]
=
[]
self
.
metadata
=
{}
def
add_host
(
self
,
sim
:
HostSim
):
for
h
in
self
.
hosts
:
...
...
@@ -108,25 +110,21 @@ class Experiment(object):
class
DistributedExperiment
(
Experiment
):
"""Describes a distributed simulation experiment."""
num_hosts
=
1
"""Number of hosts to use."""
host_mapping
:
tp
.
Dict
[
Simulator
,
int
]
"""Mapping from simulator to host ID."""
proxies_listen
:
tp
.
List
[
NetProxyListener
]
proxies_connect
:
tp
.
List
[
NetProxyConnecter
]
def
__init__
(
self
,
name
:
str
,
num_hosts
:
int
):
self
.
num_hosts
=
num_hosts
self
.
host_mapping
=
{}
self
.
proxies_listen
=
[]
self
.
proxies_connect
=
[]
super
().
__init__
(
name
)
self
.
num_hosts
=
num_hosts
"""Number of hosts to use."""
self
.
host_mapping
:
tp
.
Dict
[
Simulator
,
int
]
=
{}
"""Mapping from simulator to host ID."""
self
.
proxies_listen
:
tp
.
List
[
NetProxyListener
]
=
[]
self
.
proxies_connect
:
tp
.
List
[
NetProxyConnecter
]
=
[]
def
add_proxy
(
self
,
proxy
:
SimProxy
):
def
add_proxy
(
self
,
proxy
:
tp
.
Union
[
NetProxyListener
,
NetProxyConnecter
]
):
if
proxy
.
listen
:
self
.
proxies_listen
.
append
(
proxy
)
self
.
proxies_listen
.
append
(
tp
.
cast
(
NetProxyListener
,
proxy
)
)
else
:
self
.
proxies_connect
.
append
(
proxy
)
self
.
proxies_connect
.
append
(
tp
.
cast
(
NetProxyConnecter
,
proxy
)
)
def
all_simulators
(
self
):
return
itertools
.
chain
(
...
...
@@ -152,7 +150,7 @@ T = tp.TypeVar('T', bound=Experiment)
class
ExperimentBaseRunner
(
tp
.
Generic
[
T
]):
def
__init__
(
self
,
exp
:
T
,
env
:
ExpEnv
,
verbose
:
bool
):
self
.
exp
=
exp
self
.
exp
:
T
=
exp
self
.
env
=
env
self
.
verbose
=
verbose
self
.
out
=
ExpOutput
(
exp
)
...
...
experiments/simbricks/nodeconfig.py
View file @
74a9f167
...
...
@@ -24,6 +24,7 @@ from __future__ import annotations
import
io
import
tarfile
import
typing
as
tp
class
AppConfig
(
object
):
...
...
@@ -47,25 +48,27 @@ class AppConfig(object):
class
NodeConfig
(
object
):
def
__init__
(
self
):
"""Manages the configuration for a node."""
sim
=
'qemu'
self
.
sim
=
'qemu'
"""Name of simulator to run."""
ip
=
'10.0.0.1'
self
.
ip
=
'10.0.0.1'
"""IP address."""
prefix
=
24
self
.
prefix
=
24
"""IP prefix."""
cores
=
1
self
.
cores
=
1
"""Number of cores to be simulated."""
memory
=
8
*
1024
self
.
memory
=
8
*
1024
"""Amount of system memory in MB."""
disk_image
=
'base'
self
.
disk_image
=
'base'
"""Disk image to use."""
app
:
AppConfig
=
None
"""App to be run on simulated host."""
mtu
=
1500
self
.
mtu
=
1500
"""Networking MTU."""
nockp
=
0
self
.
nockp
=
0
"""Do not make checkpoint in Gem5."""
self
.
app
:
tp
.
Optional
[
AppConfig
]
=
None
"""App to be run on simulated host."""
def
config_str
(
self
):
if
self
.
sim
==
'qemu'
:
...
...
@@ -131,9 +134,10 @@ class NodeConfig(object):
class
LinuxNode
(
NodeConfig
):
ifname
=
'eth0'
def
__init__
(
self
):
super
().
__init__
()
self
.
ifname
=
'eth0'
self
.
drivers
=
[]
self
.
force_mac_addr
=
None
...
...
@@ -181,10 +185,13 @@ class E1000LinuxNode(LinuxNode):
class
MtcpNode
(
NodeConfig
):
disk_image
=
'mtcp'
pci_dev
=
'0000:00:02.0'
memory
=
16
*
1024
num_hugepages
=
4096
def
__init__
(
self
):
super
().
__init__
()
self
.
disk_image
=
'mtcp'
self
.
pci_dev
=
'0000:00:02.0'
self
.
memory
=
16
*
1024
self
.
num_hugepages
=
4096
def
prepare_pre_cp
(
self
):
return
super
().
prepare_pre_cp
()
+
[
...
...
@@ -231,12 +238,15 @@ class MtcpNode(NodeConfig):
class
TASNode
(
NodeConfig
):
disk_image
=
'tas'
pci_dev
=
'0000:00:02.0'
memory
=
16
*
1024
num_hugepages
=
4096
fp_cores
=
1
preload
=
True
def
__init__
(
self
):
super
().
__init__
()
self
.
disk_image
=
'tas'
self
.
pci_dev
=
'0000:00:02.0'
self
.
memory
=
16
*
1024
self
.
num_hugepages
=
4096
self
.
fp_cores
=
1
self
.
preload
=
True
def
prepare_pre_cp
(
self
):
return
super
().
prepare_pre_cp
()
+
[
...
...
@@ -325,6 +335,7 @@ class CorundumDCTCPNode(NodeConfig):
class
LinuxFEMUNode
(
NodeConfig
):
def
__init__
(
self
):
super
().
__init__
()
self
.
drivers
=
[
'nvme'
]
def
prepare_post_cp
(
self
):
...
...
@@ -355,8 +366,11 @@ class DctcpServer(AppConfig):
class
DctcpClient
(
AppConfig
):
server_ip
=
'192.168.64.1'
is_last
=
False
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'192.168.64.1'
self
.
is_last
=
False
def
run_cmds
(
self
,
node
):
if
self
.
is_last
:
...
...
@@ -374,7 +388,10 @@ class DctcpClient(AppConfig):
class
PingClient
(
AppConfig
):
server_ip
=
'192.168.64.1'
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'192.168.64.1'
def
run_cmds
(
self
,
node
):
return
[
f
'ping
{
self
.
server_ip
}
-c 100'
]
...
...
@@ -393,9 +410,12 @@ class IperfUDPServer(AppConfig):
class
IperfTCPClient
(
AppConfig
):
server_ip
=
'10.0.0.1'
procs
=
1
is_last
=
False
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'10.0.0.1'
self
.
procs
=
1
self
.
is_last
=
False
def
run_cmds
(
self
,
node
):
...
...
@@ -412,9 +432,12 @@ class IperfTCPClient(AppConfig):
class
IperfUDPClient
(
AppConfig
):
server_ip
=
'10.0.0.1'
rate
=
'150m'
is_last
=
False
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'10.0.0.1'
self
.
rate
=
'150m'
self
.
is_last
=
False
def
run_cmds
(
self
,
node
):
cmds
=
[
...
...
@@ -431,9 +454,12 @@ class IperfUDPClient(AppConfig):
class
IperfUDPShortClient
(
AppConfig
):
server_ip
=
'10.0.0.1'
rate
=
'150m'
is_last
=
False
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'10.0.0.1'
self
.
rate
=
'150m'
self
.
is_last
=
False
def
run_cmds
(
self
,
node
):
cmds
=
[
'sleep 1'
,
'iperf -c '
+
self
.
server_ip
+
' -u -n 1 '
]
...
...
@@ -442,16 +468,22 @@ class IperfUDPShortClient(AppConfig):
class
IperfUDPClientSleep
(
AppConfig
):
server_ip
=
'10.0.0.1'
rate
=
'150m'
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'10.0.0.1'
self
.
rate
=
'150m'
def
run_cmds
(
self
,
node
):
return
[
'sleep 1'
,
'sleep 10'
]
class
NoTraffic
(
AppConfig
):
is_sleep
=
1
is_server
=
0
def
__init__
(
self
):
super
().
__init__
()
self
.
is_sleep
=
1
self
.
is_server
=
0
def
run_cmds
(
self
,
node
):
cmds
=
[]
...
...
@@ -474,9 +506,12 @@ class NetperfServer(AppConfig):
class
NetperfClient
(
AppConfig
):
server_ip
=
'10.0.0.1'
duration_tp
=
10
duration_lat
=
10
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'10.0.0.1'
self
.
duration_tp
=
10
self
.
duration_lat
=
10
def
run_cmds
(
self
,
node
):
return
[
...
...
@@ -491,7 +526,10 @@ class NetperfClient(AppConfig):
class
VRReplica
(
AppConfig
):
index
=
0
def
__init__
(
self
):
super
().
__init__
()
self
.
index
=
0
def
run_cmds
(
self
,
node
):
return
[
...
...
@@ -501,7 +539,10 @@ class VRReplica(AppConfig):
class
VRClient
(
AppConfig
):
server_ips
=
[]
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ips
=
[]
def
run_cmds
(
self
,
node
):
cmds
=
[]
...
...
@@ -515,7 +556,10 @@ class VRClient(AppConfig):
class
NOPaxosReplica
(
AppConfig
):
index
=
0
def
__init__
(
self
):
super
().
__init__
()
self
.
index
=
0
def
run_cmds
(
self
,
node
):
return
[
...
...
@@ -525,9 +569,12 @@ class NOPaxosReplica(AppConfig):
class
NOPaxosClient
(
AppConfig
):
server_ips
=
[]
is_last
=
False
use_ehseq
=
False
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ips
=
[]
self
.
is_last
=
False
self
.
use_ehseq
=
False
def
run_cmds
(
self
,
node
):
cmds
=
[]
...
...
@@ -555,10 +602,13 @@ class NOPaxosSequencer(AppConfig):
class
RPCServer
(
AppConfig
):
port
=
1234
threads
=
1
max_flows
=
1234
max_bytes
=
1024
def
__init__
(
self
):
super
().
__init__
()
self
.
port
=
1234
self
.
threads
=
1
self
.
max_flows
=
1234
self
.
max_bytes
=
1024
def
run_cmds
(
self
,
node
):
exe
=
'echoserver_linux'
if
not
isinstance
(
node
,
MtcpNode
)
else
\
...
...
@@ -573,16 +623,19 @@ class RPCServer(AppConfig):
class
RPCClient
(
AppConfig
):
server_ip
=
'10.0.0.1'
port
=
1234
threads
=
1
max_flows
=
128
max_bytes
=
1024
max_pending
=
1
openall_delay
=
2
max_msgs_conn
=
0
max_pend_conns
=
8
time
=
25
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'10.0.0.1'
self
.
port
=
1234
self
.
threads
=
1
self
.
max_flows
=
128
self
.
max_bytes
=
1024
self
.
max_pending
=
1
self
.
openall_delay
=
2
self
.
max_msgs_conn
=
0
self
.
max_pend_conns
=
8
self
.
time
=
25
def
run_cmds
(
self
,
node
):
exe
=
'testclient_linux'
if
not
isinstance
(
node
,
MtcpNode
)
else
\
...
...
@@ -603,10 +656,13 @@ class RPCClient(AppConfig):
class
HTTPD
(
AppConfig
):
threads
=
1
file_size
=
64
mtcp_config
=
'lighttpd.conf'
httpd_dir
:
str
# TODO added because doesn't originally exist
def
__init__
(
self
):
super
().
__init__
()
self
.
threads
=
1
self
.
file_size
=
64
self
.
mtcp_config
=
'lighttpd.conf'
self
.
httpd_dir
=
''
# TODO added because doesn't originally exist
def
prepare_pre_cp
(
self
):
return
[
...
...
@@ -628,16 +684,25 @@ class HTTPD(AppConfig):
class
HTTPDLinux
(
HTTPD
):
httpd_dir
=
'/root/mtcp/apps/lighttpd-mtlinux'
def
__init__
(
self
):
super
().
__init__
()
self
.
httpd_dir
=
'/root/mtcp/apps/lighttpd-mtlinux'
class
HTTPDLinuxRPO
(
HTTPD
):
httpd_dir
=
'/root/mtcp/apps/lighttpd-mtlinux-rop'
def
__init__
(
self
):
super
().
__init__
()
self
.
httpd_dir
=
'/root/mtcp/apps/lighttpd-mtlinux-rop'
class
HTTPDMtcp
(
HTTPD
):
httpd_dir
=
'/root/mtcp/apps/lighttpd-mtcp'
mtcp_config
=
'm-lighttpd.conf'
def
__init__
(
self
):
super
().
__init__
()
self
.
httpd_dir
=
'/root/mtcp/apps/lighttpd-mtcp'
self
.
mtcp_config
=
'm-lighttpd.conf'
def
prepare_pre_cp
(
self
):
return
super
().
prepare_pre_cp
()
+
[
...
...
@@ -651,13 +716,16 @@ class HTTPDMtcp(HTTPD):
class
HTTPC
(
AppConfig
):
server_ip
=
'10.0.0.1'
conns
=
1000
#requests = 10000000
requests
=
10000
threads
=
1
url
=
'/file'
ab_dir
:
str
# TODO added because doesn't originally exist
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ip
=
'10.0.0.1'
self
.
conns
=
1000
#self.requests = 10000000
self
.
requests
=
10000
self
.
threads
=
1
self
.
url
=
'/file'
self
.
ab_dir
=
''
# TODO added because doesn't originally exist
def
run_cmds
(
self
,
node
):
return
[
...
...
@@ -670,11 +738,17 @@ class HTTPC(AppConfig):
class
HTTPCLinux
(
HTTPC
):
ab_dir
=
'/root/mtcp/apps/ab-linux'
def
__init__
(
self
):
super
().
__init__
()
self
.
ab_dir
=
'/root/mtcp/apps/ab-linux'
class
HTTPCMtcp
(
HTTPC
):
ab_dir
=
'/root/mtcp/apps/ab-mtcp'
def
__init__
(
self
):
super
().
__init__
()
self
.
ab_dir
=
'/root/mtcp/apps/ab-mtcp'
def
prepare_pre_cp
(
self
):
return
super
().
prepare_pre_cp
()
+
[
...
...
@@ -690,10 +764,13 @@ class MemcachedServer(AppConfig):
class
MemcachedClient
(
AppConfig
):
server_ips
=
[
'10.0.0.1'
]
threads
=
1
concurrency
=
1
throughput
=
'1k'
def
__init__
(
self
):
super
().
__init__
()
self
.
server_ips
=
[
'10.0.0.1'
]
self
.
threads
=
1
self
.
concurrency
=
1
self
.
throughput
=
'1k'
def
run_cmds
(
self
,
node
):
servers
=
[
ip
+
':11211'
for
ip
in
self
.
server_ips
]
...
...
experiments/simbricks/proxy.py
View file @
74a9f167
...
...
@@ -20,14 +20,19 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from
simbricks.simulators
import
Simulator
import
typing
as
tp
from
simbricks.simulators
import
NICSim
,
Simulator
class
SimProxy
(
Simulator
):
name
=
''
def
__init__
(
self
):
super
().
__init__
()
self
.
name
=
''
# set by the experiment runner
ip
=
''
listen
=
False
self
.
ip
=
''
self
.
listen
=
False
def
full_name
(
self
):
return
'proxy.'
+
self
.
name
...
...
@@ -35,29 +40,29 @@ class SimProxy(Simulator):
class
NetProxy
(
SimProxy
):
"""Proxy for connections between NICs and networks."""
# List of tuples (nic, with_listener)
nics
=
None
# List of tuples ((netL,netC), with_listener)
n2ns
=
None
# Shared memory size in GB
shm_size
=
2048
def
__init__
(
self
):
super
().
__init__
()
self
.
nics
:
tp
.
List
[
tp
.
Tuple
[
NICSim
,
bool
]]
=
[]
"""List of tuples (nic, with_listener)"""
self
.
n2ns
:
tp
.
List
[
tp
.
Tuple
[
tp
.
Tuple
[
NetProxyListener
,
NetProxyConnecter
],
bool
]]
=
[]
"""List of tuples ((netL,netC), with_listener)"""
self
.
shm_size
=
2048
"""Shared memory size in GB"""
def
start_delay
(
self
):
return
10
class
NetProxyListener
(
NetProxy
):
port
=
12345
connecter
=
None
listen
=
True
def
__init__
(
self
):
super
().
__init__
()
self
.
port
=
12345
self
.
connecter
=
None
self
.
listen
=
True
self
.
nics
=
[]
self
.
n2ns
=
[]
def
add_nic
(
self
,
nic
):
self
.
nics
.
append
((
nic
,
True
))
...
...
@@ -119,9 +124,8 @@ class NetProxyListener(NetProxy):
class
NetProxyConnecter
(
NetProxy
):
listener
=
None
def
__init__
(
self
,
listener
):
def
__init__
(
self
,
listener
:
NetProxyListener
):
super
().
__init__
()
self
.
listener
=
listener
listener
.
connecter
=
self
...
...
experiments/simbricks/simulators.py
View file @
74a9f167
...
...
@@ -80,11 +80,16 @@ class Simulator(object):
class
PCIDevSim
(
Simulator
):
name
=
''
sync_mode
=
0
start_tick
=
0
sync_period
=
500
pci_latency
=
500
"""Base class for PCIe device simulators."""
def
__init__
(
self
):
super
().
__init__
()
self
.
name
=
''
self
.
sync_mode
=
0
self
.
start_tick
=
0
self
.
sync_period
=
500
self
.
pci_latency
=
500
def
full_name
(
self
):
return
'dev.'
+
self
.
name
...
...
@@ -97,9 +102,14 @@ class PCIDevSim(Simulator):
class
NICSim
(
PCIDevSim
):
network
=
None
mac
=
None
eth_latency
=
500
"""Base class for NIC simulators."""
def
__init__
(
self
):
super
().
__init__
()
self
.
network
:
tp
.
Optional
[
NetSim
]
=
None
self
.
mac
:
tp
.
Optional
[
str
]
=
None
self
.
eth_latency
=
500
def
set_network
(
self
,
net
:
NetSim
):
self
.
network
=
net
...
...
@@ -134,15 +144,19 @@ class NICSim(PCIDevSim):
class
NetSim
(
Simulator
):
"""Base class for network simulators."""
name
=
''
opt
=
''
sync_mode
=
0
sync_period
=
500
eth_latency
=
500
nics
:
list
[
NICSim
]
=
[]
hosts_direct
:
list
[
HostSim
]
=
[]
net_listen
:
list
[
NetSim
]
=
[]
net_connect
:
list
[
NetSim
]
=
[]
def
__init__
(
self
):
super
().
__init__
()
self
.
name
=
''
self
.
opt
=
''
self
.
sync_mode
=
0
self
.
sync_period
=
500
self
.
eth_latency
=
500
self
.
nics
:
list
[
NICSim
]
=
[]
self
.
hosts_direct
:
list
[
HostSim
]
=
[]
self
.
net_listen
:
list
[
NetSim
]
=
[]
self
.
net_connect
:
list
[
NetSim
]
=
[]
def
full_name
(
self
):
return
'net.'
+
self
.
name
...
...
@@ -179,25 +193,27 @@ class NetSim(Simulator):
class
HostSim
(
Simulator
):
node_config
:
NodeConfig
"""Base class for host simulators."""
def
__init__
(
self
):
super
().
__init__
()
self
.
node_config
:
tp
.
Optional
[
NodeConfig
]
=
None
"""Config for the simulated host. """
name
=
''
wait
=
False
self
.
name
=
''
self
.
wait
=
False
"""
`True` - Wait for process of simulator to exit.
`False` - Don't wait and instead stop the process.
"""
sleep
=
0
cpu_freq
=
'8GHz'
self
.
sleep
=
0
self
.
cpu_freq
=
'8GHz'
sync_mode
=
0
sync_period
=
500
pci_latency
=
500
self
.
sync_mode
=
0
self
.
sync_period
=
500
self
.
pci_latency
=
500
def
__init__
(
self
):
self
.
pcidevs
:
tp
.
List
[
PCIDevSim
]
=
[]
self
.
net_directs
:
tp
.
List
[
NetSim
]
=
[]
super
().
__init__
()
def
full_name
(
self
):
return
'host.'
+
self
.
name
...
...
@@ -229,8 +245,13 @@ class HostSim(Simulator):
class
QemuHost
(
HostSim
):
sync
=
False
cpu_freq
=
'4GHz'
"""Qemu host simulator."""
def
__init__
(
self
):
super
().
__init__
()
self
.
sync
=
False
self
.
cpu_freq
=
'4GHz'
def
resreq_cores
(
self
):
if
self
.
sync
:
...
...
@@ -291,12 +312,13 @@ class QemuHost(HostSim):
class
Gem5Host
(
HostSim
):
cpu_type_cp
=
'X86KvmCPU'
cpu_type
=
'TimingSimpleCPU'
sys_clock
=
'1GHz'
"""Gem5 host simulator."""
def
__init__
(
self
):
super
().
__init__
()
self
.
cpu_type_cp
=
'X86KvmCPU'
self
.
cpu_type
=
'TimingSimpleCPU'
self
.
sys_clock
=
'1GHz'
self
.
extra_main_args
=
[]
self
.
extra_config_args
=
[]
self
.
variant
=
'fast'
...
...
@@ -369,7 +391,10 @@ class Gem5Host(HostSim):
class
CorundumVerilatorNIC
(
NICSim
):
clock_freq
=
250
# MHz
def
__init__
(
self
):
super
().
__init__
()
self
.
clock_freq
=
250
# MHz
def
resreq_mem
(
self
):
# this is a guess
...
...
@@ -394,7 +419,10 @@ class I40eNIC(NICSim):
class
E1000NIC
(
NICSim
):
debug
=
False
def
__init__
(
self
):
super
().
__init__
()
self
.
debug
=
False
def
run_cmd
(
self
,
env
):
cmd
=
self
.
basic_run_cmd
(
env
,
'/e1000_gem5/e1000_gem5'
)
...
...
@@ -404,12 +432,11 @@ class E1000NIC(NICSim):
class
MultiSubNIC
(
NICSim
):
name
=
''
multinic
=
None
def
__init__
(
self
,
mn
):
self
.
multinic
=
mn
super
().
__init__
()
self
.
name
=
''
self
.
multinic
=
mn
def
full_name
(
self
):
return
self
.
multinic
.
full_name
()
+
'.'
+
self
.
name
...
...
@@ -422,11 +449,11 @@ class MultiSubNIC(NICSim):
class
I40eMultiNIC
(
Simulator
):
name
=
''
def
__init__
(
self
):
self
.
subnics
=
[]
super
().
__init__
()
self
.
subnics
=
[]
self
.
name
=
''
def
create_subnic
(
self
):
sn
=
MultiSubNIC
(
self
)
...
...
@@ -475,7 +502,10 @@ class WireNet(NetSim):
class
SwitchNet
(
NetSim
):
sync
=
True
def
__init__
(
self
):
super
().
__init__
()
self
.
sync
=
True
def
run_cmd
(
self
,
env
):
cmd
=
env
.
repodir
+
'/sims/net/switch/net_switch'
...
...
@@ -503,8 +533,11 @@ class SwitchNet(NetSim):
class
TofinoNet
(
NetSim
):
tofino_log_path
=
'/tmp/model.ldjson'
sync
=
True
def
__init__
(
self
):
super
().
__init__
()
self
.
tofino_log_path
=
'/tmp/model.ldjson'
self
.
sync
=
True
def
run_cmd
(
self
,
env
):
cmd
=
f
'
{
env
.
repodir
}
/sims/net/tofino/tofino'
...
...
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