Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
31441586
Commit
31441586
authored
Jun 02, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to print histograms to stdout on exit
parent
f696b55f
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
218 additions
and
118 deletions
+218
-118
packet-exchange/src/client.c
packet-exchange/src/client.c
+186
-112
packet-exchange/src/send_packet.c
packet-exchange/src/send_packet.c
+26
-4
packet-exchange/src/send_packet.h
packet-exchange/src/send_packet.h
+3
-1
packet-exchange/src/server.c
packet-exchange/src/server.c
+1
-1
packet-exchange/src/utilities.h
packet-exchange/src/utilities.h
+2
-0
No files found.
packet-exchange/src/client.c
View file @
31441586
This diff is collapsed.
Click to expand it.
packet-exchange/src/send_packet.c
View file @
31441586
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
#define MESSAGE ((uint32_t)0x00FACADE)
#define MESSAGE ((uint32_t)0x00FACADE)
static
void
process_timestamps
(
struct
packet_timestamps
*
packet_ts
);
static
void
process_timestamps
(
struct
packet_timestamps
*
packet_ts
,
int64_t
histograms
[
NB_HISTOGRAMS
][
MAX_HIST_VAL
]
);
static
void
init_tx_buffer
(
size_t
_tx_buffer_len
);
static
void
init_tx_buffer
(
size_t
_tx_buffer_len
);
static
int
so_priority
=
3
;
static
int
so_priority
=
3
;
...
@@ -148,7 +148,8 @@ uint64_t get_txtime() {
...
@@ -148,7 +148,8 @@ uint64_t get_txtime() {
*/
*/
struct
packet_timestamps
send_udp_packet
(
int
use_etf
,
int
use_timestamps
,
struct
packet_timestamps
send_udp_packet
(
int
use_etf
,
int
use_timestamps
,
uint64_t
txtime
,
uint64_t
txtime
,
const
char
*
server_ip
)
{
const
char
*
server_ip
,
int64_t
histograms
[
NB_HISTOGRAMS
][
MAX_HIST_VAL
])
{
char
control
[
CMSG_SPACE
(
sizeof
(
txtime
))]
=
{};
char
control
[
CMSG_SPACE
(
sizeof
(
txtime
))]
=
{};
struct
sockaddr_in
sin
;
struct
sockaddr_in
sin
;
struct
cmsghdr
*
cmsg
;
struct
cmsghdr
*
cmsg
;
...
@@ -205,7 +206,7 @@ struct packet_timestamps send_udp_packet(int use_etf, int use_timestamps,
...
@@ -205,7 +206,7 @@ struct packet_timestamps send_udp_packet(int use_etf, int use_timestamps,
if
(
use_timestamps
)
{
if
(
use_timestamps
)
{
res
=
poll
(
&
poll_fd
,
1
,
0
);
res
=
poll
(
&
poll_fd
,
1
,
0
);
if
(
res
>
0
)
if
(
res
>
0
)
process_timestamps
(
&
packet_ts
);
process_timestamps
(
&
packet_ts
,
histograms
);
else
else
fprintf
(
stderr
,
"select failed
\n
"
);
fprintf
(
stderr
,
"select failed
\n
"
);
}
}
...
@@ -213,7 +214,27 @@ struct packet_timestamps send_udp_packet(int use_etf, int use_timestamps,
...
@@ -213,7 +214,27 @@ struct packet_timestamps send_udp_packet(int use_etf, int use_timestamps,
return
packet_ts
;
return
packet_ts
;
}
}
static
void
process_timestamps
(
struct
packet_timestamps
*
packet_ts
)
{
static
void
fill_histograms
(
struct
packet_timestamps
*
packet_ts
,
int64_t
histograms
[
NB_HISTOGRAMS
][
MAX_HIST_VAL
])
{
uint64_t
user_space_time
=
packet_ts
->
user_call_sendmsg
-
packet_ts
->
user_enter_send
;
uint64_t
kernel_space_time
=
packet_ts
->
kernel_leave
-
packet_ts
->
user_call_sendmsg
;
user_space_time
/=
1000u
;
kernel_space_time
/=
1000u
;
if
(
user_space_time
>
MAX_HIST_VAL
)
{
fprintf
(
stderr
,
"user_space_time value too high: %"
PRIu64
"us
\n
"
,
user_space_time
);
exit
(
EXIT_FAILURE
);
}
if
(
kernel_space_time
>
MAX_HIST_VAL
)
{
fprintf
(
stderr
,
"kernel_space_time value too high: %"
PRIu64
"us
\n
"
,
kernel_space_time
);
exit
(
EXIT_FAILURE
);
}
histograms
[
0
][
user_space_time
]
++
;
histograms
[
1
][
kernel_space_time
]
++
;
}
static
void
process_timestamps
(
struct
packet_timestamps
*
packet_ts
,
int64_t
histograms
[
NB_HISTOGRAMS
][
MAX_HIST_VAL
])
{
char
data
[
256
];
char
data
[
256
];
struct
msghdr
msg
;
struct
msghdr
msg
;
struct
iovec
entry
;
struct
iovec
entry
;
...
@@ -243,6 +264,7 @@ static void process_timestamps(struct packet_timestamps *packet_ts) {
...
@@ -243,6 +264,7 @@ static void process_timestamps(struct packet_timestamps *packet_ts) {
if
(
cmsg
->
cmsg_level
==
SOL_SOCKET
&&
cmsg
->
cmsg_type
==
SO_TIMESTAMPING
)
{
if
(
cmsg
->
cmsg_level
==
SOL_SOCKET
&&
cmsg
->
cmsg_type
==
SO_TIMESTAMPING
)
{
struct
timespec
*
stamp
=
(
struct
timespec
*
)
CMSG_DATA
(
cmsg
);
struct
timespec
*
stamp
=
(
struct
timespec
*
)
CMSG_DATA
(
cmsg
);
packet_ts
->
kernel_leave
=
ts_to_uint
(
*
stamp
);
packet_ts
->
kernel_leave
=
ts_to_uint
(
*
stamp
);
fill_histograms
(
packet_ts
,
histograms
);
}
else
{
}
else
{
#ifdef DEBUG
#ifdef DEBUG
fprintf
(
stderr
,
"process_timestamps: level %d type %d"
,
cmsg
->
cmsg_level
,
fprintf
(
stderr
,
"process_timestamps: level %d type %d"
,
cmsg
->
cmsg_level
,
...
...
packet-exchange/src/send_packet.h
View file @
31441586
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
#include <stdint.h>
#include <stdint.h>
#include <stdio.h>
#include <stdio.h>
#include "utilities.h"
struct
packet_timestamps
{
struct
packet_timestamps
{
uint64_t
user_enter_send
;
uint64_t
user_enter_send
;
uint64_t
user_call_sendmsg
;
uint64_t
user_call_sendmsg
;
...
@@ -11,6 +13,6 @@ struct packet_timestamps {
...
@@ -11,6 +13,6 @@ struct packet_timestamps {
};
};
void
init_udp_send
(
int
use_etf
,
int
use_timestamps
,
int
so_priority
,
char
*
network_if
,
size_t
tx_buffer_len
);
void
init_udp_send
(
int
use_etf
,
int
use_timestamps
,
int
so_priority
,
char
*
network_if
,
size_t
tx_buffer_len
);
struct
packet_timestamps
send_udp_packet
(
int
use_etf
,
int
use_timestamps
,
uint64_t
txtime
,
const
char
*
server_ip
);
struct
packet_timestamps
send_udp_packet
(
int
use_etf
,
int
use_timestamps
,
uint64_t
txtime
,
const
char
*
server_ip
,
int64_t
histograms
[
NB_HISTOGRAMS
][
MAX_HIST_VAL
]
);
#endif
#endif
packet-exchange/src/server.c
View file @
31441586
...
@@ -98,7 +98,7 @@ static void *packet_receiving_thread(void *p) {
...
@@ -98,7 +98,7 @@ static void *packet_receiving_thread(void *p) {
for
(
stats
->
packets_received
=
0
;;
stats
->
packets_received
++
)
{
for
(
stats
->
packets_received
=
0
;;
stats
->
packets_received
++
)
{
if
(
param
->
tsn_task
==
RTT_TASK
)
{
if
(
param
->
tsn_task
==
RTT_TASK
)
{
recv_udp_packet
(
param
->
sockfd
);
recv_udp_packet
(
param
->
sockfd
);
send_udp_packet
(
0
,
0
,
0
,
param
->
ip_address
);
send_udp_packet
(
0
,
0
,
0
,
param
->
ip_address
,
NULL
);
}
else
if
(
param
->
tsn_task
==
RECV_PACKET_TASK
)
{
}
else
if
(
param
->
tsn_task
==
RECV_PACKET_TASK
)
{
recv_udp_packet
(
param
->
sockfd
);
recv_udp_packet
(
param
->
sockfd
);
...
...
packet-exchange/src/utilities.h
View file @
31441586
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
#define NSEC_PER_SEC UINT64_C(1000000000)
#define NSEC_PER_SEC UINT64_C(1000000000)
#define SERVER_PORT "50000"
#define SERVER_PORT "50000"
#define SERVER_PORT_INT 50000
#define SERVER_PORT_INT 50000
#define MAX_HIST_VAL 1000
#define NB_HISTOGRAMS 3
uint64_t
ts_to_uint
(
struct
timespec
t
);
uint64_t
ts_to_uint
(
struct
timespec
t
);
void
add_ns
(
struct
timespec
*
t
,
uint64_t
ns
);
void
add_ns
(
struct
timespec
*
t
,
uint64_t
ns
);
...
...
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