Skip to content

Commit

Permalink
Add configuration of multipathServiceType in NIOTS(Listen|Connection)…
Browse files Browse the repository at this point in the history
…Bootstrap

Motivation:

Allow different devices to leverage the capabilities of Mutipath TCP (MPTCP) to
enhance the network reliability. Thanks to MPTCP, a connection can for example
automatically migrate to another interface if it deteriorates on the first one.
This can be especially interesting on MacOS X and iOS, where devices may frequently
benefit from multiple interfaces (ethernet + Wi-Fi for Macs and Wi-fi + cellular for
iOS). Allowing developers to enable MPTCP on their connections seems thus like a fine
addition to this library.

Modifications:

Added a function "withMultipath" on NIOTSConnectionBootstrap and
NIOTSListenerBootstrap, that allow to configure the type of service used for MPTCP
(defaults to disabled). This will then set the appropriate channel option, which will
be propagated to the underlying channel.

Result:

Users will now be able to easily enable Multipath TCP, allowing them to benefit from
seamless handover, interactive mode to automatically use the lowest delay interface or
aggregate mode to send data in parallel on both interfaces.
  • Loading branch information
Aperence committed Sep 2, 2024
1 parent 38ac822 commit 265156b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/NIOTransportServices/NIOTSConnectionBootstrap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ public final class NIOTSConnectionBootstrap {
return self
}

/// Specifies a type of Multipath service to use for this connection, instead of the default
/// service type for the event loop.
public func withMultipath(_ type: NWParameters.MultipathServiceType) -> Self {
self.channelOption(NIOTSChannelOptions.multipathServiceType, value: type)
}

/// Specify the `host` and `port` to connect to for the TCP `Channel` that will be established.
///
/// - parameters:
Expand Down
10 changes: 10 additions & 0 deletions Sources/NIOTransportServices/NIOTSListenerBootstrap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ public final class NIOTSListenerBootstrap {
return self
}

/// Specifies a type of Multipath service to use for this listener, instead of the default
/// service type for the event loop.
///
/// Warning: Multipath service doesn't seem supported on the listener side yet, as
/// described on https://www.mptcp.dev/macOS.html. Note that enabling Multipath
/// may then generate unexpected errors, use this function with caution.
public func withMultipath(_ type: NWParameters.MultipathServiceType) -> Self {
self.serverChannelOption(NIOTSChannelOptions.multipathServiceType, value: type)
}

/// Bind the `NIOTSListenerChannel` to `host` and `port`.
///
/// - parameters:
Expand Down

0 comments on commit 265156b

Please sign in to comment.