{"id":359539,"date":"2024-05-21T00:34:38","date_gmt":"2024-05-21T00:34:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=359539"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T00:34:38","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=359539","title":{"rendered":"<span>Multipath TCP \u0432 Go<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/fb8\/82b\/6ff\/fb882b6ff06f39487c2711c34c568f3e.jpg\" alt=\"\u041a\u0414\u041f\u0412\" title=\"\u041a\u0414\u041f\u0412\" width=\"1200\" height=\"630\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb8\/82b\/6ff\/fb882b6ff06f39487c2711c34c568f3e.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041a\u0414\u041f\u0412<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e \u0434\u0430\u043d\u043d\u044b\u043c <a href=\"https:\/\/mptcp.io\" rel=\"noopener noreferrer nofollow\">mptcp.io<\/a> \u043d\u0430 1 \u043d\u043e\u044f\u0431\u0440\u044f 2023 \u0433\u043e\u0434\u0430 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u044e\u0442 \u043e\u043a\u043e\u043b\u043e 350 \u0442\u044b\u0441\u044f\u0447 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 Multipath TCP (\u0434\u0430\u043b\u0435\u0435 &#8212; MPTCP).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee4\/0b0\/c34\/ee40b0c34ff5e5a457df6d2d7e203967.png\" alt=\"\u0413\u0440\u0430\u0444\u0438\u043a \u0441 \u0441\u0430\u0439\u0442\u0430\" title=\"\u0413\u0440\u0430\u0444\u0438\u043a \u0441 \u0441\u0430\u0439\u0442\u0430\" width=\"1305\" height=\"410\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ee4\/0b0\/c34\/ee40b0c34ff5e5a457df6d2d7e203967.png\"\/><\/p>\n<div><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u0441 \u0441\u0430\u0439\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0430\u043d\u0435\u0435 \u0443\u0436\u0435 \u0431\u044b\u043b \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/companies\/otus\/articles\/687374\/\" rel=\"noopener noreferrer nofollow\">\u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f <\/a>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430.<\/p>\n<p>\u0418, \u0435\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u0435\u043d\u0435\u0447\u043a\u043e, \u0442\u043e MPTCP \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0441\u0432\u044f\u0437\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e WiFi \u0438 \u0441\u043e\u0442\u043e\u0432\u0443\u044e \u0441\u0435\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0443\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432) \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0435\u0442\u0438.<\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/datatracker.ietf.org\/wg\/quic\/documents\/\" rel=\"noopener noreferrer nofollow\">QUIC<\/a> (<a href=\"https:\/\/github.com\/quic-go\/quic-go\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a>).<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 MPTCP \u0438 QUIC \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e MPTCP \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 TCP \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a QUIC \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 UDP \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 (\u043a\u0430\u043a TCP, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0445\u0443\u043a\u0430\u043c\u0438). \u041a\u0430\u043a-\u0442\u043e <a href=\"https:\/\/habr.com\/ru\/articles\/491818\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0438\u0441\u0430\u043b<\/a> \u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u0445 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 MPTCP \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 QUIC \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 UDP \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/598615\/\" rel=\"noopener noreferrer nofollow\">\u0438\u043c\u0435\u0435\u0442\u0441\u044f<\/a>.<\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 MPTCP <a href=\"https:\/\/datatracker.ietf.org\/group\/mptcp\/history\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442<\/a> \u0441 2009 \u0433\u043e\u0434\u0430.  IETF \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <a href=\"https:\/\/datatracker.ietf.org\/group\/mptcp\/documents\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043b\u043d\u044b\u0439  \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442<\/a> \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043a \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044e. \u0418 \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b <a href=\"https:\/\/arxiv.org\/pdf\/1308.3119v2.pdf\" rel=\"noopener noreferrer nofollow\">\u0431\u043b\u0435\u043a\u0434\u0436\u0435\u043a\u043e\u043c \u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u0430\u043c\u0438<\/a>. <\/p>\n<p>\u0414\u043b\u044f \u043c\u0435\u043d\u044f \u0435\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u044b: <a href=\"https:\/\/www.multipath-tcp.org\/\" rel=\"noopener noreferrer nofollow\">multipath-tcp.org<\/a> \u0438 \u0435\u0449\u0435 \u0438\u0445 \u043a\u043e\u0434 \u0438\u0437 <a href=\"https:\/\/github.com\/multipath-tcp\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>.<\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0434\u0430\u0432\u043d\u043e <a href=\"https:\/\/support.apple.com\/ru-ru\/101905\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0434\u0432\u0435\u0437\u043b\u0438 \u0432 iOS<\/a>, <a href=\"https:\/\/www.mptcp.dev\/\" rel=\"noopener noreferrer nofollow\">\u044f\u0434\u0440\u043e Linux<\/a>, \u0432 <a href=\"https:\/\/access.redhat.com\/documentation\/ru-ru\/red_hat_enterprise_linux\/8\/html\/configuring_and_managing_networking\/getting-started-with-multipath-tcp_configuring-and-managing-networking#understanding-mptcp_getting-started-with-multipath-tcp\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>\u00a0Red Hat \u0438 \u0442.\u0434.<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0432 <a href=\"https:\/\/go.dev\/\" rel=\"noopener noreferrer nofollow\">Go<\/a>, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <a href=\"https:\/\/go.dev\/doc\/go1.21\" rel=\"noopener noreferrer nofollow\">\u0432\u0435\u0440\u0441\u0438\u0438 1.21<\/a>, MPTCP <a href=\"https:\/\/github.com\/golang\/go\/issues\/56539\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d<\/a> \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435. \u041c\u0435\u0442\u043e\u0434\u044b<\/p>\n<ul>\n<li>\n<p>\u043a\u043b\u0438\u0435\u043d\u0442<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">func (*Dialer) SetMultipathTCP(enabled bool) func (*Dialer) MultipathTCP() bool<\/code><\/pre>\n<ul>\n<li>\n<p>\u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">func (*ListenConfig) SetMultipathTCP(enabled bool) func (*ListenConfig) MultipathTCP() bool<\/code><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0418 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u044f\u0434\u0440\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442.<\/p>\n<blockquote>\n<p>On Linux, the\u00a0<a href=\"https:\/\/go.dev\/pkg\/net\/\" rel=\"noopener noreferrer nofollow\">net<\/a>\u00a0package can now use Multipath TCP when the kernel supports it. It is not used by default. To use Multipath TCP when available on a client, call the\u00a0<code>Dialer.SetMultipathTCP<\/code>\u00a0method before calling the\u00a0<code>Dialer.Dial<\/code>\u00a0or\u00a0<code>Dialer.DialContext<\/code>\u00a0methods. To use Multipath TCP when available on a server, call the\u00a0<code>ListenConfig.SetMultipathTCP<\/code>\u00a0method before calling the\u00a0<code>ListenConfig.Listen<\/code>\u00a0method. Specify the network as\u00a0<code>\"tcp\"<\/code>\u00a0or\u00a0<code>\"tcp4\"<\/code>\u00a0or\u00a0<code>\"tcp6\"<\/code>\u00a0as usual. If Multipath TCP is not supported by the kernel or the remote host, the connection will silently fall back to TCP. To test whether a particular connection is using Multipath TCP, use the\u00a0<code>TCPConn.MultipathTCP<\/code>\u00a0method.<\/p>\n<p>In a future Go release we may enable Multipath TCP by default on systems that support it.<\/p>\n<\/blockquote>\n<p>\u041d\u043e, \u0432 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c, \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">package main  import ( \"context\" \"errors\" \"flag\" \"fmt\" \"io\" \"log\/slog\" \"net\" \"os\" )  func main() { log := slog.New(slog.NewTextHandler(       os.Stdout,        &amp;slog.HandlerOptions{AddSource: true},     )) log.Info(\"starting server\")      \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 mptcp     lc := &amp;net.ListenConfig{} if lc.MultipathTCP() { log.Error(\"multipathTCP should be off by default\") os.Exit(1) } log.Info(\"mptcp supported\")  \/\/ \u043f\u0440\u044f\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 mptcp lc.SetMultipathTCP(true) ln, err := lc.Listen(context.Background(), \"tcp\", \":8080\") if err != nil { log.Error(err.Error()) os.Exit(1) } log.Info(\"listening on port 8080\")  for { conn, err := ln.Accept() if err != nil { log.Error(\"conn\", \"error\", err) continue }  go func() { defer conn.Close() \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 mptcp isMultipathTCP, err := conn.(*net.TCPConn).MultipathTCP() fmt.Printf(\"accepted connection from %s with mptcp: %t, err: %v\\n\", conn.RemoteAddr(), isMultipathTCP, err) for { buf := make([]byte, 1024) n, err := conn.Read(buf) if err != nil { if errors.Is(err, io.EOF) { return } log.Error(\"read\", \"error\", err) os.Exit(1) } if _, err := conn.Write(buf[:n]); err != nil { log.Error(\"write\", \"error\", err) os.Exit(1) } } }() } }<\/code><\/pre>\n<ul>\n<li>\n<p>\u043a\u043b\u0438\u0435\u043d\u0442<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">package main  import ( \"fmt\" \"log\/slog\" \"net\" \"os\" \"time\" )  func main() { log := slog.New(slog.NewTextHandler(       os.Stdout,        &amp;slog.HandlerOptions{AddSource: true},     )) log.Info(\"starting client\")  \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 MPTCP d := &amp;net.Dialer{} if d.MultipathTCP() { log.Error(\"multipathTCP should be off by default\") os.Exit(1) }  \/\/ \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MPTCP d.SetMultipathTCP(true) if !d.MultipathTCP() { log.Error(\"multipathTCP is not on after having been forced to o\") os.Exit(1) } log.Info(\"mpTCP enabled\")  c, err := d.Dial(\"tcp\", \"127.0.0.1:8080\") if err != nil { log.Error(\"multipathTCP should be off by default\") os.Exit(1) } defer c.Close()  tcp, ok := c.(*net.TCPConn) if !ok { log.Error(\"struct is not a TCPConn\") os.Exit(1) }  \/\/ \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 mptcp mptcp, err := tcp.MultipathTCP() if err != nil { log.Error(\"multipathTCP should be off by default\") os.Exit(1) } log.Info(\"outgoing connection from 127.0.0.1:8080 with mptcp\")  \/\/ mptcp \u043d\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 if !mptcp { log.Error(\"outgoing connection is not with MPTCP\") os.Exit(1) }  for { snt := []byte(\"MPTCP TEST\") if _, err := c.Write(snt); err != nil { log.Error(\"write\", \"error\", err) os.Exit(1) } b := make([]byte, len(snt)) if _, err := c.Read(b); err != nil { log.Error(\"read\", \"error\", err) os.Exit(1) } fmt.Println(string(b)) time.Sleep(time.Second) } }<\/code><\/pre>\n<p>\u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432\u0437\u044f\u0442 \u043a\u043e\u0434 \u0438\u0437 <a href=\"https:\/\/colobu.com\/2023\/07\/03\/mptcp-a-go-1-21-new-feature\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/772436\/\"> https:\/\/habr.com\/ru\/articles\/772436\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u0414\u041f\u0412<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e \u0434\u0430\u043d\u043d\u044b\u043c <a href=\"https:\/\/mptcp.io\" rel=\"noopener noreferrer nofollow\">mptcp.io<\/a> \u043d\u0430 1 \u043d\u043e\u044f\u0431\u0440\u044f 2023 \u0433\u043e\u0434\u0430 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u044e\u0442 \u043e\u043a\u043e\u043b\u043e 350 \u0442\u044b\u0441\u044f\u0447 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 Multipath TCP (\u0434\u0430\u043b\u0435\u0435 &#8212; MPTCP).<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0413\u0440\u0430\u0444\u0438\u043a \u0441 \u0441\u0430\u0439\u0442\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0430\u043d\u0435\u0435 \u0443\u0436\u0435 \u0431\u044b\u043b \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/companies\/otus\/articles\/687374\/\" rel=\"noopener noreferrer nofollow\">\u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f <\/a>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430.<\/p>\n<p>\u0418, \u0435\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u0435\u043d\u0435\u0447\u043a\u043e, \u0442\u043e MPTCP \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0441\u0432\u044f\u0437\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e WiFi \u0438 \u0441\u043e\u0442\u043e\u0432\u0443\u044e \u0441\u0435\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0443\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432) \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0435\u0442\u0438.<\/p>\n<p>\u0414\u0440\u0443\u0433\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/datatracker.ietf.org\/wg\/quic\/documents\/\" rel=\"noopener noreferrer nofollow\">QUIC<\/a> (<a href=\"https:\/\/github.com\/quic-go\/quic-go\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a>).<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 MPTCP \u0438 QUIC \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e MPTCP \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 TCP \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a QUIC \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 UDP \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 (\u043a\u0430\u043a TCP, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0445\u0443\u043a\u0430\u043c\u0438). \u041a\u0430\u043a-\u0442\u043e <a href=\"https:\/\/habr.com\/ru\/articles\/491818\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0438\u0441\u0430\u043b<\/a> \u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u0445 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 MPTCP \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 QUIC \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 UDP \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/598615\/\" rel=\"noopener noreferrer nofollow\">\u0438\u043c\u0435\u0435\u0442\u0441\u044f<\/a>.<\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 MPTCP <a href=\"https:\/\/datatracker.ietf.org\/group\/mptcp\/history\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442<\/a> \u0441 2009 \u0433\u043e\u0434\u0430.  IETF \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <a href=\"https:\/\/datatracker.ietf.org\/group\/mptcp\/documents\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043b\u043d\u044b\u0439  \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442<\/a> \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043a \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044e. \u0418 \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b <a href=\"https:\/\/arxiv.org\/pdf\/1308.3119v2.pdf\" rel=\"noopener noreferrer nofollow\">\u0431\u043b\u0435\u043a\u0434\u0436\u0435\u043a\u043e\u043c \u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u0430\u043c\u0438<\/a>. <\/p>\n<p>\u0414\u043b\u044f \u043c\u0435\u043d\u044f \u0435\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u044b: <a href=\"https:\/\/www.multipath-tcp.org\/\" rel=\"noopener noreferrer nofollow\">multipath-tcp.org<\/a> \u0438 \u0435\u0449\u0435 \u0438\u0445 \u043a\u043e\u0434 \u0438\u0437 <a href=\"https:\/\/github.com\/multipath-tcp\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>.<\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0434\u0430\u0432\u043d\u043e <a href=\"https:\/\/support.apple.com\/ru-ru\/101905\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0434\u0432\u0435\u0437\u043b\u0438 \u0432 iOS<\/a>, <a href=\"https:\/\/www.mptcp.dev\/\" rel=\"noopener noreferrer nofollow\">\u044f\u0434\u0440\u043e Linux<\/a>, \u0432 <a href=\"https:\/\/access.redhat.com\/documentation\/ru-ru\/red_hat_enterprise_linux\/8\/html\/configuring_and_managing_networking\/getting-started-with-multipath-tcp_configuring-and-managing-networking#understanding-mptcp_getting-started-with-multipath-tcp\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>\u00a0Red Hat \u0438 \u0442.\u0434.<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0432 <a href=\"https:\/\/go.dev\/\" rel=\"noopener noreferrer nofollow\">Go<\/a>, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <a href=\"https:\/\/go.dev\/doc\/go1.21\" rel=\"noopener noreferrer nofollow\">\u0432\u0435\u0440\u0441\u0438\u0438 1.21<\/a>, MPTCP <a href=\"https:\/\/github.com\/golang\/go\/issues\/56539\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d<\/a> \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435. \u041c\u0435\u0442\u043e\u0434\u044b<\/p>\n<ul>\n<li>\n<p>\u043a\u043b\u0438\u0435\u043d\u0442<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">func (*Dialer) SetMultipathTCP(enabled bool) func (*Dialer) MultipathTCP() bool<\/code><\/pre>\n<ul>\n<li>\n<p>\u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">func (*ListenConfig) SetMultipathTCP(enabled bool) func (*ListenConfig) MultipathTCP() bool<\/code><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0418 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u044f\u0434\u0440\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442.<\/p>\n<blockquote>\n<p>On Linux, the\u00a0<a href=\"https:\/\/go.dev\/pkg\/net\/\" rel=\"noopener noreferrer nofollow\">net<\/a>\u00a0package can now use Multipath TCP when the kernel supports it. It is not used by default. To use Multipath TCP when available on a client, call the\u00a0<code>Dialer.SetMultipathTCP<\/code>\u00a0method before calling the\u00a0<code>Dialer.Dial<\/code>\u00a0or\u00a0<code>Dialer.DialContext<\/code>\u00a0methods. To use Multipath TCP when available on a server, call the\u00a0<code>ListenConfig.SetMultipathTCP<\/code>\u00a0method before calling the\u00a0<code>ListenConfig.Listen<\/code>\u00a0method. Specify the network as\u00a0<code>\"tcp\"<\/code>\u00a0or\u00a0<code>\"tcp4\"<\/code>\u00a0or\u00a0<code>\"tcp6\"<\/code>\u00a0as usual. If Multipath TCP is not supported by the kernel or the remote host, the connection will silently fall back to TCP. To test whether a particular connection is using Multipath TCP, use the\u00a0<code>TCPConn.MultipathTCP<\/code>\u00a0method.<\/p>\n<p>In a future Go release we may enable Multipath TCP by default on systems that support it.<\/p>\n<\/blockquote>\n<p>\u041d\u043e, \u0432 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c, \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">package main  import ( \"context\" \"errors\" \"flag\" \"fmt\" \"io\" \"log\/slog\" \"net\" \"os\" )  func main() { log := slog.New(slog.NewTextHandler(       os.Stdout,        &amp;slog.HandlerOptions{AddSource: true},     )) log.Info(\"starting server\")      \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 mptcp     lc := &amp;net.ListenConfig{} if lc.MultipathTCP() { log.Error(\"multipathTCP should be off by default\") os.Exit(1) } log.Info(\"mptcp supported\")  \/\/ \u043f\u0440\u044f\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 mptcp lc.SetMultipathTCP(true) ln, err := lc.Listen(context.Background(), \"tcp\", \":8080\") if err != nil { log.Error(err.Error()) os.Exit(1) } log.Info(\"listening on port 8080\")  for { conn, err := ln.Accept() if err != nil { log.Error(\"conn\", \"error\", err) continue }  go func() { defer conn.Close() \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 mptcp isMultipathTCP, err := conn.(*net.TCPConn).MultipathTCP() fmt.Printf(\"accepted connection from %s with mptcp: %t, err: %v\\n\", conn.RemoteAddr(), isMultipathTCP, err) for { buf := make([]byte, 1024) n, err := conn.Read(buf) if err != nil { if errors.Is(err, io.EOF) { return } log.Error(\"read\", \"error\", err) os.Exit(1) } if _, err := conn.Write(buf[:n]); err != nil { log.Error(\"write\", \"error\", err) os.Exit(1) } } }() } }<\/code><\/pre>\n<ul>\n<li>\n<p>\u043a\u043b\u0438\u0435\u043d\u0442<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">package main  import ( \"fmt\" \"log\/slog\" \"net\" \"os\" \"time\" )  func main() { log := slog.New(slog.NewTextHandler(       os.Stdout,        &amp;slog.HandlerOptions{AddSource: true},     )) log.Info(\"starting client\")  \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 MPTCP d := &amp;net.Dialer{} if d.MultipathTCP() { log.Error(\"multipathTCP should be off by default\") os.Exit(1) }  \/\/ \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MPTCP d.SetMultipathTCP(true) if !d.MultipathTCP() { log.Error(\"multipathTCP is not on after having been forced to o\") os.Exit(1) } log.Info(\"mpTCP enabled\")  c, err := d.Dial(\"tcp\", \"127.0.0.1:8080\") if err != nil { log.Error(\"multipathTCP should be off by default\") os.Exit(1) } defer c.Close()  tcp, ok := c.(*net.TCPConn) if !ok { log.Error(\"struct is not a TCPConn\") os.Exit(1) }  \/\/ \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 mptcp mptcp, err := tcp.MultipathTCP() if err != nil { log.Error(\"multipathTCP should be off by default\") os.Exit(1) } log.Info(\"outgoing connection from 127.0.0.1:8080 with mptcp\")  \/\/ mptcp \u043d\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 if !mptcp { log.Error(\"outgoing connection is not with MPTCP\") os.Exit(1) }  for { snt := []byte(\"MPTCP TEST\") if _, err := c.Write(snt); err != nil { log.Error(\"write\", \"error\", err) os.Exit(1) } b := make([]byte, len(snt)) if _, err := c.Read(b); err != nil { log.Error(\"read\", \"error\", err) os.Exit(1) } fmt.Println(string(b)) time.Sleep(time.Second) } }<\/code><\/pre>\n<p>\u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432\u0437\u044f\u0442 \u043a\u043e\u0434 \u0438\u0437 <a href=\"https:\/\/colobu.com\/2023\/07\/03\/mptcp-a-go-1-21-new-feature\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/772436\/\"> https:\/\/habr.com\/ru\/articles\/772436\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-359539","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/359539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=359539"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/359539\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=359539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=359539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=359539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}