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
4ee2aa2b
Commit
4ee2aa2b
authored
Feb 14, 2021
by
Antoine Kaufmann
Browse files
lib/netif: refactor identifier names for google style
parent
12cca0cf
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
66 deletions
+66
-66
lib/simbricks/netif/netsim.c
lib/simbricks/netif/netsim.c
+12
-12
lib/simbricks/netif/netsim.h
lib/simbricks/netif/netsim.h
+12
-12
lib/simbricks/nicif/nicsim.c
lib/simbricks/nicif/nicsim.c
+2
-2
sims/external/ns-3
sims/external/ns-3
+1
-1
sims/net/switch/net_switch.cc
sims/net/switch/net_switch.cc
+13
-13
sims/net/tap/net_tap.c
sims/net/tap/net_tap.c
+5
-5
sims/net/wire/net_wire.c
sims/net/wire/net_wire.c
+21
-21
No files found.
lib/simbricks/netif/netsim.c
View file @
4ee2aa2b
...
...
@@ -36,7 +36,7 @@
static
uint64_t
current_epoch
=
0
;
int
netsim_init
(
struct
netsim_interface
*
nsif
,
const
char
*
eth_socket_path
,
int
SimbricksNetIfInit
(
struct
SimbricksNetIf
*
nsif
,
const
char
*
eth_socket_path
,
int
*
sync_eth
)
{
struct
SimbricksProtoNetDevIntro
di
;
struct
SimbricksProtoNetNetIntro
ni
;
...
...
@@ -85,13 +85,13 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
return
0
;
}
void
netsim_cleanup
(
struct
netsim_interface
*
nsif
)
{
fprintf
(
stderr
,
"
netsim_c
leanup: TODO
\n
"
);
void
SimbricksNetIfCleanup
(
struct
SimbricksNetIf
*
nsif
)
{
fprintf
(
stderr
,
"
SimbricksNetIfC
leanup: TODO
\n
"
);
abort
();
}
volatile
union
SimbricksProtoNetD2N
*
netsim_d2n_p
oll
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
)
{
volatile
union
SimbricksProtoNetD2N
*
SimbricksNetIfD2NP
oll
(
struct
SimbricksNetIf
*
nsif
,
uint64_t
timestamp
)
{
volatile
union
SimbricksProtoNetD2N
*
msg
=
(
volatile
union
SimbricksProtoNetD2N
*
)(
nsif
->
d2n_queue
+
nsif
->
d2n_pos
*
nsif
->
d2n_elen
);
...
...
@@ -110,15 +110,15 @@ volatile union SimbricksProtoNetD2N *netsim_d2n_poll(
return
msg
;
}
void
netsim_d2n_done
(
struct
netsim_interface
*
nsif
,
void
SimbricksNetIfD2NDone
(
struct
SimbricksNetIf
*
nsif
,
volatile
union
SimbricksProtoNetD2N
*
msg
)
{
msg
->
dummy
.
own_type
=
(
msg
->
dummy
.
own_type
&
SIMBRICKS_PROTO_NET_D2N_MSG_MASK
)
|
SIMBRICKS_PROTO_NET_D2N_OWN_DEV
;
}
volatile
union
SimbricksProtoNetN2D
*
netsim_n2d_a
lloc
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
)
{
volatile
union
SimbricksProtoNetN2D
*
SimbricksNetIfN2DA
lloc
(
struct
SimbricksNetIf
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
)
{
volatile
union
SimbricksProtoNetN2D
*
msg
=
(
volatile
union
SimbricksProtoNetN2D
*
)(
nsif
->
n2d_queue
+
nsif
->
n2d_pos
*
nsif
->
n2d_elen
);
...
...
@@ -135,7 +135,7 @@ volatile union SimbricksProtoNetN2D *netsim_n2d_alloc(
return
msg
;
}
int
netsim_n2d_sync
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
int
SimbricksNetIfN2DSync
(
struct
SimbricksNetIf
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
,
uint64_t
sync_delay
,
int
sync_mode
)
{
volatile
union
SimbricksProtoNetN2D
*
msg
;
volatile
struct
SimbricksProtoNetN2DSync
*
sync
;
...
...
@@ -161,7 +161,7 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
return
0
;
}
msg
=
netsim_n2d_a
lloc
(
nsif
,
timestamp
,
latency
);
msg
=
SimbricksNetIfN2DA
lloc
(
nsif
,
timestamp
,
latency
);
if
(
msg
==
NULL
)
return
-
1
;
...
...
@@ -173,7 +173,7 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
return
0
;
}
void
netsim_a
dvance
_e
poch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
void
SimbricksNetIfA
dvance
E
poch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
{
if
(
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
)
{
if
(
timestamp
-
current_epoch
>=
sync_delay
)
{
...
...
@@ -182,7 +182,7 @@ void netsim_advance_epoch(uint64_t timestamp, uint64_t sync_delay,
}
}
uint64_t
netsim_a
dvance
_t
ime
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
uint64_t
SimbricksNetIfA
dvance
T
ime
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
{
switch
(
sync_mode
)
{
case
SIMBRICKS_PROTO_SYNC_SIMBRICKS
:
...
...
lib/simbricks/netif/netsim.h
View file @
4ee2aa2b
...
...
@@ -30,7 +30,7 @@
#include <simbricks/proto/network.h>
struct
netsim_interface
{
struct
SimbricksNetIf
{
uint8_t
*
d2n_queue
;
size_t
d2n_pos
;
size_t
d2n_elen
;
...
...
@@ -46,25 +46,25 @@ struct netsim_interface {
int
sync
;
};
int
netsim_init
(
struct
netsim_interface
*
nsif
,
const
char
*
eth_socket_path
,
int
SimbricksNetIfInit
(
struct
SimbricksNetIf
*
nsif
,
const
char
*
eth_socket_path
,
int
*
sync_eth
);
void
netsim_cleanup
(
struct
netsim_interface
*
nsif
);
void
SimbricksNetIfCleanup
(
struct
SimbricksNetIf
*
nsif
);
volatile
union
SimbricksProtoNetD2N
*
netsim_d2n_p
oll
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
);
void
netsim_d2n_done
(
struct
netsim_interface
*
nsif
,
volatile
union
SimbricksProtoNetD2N
*
SimbricksNetIfD2NP
oll
(
struct
SimbricksNetIf
*
nsif
,
uint64_t
timestamp
);
void
SimbricksNetIfD2NDone
(
struct
SimbricksNetIf
*
nsif
,
volatile
union
SimbricksProtoNetD2N
*
msg
);
static
inline
uint64_t
netsim_d2n_timestamp
(
struct
netsim_interface
*
nsif
)
{
static
inline
uint64_t
SimbricksNetIfD2NTimestamp
(
struct
SimbricksNetIf
*
nsif
)
{
return
nsif
->
d2n_timestamp
;
}
volatile
union
SimbricksProtoNetN2D
*
netsim_n2d_a
lloc
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
);
int
netsim_n2d_sync
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
volatile
union
SimbricksProtoNetN2D
*
SimbricksNetIfN2DA
lloc
(
struct
SimbricksNetIf
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
);
int
SimbricksNetIfN2DSync
(
struct
SimbricksNetIf
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
,
uint64_t
sync_delay
,
int
sync_mode
);
void
netsim_a
dvance
_e
poch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
void
SimbricksNetIfA
dvance
E
poch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
);
uint64_t
netsim_a
dvance
_t
ime
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
uint64_t
SimbricksNetIfA
dvance
T
ime
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
);
#endif // SIMBRICKS_NETIF_NETSIM_H_
lib/simbricks/nicif/nicsim.c
View file @
4ee2aa2b
...
...
@@ -22,6 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <simbricks/nicif/nicsim.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -29,8 +31,6 @@
#include <sys/socket.h>
#include <unistd.h>
#include <simbricks/nicif/nicsim.h>
#include "lib/simbricks/nicif/internal.h"
#include <simbricks/proto/base.h>
...
...
ns-3
@
763b902b
Compare
160793a4
...
763b902b
Subproject commit
160793a40cc120da2a3175b62e813bb750683c69
Subproject commit
763b902bbcde6cc675c9210db9abaa2bb3e1c4d4
sims/net/switch/net_switch.cc
View file @
4ee2aa2b
...
...
@@ -75,7 +75,7 @@ static uint64_t cur_ts = 0;
static
int
exiting
=
0
;
static
const
volatile
uint8_t
bcast
[
6
]
=
{
0xFF
};
static
const
MAC
bcast_addr
(
bcast
);
static
std
::
vector
<
struct
netsim_interface
>
nsifs
;
static
std
::
vector
<
struct
SimbricksNetIf
>
nsifs
;
static
std
::
unordered_map
<
MAC
,
int
>
mac_table
;
static
void
sigint_handler
(
int
dummy
)
{
...
...
@@ -85,7 +85,7 @@ static void sigint_handler(int dummy) {
static
void
forward_pkt
(
volatile
struct
SimbricksProtoNetD2NSend
*
tx
,
int
port
)
{
volatile
union
SimbricksProtoNetN2D
*
msg_to
;
msg_to
=
netsim_n2d_a
lloc
(
&
nsifs
[
port
],
cur_ts
,
eth_latency
);
msg_to
=
SimbricksNetIfN2DA
lloc
(
&
nsifs
[
port
],
cur_ts
,
eth_latency
);
if
(
msg_to
!=
NULL
)
{
volatile
struct
SimbricksProtoNetN2DRecv
*
rx
;
rx
=
&
msg_to
->
recv
;
...
...
@@ -101,9 +101,9 @@ static void forward_pkt(volatile struct SimbricksProtoNetD2NSend *tx,
}
}
static
void
switch_pkt
(
struct
netsim_interface
*
nsif
,
int
iport
)
{
static
void
switch_pkt
(
struct
SimbricksNetIf
*
nsif
,
int
iport
)
{
volatile
union
SimbricksProtoNetD2N
*
msg_from
=
netsim_d2n_p
oll
(
nsif
,
cur_ts
);
SimbricksNetIfD2NP
oll
(
nsif
,
cur_ts
);
if
(
msg_from
==
NULL
)
{
return
;
}
...
...
@@ -136,7 +136,7 @@ static void switch_pkt(struct netsim_interface *nsif, int iport) {
fprintf
(
stderr
,
"switch_pkt: unsupported type=%u
\n
"
,
type
);
abort
();
}
netsim_d2n_d
one
(
nsif
,
msg_from
);
SimbricksNetIfD2ND
one
(
nsif
,
msg_from
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -148,9 +148,9 @@ int main(int argc, char *argv[]) {
while
((
c
=
getopt
(
argc
,
argv
,
"s:S:E:m:"
))
!=
-
1
&&
!
bad_option
)
{
switch
(
c
)
{
case
's'
:
{
struct
netsim_interface
nsif
;
struct
SimbricksNetIf
nsif
;
int
sync
=
1
;
if
(
netsim_i
nit
(
&
nsif
,
optarg
,
&
sync
)
!=
0
)
{
if
(
SimbricksNetIfI
nit
(
&
nsif
,
optarg
,
&
sync
)
!=
0
)
{
fprintf
(
stderr
,
"connecting to %s failed
\n
"
,
optarg
);
return
EXIT_FAILURE
;
}
...
...
@@ -193,13 +193,13 @@ int main(int argc, char *argv[]) {
while
(
!
exiting
)
{
// Sync all interfaces
for
(
auto
&
nsif
:
nsifs
)
{
if
(
netsim_n2d_s
ync
(
&
nsif
,
cur_ts
,
eth_latency
,
sync_period
,
sync_mode
)
!=
0
)
{
fprintf
(
stderr
,
"
netsim_n2d_s
ync failed
\n
"
);
if
(
SimbricksNetIfN2DS
ync
(
&
nsif
,
cur_ts
,
eth_latency
,
sync_period
,
sync_mode
)
!=
0
)
{
fprintf
(
stderr
,
"
SimbricksNetIfN2DS
ync failed
\n
"
);
abort
();
}
}
netsim_a
dvance
_e
poch
(
cur_ts
,
sync_period
,
sync_mode
);
SimbricksNetIfA
dvance
E
poch
(
cur_ts
,
sync_period
,
sync_mode
);
// Switch packets
uint64_t
min_ts
;
...
...
@@ -209,7 +209,7 @@ int main(int argc, char *argv[]) {
auto
&
nsif
=
nsifs
.
at
(
port
);
switch_pkt
(
&
nsif
,
port
);
if
(
nsif
.
sync
)
{
uint64_t
ts
=
netsim_d2n_t
imestamp
(
&
nsif
);
uint64_t
ts
=
SimbricksNetIfD2NT
imestamp
(
&
nsif
);
min_ts
=
ts
<
min_ts
?
ts
:
min_ts
;
}
}
...
...
@@ -217,7 +217,7 @@ int main(int argc, char *argv[]) {
// Update cur_ts
if
(
min_ts
<
ULLONG_MAX
)
{
cur_ts
=
netsim_a
dvance
_t
ime
(
min_ts
,
sync_period
,
sync_mode
);
cur_ts
=
SimbricksNetIfA
dvance
T
ime
(
min_ts
,
sync_period
,
sync_mode
);
}
}
...
...
sims/net/tap/net_tap.c
View file @
4ee2aa2b
...
...
@@ -37,7 +37,7 @@
// #define DEBUG_PKTMETA
static
struct
netsim_interface
nsif
;
static
struct
SimbricksNetIf
nsif
;
static
int
tap_fd
;
static
int
tap_open
(
const
char
*
name
)
{
...
...
@@ -73,7 +73,7 @@ static void d2n_send(volatile struct SimbricksProtoNetD2NSend *s) {
}
static
void
poll_d2n
(
void
)
{
volatile
union
SimbricksProtoNetD2N
*
msg
=
netsim_d2n_p
oll
(
&
nsif
,
0
);
volatile
union
SimbricksProtoNetD2N
*
msg
=
SimbricksNetIfD2NP
oll
(
&
nsif
,
0
);
uint8_t
type
;
/* message not ready */
...
...
@@ -90,7 +90,7 @@ static void poll_d2n(void) {
fprintf
(
stderr
,
"poll_d2n: unsupported type=%u
\n
"
,
type
);
}
netsim_d2n_d
one
(
&
nsif
,
msg
);
SimbricksNetIfD2ND
one
(
&
nsif
,
msg
);
}
static
void
*
rx_handler
(
void
*
arg
)
{
...
...
@@ -99,7 +99,7 @@ static void *rx_handler(void *arg) {
ssize_t
len
;
while
(
1
)
{
msg
=
netsim_n2d_a
lloc
(
&
nsif
,
0
,
0
);
msg
=
SimbricksNetIfN2DA
lloc
(
&
nsif
,
0
,
0
);
if
(
msg
==
NULL
)
{
fprintf
(
stderr
,
"coudl not allocate message for rx
\n
"
);
abort
();
...
...
@@ -135,7 +135,7 @@ int main(int argc, char *argv[]) {
}
sync
=
0
;
if
(
netsim_i
nit
(
&
nsif
,
argv
[
2
],
&
sync
)
!=
0
)
{
if
(
SimbricksNetIfI
nit
(
&
nsif
,
argv
[
2
],
&
sync
)
!=
0
)
{
close
(
tap_fd
);
return
-
1
;
}
...
...
sims/net/wire/net_wire.c
View file @
4ee2aa2b
...
...
@@ -53,10 +53,10 @@ static void sigusr1_handler(int dummy) {
fprintf
(
stderr
,
"main_time = %lu
\n
"
,
cur_ts
);
}
static
void
move_pkt
(
struct
netsim_interface
*
from
,
struct
netsim_interface
*
to
)
{
static
void
move_pkt
(
struct
SimbricksNetIf
*
from
,
struct
SimbricksNetIf
*
to
)
{
volatile
union
SimbricksProtoNetD2N
*
msg_from
=
netsim_d2n_p
oll
(
from
,
cur_ts
);
SimbricksNetIfD2NP
oll
(
from
,
cur_ts
);
volatile
union
SimbricksProtoNetN2D
*
msg_to
;
volatile
struct
SimbricksProtoNetD2NSend
*
tx
;
volatile
struct
SimbricksProtoNetN2DRecv
*
rx
;
...
...
@@ -80,7 +80,7 @@ static void move_pkt(struct netsim_interface *from,
pcap_dump
((
unsigned
char
*
)
dumpfile
,
&
ph
,
(
unsigned
char
*
)
tx
->
data
);
}
msg_to
=
netsim_n2d_a
lloc
(
to
,
cur_ts
,
eth_latency
);
msg_to
=
SimbricksNetIfN2DA
lloc
(
to
,
cur_ts
,
eth_latency
);
if
(
msg_to
!=
NULL
)
{
rx
=
&
msg_to
->
recv
;
rx
->
len
=
tx
->
len
;
...
...
@@ -99,11 +99,11 @@ static void move_pkt(struct netsim_interface *from,
abort
();
}
netsim_d2n_d
one
(
from
,
msg_from
);
SimbricksNetIfD2ND
one
(
from
,
msg_from
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
netsim_interface
nsif_a
,
nsif_b
;
struct
SimbricksNetIf
nsif_a
,
nsif_b
;
uint64_t
ts_a
,
ts_b
;
int
sync_a
,
sync_b
;
pcap_t
*
pc
=
NULL
;
...
...
@@ -144,42 +144,42 @@ int main(int argc, char *argv[]) {
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
sync_a
=
sync_b
=
1
;
if
(
netsim_i
nit
(
&
nsif_a
,
argv
[
1
],
&
sync_a
)
!=
0
)
{
if
(
SimbricksNetIfI
nit
(
&
nsif_a
,
argv
[
1
],
&
sync_a
)
!=
0
)
{
return
-
1
;
}
if
(
netsim_i
nit
(
&
nsif_b
,
argv
[
2
],
&
sync_b
)
!=
0
)
{
if
(
SimbricksNetIfI
nit
(
&
nsif_b
,
argv
[
2
],
&
sync_b
)
!=
0
)
{
return
-
1
;
}
printf
(
"start polling
\n
"
);
while
(
!
exiting
)
{
if
(
netsim_n2d_s
ync
(
&
nsif_a
,
cur_ts
,
eth_latency
,
sync_period
,
sync_mode
)
!=
0
)
{
fprintf
(
stderr
,
"
netsim_n2d_s
ync(nsif_a) failed
\n
"
);
if
(
SimbricksNetIfN2DS
ync
(
&
nsif_a
,
cur_ts
,
eth_latency
,
sync_period
,
sync_mode
)
!=
0
)
{
fprintf
(
stderr
,
"
SimbricksNetIfN2DS
ync(nsif_a) failed
\n
"
);
abort
();
}
if
(
netsim_n2d_s
ync
(
&
nsif_b
,
cur_ts
,
eth_latency
,
sync_period
,
sync_mode
)
!=
0
)
{
fprintf
(
stderr
,
"
netsim_n2d_s
ync(nsif_a) failed
\n
"
);
if
(
SimbricksNetIfN2DS
ync
(
&
nsif_b
,
cur_ts
,
eth_latency
,
sync_period
,
sync_mode
)
!=
0
)
{
fprintf
(
stderr
,
"
SimbricksNetIfN2DS
ync(nsif_a) failed
\n
"
);
abort
();
}
netsim_a
dvance
_e
poch
(
cur_ts
,
sync_period
,
sync_mode
);
SimbricksNetIfA
dvance
E
poch
(
cur_ts
,
sync_period
,
sync_mode
);
do
{
move_pkt
(
&
nsif_a
,
&
nsif_b
);
move_pkt
(
&
nsif_b
,
&
nsif_a
);
ts_a
=
netsim_d2n_t
imestamp
(
&
nsif_a
);
ts_b
=
netsim_d2n_t
imestamp
(
&
nsif_b
);
ts_a
=
SimbricksNetIfD2NT
imestamp
(
&
nsif_a
);
ts_b
=
SimbricksNetIfD2NT
imestamp
(
&
nsif_b
);
}
while
(
!
exiting
&&
((
sync_a
&&
ts_a
<=
cur_ts
)
||
(
sync_b
&&
ts_b
<=
cur_ts
)));
if
(
sync_a
&&
sync_b
)
cur_ts
=
netsim_a
dvance
_t
ime
(
ts_a
<=
ts_b
?
ts_a
:
ts_b
,
sync_period
,
sync_mode
);
cur_ts
=
SimbricksNetIfA
dvance
T
ime
(
ts_a
<=
ts_b
?
ts_a
:
ts_b
,
sync_period
,
sync_mode
);
else
if
(
sync_a
)
cur_ts
=
netsim_a
dvance
_t
ime
(
ts_a
,
sync_period
,
sync_mode
);
cur_ts
=
SimbricksNetIfA
dvance
T
ime
(
ts_a
,
sync_period
,
sync_mode
);
else
if
(
sync_b
)
cur_ts
=
netsim_a
dvance
_t
ime
(
ts_b
,
sync_period
,
sync_mode
);
cur_ts
=
SimbricksNetIfA
dvance
T
ime
(
ts_b
,
sync_period
,
sync_mode
);
}
if
(
dumpfile
)
...
...
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