Skip to content

Commit

Permalink
remove invalid option; performance updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cnbatch committed Oct 9, 2023
1 parent ef8e2f6 commit 9704727
Show file tree
Hide file tree
Showing 19 changed files with 319 additions and 195 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ encryption_algorithm=AES-GCM
| stun_server | STUN 服务器地址 ||listen_port 为端口范围模式时不可使用|
| log_path | 存放 Log 的目录 ||不能指向文件本身|
| kcp_mtu | 正整数 ||预设值1440|
| kcp_conserve | yes<br>true<br>1<br>no<br>false<br>0 ||使“快速ACK”稍微缓和|
| kcp | manual<br>fast1 - 6<br>regular1 - 5<br> &nbsp; ||手动设置<br>快速<br>常速<br>(末尾数字:数值越小,速度越快)|
| kcp_sndwnd | 正整数 ||预设值见下表,可以单独覆盖|
| kcp_rcvwnd | 正整数 ||预设值见下表,可以单独覆盖|
Expand All @@ -180,7 +179,7 @@ encryption_algorithm=AES-GCM
| outbound_bandwidth | 正整数 ||出站带宽,用于通讯过程中动态更新 kcp_sndwnd 的值|
| inbound_bandwidth | 正整数 ||入站带宽,用于通讯过程中动态更新 kcp_rcvwnd 的值|
| ipv4_only | yes<br>true<br>1<br>no<br>false<br>0 ||若系统禁用了 IPv6,须启用该选项并设为 yes 或 true 或 1|
| blast | yes<br>true<br>1<br>no<br>false<br>0 ||尝试忽略 KCP 流控设置,尽可能迅速地转发数据包。可能会导致负载过大|
| blast | yes<br>true<br>1<br>no<br>false<br>0 ||默认开启。在 KCP 流控设置的基础上,尽可能迅速地转发数据包|
| [listener] | N/A |是<br>(仅限中继模式)|中继模式的标签,用于指定监听模式的 KCP 设置<br>该标签表示与客户端交互数据|
| [forwarder] | N/A |是<br>(仅限中继模式)|中继模式的标签,用于指定转运模式的 KCP 设置<br>该标签表示与服务端交互数据|

Expand Down Expand Up @@ -219,14 +218,15 @@ encryption_algorithm=AES-GCM
| ---- | :----: | :----: | :----: | :----: | :----: |:----: |
| regular1 | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular2 | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular3* | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular4* | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular5* | 1024 | 1024 | 0 | 1 | 3 | 1 |
| regular3 | 1024 | 1024 | 0 | 1 | 2 | 1 |
| regular4 | 1024 | 1024 | 0 | 10 | 2 | 1 |
| regular5 | 1024 | 1024 | 0 | 30 | 2 | 1 |

其中,丢包率越高(高于 10%),kcp_nodelay=1 就比 kcp_nodelay=2 越有优势。在丢包率不特别高的情况下,kcp_nodelay=2 可使延迟抖动更为平滑。

如果想减少流量浪费、不介意延迟稍微增加,可以选择 regular 模式。<br />
标记了星号的模式 (regular3 ~ 5) 启用了 kcp_conserve 选项,丢包造成的延迟稍微高一些,浪费的流量稍微少一点。
对于不追求低延迟、只需要大流量传输的场景,请使用 **regular 3 ~ 5**。<br />
若使用时认为 CPU **负载过重**,那么可以考虑关闭 blast 选项(设置成 `blast=0`),缺点是流量传输率会减半。

