Skip to content

First version of Multipath TCP support in curl#9713

Closed
obonaventure wants to merge 1 commit intocurl:masterfrom
mptcp-apps:mptcp-clean
Closed

First version of Multipath TCP support in curl#9713
obonaventure wants to merge 1 commit intocurl:masterfrom
mptcp-apps:mptcp-clean

Conversation

@obonaventure
Copy link

@obonaventure obonaventure commented Oct 12, 2022

Initial support for Multipath TCP for curl. Multipath TCP is a TCP extension defined in RFC8684 that is supported by recent Linux kernels (5.13+). Multipath TCP allows a TCP connection to use different paths (e.g. Wi-Fi and cellular on smartphones, IPv4 and IPv6, ...). Multipath TCP is enabled by default on recent Linux distributions (Debian, Ubuntu, Redhat,...)

This patch provides the --multipath command line option that enables Multipath TCP when set. If running on a kernel that does not support Multipath TCP, curl remembers the fact that Multipath TCP does not work and does not attempt anymore to use Multipath TCP when creating a TCP connection. Another possibility would be to always enable Multipath TCP by default on Linux.

With the patch, curl reports the activation of Multipath TCP when interacting with a Multipath TCP server.

Compile with -DMPTCP to enable Multipath TCP support

* Multipath TCP is enabled.
*   Trying [2001:41d0:a:ffcf::1]:80...
* Failed to set TCP_KEEPIDLE on fd 5
* Failed to set TCP_KEEPINTVL on fd 5
* Connected to test.multipath-tcp.org (2001:41d0:a:ffcf::1) port 80 (#0)
* Multipath TCP was accepted by the remote server.
> GET / HTTP/1.1
> Host: test.multipath-tcp.org
> User-Agent: curl/7.86.0-DEV
> Accept: */*
>
* Mark bundle as not supporting multiuse < HTTP/1.1 200 OK
< Content-Type: text/html
< Accept-Ranges: bytes
< ETag: "4215149735"
< Last-Modified: Tue, 05 Jul 2022 16:11:47 GMT
< Content-Length: 389
< Date: Wed, 12 Oct 2022 16:32:51 GMT
< Server: lighttpd/1.4.59
<
<!DOCTYPE html>
<html>
<head>
<title>Welcome to test.multipath-tcp.org!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to test.multipath-tcp.org !</h1>
<p>This web server runs Multipath TCP v1</p>

<p><em>Thank you for using Multipath TCP.</em></p> </body>
</html>
* Connection #0 to host test.multipath-tcp.org left intact

First version of Multipath TCP support in curl, compile with ./configure CPPFLAGS="-DMPTCP"

Initial support for Multipath TCP for curl. Multipath TCP is a TCP extension defined in
RFC8684 that is supported by recent Linux kernels (5.13+). Multipath TCP allows a
TCP connection to use different paths (e.g. Wi-Fi and cellular on smartphones, IPv4 and
IPv6, ...). Multipath TCP is enabled by default on recent Linux distributions
(Debian, Ubuntu, Redhat,...)

This patch provides the --multipath command line option that enables Multipath TCP
when set. If running on a kernel that does not support Multipath TCP, curl remembers
the fact that Multipath TCP does not work and does not attempt anymore to use Multipath TCP
when creating a TCP connection. Another possibility would be to always enable Multipath
TCP by default on Linux.

With the patch, curl reports the activation of Multipath TCP when interacting with a
Multipath TCP server.

Compile with -DMPTCP to enable Multipath TCP support

* Multipath TCP is enabled.
*   Trying [2001:41d0:a:ffcf::1]:80...
* Failed to set TCP_KEEPIDLE on fd 5
* Failed to set TCP_KEEPINTVL on fd 5
* Connected to test.multipath-tcp.org (2001:41d0:a:ffcf::1) port 80 (#0)
* Multipath TCP was accepted by the remote server.
> GET / HTTP/1.1
> Host: test.multipath-tcp.org
> User-Agent: curl/7.86.0-DEV
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html
< Accept-Ranges: bytes
< ETag: "4215149735"
< Last-Modified: Tue, 05 Jul 2022 16:11:47 GMT
< Content-Length: 389
< Date: Wed, 12 Oct 2022 16:32:51 GMT
< Server: lighttpd/1.4.59
<
<!DOCTYPE html>
<html>
<head>
<title>Welcome to test.multipath-tcp.org!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to test.multipath-tcp.org !</h1>
<p>This web server runs Multipath TCP v1</p>

<p><em>Thank you for using Multipath TCP.</em></p>
</body>
</html>
* Connection #0 to host test.multipath-tcp.org left intact

First version of Multipath TCP support in curl, compile with ./configure CPPFLAGS="-DMPTCP"
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. I think this is a future that might get appreciated. I think the PR needs a little more polish though. There is also no docs. I imagine creating tests for this is hard.

/* Set Multipath TCP */
CURLOPT(CURLOPT_TCP_MULTIPATH, CURLOPTTYPE_LONG, 316),
#endif

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public header, it cannot use #ifdefs like this. The symbols need to be provided no matter what.

#endif /* MPTCP */



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block looks like it's there for debugging? Maybe use #ifdef DEBUGBUILD as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good suggestion

Curl_set_in_callback(data, false);
}
else
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't modify whitespace.

#endif

return CURLE_OK;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

conn->bits.close = closeit; /* the only place in the source code that
should assign this bit */
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

#include <netinet/in.h> /* IPPROTO_TCP */
#endif


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just no

(void)protocol;

listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
printf("mptcp\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug leftover?


listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
printf("mptcp\n");
listener = socket(AF_INET, SOCK_STREAM, IPPROTO_MPTCP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

#endif
#endif


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why duplicate this snippet?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mistake, apologies. Windows does not support MPTCP and nothing needs to be changed in this file

{"Em", "tlsauthtype", ARG_STRING},
#ifdef MPTCP
{"EM", "multipath", ARG_BOOL},
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cmdline options cannot be ifdef'ed like this, as the tool might not know what features the lib was built with.

@obonaventure
Copy link
Author

Thanks for your comments, I'm looking at them and will propose an update. I'll propose some documentation. For the tests, I can propose a modification to the http server to enable multipath tcp and then add a few tests. These tests would only work on recent linux kernels.

@bagder bagder added the feature-window A merge of this requires an open feature window label Oct 13, 2022
@bagder
Copy link
Member

bagder commented Dec 3, 2022

Additionally: macOS supports multipath TCP as well so it would make sense to provide this feature there was well.

Are you still up for working on this PR?

@bagder
Copy link
Member

bagder commented May 14, 2023

Abandoned.

@bagder bagder closed this May 14, 2023
@gvanem
Copy link
Contributor

gvanem commented May 15, 2023

Looks like someone else has added MTCP to curl (on Windows at least):
https://github.com/ngi-mptcp/curl/wiki/Multipath-TCP-on-Windows-10

With the help of wintap and LKL; a Linux Kernel Library. Fascinating stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connecting & proxies feature-window A merge of this requires an open feature window

Development

Successfully merging this pull request may close these issues.

3 participants