RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

sys/net/gnrc: implement sock_aux_timestamp for TX

Open maribu opened this issue 4 years ago • 9 comments

Contribution description

  • Introduce type netdev_tx_info_t, which contains a timestamp if (pseudo-)module netdev_tx_info_timestamp is used
  • Extend gnrc_tx_sync_t to contain a member netdev_tx_info_t tx_info, which can be used to transfer TX info up the stack
  • Extend gnrc_netif to pass the new tx_info member of gnrc_tx_sync_t to netdev_driver_t::confirm_send() when module gnrc_tx_sync is used
  • Extend gnrc_sock to pass timestamp in gnrc_tx_sync_t::tx_info up to sock_udp_send_aux() / sock_ip_send_aux(), which in turn are extended to pass this on to the user
  • Implement PTP timestamping for TX in stm32_eth

Testing procedure

  • make BOARD=nucleo-f767zi -C tests/sock_udp_aux flash term
  • Check the IPv6 address of the Nucleo via ifconfig
  • Send UDP packets directed at port 12345 of the Nucleo

The output should look like this

2021-01-29 09:53:25,054 # main(): This is RIOT! (Version: 2021.04-devel-366-g1932ed-tx_timestamp)
2021-01-29 09:53:25,058 # UDP echo server listening at port 12345
> ifconfig
2021-01-29 09:53:28,013 #  ifconfig
2021-01-29 09:53:28,018 # Iface  4  HWaddr: AA:C8:16:C2:3C:6D  Link: up 
2021-01-29 09:53:28,024 #           L2-PDU:1500  MTU:1500  HL:64  Source address length: 6
2021-01-29 09:53:28,027 #           Link type: wired
2021-01-29 09:53:28,032 #           inet6 addr: fe80::a8c8:16ff:fec2:3c6d  scope: link  VAL
2021-01-29 09:53:28,035 #           inet6 group: ff02::1
2021-01-29 09:53:28,038 #           inet6 group: ff02::1:ffc2:3c6d
2021-01-29 09:53:28,039 #           
2021-01-29 09:53:28,042 #           Statistics for Layer 2
2021-01-29 09:53:28,045 #             RX packets 2  bytes 180
2021-01-29 09:53:28,050 #             TX packets 2 (Multicast: 2)  bytes 140
2021-01-29 09:53:28,053 #             TX succeeded 2 errors 0
2021-01-29 09:53:28,056 #           Statistics for IPv6
2021-01-29 09:53:28,059 #             RX packets 2  bytes 152
2021-01-29 09:53:28,063 #             TX packets 2 (Multicast: 2)  bytes 112
2021-01-29 09:53:28,067 #             TX succeeded 2 errors 0
2021-01-29 09:53:28,067 # 
>
2021-01-29 09:53:33,848 # Received a message via: [fe80::a8c8:16ff:fec2:3c6d]:12345
2021-01-29 09:53:33,851 # Received a message at: 8795389140 ns
2021-01-29 09:53:33,854 # Received a message with: No RSSI value
2021-01-29 09:53:33,857 # Sent echo at: 8807312980 ns
2021-01-29 09:53:33,862 # Received a message via: [fe80::a8c8:16ff:fec2:3c6d]:12345
2021-01-29 09:53:33,865 # Received a message at: 8807667580 ns
2021-01-29 09:53:33,869 # Received a message with: No RSSI value
2021-01-29 09:53:33,871 # Sent echo at: 8821608820 ns
2021-01-29 09:53:42,175 # Received a message via: [fe80::a8c8:16ff:fec2:3c6d]:12345
2021-01-29 09:53:42,179 # Received a message at: 17122866530 ns
2021-01-29 09:53:42,182 # Received a message with: No RSSI value
2021-01-29 09:53:42,185 # Sent echo at: 17134910120 ns
2021-01-29 09:53:42,190 # Received a message via: [fe80::a8c8:16ff:fec2:3c6d]:12345
2021-01-29 09:53:42,193 # Received a message at: 17135254480 ns
2021-01-29 09:53:42,196 # Received a message with: No RSSI value
2021-01-29 09:53:42,199 # Sent echo at: 17149379960 ns
2021-01-29 09:53:43,471 # Received a message via: [fe80::a8c8:16ff:fec2:3c6d]:12345
2021-01-29 09:53:43,474 # Received a message at: 18418614030 ns
2021-01-29 09:53:43,478 # Received a message with: No RSSI value
2021-01-29 09:53:43,481 # Sent echo at: 18430627420 ns
2021-01-29 09:53:43,486 # Received a message via: [fe80::a8c8:16ff:fec2:3c6d]:12345
2021-01-29 09:53:43,489 # Received a message at: 18430879180 ns
2021-01-29 09:53:43,492 # Received a message with: No RSSI value
2021-01-29 09:53:43,495 # Sent echo at: 18445097980 ns

Issues/PRs references

Depends on and includes:

  • [x] https://github.com/RIOT-OS/RIOT/pull/15694
  • [x] https://github.com/RIOT-OS/RIOT/pull/15821

maribu avatar Jan 29 '21 08:01 maribu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

stale[bot] avatar Mar 02 '22 13:03 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

stale[bot] avatar Nov 02 '22 02:11 stale[bot]

IIRC we have some form of confirm send now?

benpicco avatar Nov 02 '22 11:11 benpicco

Yes, this should indeed work, provided that a driver would actually use confirm_send. But with lwIP support still missing, conversion of drivers has not started yet :/

maribu avatar Nov 02 '22 13:11 maribu

This needs a rebase.

benpicco avatar May 13 '24 09:05 benpicco

This was a hell of a rebase, but it seems to work:

$ make BOARD=nucleo-f767zi flash term -C tests/net/sock_udp_aux
Building application "tests_sock_udp_aux" for "nucleo-f767zi" with CPU "stm32".

"make" -C /home/maribu/Repos/software/RIOT/master/pkg/cmsis/ 
"make" -C /home/maribu/Repos/software/RIOT/master/boards/common/init
"make" -C /home/maribu/Repos/software/RIOT/master/boards/nucleo-f767zi
Remapping MOSI of SPI_DEV(0) from PA7 to PB5 to solve pin conflict. (PA7 is also connected to the RMII_DV of the Ethernet Phy.)
"make" -C /home/maribu/Repos/software/RIOT/master/boards/common/nucleo
"make" -C /home/maribu/Repos/software/RIOT/master/core
"make" -C /home/maribu/Repos/software/RIOT/master/core/lib
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/stm32
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/cortexm_common
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/cortexm_common/periph
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/stm32/periph
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/stm32/stmclk
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/stm32/vectors
"make" -C /home/maribu/Repos/software/RIOT/master/drivers
"make" -C /home/maribu/Repos/software/RIOT/master/drivers/netdev
"make" -C /home/maribu/Repos/software/RIOT/master/drivers/periph_common
"make" -C /home/maribu/Repos/software/RIOT/master/sys
"make" -C /home/maribu/Repos/software/RIOT/master/sys/auto_init
"make" -C /home/maribu/Repos/software/RIOT/master/sys/div
"make" -C /home/maribu/Repos/software/RIOT/master/sys/event
"make" -C /home/maribu/Repos/software/RIOT/master/sys/evtimer
"make" -C /home/maribu/Repos/software/RIOT/master/sys/fmt
"make" -C /home/maribu/Repos/software/RIOT/master/sys/frac
"make" -C /home/maribu/Repos/software/RIOT/master/sys/iolist
"make" -C /home/maribu/Repos/software/RIOT/master/sys/isrpipe
"make" -C /home/maribu/Repos/software/RIOT/master/sys/libc
"make" -C /home/maribu/Repos/software/RIOT/master/sys/luid
"make" -C /home/maribu/Repos/software/RIOT/master/sys/malloc_thread_safe
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/crosslayer/inet_csum
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/netapi
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/netif
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/netif/ethernet
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/netif/hdr
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/netif/init_devs
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/netreg
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/network_layer/icmpv6
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/network_layer/icmpv6/echo
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/network_layer/ipv6
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/network_layer/ipv6/hdr
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/network_layer/ipv6/nib
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/network_layer/ndp
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/pkt
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/pktbuf
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/pktbuf_static
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/sock
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/sock/udp
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/transport_layer/udp
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/gnrc/tx_sync
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/link_layer/eui_provider
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/link_layer/l2util
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/netif
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/netutils
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/network_layer/icmpv6
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/network_layer/ipv6/addr
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/network_layer/ipv6/hdr
"make" -C /home/maribu/Repos/software/RIOT/master/sys/net/transport_layer/udp
"make" -C /home/maribu/Repos/software/RIOT/master/sys/newlib_syscalls_default
"make" -C /home/maribu/Repos/software/RIOT/master/sys/pm_layered
"make" -C /home/maribu/Repos/software/RIOT/master/sys/preprocessor
"make" -C /home/maribu/Repos/software/RIOT/master/sys/ps
"make" -C /home/maribu/Repos/software/RIOT/master/sys/random
"make" -C /home/maribu/Repos/software/RIOT/master/sys/shell
"make" -C /home/maribu/Repos/software/RIOT/master/sys/shell/cmds
"make" -C /home/maribu/Repos/software/RIOT/master/sys/stdio
"make" -C /home/maribu/Repos/software/RIOT/master/sys/stdio_uart
"make" -C /home/maribu/Repos/software/RIOT/master/sys/tsrb
"make" -C /home/maribu/Repos/software/RIOT/master/sys/ztimer
   text	  data	   bss	   dec	   hex	filename
  61028	   172	 15760	 76960	 12ca0	/home/maribu/Repos/software/RIOT/master/tests/net/sock_udp_aux/bin/nucleo-f767zi/tests_sock_udp_aux.elf
/home/maribu/Repos/software/RIOT/master/dist/tools/openocd/openocd.sh flash /home/maribu/Repos/software/RIOT/master/tests/net/sock_udp_aux/bin/nucleo-f767zi/tests_sock_udp_aux.elf
### Flashing Target ###
Open On-Chip Debugger 0.12.0+dev-snapshot (2024-01-17-08:38)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter serial' not 'hla_serial'
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : clock speed 2000 kHz
Info : STLINK V2J38M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.246224
Info : [stm32f7x.cpu] Cortex-M7 r1p0 processor detected
Info : [stm32f7x.cpu] target has 8 breakpoints, 4 watchpoints
Info : [stm32f7x.cpu] Examination succeed
Info : starting gdb server for stm32f7x.cpu on 0
Info : Listening on port 43969 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f7x.cpu       hla_target little stm32f7x.cpu       unknown
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
[stm32f7x.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08001194 msp: 0x20000200
Info : device id = 0x10016451
Info : flash size = 2048 KiB
Info : Single Bank 2048 kiB STM32F76x/77x found
auto erase enabled
wrote 65536 bytes from file /home/maribu/Repos/software/RIOT/master/tests/net/sock_udp_aux/bin/nucleo-f767zi/tests_sock_udp_aux.elf in 1.514101s (42.269 KiB/s)
verified 61200 bytes in 0.330502s (180.833 KiB/s)
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
shutdown command invoked
Done flashing
/home/maribu/Repos/software/RIOT/master/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200"  
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2024-05-13 19:17:43,758 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2024-05-13 19:17:46,516 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:17:46,519 # Received a message at: 2911628590 ns
2024-05-13 19:17:46,522 # Received a message with: No RSSI value
2024-05-13 19:17:46,525 # Sent echo at: 2923611310 ns
2024-05-13 19:17:46,530 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:17:46,533 # Received a message at: 2923903340 ns
2024-05-13 19:17:46,537 # Received a message with: No RSSI value
2024-05-13 19:17:46,539 # Sent echo at: 2937983980 ns
2024-05-13 19:17:51,807 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:17:51,811 # Received a message at: 8203303810 ns
2024-05-13 19:17:51,814 # Received a message with: No RSSI value
2024-05-13 19:17:51,817 # Sent echo at: 8215286610 ns
2024-05-13 19:17:51,822 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:17:51,825 # Received a message at: 8215667610 ns
2024-05-13 19:17:51,828 # Received a message with: No RSSI value
2024-05-13 19:17:51,831 # Sent echo at: 8229661680 ns
2024-05-13 19:17:54,006 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:17:54,009 # Received a message at: 10401876680 ns
2024-05-13 19:17:54,013 # Received a message with: No RSSI value
2024-05-13 19:17:54,015 # Sent echo at: 10413945410 ns
2024-05-13 19:17:54,020 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:17:54,024 # Received a message at: 10414264840 ns
2024-05-13 19:17:54,027 # Received a message with: No RSSI value
2024-05-13 19:17:54,030 # Sent echo at: 10428463150 ns
2024-05-13 19:18:00,095 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:00,099 # Received a message at: 16491132940 ns
2024-05-13 19:18:00,102 # Received a message with: No RSSI value
2024-05-13 19:18:00,105 # Sent echo at: 16503204020 ns
2024-05-13 19:18:00,110 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:00,113 # Received a message at: 16503560650 ns
2024-05-13 19:18:00,116 # Received a message with: No RSSI value
2024-05-13 19:18:00,119 # Sent echo at: 16517726680 ns
2024-05-13 19:18:00,684 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:00,687 # Received a message at: 17079406300 ns
2024-05-13 19:18:00,690 # Received a message with: No RSSI value
2024-05-13 19:18:00,693 # Sent echo at: 17091477780 ns
2024-05-13 19:18:00,698 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:00,701 # Received a message at: 17091796330 ns
2024-05-13 19:18:00,705 # Received a message with: No RSSI value
2024-05-13 19:18:00,707 # Sent echo at: 17105995770 ns
2024-05-13 19:18:01,160 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:01,163 # Received a message at: 17555448650 ns
2024-05-13 19:18:01,166 # Received a message with: No RSSI value
2024-05-13 19:18:01,169 # Sent echo at: 17567519570 ns
2024-05-13 19:18:01,174 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:01,177 # Received a message at: 17567850400 ns
2024-05-13 19:18:01,181 # Received a message with: No RSSI value
2024-05-13 19:18:01,184 # Sent echo at: 17582037080 ns
2024-05-13 19:18:01,636 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:01,640 # Received a message at: 18031926790 ns
2024-05-13 19:18:01,643 # Received a message with: No RSSI value
2024-05-13 19:18:01,645 # Sent echo at: 18043997910 ns
2024-05-13 19:18:01,651 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:01,654 # Received a message at: 18044345220 ns
2024-05-13 19:18:01,657 # Received a message with: No RSSI value
2024-05-13 19:18:01,660 # Sent echo at: 18058515780 ns
2024-05-13 19:18:02,095 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:02,099 # Received a message at: 18491363440 ns
2024-05-13 19:18:02,102 # Received a message with: No RSSI value
2024-05-13 19:18:02,105 # Sent echo at: 18503434600 ns
2024-05-13 19:18:02,110 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:02,113 # Received a message at: 18503774760 ns
2024-05-13 19:18:02,117 # Received a message with: No RSSI value
2024-05-13 19:18:02,119 # Sent echo at: 18517951750 ns
2024-05-13 19:18:02,587 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:02,591 # Received a message at: 18983181510 ns
2024-05-13 19:18:02,594 # Received a message with: No RSSI value
2024-05-13 19:18:02,597 # Sent echo at: 18995253030 ns
2024-05-13 19:18:02,602 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:02,605 # Received a message at: 18995580270 ns
2024-05-13 19:18:02,609 # Received a message with: No RSSI value
2024-05-13 19:18:02,611 # Sent echo at: 19009770660 ns
2024-05-13 19:18:02,996 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:03,000 # Received a message at: 19392172690 ns
2024-05-13 19:18:03,003 # Received a message with: No RSSI value
2024-05-13 19:18:03,006 # Sent echo at: 19404243730 ns
2024-05-13 19:18:03,011 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:03,014 # Received a message at: 19404538240 ns
2024-05-13 19:18:03,018 # Received a message with: No RSSI value
2024-05-13 19:18:03,020 # Sent echo at: 19418791230 ns
2024-05-13 19:18:03,355 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:03,359 # Received a message at: 19751116490 ns
2024-05-13 19:18:03,362 # Received a message with: No RSSI value
2024-05-13 19:18:03,365 # Sent echo at: 19763187890 ns
2024-05-13 19:18:03,370 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:03,373 # Received a message at: 19763504440 ns
2024-05-13 19:18:03,376 # Received a message with: No RSSI value
2024-05-13 19:18:03,379 # Sent echo at: 19777706000 ns
2024-05-13 19:18:04,414 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:04,417 # Received a message at: 20809582200 ns
2024-05-13 19:18:04,420 # Received a message with: No RSSI value
2024-05-13 19:18:04,423 # Sent echo at: 20821652640 ns
2024-05-13 19:18:04,428 # Received a message via: [fe80::6824:8dff:fe9e:4d53]:12345
2024-05-13 19:18:04,432 # Received a message at: 20821967680 ns
2024-05-13 19:18:04,435 # Received a message with: No RSSI value
2024-05-13 19:18:04,438 # Sent echo at: 20836170270 ns

maribu avatar May 13 '24 17:05 maribu

Murdock results

:x: FAILED

5129a8dad1aef28e3b89fea030c9886fcc6d03ae sys/net/gnrc: add dependencies for sock_aux_timestamp

Success Failures Total Runtime
1319 0 9265 02m:35s

Artifacts

riot-ci avatar May 13 '24 17:05 riot-ci

tests/net/gnrc_sock_{ip, udp} are still failing

benpicco avatar Jun 06 '24 15:06 benpicco

tests/net/gnrc_sock_{ip, udp} are still failing

Indeed :frowning:. It also fails for me in master when I use

$ USEMODULE=gnrc_tx_sync make -C tests/net/gnrc_sock_ip

gnrc_tx_sync hooks into the reference counting of outgoing packets. If the outgoing packet is never freed again, it will deadlock. So either there is a memory leak (that now is turned into a deadlock with gnrc_tx_sync), or gnrc_tx_sync contains a bug. I'll take a look tomorrow.

maribu avatar Jun 06 '24 19:06 maribu