### Log 文件
在首次获取打洞后的 IP 地址与端口后,以及打洞的 IP 地址与端口发生变化后,会向 Log 目录创建 ip_address.txt 文件(若存在就覆盖),将 IP 地址与端口写进去。
Expand Down Expand Up @@ -400,6 +400,9 @@ make
## 其它注意事项
### 多种系统都遇到的 Too Many Open Files
大多数情况下,这种提示只会在服务器端遇到,不会在客户端遇到。
如果确实在客户端遇到了,请检查 `mux_tunnels` 的数值是否过高(请顺便参考“多路复用 (mux_tunnels=N)”段落)。
#### GhostBSD
一般情况下,绝大多数 BSD 系统都不会遇到这种事,只有 2023 年下半年更新后的 GhostBSD 才会遇到这种现象。
Expand Down Expand Up @@ -459,7 +462,7 @@ sysctl -w net.inet6.ip6.v6only=0
需要提醒的是,使用两种校验码仍然无法 100% 避免内容错误,TCP 本身也是一样。如果确实需要精确无误,请启用加密选项。
## 多路复用
## 多路复用 (mux_tunnels=N)
KCP Tube 虽然有“多路复用”的功能,但默认并不主动打开。每接受一个入站连接,就会创建一个对应的出站连接。
原因是为了躲避运营商的 QoS。多路复用状态下,一旦某个端口号被 QoS,就会导致共用端口号的其它会话同时受阻,直到更换端口号为止。
Expand All @@ -478,7 +481,7 @@ KCP Tube 虽然有“多路复用”的功能,但默认并不主动打开。
- OpenVPN
- Wireguard
启用“多路复用”后,KCP 通道的超时时间为 30 秒。
启用“多路复用”后,KCP 通道的超时时间为 30 秒。一般来说,`mux_tunnels 设置成 3 ~ 10 就够用了,不需要设置过高的数值。
## 关于代码
### TCP
Expand Down
21 changes: 12 additions & 9 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ encryption_algorithm=AES-GCM
| stun_server | STUN Server's address |No| Cannot be used if listen_port option is port range mode|
| log_path | The directory where the Logs are stored |No|Cannot point to the file itself|
| kcp_mtu | Positive Integer |No|Default value is 1440|
| kcp_conserve | yes<br>true<br>1<br>no<br>false<br>0 |No|Ease up on the 'fast ACK' a little bit.|
| kcp | manual<br>fast1 - 6<br>regular1 - 5<br> &nbsp; |Yes|Setup Manually<br>Fast Modes<br>Regular Speeds<br>(the number at the end: the smaller the value, the faster the speed)|
| kcp_sndwnd | Positive Integer |No|See the table below for default values, which can be overridden individually|
| kcp_rcvwnd | Positive Integer |No|See the table below for default values, which can be overridden individually|
Expand All @@ -180,7 +179,7 @@ encryption_algorithm=AES-GCM
| outbound_bandwidth | Positive Integer |No|Outbound bandwidth, used to dynamically update the value of kcp_sndwnd during communication|
| inbound_bandwidth | Positive Integer |No|Inbound bandwidth, used to dynamically update the value of kcp_rcvwnd during communication|
| ipv4_only | yes<br>true<br>1<br>no<br>false<br>0 |No|If the system disables IPv6, this option must be enabled and set to yes or true or 1|
| blast | yes<br>true<br>1<br>no<br>false<br>0 |No|Packets are forwarded as quickly as possible regardless of KCP flow control settings. May lead to overload.|
| blast | yes<br>true<br>1<br>no<br>false<br>0 |No|Enabled by default. Based on the KCP flow control settings, packets are forwarded as quickly as possible.|
| [listener] | N/A |Yes<br>(Relay Mode only)|Section Name of Relay Mode, KCP settings for specifying the listening mode<br>This tag represents data exchanged with the client|
| [forwarder] | N/A |Yes<br>(Relay Mode only)|Section Name of Relay Mode, KCP settings for specifying the forwarding mode<br>This tag represents data exchanged with the server|

Expand Down Expand Up @@ -219,15 +218,15 @@ This bandwidth values should not larger than your actual bandwidth, otherwise th
| ---- | :----: | :----: | :----: | :----: | :----: |:----: |
| regular1 | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular2 | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular3* | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular4* | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular5* | 1024 | 1024 | 0 | 1 | 3 | 1 |
| regular3 | 1024 | 1024 | 0 | 1 | 2 | 1 |
| regular4 | 1024 | 1024 | 0 | 10 | 2 | 1 |
| regular5 | 1024 | 1024 | 0 | 30 | 2 | 1 |

Note: If the packet loss rate is high enough (higner than 10%), kcp_nodelay=1 may better than kcp_nodelay=2. If the packet loss rate is not too high, kcp_nodelay=2 can make the network latency smoother.

If you want to reduce traffic waste and also accept a little bit more latency increase, please try choosing regular modes.<br />
The star-marked modes (regular3 ~ 5) have enabled the kcp_conserve option, which leads to slightly higher latency caused by packet loss, but reduces wastage of traffic to some extent.

For scenarios that do not require low latency but only need high throughput transmission, please use **regular 3 - 5**.<br />
If the CPU load is deemed too heavy during usage, consider disabling the blast option (set it to `blast=0`), but note that the transmission rate will be halved as a drawback.

### Log File
After obtaining the IP address and port after NAT hole punching for the first time, and after the IP address and port of NAT hole punching change, an ip_address.txt file will be created in the Log directory (overwrite if it exists), and the IP address and port will be written in.
Expand Down Expand Up @@ -402,6 +401,9 @@ If the system does not support IPv6 or IPv6 is disabled, please set ipv4_only=tr
## Other Considerations
### ‘Too Many Open Files’ of multiple Operation Systems
In most cases, this kind of message only occurs on the server side, not on the client side.
If you do encounter it on the client side, please check whether the value of mux_tunnels is set too high. (please also refer to the paragraph on "Multiplexing (mux_tunnels=N)")
#### GhostBSD
In general, most BSD systems will not encounter this issue, only GhostBSD updated in the second half of 2023 will encounter it.
Expand Down Expand Up @@ -461,7 +463,7 @@ The calculation speed of these two checksums is fast enough, concise and practic
It should be reminded that using two checksums still cannot completely avoid content errors, just like TCP itself. If you really need accuracy, please enable the encryption option.
## Multiplexing
## Multiplexing (mux_tunnels=N)
The function of multiplexing is not automatically enabled by default. For each incoming connection accepted, a corresponding outgoing connection is created.
The reason is to avoid the QoS of operators. Once a port number is affected by QoS in multiplexing mode, other sessions sharing the same port number will also be blocked until the port number is changed.
Expand All @@ -480,7 +482,8 @@ If you really need to use the ‘multiplexing’ function, you can refer to the
- OpenVPN
- Wireguard
The timeout period for KCP channel is 30 seconds after enabling the multiplexing function.
The timeout period for KCP channel is 30 seconds after enabling the multiplexing function. In most cases, setting `mux_tunnels` to 3 - 10 is enough, and there is no need to set an excessively high value.
## About the codes
### TCP
Expand Down
13 changes: 6 additions & 7 deletions docs/parameters_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
| stun_server | STUN Server's address |No| Cannot be used if listen_port option is port range mode|
| log_path | The directory where the Logs are stored |No|Cannot point to the file itself|
| kcp_mtu | Positive Integer |No|Default value is 1440|
| kcp_conserve | yes<br>true<br>1<br>no<br>false<br>0 |No|Ease up on the 'fast ACK' a little bit.|
| kcp | manual<br>fast1 - 6<br>regular1 - 5<br> &nbsp; |Yes|Setup Manually<br>Fast Modes<br>Regular Speeds<br>(the number at the end: the smaller the value, the faster the speed)|
| kcp_sndwnd | Positive Integer |No|See the table below for default values, which can be overridden individually|
| kcp_rcvwnd | Positive Integer |No|See the table below for default values, which can be overridden individually|
Expand All @@ -27,7 +26,7 @@
| outbound_bandwidth | Positive Integer |No|Outbound bandwidth, used to dynamically update the value of kcp_sndwnd during communication|
| inbound_bandwidth | Positive Integer |No|Inbound bandwidth, used to dynamically update the value of kcp_rcvwnd during communication|
| ipv4_only | yes<br>true<br>1<br>no<br>false<br>0 |No|If the system disables IPv6, this option must be enabled and set to yes or true or 1|
| blast | yes<br>true<br>1<br>no<br>false<br>0 |No|Packets are forwarded as quickly as possible regardless of KCP flow control settings. May lead to overload.|
| blast | yes<br>true<br>1<br>no<br>false<br>0 |No|Enabled by default. Based on the KCP flow control settings, packets are forwarded as quickly as possible.|
| [listener] | N/A |Yes<br>(Relay Mode only)|Section Name of Relay Mode, KCP settings for specifying the listening mode<br>This tag represents data exchanged with the client|
| [forwarder] | N/A |Yes<br>(Relay Mode only)|Section Name of Relay Mode, KCP settings for specifying the forwarding mode<br>This tag represents data exchanged with the server|

Expand Down Expand Up @@ -66,15 +65,15 @@ This bandwidth values should not larger than your actual bandwidth, otherwise th
| ---- | :----: | :----: | :----: | :----: | :----: |:----: |
| regular1 | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular2 | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular3* | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular4* | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular5* | 1024 | 1024 | 0 | 1 | 3 | 1 |
| regular3 | 1024 | 1024 | 0 | 1 | 2 | 1 |
| regular4 | 1024 | 1024 | 0 | 10 | 2 | 1 |
| regular5 | 1024 | 1024 | 0 | 30 | 2 | 1 |

Note: If the packet loss rate is high enough (higner than 10%), kcp_nodelay=1 may better than kcp_nodelay=2. If the packet loss rate is not too high, kcp_nodelay=2 can make the network latency smoother.

If you want to reduce traffic waste and also accept a little bit more latency increase, please try choosing regular modes.<br />
The star-marked modes (regular3 ~ 5) have enabled the kcp_conserve option, which leads to slightly higher latency caused by packet loss, but reduces wastage of traffic to some extent.

For scenarios that do not require low latency but only need high throughput transmission, please use **regular 3 - 5**.<br />
If the CPU load is deemed too heavy during usage, consider disabling the blast option (set it to `blast=0`), but note that the transmission rate will be halved as a drawback.

# Log File
After obtaining the IP address and port after NAT hole punching for the first time, and after the IP address and port of NAT hole punching change, an ip_address.txt file will be created in the Log directory (overwrite if it exists), and the IP address and port will be written in.
Expand Down
12 changes: 6 additions & 6 deletions docs/parameters_zh-hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
| stun_server | STUN 服务器地址 ||listen_port 为端口范围模式时不可使用|
| log_path | 存放 Log 的目录 ||不能指向文件本身|
| kcp_mtu | 正整数 ||预设值1440|
| kcp_conserve | yes<br>true<br>1<br>no<br>false<br>0 ||使“快速ACK”稍微缓和|
| kcp | manual<br>fast1 - 6<br>regular1 - 5<br> &nbsp; ||手动设置<br>快速<br>常速<br>(末尾数字:数值越小,速度越快)|
| kcp_sndwnd | 正整数 ||预设值见下表,可以单独覆盖|
| kcp_rcvwnd | 正整数 ||预设值见下表,可以单独覆盖|
Expand All @@ -27,7 +26,7 @@
| outbound_bandwidth | 正整数 ||出站带宽,用于通讯过程中动态更新 kcp_sndwnd 的值|
| inbound_bandwidth | 正整数 ||入站带宽,用于通讯过程中动态更新 kcp_rcvwnd 的值|
| ipv4_only | yes<br>true<br>1<br>no<br>false<br>0 ||若系统禁用了 IPv6,须启用该选项并设为 yes 或 true 或 1|
| blast | yes<br>true<br>1<br>no<br>false<br>0 ||尝试忽略 KCP 流控设置,尽可能迅速地转发数据包。可能会导致负载过大|
| blast | yes<br>true<br>1<br>no<br>false<br>0 ||默认开启。在 KCP 流控设置的基础上,尽可能迅速地转发数据包|
| [listener] | N/A |是<br>(仅限中继模式)|中继模式的标签,用于指定监听模式的 KCP 设置<br>该标签表示与客户端交互数据|
| [forwarder] | N/A |是<br>(仅限中继模式)|中继模式的标签,用于指定转运模式的 KCP 设置<br>该标签表示与服务端交互数据|

Expand Down Expand Up @@ -66,14 +65,15 @@
| ---- | :----: | :----: | :----: | :----: | :----: |:----: |
| regular1 | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular2 | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular3* | 1024 | 1024 | 1 | 1 | 5 | 1 |
| regular4* | 1024 | 1024 | 2 | 1 | 5 | 1 |
| regular5* | 1024 | 1024 | 0 | 1 | 3 | 1 |
| regular3 | 1024 | 1024 | 0 | 1 | 2 | 1 |
| regular4 | 1024 | 1024 | 0 | 10 | 2 | 1 |
| regular5 | 1024 | 1024 | 0 | 30 | 2 | 1 |

其中,丢包率越高(高于 10%),kcp_nodelay=1 就比 kcp_nodelay=2 越有优势。在丢包率不特别高的情况下,kcp_nodelay=2 可使延迟抖动更为平滑。

如果想减少流量浪费、不介意延迟稍微增加,可以选择 regular 模式。<br />
标记了星号的模式 (regular3 ~ 5) 启用了 kcp_conserve 选项,丢包造成的延迟稍微高一些,浪费的流量稍微少一点。
对于不追求低延迟、只需要大流量传输的场景,请使用 **regular 3 ~ 5**。<br />
若使用时认为 CPU **负载过重**,那么可以考虑关闭 blast 选项(设置成 `blast=0`),缺点是流量传输率会减半。

# Log 文件
在首次获取打洞后的 IP 地址与端口后,以及打洞的 IP 地址与端口发生变化后,会向 Log 目录创建 ip_address.txt 文件(若存在就覆盖),将 IP 地址与端口写进去。
Expand Down
Loading

0 comments on commit 9704727

Please sign in to comment.