-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat(nebula_hw_interfaces): better UDP socket #231
Conversation
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
…o everywhere Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
…down Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #231 +/- ##
==========================================
+ Coverage 26.10% 27.21% +1.11%
==========================================
Files 100 104 +4
Lines 9218 9458 +240
Branches 2215 2322 +107
==========================================
+ Hits 2406 2574 +168
- Misses 6423 6449 +26
- Partials 389 435 +46
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
… feat/better-udp-socket
…received Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Unit tests have been written, but things like querying |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments! Many are questions and there are no must-do changes but please have a look and I will approve once confirmed.
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
* @brief Gracefully stops the active receiver thread (if any) but keeps the socket alive. The | ||
* same socket can later be subscribed again. | ||
*/ | ||
UdpSocket & unsubscribe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the socket is kept alive, should we consider shutting it down to prevent reading from it?
shutdown(sock_fd_, SHUT_RD);
and associated error handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that
- the only reads made are in the now-stopped
receive_thread_
- the user might want to re-subscribe with the same socket later (kind of an esoteric argument maybe...)
- I'm not sure how to re-open a connection once shut down
I think it would best be left open. As far as I understand, since the socket is not actually close
d by shutdown
, there should not be any performance/resource difference between doing/not doing it here.
|
||
~UdpSocket() | ||
{ | ||
unsubscribe(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to leave any subscribed multicast groups on destruction? (or in unsubscribe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that Linux does this automatically: StackOverflow.
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Show resolved
Hide resolved
...a_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
… a compiler error Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
nit: (i.e., ignore as needed) |
Thanks for the PR. It had been a while since I got to see direct socket programming 😃 |
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
…lity modifiers Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
@drwnz @knzo25 Thank you for your feedback, I think I addressed everything now.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
…like optional.emplace() etc. Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
PR Type
Description
The current Boost.ASIO/transport_drivers implementation is bloated and does not offer all the features we need for accurate timing and packet loss measurement.
Specifically, a good equivalent to
recvmsg
(seeman recvmsg
for details) is not supported.This PR introduces a new, minimal and robust UDP socket implementation with the following features:
SO_TIMESTAMP
(seeman 7 socket
)SO_RXQ_OVFL
(seeman 7 socket
)*: Depending on the network interface hardware, the timestamp will be measured in hardware on packet arrival, or by the kernel in software as soon as possible after. In any case, the timing is much more accurate than doing it in user space, where scheduling has a huge impact on accuracy.
Usage
I aimed to document the class as well as possible, but still, here is a quick rundown of how to use the socket:
Functions can also be chained like this:
auto sock = UdpSocket().init(...).bind().subscribe(...);
Pre-Review Checklist for the PR Author
PR Author should check the checkboxes below when creating the PR.
Checklist for the PR Reviewer
Reviewers should check the checkboxes below before approval.
Post-Review Checklist for the PR Author
PR Author should check the checkboxes below before merging.
CI Checks