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
cb90ef6c
Commit
cb90ef6c
authored
Jun 03, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalize jitter value for the server histogram
parent
f30202f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
16 deletions
+34
-16
packet-exchange/src/server.c
packet-exchange/src/server.c
+32
-14
packet-exchange/src/utilities.h
packet-exchange/src/utilities.h
+2
-2
No files found.
packet-exchange/src/server.c
View file @
cb90ef6c
...
...
@@ -40,6 +40,7 @@ typedef struct thread_stat {
}
thread_stat_t
;
typedef
struct
thread_param
{
int
interval
;
int
priority
;
thread_stat_t
stats
;
...
...
@@ -82,13 +83,14 @@ struct timespec measures_start;
struct
timespec
measures_end
;
static
void
help
(
char
*
argv
[])
{
printf
(
"Usage: %s [-aghtv] [-b CLIENT_IP] [-d BUF_LEN] [-f IF] [-p PRIO] [-r USEC]
\n\n
"
,
argv
[
0
]);
printf
(
"Usage: %s [-aghtv] [-b CLIENT_IP] [-d BUF_LEN] [-f IF] [-
i USEC] [-
p PRIO] [-r USEC]
\n\n
"
,
argv
[
0
]);
printf
(
" -a Run the real time thread on CPU1
\n
"
);
printf
(
" -b CLIENT_IP Server side RTT
\n
"
);
printf
(
" -d BUF_LEN Set the length of tx buffer
\n
"
);
printf
(
" -f IF Set the network interface to be used
\n
"
);
printf
(
" -g Print histograms to sdtout on exit
\n
"
);
printf
(
" -h Show help
\n
"
);
printf
(
" -i USEC Wake up the real time thread every USEC microseconds (Default: 10ms)
\n
"
);
printf
(
" -p PRIO Run the real time thread at priority PRIO
\n
"
);
printf
(
" -r USEC Refresh the non real time main thread every USEC microseconds
\n
"
);
printf
(
" -t Enable timestamps
\n
"
);
...
...
@@ -105,6 +107,7 @@ static void *packet_receiving_thread(void *p) {
thread_stat_t
*
stats
=
&
param
->
stats
;
uint64_t
diff
=
0
;
cpu_set_t
mask
;
int64_t
dist_to_interval
;
stats
->
min_interval
=
UINT64_MAX
;
stats
->
max_interval
=
0
;
...
...
@@ -142,12 +145,16 @@ static void *packet_receiving_thread(void *p) {
stats
->
min_interval
=
diff
<
stats
->
min_interval
?
diff
:
stats
->
min_interval
;
stats
->
max_interval
=
diff
>
stats
->
max_interval
?
diff
:
stats
->
max_interval
;
if
(
diff
>
MAX_HIST_VAL
*
1000
)
{
fprintf
(
stderr
,
"jitter higher than MAX_HIST_VAL
\n
"
);
exit
(
EXIT_FAILURE
);
}
else
{
histograms
[
2
][
diff
/
1000
]
=
diff
/
1000
;
if
(
enable_histograms
)
{
dist_to_interval
=
(
diff
-
param
->
interval
)
/
1000
;
dist_to_interval
+=
MAX_HIST_VAL
/
2
;
if
(
dist_to_interval
>
((
int
)
MAX_HIST_VAL
)
||
dist_to_interval
<
0
)
{
fprintf
(
stderr
,
"jitter higher than MAX_HIST_VAL
\n
"
);
exit
(
EXIT_FAILURE
);
}
else
{
histograms
[
2
][
dist_to_interval
]
++
;
}
}
}
...
...
@@ -172,6 +179,7 @@ int main(int argc, char *argv[]) {
stats
=
&
param
->
stats
;
// Default configuration values
param
->
interval
=
100000
*
1000
;
param
->
priority
=
99
;
enable_affinity
=
0
;
...
...
@@ -243,7 +251,7 @@ static void print_histograms() {
duration_hour
=
duration
/
NSEC_PER_SEC
/
3600
;
duration_minutes
=
duration
/
NSEC_PER_SEC
/
60
-
duration_hour
*
60
;
interval
=
(
param
->
stats
.
min_interval
+
param
->
stats
.
max_interval
)
/
2
/
1000
;
interval
=
param
->
interval
/
1000
;
printf
(
"{
\"
measure_sets
\"
: [{"
"
\"
measure_type
\"
:
\"
packet_recv_timestamps
\"
,"
...
...
@@ -268,21 +276,28 @@ static void print_histograms() {
printf
(
"%s"
,
(
i
+
1
<
2
?
"], "
:
"]"
));
}
max_hist_val
=
0
;
for
(
int
j
=
0
;
j
<
MAX_HIST_VAL
&&
histograms
[
2
][
j
];
j
++
)
max_hist_val
=
j
;
min_hist_val
=
0
;
for
(
int
j
=
MAX_HIST_VAL
-
1
;
j
>=
0
&&
histograms
[
2
][
j
];
j
--
)
min_hist_val
=
j
;
printf
(
"]}, {"
"
\"
measure_type
\"
:
\"
packet_jitter
\"
,"
"
\"
props_names
\"
: [
\"
jitter
\"
],"
"
\"
units
\"
: [
\"
us
\"
],"
"
\"
props_type
\"
:
\"
histogram
\"
,"
"
\"
middle
\"
:
\"
%d
\"
,"
"
\"
metadata
\"
: {"
"
\"
i
\"
:
\"
%dus
\"
,
\"
duration
\"
:
\"
%dh%d
\"
"
"},"
"
\"
props
\"
: [["
,
interval
,
duration_hour
,
duration_minutes
);
"
\"
props
\"
: [["
,
interval
,
MAX_HIST_VAL
/
2
-
min_hist_val
,
duration_hour
,
duration_minutes
);
max_hist_val
=
0
;
for
(
int
j
=
0
;
j
<
MAX_HIST_VAL
&&
histograms
[
2
][
j
];
j
++
)
max_hist_val
=
j
;
for
(
int
j
=
0
;
j
<
max_hist_val
;
j
++
)
for
(
int
j
=
min_hist_val
;
j
<
max_hist_val
;
j
++
)
printf
(
"%"
PRIi64
"%s"
,
histograms
[
2
][
j
],
(
j
+
1
<
max_hist_val
?
", "
:
""
));
printf
(
"]]}]}
\n
"
);
...
...
@@ -330,6 +345,9 @@ static void process_options(int argc, char *argv[]) {
help
(
argv
);
exit
(
EXIT_SUCCESS
);
break
;
case
'i'
:
param
->
interval
=
atoi
(
optarg
)
*
1000
;
break
;
case
'g'
:
enable_histograms
=
1
;
break
;
...
...
packet-exchange/src/utilities.h
View file @
cb90ef6c
...
...
@@ -10,8 +10,8 @@
#define NSEC_PER_SEC UINT64_C(1000000000)
#define SERVER_PORT "50000"
#define SERVER_PORT_INT 50000
#define MAX_HIST_VAL
1
000
#define NB_HISTOGRAMS
2
#define MAX_HIST_VAL
2
000
#define NB_HISTOGRAMS
3
typedef
struct
packet_timestamps
{
uint64_t
enter_user_space
;
...
...
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