-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ethos: race condition seems to cause packet loss #17254
Comments
That the loss does not happen on the host side, can be seen by the fact, that there is no diagnostic output indicating that from the host-side tool (which the patch also adds). |
The issue is not reproducable on |
If I output the bytes at the "two ends of the wire" like this diff --git a/core/include/log.h b/core/include/log.h
index d656f4ab21..05349f0314 100644
--- a/core/include/log.h
+++ b/core/include/log.h
@@ -68,7 +68,7 @@ enum {
/**
* @brief Default log level define
*/
-#define LOG_LEVEL LOG_INFO
+#define LOG_LEVEL LOG_NONE
#endif
/**
diff --git a/dist/tools/ethos/ethos.c b/dist/tools/ethos/ethos.c
index fc4f8c94ce..a93f1ae817 100644
--- a/dist/tools/ethos/ethos.c
+++ b/dist/tools/ethos/ethos.c
@@ -44,6 +44,8 @@
/* Size of serial write buffer */
#define SERIAL_BUFFER_SIZE 64
+static int _serial_fd;
+
static void usage(void)
{
fprintf(stderr, "Usage: ethos <tap> <serial> [baudrate]\n");
@@ -52,6 +54,14 @@ static void usage(void)
static void checked_write(int handle, void *buffer, int nbyte)
{
+ if (handle == _serial_fd) {
+ for (int i = 0; i < nbyte; i++) {
+ const uint8_t c = ((uint8_t *)buffer)[i];
+ fputc((c >> 4) + '0', stderr);
+ fputc((c & 0xf) + '0', stderr);
+ }
+ fputc('\n', stderr);
+ }
while (nbyte > 0) {
ssize_t res = write(handle, buffer, nbyte);
if (res <= 0) {
@@ -526,6 +536,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Error opening serial device %s\n", argv[2]);
return 1;
}
+ _serial_fd = serial_fd;
fd_set readfds;
int max_fd = (serial_fd > tap_fd) ? serial_fd : tap_fd;
diff --git a/drivers/ethos/ethos.c b/drivers/ethos/ethos.c
index 8fd83b8692..c91a52403f 100644
--- a/drivers/ethos/ethos.c
+++ b/drivers/ethos/ethos.c
@@ -139,6 +139,14 @@ static void ethos_isr(void *arg, uint8_t c)
{
ethos_t *dev = (ethos_t *) arg;
+ if (c == 0x7e) {
+ fputc('\n', stdout);
+ }
+ fputc((c >> 4) + '0', stdout);
+ fputc((c & 0xf) + '0', stdout);
+ if (c == 0x7e) {
+ fputc('\n', stdout);
+ }
switch (dev->state) {
case WAIT_FRAMESTART:
if (c == ETHOS_FRAME_DELIMITER) {
diff --git a/examples/gnrc_border_router/Makefile.board.dep b/examples/gnrc_border_router/Makefile.board.dep
index 12f755ceb4..40a7fe5d88 100644
--- a/examples/gnrc_border_router/Makefile.board.dep
+++ b/examples/gnrc_border_router/Makefile.board.dep
@@ -3,7 +3,7 @@ ifeq (,$(filter native,$(BOARD)))
ifeq (slip,$(UPLINK))
USEMODULE += slipdev_stdio
else ifeq (ethos,$(UPLINK))
- USEMODULE += stdio_ethos
+ USEMODULE += ethos
else ifeq (wifi,$(UPLINK))
ifneq (,$(filter esp32 esp8266,$(CPU)))
USEMODULE += esp_wifi
diff --git a/examples/gnrc_border_router/Makefile.ethos.conf b/examples/gnrc_border_router/Makefile.ethos.conf
index 9a7d1484cd..bbabde3835 100644
--- a/examples/gnrc_border_router/Makefile.ethos.conf
+++ b/examples/gnrc_border_router/Makefile.ethos.conf
@@ -1,4 +1,4 @@
-CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
+CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE) -DETHOS_UART="UART_DEV(1)"
STATIC_ROUTES ?= 1
@@ -9,4 +9,4 @@ endif
# Configure terminal parameters
TERMDEPS += host-tools
TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh
-TERMFLAGS ?= $(FLAGS_EXTRAS) $(PORT) $(TAP) $(IPV6_PREFIX) $(ETHOS_BAUDRATE)
+TERMFLAGS ?= $(FLAGS_EXTRAS) /dev/ttyUSB0 $(TAP) $(IPV6_PREFIX) $(ETHOS_BAUDRATE) and use ethos over an external FTDI adapter (I first made sure that the issue persists as described in OP), I get after some manual work the following diff: --- ethos-host-bytes.txt 2021-11-23 18:49:07.722777135 +0100
+++ ethos-node-bytes.txt 2021-11-23 18:49:04.852746903 +0100
@@ -7,25 +7,25 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f500390001
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f400390002
+a600e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f400390002
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f300390003
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f200390004
+a6efe2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f200390004
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f100390005
+a66b88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f100390005
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f000390006
+a6efbc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0f000390006
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ef00390007
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ee00390008
+a6becbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ee00390008
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ed00390009
@@ -34,31 +34,31 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ec0039000a
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0eb0039000b
+a688bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0eb0039000b
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ea0039000c
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e90039000d
+a67d86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e90039000d
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e80039000e
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e70039000f
+a6887d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e70039000f
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e600390010
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e500390011
+a6bb7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e500390011
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e400390012
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e300390013
+a6bcf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e300390013
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e200390014
@@ -67,13 +67,13 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e100390015
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e000390016
+a6becbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0e000390016
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0df00390017
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0de00390018
+a6cbdd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0de00390018
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0dd00390019
@@ -82,7 +82,7 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0dc0039001a
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0db0039001b
+a65d86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0db0039001b
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0da0039001c
@@ -91,7 +91,7 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d90039001d
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d80039001e
+a6bb5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d80039001e
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d70039001f
@@ -100,13 +100,13 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d600390020
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d500390021
+a6868400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d500390021
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d400390022
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d300390023
+a6e2cbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d300390023
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d200390024
@@ -115,7 +115,7 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d100390025
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d000390026
+a6bcf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0d000390026
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0cf00390027
@@ -124,25 +124,25 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ce00390028
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0cd00390029
+a6efbc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0cd00390029
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0cc0039002a
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0cb0039002b
+a6becbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0cb0039002b
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0ca0039002c
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c90039002d
+a6e2f54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c90039002d
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c80039002e
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c70039002f
+a6efbc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c70039002f
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c600390030
@@ -151,7 +151,7 @@
a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c500390031
7e
7e
-a66bef88bbbee2bc7d5dcbf54f86dd6007b38400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c400390032
+a6868400083a40fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbe8000e0c400390032
7e
7e
a66bef88bbbee2bc7d5dcbf54f86dd600dc35000161140fe80000000000000e0bc7d5dfffecbf54ffe80000000000000a46beffffe88bbbeb1df30390016b78a The manual work enticed: aligning newlines and mapping the ASCII-based hexadecimal output to the traditional one:
So I definitely use bytes (at with this approach), but maybe this is due to the interrupt being blocked, since I print stuff in it 😅. |
I used a |
Same goes for |
This:
let's me think, that the latter of the initial quote is rather the case. Especially, since I multiplexed stdio over SLIP in that trial. |
The race condition is fixed in #17265. |
Description
I did not finish my final analysis yet, but there seems to be a race condition in the RIOT-side of
ethos
, that is the cause of packet loss over the wire: I was able to pinpoint loss inethos
to thisif
not being takenRIOT/drivers/ethos/ethos.c
Lines 94 to 98 in 68e1d29
not being called, since
dev->accept_new
, when barraging the ethos line (withethos_stdio
).Steps to reproduce the issue
I used the the following patch to analyze the loss behavior:
Patch
and flashed the
examples/gnrc_border_router
example in its default config to aniotlab-m3
.The patch introduces several diagnostic tools:
Escaped X (offset Y) in Z
can be ignored, it was just used to assure the issue does not stem from escaping.!a
is printed every time in_handle_char
when theif (dev->accept_new)
branch is not taken,n;Z
is printed when in the netdevrecv
method the echo request sequence numberZ-1
was skippedreq_recv
is introduced to theexamples/gnrc_border_router
example that prints the number of ICMPv6 echo requests seen by the netdevrecv
method.I used
ifconfig
to determine the link-local address of the ethos interface on theiotlab-m3
and pinged it with an interval of 10ms.Expected results
The number of
packets transmitted
byping
should equal the number returned by the patched-inreq_recv
command, the live diagnostic output added by the patch should not appear (except for theEscaped X (offset Y) in Z
output).Actual results
The number of
packets transmitted
byping
is larger than the number returned by the patched-inreq_recv
command, the live diagnostic output showswhere Z is an echo request sequence number that saw no predecessor, is shown for every echo request that is missing in the number returned by the patched-in
req_recv
command, indicating, that the echo request was lost, due to branch above not taken (!a
may be shown multiple times beforen;Z
due to other frames lost).Versions
Analysis was done on 770fe2f, but I guess this issue exists since the inception of
ethos
.The text was updated successfully, but these errors were encountered: