Skip to content
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

Support propagating ECN information on AddressedEnvelopes #1472

Closed
5 tasks
Lukasa opened this issue Apr 7, 2020 · 3 comments
Closed
5 tasks

Support propagating ECN information on AddressedEnvelopes #1472

Lukasa opened this issue Apr 7, 2020 · 3 comments

Comments

@Lukasa
Copy link
Contributor

Lukasa commented Apr 7, 2020

It is possible that users of datagram channels may be interested in ECN information associated with the IP packets that carry the datagrams. It's possible to obtain this information from the OS and for us to propagate it through the channel, but today we do not.

The proposal for how to do so comes in multiple parts, each of which is probably a separate chunk of work:

  • Add support for AddressedEnvelope to carry arbitrary metadata in a performant way

    This probably involves adding a metadata field to AddressedEnvelope that is usually empty, and only ever filled when necessary. This metadata will need to be keyed and typed. This is a straightforward Swift-level data structure problem, and requires no NIO-specific knowledge.

  • Move datagram channels over to using recvmsg in the single-read case, instead of recvfrom. (Move DatagramChannel over to using recvmsg. #1473)

    This allows us to extract metadata from socket reads.

  • Wire up extracting metadata of known types from recvmsg.

    Just a straightforward extension. We need to minimise allocations here, so we should aim to be careful about how we build this. Ideally we'll use the stack.

  • Add a ChannelOption that allows users to request ECN information, and then make sure we extract and propagate that information.

  • Update swift-nio-transport-services to support this new flag, as Network.framework automatically provides this information for us.

PeterAdams-A added a commit that referenced this issue May 5, 2020
Add Optional ECN MetaData to Addressed Envelope

Motivation:

This is a very small step along the path to #1472

Modifications:

Add an optional metadata field to addressed envelope. Currently the only possible data is ECN information. This is not currently populated anywhere.

Result:

Metadata in place for future work.

Co-authored-by: Cory Benfield <lukasa@apple.com>
@PeterAdams-A
Copy link
Contributor

Solved for swift-nio iin #1587, #1590, #1591, #1593 , #1594 and #1596.

I've made an issue in transport services - apple/swift-nio-transport-services#100 to track adding this support there.

@ovidiuurotaru
Copy link

Can we also read ECN flags using NIO?

@Lukasa
Copy link
Contributor Author

Lukasa commented Feb 16, 2022

Yes, this is implemented. Set ChannelOption.explicitCongestionNotification on your DatagramBootstrap to enable it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants