Skip to content

Commit

Permalink
Add configuration of multipathServiceType in NIOTSConnectionBootstrap
Browse files Browse the repository at this point in the history
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, that allow to configure
the type of service used for MPTCP (defaults to disabled). This value will be stored
in a field, and then propagated to the underlying channel when the connect method
will be called. Also updated the parameters field of NIOTSConnectionChannel to set
the multipathServiceType accordingly.

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 Aug 23, 2024
1 parent 38ac822 commit b41c098
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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
4 changes: 3 additions & 1 deletion Sources/NIOTransportServices/NIOTSConnectionChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ internal final class NIOTSConnectionChannel: StateManagedNWConnectionChannel {
internal var connectPromise: EventLoopPromise<Void>?

internal var parameters: NWParameters {
NWParameters(tls: self.tlsOptions, tcp: self.tcpOptions)
let parameters = NWParameters(tls: self.tlsOptions, tcp: self.tcpOptions)
parameters.multipathServiceType = self.multipathServiceType
return parameters
}

/// The TCP options for this connection.
Expand Down

0 comments on commit b41c098

Please sign in to comment.