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
1c2e19bc
"...en/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "2246d2c7c4afb5156d68500b53d7f5693428b29e"
Commit
1c2e19bc
authored
Apr 30, 2021
by
Hejing Li
Browse files
Merge branch 'master' of github.com:simbricks/simbricks
parents
1b48864c
3fa7661e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
experiments/run.py
experiments/run.py
+5
-0
experiments/simbricks/simulators.py
experiments/simbricks/simulators.py
+6
-1
sims/net/switch/net_switch.cc
sims/net/switch/net_switch.cc
+27
-1
No files found.
experiments/run.py
View file @
1c2e19bc
...
@@ -52,6 +52,8 @@ parser.add_argument('--force', action='store_const', const=True, default=False,
...
@@ -52,6 +52,8 @@ parser.add_argument('--force', action='store_const', const=True, default=False,
parser
.
add_argument
(
'--verbose'
,
action
=
'store_const'
,
const
=
True
,
parser
.
add_argument
(
'--verbose'
,
action
=
'store_const'
,
const
=
True
,
default
=
False
,
default
=
False
,
help
=
'Verbose output'
)
help
=
'Verbose output'
)
parser
.
add_argument
(
'--pcap'
,
action
=
'store_const'
,
const
=
True
,
default
=
False
,
help
=
'Dump pcap file (if supported by simulator)'
)
g_env
=
parser
.
add_argument_group
(
'Environment'
)
g_env
=
parser
.
add_argument_group
(
'Environment'
)
g_env
.
add_argument
(
'--repo'
,
metavar
=
'DIR'
,
type
=
str
,
g_env
.
add_argument
(
'--repo'
,
metavar
=
'DIR'
,
type
=
str
,
...
@@ -104,6 +106,9 @@ def add_exp(e, run, prereq, create_cp, restore_cp):
...
@@ -104,6 +106,9 @@ def add_exp(e, run, prereq, create_cp, restore_cp):
env
=
exp
.
ExpEnv
(
args
.
repo
,
workdir
,
cpdir
)
env
=
exp
.
ExpEnv
(
args
.
repo
,
workdir
,
cpdir
)
env
.
create_cp
=
create_cp
env
.
create_cp
=
create_cp
env
.
restore_cp
=
restore_cp
env
.
restore_cp
=
restore_cp
env
.
pcap_file
=
''
if
args
.
pcap
:
env
.
pcap_file
=
workdir
+
'/pcap'
run
=
runtime
.
Run
(
e
,
run
,
env
,
outpath
,
prereq
)
run
=
runtime
.
Run
(
e
,
run
,
env
,
outpath
,
prereq
)
rt
.
add_run
(
run
)
rt
.
add_run
(
run
)
...
...
experiments/simbricks/simulators.py
View file @
1c2e19bc
...
@@ -239,15 +239,20 @@ class I40eNIC(NICSim):
...
@@ -239,15 +239,20 @@ class I40eNIC(NICSim):
class
WireNet
(
NetSim
):
class
WireNet
(
NetSim
):
def
run_cmd
(
self
,
env
):
def
run_cmd
(
self
,
env
):
assert
len
(
self
.
nics
)
==
2
assert
len
(
self
.
nics
)
==
2
return
'%s/sims/net/wire/net_wire %s %s %d %d %d'
%
\
cmd
=
'%s/sims/net/wire/net_wire %s %s %d %d %d'
%
\
(
env
.
repodir
,
env
.
nic_eth_path
(
self
.
nics
[
0
]),
(
env
.
repodir
,
env
.
nic_eth_path
(
self
.
nics
[
0
]),
env
.
nic_eth_path
(
self
.
nics
[
1
]),
env
.
nic_eth_path
(
self
.
nics
[
1
]),
self
.
sync_mode
,
self
.
sync_period
,
self
.
eth_latency
)
self
.
sync_mode
,
self
.
sync_period
,
self
.
eth_latency
)
if
len
(
env
.
pcap_file
)
>
0
:
cmd
+=
' '
+
env
.
pcap_file
return
cmd
class
SwitchNet
(
NetSim
):
class
SwitchNet
(
NetSim
):
def
run_cmd
(
self
,
env
):
def
run_cmd
(
self
,
env
):
cmd
=
env
.
repodir
+
'/sims/net/switch/net_switch'
cmd
=
env
.
repodir
+
'/sims/net/switch/net_switch'
cmd
+=
f
' -m
{
self
.
sync_mode
}
-S
{
self
.
sync_period
}
-E
{
self
.
eth_latency
}
'
cmd
+=
f
' -m
{
self
.
sync_mode
}
-S
{
self
.
sync_period
}
-E
{
self
.
eth_latency
}
'
if
len
(
env
.
pcap_file
)
>
0
:
cmd
+=
' -p '
+
env
.
pcap_file
for
n
in
self
.
nics
:
for
n
in
self
.
nics
:
cmd
+=
' -s '
+
env
.
nic_eth_path
(
n
)
cmd
+=
' -s '
+
env
.
nic_eth_path
(
n
)
return
cmd
return
cmd
...
...
sims/net/switch/net_switch.cc
View file @
1c2e19bc
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
*/
*/
#include <unistd.h>
#include <unistd.h>
#include <pcap/pcap.h>
#include <cassert>
#include <cassert>
#include <climits>
#include <climits>
...
@@ -40,6 +41,7 @@ extern "C" {
...
@@ -40,6 +41,7 @@ extern "C" {
static
uint64_t
sync_period
=
(
500
*
1000ULL
);
// 500ns
static
uint64_t
sync_period
=
(
500
*
1000ULL
);
// 500ns
static
uint64_t
eth_latency
=
(
500
*
1000ULL
);
// 500ns
static
uint64_t
eth_latency
=
(
500
*
1000ULL
);
// 500ns
static
pcap_dumper_t
*
dumpfile
=
nullptr
;
/* MAC address type */
/* MAC address type */
struct
MAC
{
struct
MAC
{
...
@@ -85,6 +87,18 @@ static void sigint_handler(int dummy) {
...
@@ -85,6 +87,18 @@ static void sigint_handler(int dummy) {
static
void
forward_pkt
(
volatile
struct
SimbricksProtoNetD2NSend
*
tx
,
static
void
forward_pkt
(
volatile
struct
SimbricksProtoNetD2NSend
*
tx
,
size_t
port
)
{
size_t
port
)
{
volatile
union
SimbricksProtoNetN2D
*
msg_to
;
volatile
union
SimbricksProtoNetN2D
*
msg_to
;
struct
pcap_pkthdr
ph
;
// log to pcap file if initialized
if
(
dumpfile
)
{
memset
(
&
ph
,
0
,
sizeof
(
ph
));
ph
.
ts
.
tv_sec
=
cur_ts
/
1000000000000ULL
;
ph
.
ts
.
tv_usec
=
(
cur_ts
%
1000000000000ULL
)
/
1000ULL
;
ph
.
caplen
=
tx
->
len
;
ph
.
len
=
tx
->
len
;
pcap_dump
((
unsigned
char
*
)
dumpfile
,
&
ph
,
(
unsigned
char
*
)
tx
->
data
);
}
msg_to
=
SimbricksNetIfN2DAlloc
(
&
nsifs
[
port
],
cur_ts
,
eth_latency
);
msg_to
=
SimbricksNetIfN2DAlloc
(
&
nsifs
[
port
],
cur_ts
,
eth_latency
);
if
(
msg_to
!=
NULL
)
{
if
(
msg_to
!=
NULL
)
{
volatile
struct
SimbricksProtoNetN2DRecv
*
rx
;
volatile
struct
SimbricksProtoNetN2DRecv
*
rx
;
...
@@ -143,9 +157,10 @@ int main(int argc, char *argv[]) {
...
@@ -143,9 +157,10 @@ int main(int argc, char *argv[]) {
int
c
;
int
c
;
int
bad_option
=
0
;
int
bad_option
=
0
;
int
sync_mode
=
SIMBRICKS_PROTO_SYNC_SIMBRICKS
;
int
sync_mode
=
SIMBRICKS_PROTO_SYNC_SIMBRICKS
;
pcap_t
*
pc
=
nullptr
;
// Parse command line argument
// Parse command line argument
while
((
c
=
getopt
(
argc
,
argv
,
"s:S:E:m:"
))
!=
-
1
&&
!
bad_option
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"s:S:E:m:
p:
"
))
!=
-
1
&&
!
bad_option
)
{
switch
(
c
)
{
switch
(
c
)
{
case
's'
:
{
case
's'
:
{
struct
SimbricksNetIf
nsif
;
struct
SimbricksNetIf
nsif
;
...
@@ -172,6 +187,17 @@ int main(int argc, char *argv[]) {
...
@@ -172,6 +187,17 @@ int main(int argc, char *argv[]) {
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
break
;
break
;
case
'p'
:
pc
=
pcap_open_dead_with_tstamp_precision
(
DLT_EN10MB
,
65535
,
PCAP_TSTAMP_PRECISION_NANO
);
if
(
pc
==
nullptr
)
{
perror
(
"pcap_open_dead failed"
);
return
EXIT_FAILURE
;
}
dumpfile
=
pcap_dump_open
(
pc
,
optarg
);
break
;
default:
default:
fprintf
(
stderr
,
"unknown option %c
\n
"
,
c
);
fprintf
(
stderr
,
"unknown option %c
\n
"
,
c
);
bad_option
=
1
;
bad_option
=
1
;
...
...
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