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
781fea12
Commit
781fea12
authored
May 28, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to pass the tx buffer length
parent
2c75283c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
15 deletions
+47
-15
packet-exchange/src/client.c
packet-exchange/src/client.c
+19
-10
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
+2
-1
No files found.
packet-exchange/src/client.c
View file @
781fea12
...
@@ -3,14 +3,15 @@
...
@@ -3,14 +3,15 @@
*
*
* Bash options:
* Bash options:
*
*
* -a Run the real time thread on CPU1
* -a Run the real time thread on CPU1
* -e Set a txtime (to be used in an ETF qdisc)
* -d TX_BUFFER_LEN Set the length of tx buffer
* -f Set the network interface to be used
* -e Set a txtime (to be used in an ETF qdisc)
* -i USEC Wake up the real time thread every USEC microseconds (Default: 10ms)
* -f Set the network interface to be used
* -l N Wake up the real time thread N times (Default: 0)
* -i USEC Wake up the real time thread every USEC microseconds (Default: 10ms)
* -p PRIO Run the real time thread at priority PRIO
* -l N Wake up the real time thread N times (Default: 0)
* -r USEC Refresh the non real time main thread every USEC microseconds (Default: 50ms)
* -p PRIO Run the real time thread at priority PRIO
* -t Enable timestamps
* -r USEC Refresh the non real time main thread every USEC microseconds (Default: 50ms)
* -t Enable timestamps
*
*
* Large portions taken from cyclictest
* Large portions taken from cyclictest
*
*
...
@@ -54,6 +55,7 @@ typedef struct thread_param {
...
@@ -54,6 +55,7 @@ typedef struct thread_param {
typedef
struct
main_param
{
typedef
struct
main_param
{
int
refresh_rate
;
int
refresh_rate
;
int
packet_priority
;
int
packet_priority
;
size_t
tx_buffer_len
;
}
main_param_t
;
}
main_param_t
;
static
inline
void
add_ns
(
struct
timespec
*
t
,
uint64_t
ns
);
static
inline
void
add_ns
(
struct
timespec
*
t
,
uint64_t
ns
);
...
@@ -126,7 +128,7 @@ int main(int argc, char *argv[]) {
...
@@ -126,7 +128,7 @@ int main(int argc, char *argv[]) {
// Process bash options
// Process bash options
process_options
(
argc
,
argv
,
&
param
,
&
main_param
);
process_options
(
argc
,
argv
,
&
param
,
&
main_param
);
init_udp_etf
(
param
.
enable_etf
,
param
.
enable_timestamps
,
main_param
.
packet_priority
,
param
.
network_if
);
init_udp_etf
(
param
.
enable_etf
,
param
.
enable_timestamps
,
main_param
.
packet_priority
,
param
.
network_if
,
main_param
.
tx_buffer_len
);
usleep
(
10000
);
usleep
(
10000
);
...
@@ -150,7 +152,7 @@ int main(int argc, char *argv[]) {
...
@@ -150,7 +152,7 @@ int main(int argc, char *argv[]) {
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
main_param_t
*
main_param
)
{
main_param_t
*
main_param
)
{
for
(;;)
{
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"aef:i:l:p:q:r:t"
);
int
c
=
getopt
(
argc
,
argv
,
"a
d:
ef:i:l:p:q:r:t"
);
if
(
c
==
-
1
)
break
;
if
(
c
==
-
1
)
break
;
...
@@ -158,6 +160,13 @@ static void process_options(int argc, char *argv[], thread_param_t *param,
...
@@ -158,6 +160,13 @@ static void process_options(int argc, char *argv[], thread_param_t *param,
case
'a'
:
case
'a'
:
param
->
enable_affinity
=
1
;
param
->
enable_affinity
=
1
;
break
;
break
;
case
'd'
:
main_param
->
tx_buffer_len
=
atoi
(
optarg
);
if
(
main_param
->
tx_buffer_len
<
1
)
{
fprintf
(
stderr
,
"TX_BUFFER_LEN should be greater than 1
\n
"
);
exit
(
EXIT_FAILURE
);
}
break
;
case
'e'
:
case
'e'
:
param
->
enable_etf
=
1
;
param
->
enable_etf
=
1
;
break
;
break
;
...
...
packet-exchange/src/send_packet.c
View file @
781fea12
...
@@ -44,11 +44,12 @@
...
@@ -44,11 +44,12 @@
static
void
print_timestamps
(
struct
msghdr
*
msg
,
uint64_t
txtime
);
static
void
print_timestamps
(
struct
msghdr
*
msg
,
uint64_t
txtime
);
static
void
process_timestamps
(
uint64_t
txtime
);
static
void
process_timestamps
(
uint64_t
txtime
);
static
void
init_tx_buffer
(
size_t
_tx_buffer_len
);
static
int
so_priority
=
3
;
static
int
so_priority
=
3
;
static
struct
sock_txtime
sk_txtime
;
static
struct
sock_txtime
sk_txtime
;
static
unsigned
char
tx_buffer
[
1024
]
=
"Hi"
;
static
unsigned
char
*
tx_buffer
;
static
size_t
tx_buffer_len
=
sizeof
(
tx_buffer
)
;
static
size_t
tx_buffer_len
;
static
int
fd
;
static
int
fd
;
static
int64_t
tai_offset
;
static
int64_t
tai_offset
;
...
@@ -69,15 +70,35 @@ static int set_if(char *network_if) {
...
@@ -69,15 +70,35 @@ static int set_if(char *network_if) {
return
ifreq
.
ifr_ifindex
;
return
ifreq
.
ifr_ifindex
;
}
}
static
void
init_tx_buffer
(
size_t
_tx_buffer_len
)
{
if
(
_tx_buffer_len
<
1
)
{
fprintf
(
stderr
,
"tx buffer length should be greater than 1
\n
"
);
exit
(
EXIT_FAILURE
);
}
tx_buffer_len
=
_tx_buffer_len
;
tx_buffer
=
malloc
(
tx_buffer_len
);
for
(
int
i
=
0
;
i
<
(
((
int
)
tx_buffer_len
)
-
1
);
i
++
)
{
tx_buffer
[
i
]
=
(
unsigned
char
)
i
;
}
tx_buffer
[
tx_buffer_len
-
1
]
=
'\0'
;
}
/*
/*
* Init UDP socket
* Init UDP socket
*/
*/
void
init_udp_etf
(
int
use_etf
,
int
use_timestamps
,
int
packet_priority
,
void
init_udp_etf
(
int
use_etf
,
int
use_timestamps
,
int
packet_priority
,
char
*
network_if
)
{
char
*
network_if
,
size_t
_tx_buffer_len
)
{
int
index
;
int
index
;
struct
timespec
ts_mon
;
struct
timespec
ts_mon
;
struct
timespec
ts_tai
;
struct
timespec
ts_tai
;
init_tx_buffer
(
_tx_buffer_len
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts_mon
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts_mon
);
clock_gettime
(
CLOCK_TAI
,
&
ts_tai
);
clock_gettime
(
CLOCK_TAI
,
&
ts_tai
);
tai_offset
=
(
ts_mon
.
tv_sec
-
ts_tai
.
tv_sec
)
*
NSEC_PER_SEC
+
(
ts_mon
.
tv_nsec
-
ts_tai
.
tv_nsec
);
tai_offset
=
(
ts_mon
.
tv_sec
-
ts_tai
.
tv_sec
)
*
NSEC_PER_SEC
+
(
ts_mon
.
tv_nsec
-
ts_tai
.
tv_nsec
);
...
@@ -240,12 +261,13 @@ static void print_timestamps(struct msghdr *msg, uint64_t txtime) {
...
@@ -240,12 +261,13 @@ static void print_timestamps(struct msghdr *msg, uint64_t txtime) {
}
}
#ifdef DEBUG
#ifdef DEBUG
/*
/*
* Code from scheduled_tx_tools
* Code from scheduled_tx_tools
*/
*/
static
int
process_socket_error_queue
()
{
static
int
process_socket_error_queue
()
{
uint8_t
msg_control
[
CMSG_SPACE
(
sizeof
(
struct
sock_extended_err
))];
uint8_t
msg_control
[
CMSG_SPACE
(
sizeof
(
struct
sock_extended_err
))];
unsigned
char
err_buffer
[
sizeof
(
tx_buffer
)
];
unsigned
char
err_buffer
[
256
];
struct
sock_extended_err
*
serr
;
struct
sock_extended_err
*
serr
;
struct
cmsghdr
*
cmsg
;
struct
cmsghdr
*
cmsg
;
__u64
tstamp
=
0
;
__u64
tstamp
=
0
;
...
...
packet-exchange/src/send_packet.h
View file @
781fea12
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
#define SEND_PACKET_H
#define SEND_PACKET_H
#include <stdint.h>
#include <stdint.h>
#include <stdio.h>
void
init_udp_etf
(
int
use_etf
,
int
use_timestamps
,
int
so_priority
,
char
*
network_if
);
void
init_udp_etf
(
int
use_etf
,
int
use_timestamps
,
int
so_priority
,
char
*
network_if
,
size_t
tx_buffer_len
);
void
send_udp_packet
(
int
use_etf
,
int
use_timestamps
,
uint64_t
txtime
,
const
char
*
server_ip
);
void
send_udp_packet
(
int
use_etf
,
int
use_timestamps
,
uint64_t
txtime
,
const
char
*
server_ip
);
#endif
#endif
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