-
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
sys/net/gnrc/tx_sync: new module #15694
Conversation
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.
Some initial thoughts.
Rebased on master, as #15839 is now merged. I guess it is time to also add synchronization for the link-layer fragmentation use case, so that the WIP label can be dropped. |
872b599
to
7886b0e
Compare
let's reorder the commits, so that each commit can be individually compiled to ease |
6c2525e
to
3442a87
Compare
So, |
@jia200x suggested that it is a bad idea to bundle I can split this out and just split the Generally, I do believe that throttling 6LoWPAN fragmentation to match the speed of the transceiver is beneficial. (I also agree that just blocking in the 6LoWPAN thread is a quick and dirty hack, rather than a clean solution.) But I fully agree that bundling throttling of fragmentation with I will look into this asap. |
I still think this would be a small price to pay for getting actually working 6LoWPAN fragmentation with all drivers. (And the possibility to remove the hacks that were added to the drivers to make 6LoWPAN fragmentation work) |
Agreed. But there is no harm in allowing the user to decide on this. E.g. one could instead use (And we could still add (say) |
well, wouldn't 6LoWPAN work with all |
I had to add |
Ah yes, but you don't need to add that if you use the Radio HAL (the send function never blocks). That's how it's implemented in the CC2538 and NRF802154 |
Both The hack in the |
I remember you proposed to create a "generic network device" in the RDM. Although there were some discussions there, maybe this use case can be a concrete example (let's say a generic radio + some technology specific extensions). |
I'm still all in for this :-) In the meantime, allowing users to throttle the 6LoWPAN thread should be a quick fix. But anyway, I dropped this from this PR, so that this could be a separate PR and a separate (pseudo)module. We could document that we plan removing this module right away, when a better solution is merged. |
The new `gnrc_tx_sync` module allows users of the GNRC network stack to synchronize with the actual transmission of outgoing packets. This is directly integrated into gnrc_sock. Hence, if `gnrc_tx_sync` is used, calls to e.g. sock_udp_send() will block until the network stack has processed the message. Use cases: 1. Prevent packet drop when sending at high rate - If the application is sending faster than the stack can handle, the message queues will overflow and outgoing packets are lost 2. Passing auxiliary data about the transmission back the stack - When e.g. the number of required retransmissions, the transmission time stamp, etc. should be made available to a user of an UDP sock, a synchronization mechanism is needed 3. Simpler error reporting without footguns - The current approach of using `core/msg` for passing up error messages is difficult to use if other message come in. Currently, gnrc_sock is busy-waiting and fetching messages from the message queue until the number of expected status reports is received. It will enqueue all non-status-report messages again at the end of the queue. This has multiple issues: - Busy waiting is especially in lower power scenarios with time slotted MAC protocols harmful, as the CPU will remain active and consume power even though the it could sleep until the TX slot is reached - The status reports from the network stack are send to the user thread blocking. If the message queue of the user thread is full, the network stack would block until the user stack can fetch the messages. If another higher priority thread would start sending a message, it would busy wait for its status reports to completely come in. Hence, the first thread doesn't get CPU time to fetch messages and unblock the network stack. As a result, the system would lock up completely. - Just adding the error/status code to the gnrc_tx_sync_t would preallocate and reserve memory for the error reporting. That way gnrc_sock does not need to search through the message queue for status reports and the network stack does not need to block for the user thread fetching it.
@miri64: I adapted the test to now use a simulated IEEE 802.15.4 or a simulated Ethernet devices and dropped the additional netdev type. |
From my side this is ready to get merged, so please squash. Let's see if Murdock finds any issues. |
It is currently not possible to use both gnrc_tx_sync and gnrc_sixlowpand_frag_sfr at the same time - this will be added in a follow up PR.
All green :-) |
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.
Then take this green as well :-)! ACK!
Thanks! :-) |
From #15694 (comment)
See #16020 |
Contribution description
The new
gnrc_tx_sync
module allows users of the GNRC network stack to synchronize with the actual transmission of outgoing packets. This is directly integrated into gnrc_sock. Hence, ifgnrc_tx_sync
is used, calls to e.g. sock_udp_send() will block until the network stack has processed the message.Use cases:
core/msg
for passing up error messages is difficult to use if other message come in. Currently, gnrc_sock is busy-waiting and fetching messages from the message queue until the number of expected status reports is received. It will enqueue all non-status-report messages again at the end of the queue. This has multiple issues:Testing procedure
tests/gnrc_tx_sync
as is. It should pass.USEMODULE += gnrc_tx_sync
in the test'sMakefile
. The test should fail now.State
The first should be handled before merging, the second could be a follow up.
Issues/PRs references
None