Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support mptcp #2520

Merged
merged 1 commit into from
Sep 7, 2023
Merged

support mptcp #2520

merged 1 commit into from
Sep 7, 2023

Conversation

yylt
Copy link
Contributor

@yylt yylt commented Sep 5, 2023

在 go 1.21 新增 mptcp 支持,当前 go mod 也规定使用 1.21, 所以新增 mptcp sockeop,使用如下配置和通过 ss 查看 信息

"inbounds": [
	{
		"port": 1080,
		"listen": "0.0.0.0",
		"protocol": "http",
		"tag": "http",
		"settings": {
		  "allowTransparent": false
		}
	},
]

"outbounds": [
  {
      "protocol": "trojan",
      "tag": "grpc",
      "streamSettings": {
        "network": "grpc",
        "security": "tls",
        "tlsSettings": {
          "serverName": "xxxxxx",
          "alpn": ["h2", "http/1.1"]
        },
        "sockopt": {
          "tcpMptcp": true, //这里有两个 grpc ,一个true,一个false,没有列出false的outbound
          "tcpNoDelay": true
        },
        "grpcSettings": {
          "multiMode": true,
          "user_agent": "chrome",
          "idle_timeout": 3600,
          "serviceName": "gapi"
        }
      },
      "settings": {
        "servers": [
          {
            "address": "xxxxxx",
            "port": 443,
            "password": "xxxxxx"
          }
        ]
      }
    },
  }
]

ss 对比内容

	 cubic wscale:7,7 rto:460 rtt:257.208/18.597 ato:40 mss:1188 pmtu:1500 rcvmss:1188 advmss:1448 cwnd:10 bytes_sent:10166 bytes_retrans:52 bytes_acked:10115 bytes_received:85807012 segs_out:10207 segs_in:73074 data_segs_out:160 data_segs_in:73033 send 370kbps lastsnd:940 lastrcv:536 lastack:536 pacing_rate 739kbps delivery_rate 55.9kbps delivered:161 busy:17980ms retrans:0/2 dsack_dups:1 rcv_rtt:358.075 rcv_space:14480 rcv_ssthresh:3145728 minrtt:196.87 tcp-ulp-mptcp flags:mc token:0000(id:0)/514f3b12(id:0) seq:51d4a4c sfseq:51d4a4d ssnoff:5b3720ea maplen:558                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

	 cubic wscale:7,7 rto:488 rtt:271.648/44.721 ato:40 mss:1188 pmtu:1500 rcvmss:1188 advmss:1448 cwnd:10 bytes_sent:10955 bytes_retrans:35 bytes_acked:10921 bytes_received:72582364 segs_out:8182 segs_in:61338 data_segs_out:165 data_segs_in:61293 send 350kbps lastsnd:34272 lastrcv:34272 lastack:3272 pacing_rate 700kbps delivery_rate 173kbps delivered:166 app_limited busy:19036ms retrans:0/1 dsack_dups:1 reord_seen:2 rcv_rtt:226.487 rcv_space:3080612 rcv_ssthresh:3145728 minrtt:195.092  

@yuhan6665
Copy link
Member

会 break go 1.20 的话。。openwrt 会不会有问题?

@RPRX
Copy link
Member

RPRX commented Sep 7, 2023

Go 1.21.1 都出了,Xray-core v1.8.5 发布的时候 openwrt 该有 go 1.21 了吧,所以应该不会有问题

@RPRX RPRX merged commit c00e56c into XTLS:main Sep 7, 2023
35 checks passed
@RPRX
Copy link
Member

RPRX commented Sep 7, 2023

感谢 PR

@Smallthing
Copy link

还是没懂这个东西怎么用。。。多个outbund怎么合并

@yylt
Copy link
Contributor Author

yylt commented Sep 8, 2023

还是没懂这个东西怎么用。。。多个outbund怎么合并

工作原理说明:

  1. MPTCP在发送端和接收端建立MPTCP连接,协商使用MPTCP。
  2. MPTCP在发送端和接收端分别建立多个TCP子连接(子流)。
  3. 发送端可以将数据分片发送到不同的TCP子流。
  4. 接收端会将从不同子流接收的数据汇聚合并,交付给应用层。
  5. 子流之间可以传输不同的数据分片,以达到均衡负载和提高网络利用率的目的。
  6. 如果某个子连接断开,MPTCP可以快速切换traffic到其他子连接,提高可靠性。

这个不是作用于 outbound,配置在单个(in|out) bound(tcp类型)的 sockopt 上,是内核 socket,如果保证速度和稳定性,建议配置以下方式

      "streamSettings": {
        "sockopt": {
          "tcpMptcp": true, // 设置 socket 使用 mptcp
          "tcpNoDelay": true
        },
      }

@yylt yylt deleted the mptcp branch September 8, 2023 07:36
@RPRX
Copy link
Member

RPRX commented Sep 8, 2023

目前 Go 1.21 提供的就是一个函数设 true 或 false,没有其它能手动控制的东西

@us254
Copy link

us254 commented Sep 8, 2023

"在服务器的入站和客户端的出站同时配置MPTCP是否有必要?MPTCP是否仅限于在Android客户端上运行,因为它具有Linux内核,在Windows上无法兼容?"

Should MPTCP be configured concurrently on both the server's inbound and the client's outbound sides? Is MPTCP limited to functioning solely on the Android client due to its Linux kernel, with no compatibility on Windows?

@chika0801
Copy link
Contributor

chika0801 commented Sep 8, 2023

这参数要两端(客户端出站、服务端入站)配置中都加上。

@jh0072110
Copy link

测试了一下,怎么感觉加入了mptcp后掉速严重…

@Fangliding
Copy link
Member

@jh0072110 毕竟大家都不知道吃到的是螃蟹还是雪意面

@chika0801
Copy link
Contributor

有什么测试方法说下了?

@wy15
Copy link

wy15 commented Sep 12, 2023

@us254 bard说
iOS 从 iOS 11 支持,macOS 从 macOS 10.14 Mojave,Windows 从 Windows 10 版本 1809

@chika0801
Copy link
Contributor

Go 1.21.1 都出了,Xray-core v1.8.5 发布的时候 openwrt 该有 go 1.21 了吧,所以应该不会有问题

@RPRX openwrt 有 go 1.21.1 了,编译使用了没有问题

@BI7PRK
Copy link

BI7PRK commented Nov 19, 2023

请教:原有的 tcpFastOpentcpNoDelay 参数是有不同的意义吗?

@us254
Copy link

us254 commented Dec 6, 2023

请教:原有的 tcpFastOpentcpNoDelay 参数是有不同的意义吗?

Concerning your inquiry about tcpFastOpen and tcpNoDelay:

  • tcpFastOpen: This is a technique to speed up the opening of successive TCP connections between two endpoints. It reduces the number of round-trip times (RTTs) needed to establish a connection, thereby lowering latency.

  • tcpNoDelay: This setting disables the Nagle's algorithm on TCP sockets and is used to send packets immediately without waiting for the TCP acknowledgment corresponding to the previous packet, which may also decrease latency but can increase the number of small packets ("packetization") on the network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants