add MPTCPv1 support
Geliang Tang
reviewerPATCH v3 1/1 add MPTCPv1 support
The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in the upstream Linux kernel since v5.6.
MPTCP is strongly tied to TCP, and the kernel APIs are almost the same. The only required dependency is the 'IPPROTO_MPTCP' protocol number definition, which should be provided by the netinet/in.h header if it is recent enough.
This patch adds a new flag '-m' or '--multipath' to support MPTCPv1. It can be used like this:
Quoted 2 lines
iperf3 -m -s
iperf3 -m -c 127.0.0.1
There is no need to check for IPPROTO_MPTCP support in configure.ac at build time, it is at runtime we will see if the kernel being use supports or not MPTCP.
If IPPROTO_MPTCP is not supported by the kernel being tested, it is normal to fail because the feature is not available and the user explicitly asked to use MPTCP.
--- src/iperf.h | 3 +++ src/iperf3.1 | 4 ++++ src/iperf_api.c | 15 ++++++++++++++- src/iperf_locale.c | 3 +++ src/iperf_tcp.c | 18 +++++++++++++++--- src/net.c | 10 +++++----- src/net.h | 2 +- 7 files changed, 45 insertions(+), 10 deletions(-)
src/iperf.h +3 -0
@@ -339,6 +339,9 @@ struct iperf_testint udp_counters_64bit;/* --use-64-bit-udp-counters */ int forceflush;/* --forceflush - flushing output at every interval */ int multisend; +#if defined(linux) +int multipath; +#endif int repeating_payload;/* --repeating-payload */ int timestamps;/* --timestamps */ char *timestamp_format;
src/iperf3.1 +4 -0
@@ -193,6 +193,10 @@ parameter is specified in ms, and defaults to the system settings. This functionality depends on the TCP_USER_TIMEOUT socket option, and will not work on systems that do not support it. .TP +.BR -m ", " --multipath " " +use multipath variant for the current protocol. This only applies to +TCP and enables MPTCP usage. +.TP .BR -d ", " --debug " " emit debugging output. Primarily (perhaps exclusively) of use to developers.
src/iperf_api.c +14 -1
@@ -1144,6 +1144,9 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) {"idle-timeout", required_argument, NULL, OPT_IDLE_TIMEOUT}, {"rcv-timeout", required_argument, NULL, OPT_RCV_TIMEOUT}, {"snd-timeout", required_argument, NULL, OPT_SND_TIMEOUT}, +#if defined(linux) + {"multipath", no_argument, NULL, 'm'}, +#endif {"debug", optional_argument, NULL, 'd'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}
@@ -1169,7 +1172,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)FILE *ptr_file;#endif /* HAVE_SSL */ -while ((flag =getopt_long (argc, argv,"p:f:i:D1VJvsc:ub:t:n:k:l:P:Rw:B:M:N46S:L:ZO:F:A:T:C:dI:hX:" , longopts,NULL )) !=-1 ) { +while ((flag =getopt_long (argc, argv,"p:f:i:D1VJvsc:ub:t:n:k:l:P:Rw:B:mM:N46S:L:ZO:F:A:T:C:dI:hX:" , longopts,NULL )) !=-1 ) {switch (flag) {case 'p' : portno =atoi (optarg);
@@ -1639,6 +1642,12 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) test->settings->connect_timeout =unit_atoi (optarg); client_flag =1 ;break ; +#if defined(linux) +case 'm' : +set_protocol (test, Ptcp); + test->multipath =1 ; +break ; +#endif case 'h' :usage_long (stdout);exit (0 );
@@ -2216,6 +2225,8 @@ send_parameters(struct iperf_test *test)cJSON_AddTrueToObject (j,"reverse" );if (test->bidirectional)cJSON_AddTrueToObject (j,"bidirectional" ); +if (test->multipath) +cJSON_AddTrueToObject (j,"multipath" );if (test->settings->socket_bufsize)cJSON_AddNumberToObject (j,"window" , test->settings->socket_bufsize);if (test->settings->blksize)
@@ -2332,6 +2343,8 @@ get_parameters(struct iperf_test *test)iperf_set_test_reverse (test,1 );if ((j_p =cJSON_GetObjectItem (j,"bidirectional" )) !=NULL )iperf_set_test_bidirectional (test,1 ); +if ((j_p =cJSON_GetObjectItem (j,"multipath" )) !=NULL ) + test->multipath =1 ;if ((j_p =cJSON_GetObjectItem (j,"window" )) !=NULL ) test->settings->socket_bufsize = j_p->valueint;if ((j_p =cJSON_GetObjectItem (j,"len" )) !=NULL )
src/iperf_locale.c +3 -0
@@ -128,6 +128,9 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"" --snd-timeout # timeout for unacknowledged TCP data\n" " (in ms, default is system settings)\n"#endif /* HAVE_TCP_USER_TIMEOUT */ +#if defined(linux) + " -m, --multipath use MPTCP rather than plain TCP\n" +#endif " -d, --debug[=#] emit debugging output\n" " (optional optional \"=\" and debug level: 1-4. Default is 4 - all messages)\n" " -v, --version show version information and quit\n"
src/iperf_tcp.c +15 -3
@@ -44,6 +44,10 @@#include "net.h" #include "cjson.h" +#ifndef IPPROTO_MPTCP +#define IPPROTO_MPTCP 262 +#endif +#if defined(HAVE_FLOWLABEL )#include "flowlabel.h" #endif /* HAVE_FLOWLABEL */
@@ -182,9 +186,10 @@ iperf_tcp_listen(struct iperf_test *test)* * It's not clear whether this is a requirement or a convenience. */ -if (test->no_delay || test->settings->mss || test->settings->socket_bufsize) { +if (test->no_delay || test->multipath || test->settings->mss || test->settings->socket_bufsize) {struct addrinfo hints, *res;char portstr[6 ]; +int proto =0 ;FD_CLR (s, &test->read_set);close (s);
@@ -210,7 +215,10 @@ iperf_tcp_listen(struct iperf_test *test)return -1 ; } -if ((s =socket (res->ai_family,SOCK_STREAM ,0 )) <0 ) { +if (test->multipath) + proto =IPPROTO_MPTCP ; + +if ((s =socket (res->ai_family,SOCK_STREAM , proto)) <0 ) {freeaddrinfo (res); i_errno =IESTREAMLISTEN ;return -1 ;
@@ -375,8 +383,12 @@ iperf_tcp_connect(struct iperf_test *test)socklen_t optlen;int saved_errno;int rcvbuf_actual, sndbuf_actual; +int proto =0 ; + +if (test->multipath) + proto =IPPROTO_MPTCP ; - s =create_socket (test->settings->domain,SOCK_STREAM , test->bind_address, test->bind_dev, test->bind_port, test->server_hostname, test->server_port, &server_res); + s =create_socket (test->settings->domain,SOCK_STREAM , proto, test->bind_address, test->bind_dev, test->bind_port, test->server_hostname, test->server_port, &server_res);if (s <0 ) { i_errno =IESTREAMCONNECT ;return -1 ;
src/net.c +5 -5
@@ -124,7 +124,7 @@ timeout_connect(int s, const struct sockaddr *name, socklen_t namelen,/* create a socket */ int -create_socket (int domain,int proto,const char *local,const char *bind_dev,int local_port,const char *server,int port,struct addrinfo **server_res_out) +create_socket (int domain,int type,int proto,const char *local,const char *bind_dev,int local_port,const char *server,int port,struct addrinfo **server_res_out) {struct addrinfo hints, *local_res =NULL , *server_res =NULL ;int s, saved_errno;
@@ -133,14 +133,14 @@ create_socket(int domain, int proto, const char *local, const char *bind_dev, inif (local) {memset (&hints,0 ,sizeof (hints)); hints.ai_family = domain; - hints.ai_socktype = proto; + hints.ai_socktype = type;if ((gerror =getaddrinfo (local,NULL , &hints, &local_res)) !=0 )return -1 ; }memset (&hints,0 ,sizeof (hints)); hints.ai_family = domain; - hints.ai_socktype = proto; + hints.ai_socktype = type;snprintf (portstr,sizeof (portstr),"%d" , port);if ((gerror =getaddrinfo (server, portstr, &hints, &server_res)) !=0 ) {if (local)
@@ -148,7 +148,7 @@ create_socket(int domain, int proto, const char *local, const char *bind_dev, inreturn -1 ; } - s =socket (server_res->ai_family, proto,0 ); + s =socket (server_res->ai_family, type, proto);if (s <0 ) {if (local)freeaddrinfo (local_res);
@@ -238,7 +238,7 @@ netdial(int domain, int proto, const char *local, const char *bind_dev, int locastruct addrinfo *server_res =NULL ;int s, saved_errno; - s =create_socket (domain, proto, local, bind_dev, local_port, server, port, &server_res); + s =create_socket (domain, proto,0 , local, bind_dev, local_port, server, port, &server_res);if (s <0 ) {return -1 ; }
src/net.h +1 -1
@@ -28,7 +28,7 @@#define __NET_Hint timeout_connect (int s,const struct sockaddr *name,socklen_t namelen,int timeout); -int create_socket (int domain,int proto,const char *local,const char *bind_dev,int local_port,const char *server,int port,struct addrinfo **server_res_out); +int create_socket (int domain,int type,int proto,const char *local,const char *bind_dev,int local_port,const char *server,int port,struct addrinfo **server_res_out);int netdial (int domain,int proto,const char *local,const char *bind_dev,int local_port,const char *server,int port,int timeout);int netannounce (int domain,int proto,const char *local,const char *bind_dev,int port);int Nread (int fd,char *buf,size_t count,int prot);
Signature · 1 line
2.40.1
Matthieu Baerts
maintainerHi Geliang,
11 Mar 2024 08:04:05 Geliang Tang <[email protected]>:
Quoted 9 lines
The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in the upstream Linux kernel since v5.6.
MPTCP is strongly tied to TCP, and the kernel APIs are almost the same. The only required dependency is the '
IPPROTO_MPTCP' protocol number definition, which should be provided by thenetinet/in.hheader if it is recent enough.This patch adds a new flag '-m' or '--multipath' to support MPTCPv1.
I just noticed you switched back to "multipath" instead of "mptcp". I think it is best to stick with "mptcp", because "multipath" is too vague, thus confusing: it could be multipath as in multiple flows, multicast, with other protocols like UDP, etc.
Best to use "mptcp" everywhere: variables, strings, description, etc.
Quoted 4 lines
It can be used like this:
Quoted 2 lines
iperf3 -m -s
iperf3 -m -c 127.0.0.1
If the server doesn't have "-m", only the client, does it use MPTCP?
Cheers,
Matt
Geliang Tang
reviewerHi Matt,
Quoted 12 lines · Matthieu Baerts
Hi Geliang,
11 Mar 2024 08:04:05 Geliang Tang <[email protected]>:
Quoted 8 lines
The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in the upstream Linux kernel since v5.6.
MPTCP is strongly tied to TCP, and the kernel APIs are almost the same. The only required dependency is the '
IPPROTO_MPTCP' protocol number definition, which should be provided by thenetinet/in.hheader if it is recent enough.
Quoted 8 lines
Quoted 1 line
This patch adds a new flag '-m' or '--multipath' to support MPTCPv1.
I just noticed you switched back to "multipath" instead of "mptcp". I think it is best to stick with "mptcp", because "multipath" is too vague, thus confusing: it could be multipath as in multiple flows, multicast, with other protocols like UDP, etc.
Best to use "mptcp" everywhere: variables, strings, description, etc.
Sure, I'll send a v4 to update the flag to '--mptcp'. But I don't know how to update the pull request on github. Should I send another pull request?
Quoted 8 lines
Quoted 6 lines
It can be used like this:
Quoted 2 lines
iperf3 -m -s
iperf3 -m -c 127.0.0.1If the server doesn't have "-m", only the client, does it use MPTCP?
Yes, it use MPTCP in this case. I just tested it.
Thanks,
-Geliang
Quoted 3 lines
Cheers,
Matt
Matthieu Baerts
maintainerHi Geliang,
Quoted 17 lines · Geliang Tang
Hi Matt,
Quoted 14 lines · Matthieu Baerts
Hi Geliang,
11 Mar 2024 08:04:05 Geliang Tang <[email protected]>:
Quoted 9 lines
The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in the upstream Linux kernel since v5.6.
MPTCP is strongly tied to TCP, and the kernel APIs are almost the same. The only required dependency is the '
IPPROTO_MPTCP' protocol number definition, which should be provided by thenetinet/in.hheader if it is recent enough.This patch adds a new flag '-m' or '--multipath' to support MPTCPv1.
Quoted 8 lines
Quoted 6 lines
I just noticed you switched back to "multipath" instead of "mptcp". I think it is best to stick with "mptcp", because "multipath" is too vague, thus confusing: it could be multipath as in multiple flows, multicast, with other protocols like UDP, etc.
Best to use "mptcp" everywhere: variables, strings, description, etc.
Sure, I'll send a v4 to update the flag to '--mptcp'.
Thanks!
Quoted 3 lines
But I don't know
how to update the pull request on github. Should I send another pull request?
No, please don't open a new pull request, nor close the old one, simply override your remote branch on GitHub (git push --force).
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
It can be used like this:>>>
Quoted 2 lines
iperf3 -m -s
iperf3 -m -c 127.0.0.1If the server doesn't have "-m", only the client, does it use MPTCP?
Yes, it use MPTCP in this case. I just tested it.
Great, thank you for having tested that!
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerQuoted 29 lines · Matthieu Baerts
Hi Geliang,
Quoted 17 lines · Geliang Tang
Hi Matt,
Quoted 14 lines · Matthieu Baerts
Hi Geliang,
11 Mar 2024 08:04:05 Geliang Tang <[email protected]>:
Quoted 9 lines
The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in the upstream Linux kernel since v5.6.
MPTCP is strongly tied to TCP, and the kernel APIs are almost the same. The only required dependency is the '
IPPROTO_MPTCP' protocol number definition, which should be provided by thenetinet/in.hheader if it is recent enough.This patch adds a new flag '-m' or '--multipath' to support MPTCPv1.
Quoted 8 lines
Quoted 6 lines
I just noticed you switched back to "multipath" instead of "mptcp". I think it is best to stick with "mptcp", because "multipath" is too vague, thus confusing: it could be multipath as in multiple flows, multicast, with other protocols like UDP, etc.
Best to use "mptcp" everywhere: variables, strings, description, etc.
Sure, I'll send a v4 to update the flag to '--mptcp'.
Quoted 8 lines
Thanks!
Quoted 3 lines
But I don't know
how to update the pull request on github. Should I send another pull request?No, please don't open a new pull request, nor close the old one, simply override your remote branch on GitHub (
git push --force).
Sorry, I open a new one before reading this:
https://github.com/esnet/iperf/pull/1661
Quoted 15 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
It can be used like this:>>>
Quoted 2 lines
iperf3 -m -s
iperf3 -m -c 127.0.0.1If the server doesn't have "-m", only the client, does it use MPTCP?
Yes, it use MPTCP in this case. I just tested it.
Great, thank you for having tested that!
Cheers,
MattSignature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerHi Matt,
Quoted 45 lines · Geliang Tang
Quoted 44 lines · Matthieu Baerts
Hi Geliang,
Quoted 29 lines · Geliang Tang
Hi Matt,
Quoted 26 lines · Matthieu Baerts
Hi Geliang,
11 Mar 2024 08:04:05 Geliang Tang <[email protected]>:
Quoted 12 lines
The Multipath TCP (MPTCP) protocol (v1 / RFC 8684) has been added in
the upstream Linux kernel since v5.6.MPTCP is strongly tied to TCP, and the kernel APIs are almost the same.
The only required dependency is the 'IPPROTO_MPTCP' protocol number
definition, which should be provided by thenetinet/in.hheader if it
is recent enough.Quoted 2 lines
This patch adds a new flag '-m' or '--multipath' to support MPTCPv1.
I just noticed you switched back to "multipath" instead of "mptcp".
I think it is best to stick with "mptcp", because "multipath" is too vague, thus confusing: it could be multipath as in multiple
flows, multicast, with other protocols like UDP, etc.Quoted 4 lines
Quoted 2 lines
Best to use "mptcp" everywhere: variables, strings, description, etc.
Sure, I'll send a v4 to update the flag to '--mptcp'.
Thanks!
Quoted 4 lines
But I don't know
how to update the pull request on github. Should I send another pull
request?
Quoted 7 lines
Quoted 3 lines
No, please don't open a new pull request, nor close the old one, simply
override your remote branch on GitHub (git push --force).Sorry, I open a new one before reading this:
This pull request has not been merged yet, and I recently found that it has conflicted with other code, so I resolved the conflict and updated it this pull request again.
In addition, I found that before my pull request, there was already a pull request for MPTCP support waiting
(https://github.com/esnet/iperf/pull/1615 by "marcosfsch"). I guess it is because there are two conflicting requests with the same purpose that MPTCP support has not been merged. If this is the reason, can we contact "marcosfsch" to see if these two requests can be merged into one? It doesn't matter whether mine or his is merged.
Or the reason why it has not been merged is that iperf maintainers are not interested in MPTCP support because he has not given us any feedback. If this is the case, it seems we have no choice but to give up supporting MPTCP in iperf.
Thanks,
-Geliang
Quoted 18 lines
Quoted 17 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
It can be used like this:>>>
Quoted 2 lines
iperf3 -m -s
iperf3 -m -c 127.0.0.1If the server doesn't have "-m", only the client, does it use MPTCP?
Yes, it use MPTCP in this case. I just tested it.
Great, thank you for having tested that!
Cheers,
MattSignature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerHi Geliang,
Quoted 1 line · Geliang Tang
On Tue, 2024-03-12 at 16:14 +0800, Geliang Tang wrote:
(...)
Quoted 7 lines
Quoted 3 lines
Sorry, I open a new one before reading this:
This pull request has not been merged yet, and I recently found that it has conflicted with other code, so I resolved the conflict and updated it this pull request again.
Thank you for having done that!
Quoted 7 lines
In addition, I found that before my pull request, there was already a pull request for MPTCP support waiting
(https://github.com/esnet/iperf/pull/1615 by "marcosfsch"). I guess it is because there are two conflicting requests with the same purpose that MPTCP support has not been merged. If this is the reason, can we contact "marcosfsch" to see if these two requests can be merged into one? It doesn't matter whether mine or his is merged.
I don't think that's the reason, but I just added a message on PR #1615.
Quoted 4 lines
Or the reason why it has not been merged is that iperf maintainers are not interested in MPTCP support because he has not given us any feedback. If this is the case, it seems we have no choice but to give up supporting MPTCP in iperf.
Yes, that's a shame they didn't even provide any feedback... If they don't want it, they should at least be clear about that. I just added a message on your PR #1661, will see... Because I don't think we want to maintain an MPTCP version on our side (who will use it apart from us?).
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.