56 Commits

Author SHA1 Message Date
wangyu-
2cc560088b Update README.md 2017-11-07 02:58:34 -08:00
wangyu-
b83b21f2eb Merge branch 'master' of https://github.com/wangyu-/UDPspeeder 2017-11-07 03:55:01 -06:00
wangyu-
f526046846 do not drop packet in mode 1 2017-11-07 03:54:54 -06:00
wangyu-
1be5fb5fc1 Update README.zh-cn.md 2017-11-06 18:53:00 -08:00
wangyu-
27874aa413 changed parameter 2017-11-06 03:19:28 -06:00
wangyu-
fde2329528 Merge branch 'master' of https://github.com/wangyu-/UDPspeeder 2017-11-06 03:17:38 -06:00
wangyu-
30b78c1339 changed parameter 2017-11-06 03:17:34 -06:00
wangyu-
17a3074b34 Update README.zh-cn.md 2017-11-05 03:38:20 -08:00
wangyu-
cce7d18163 Update README.zh-cn.md 2017-11-04 21:50:37 -07:00
wangyu-
90029e1ea7 Update README.zh-cn.md 2017-11-03 22:50:24 -07:00
wangyu-
c26a4708ee Update README.zh-cn.md 2017-11-03 22:49:28 -07:00
wangyu-
fdbf4ab205 Update udpspeeder_openvpn.md 2017-11-03 22:46:33 -07:00
wangyu-
7ee72ee84c Update udpspeeder_openvpn.md 2017-11-03 22:45:39 -07:00
wangyu-
cac5f8271c Update README.zh-cn.md 2017-10-31 21:19:26 -07:00
wangyu-
219e8e2592 Update README.zh-cn.md 2017-10-31 21:18:33 -07:00
wangyu-
02b4d59500 Update README.zh-cn.md 2017-10-31 21:18:02 -07:00
wangyu-
894bf7cd0d Update README.zh-cn.md 2017-10-31 20:52:50 -07:00
wangyu-
a8cab43139 Update README.zh-cn.md 2017-10-31 20:52:31 -07:00
wangyu-
369a9d8e1b Update README.zh-cn.md 2017-10-31 20:51:39 -07:00
wangyu-
0f7894f42f revert last comit 2017-10-31 22:29:16 -05:00
wangyu-
d7daae25bf relax restriction for fec_data_num==1 2017-10-31 22:14:57 -05:00
wangyu-
d7271b74b4 Merge branch 'master' of https://github.com/wangyu-/UDPspeeder 2017-10-31 22:05:58 -05:00
wangyu-
1eeef14470 update log 2017-10-31 22:05:51 -05:00
wangyu-
9d30caffc9 Add files via upload 2017-11-01 10:35:01 +08:00
wangyu-
e50e383ede Delete ping_compare_cn.PNG 2017-10-31 19:34:47 -07:00
wangyu-
c73a197971 Update README.zh-cn.md 2017-10-31 19:31:24 -07:00
wangyu-
ba44617124 Add files via upload 2017-11-01 10:30:10 +08:00
wangyu-
19e718f0a3 new function tcp csum 2017-10-31 19:43:25 -05:00
wangyu-
bd323be9c4 fixed log 2017-10-30 20:29:04 -05:00
wangyu-
35a85e38ae fixed a missed continue 2017-10-30 11:23:37 -05:00
wangyu-
4871983b8f Update README.zh-cn.md 2017-10-30 08:40:17 -07:00
wangyu-
fec3c39cad Update README.zh-cn.md 2017-10-30 08:38:18 -07:00
wangyu-
4d55348a4d Update README.md 2017-10-30 08:35:41 -07:00
wangyu-
36eef02d8a Update README.md 2017-10-30 08:35:24 -07:00
wangyu-
3fd48dd20e Update README.md 2017-10-30 08:33:56 -07:00
wangyu-
766aa274d9 Update README.md 2017-10-30 08:33:36 -07:00
wangyu-
d961537682 Update udpspeeder_openvpn.md 2017-10-29 23:42:21 -07:00
wangyu-
4dcfe87bd3 Update README.zh-cn.md 2017-10-29 20:47:23 -07:00
wangyu-
2aa0ece465 Update README.md 2017-10-29 20:46:24 -07:00
wangyu-
05fd84b675 Update README.zh-cn.md 2017-10-29 03:41:28 -07:00
wangyu-
1e00ff7c87 add option keep-reconnect 2017-10-28 08:56:24 -05:00
wangyu-
c76818c6a8 trival 2017-10-28 07:44:25 -05:00
wangyu-
e3e2fe6d36 changed default sub-net 2017-10-28 06:48:24 -05:00
wangyu-
7cd87e7b59 trival 2017-10-28 04:36:37 -05:00
wangyu-
c3aae9579b refactor 2017-10-28 02:05:14 -05:00
wangyu-
d9f80781a2 changed --tun-dev to required argument 2017-10-28 01:45:50 -05:00
wangyu-
203604e1b5 Merge branch 'master' of https://github.com/wangyu-/UDPspeeder 2017-10-28 01:03:12 -05:00
wangyu-
5ac6e30c8e removed tun_dev.cpp and .h 2017-10-28 01:02:58 -05:00
wangyu-
6728d5a561 add dest ip restriction 2017-10-28 00:45:19 -05:00
wangyu-
f9eaae172f fixed typo 2017-10-27 23:19:08 -05:00
wangyu-
a0eeedb12a more log,more robust 2017-10-27 22:51:33 -05:00
wangyu-
324d34c87a Update README.zh-cn.md 2017-10-27 20:25:17 -07:00
wangyu-
1fe64b5689 Update README.zh-cn.md 2017-10-27 20:20:35 -07:00
wangyu-
d5e900e91c aloww len==fec_mtu 2017-10-27 21:16:59 -05:00
wangyu-
8e00273db4 just commit 2017-10-27 08:28:43 -05:00
wangyu-
73d68a2baf just commit 2017-10-27 05:23:46 -05:00
14 changed files with 280 additions and 205 deletions

View File

@@ -1,6 +0,0 @@
For English speaking user
https://github.com/wangyu-/UDPspeeder/wiki/Issue-Guide
中文用户请看:
https://github.com/wangyu-/UDPspeeder/wiki/发Issue前请看
(否则Issue可能被忽略或被直接关掉)

112
README.md
View File

@@ -1,9 +1,8 @@
# UDPspeeder
Network Speed-Up Tool. Boost your Connection on a High Lantency High Packet-Loss Link by using Forward Error Correction.
A Tunnel which Improves your Network Quality on a High-latency Lossy Link by using Forward Error Correction.
When used alone, UDPspeeder improves only UDP connection. Nevertheless, if you used UDPspeeder + any UDP-based VPN together,
you can improve any traffic(include TCP/UDP/ICMP), currently OpenVPN/L2TP/ShadowVPN are confirmed to be supported。
When used alone, UDPspeeder speeds-up only UDP connection. Nevertheless, if you used UDPspeeder + any UDP-based VPN together,
you can speed-up any traffic(include TCP/UDP/ICMP), currently OpenVPN/L2TP/ShadowVPN are confirmed to be supported。
![](/images/en/udpspeeder.PNG)
@@ -13,10 +12,22 @@ or
Assume your local network to your server is lossy. Just establish a VPN connection to your server with UDPspeeder + any UDP-based VPN, access your server via this VPN connection, then your connection quality will be significantly improved. With well-tuned parameters , you can easily reduce IP or UDP/ICMP packet-loss-rate to less than 0.01% . Besides reducing packet-loss-rate, UDPspeeder can also significantly improve your TCP latency and TCP single-thread download speed.
[UDPspeeder Wiki](https://github.com/wangyu-/UDPspeeder/wiki)
[简体中文](/doc/README.zh-cn.md)(内容更丰富)
###### Note
You can use udp2raw with UDPspeeder together to get better speed on some ISP with UDP QoS(UDP throttling).
udp2raw's repo
https://github.com/wangyu-/udp2raw-tunnel
You can also try tinyFecVPN, a lightweight high-performance VPN with build-in FEC support:
tinyFecVPN's repo:
https://github.com/wangyu-/tinyFecVPN
# Efficacy
tested on a link with 100ms latency and 10% packet loss at both direction
@@ -29,7 +40,7 @@ tested on a link with 100ms latency and 10% packet loss at both direction
# Supported Platforms
Linux host (including desktop Linux,Android phone/tablet, OpenWRT router, or Raspberry PI).
For Windows and MacOS You can run UDPspeeder inside [this](https://github.com/wangyu-/udp2raw-tunnel/releases/download/20171108.0/lede-17.01.2-x86_virtual_machine_image.zip) 7.5mb virtual machine image.
For Windows and MacOS You can run UDPspeeder inside [this](https://github.com/wangyu-/udp2raw-tunnel/releases/download/20170918.0/lede-17.01.2-x86_virtual_machine_image_with_udp2raw_pre_installed.zip) 7.5mb virtual machine image.
# How does it work
@@ -56,7 +67,7 @@ Check wikipedia for more info, https://en.wikipedia.org/wiki/ReedSolomon_erro
### Installing
Download binary release from https://github.com/wangyu-/UDPspeeder/releases
### Running (improves UDP traffic only)
### Running (speed-up UDP only)
Assume your server ip is 44.55.66.77, you have a service listening on udp port 7777.
```bash
@@ -67,7 +78,7 @@ Assume your server ip is 44.55.66.77, you have a service listening on udp port 7
./speederv2 -c -l0.0.0.0:3333 -r44.55.66.77:4096 -f20:10 -k "passwd"
```
Now connecting to UDP port 3333 at the client side is equivalent to connecting to port 7777 at the server side, and the connection has been boosted by UDPspeeder.
Now connecting to UDP port 3333 at the client side is equivalent to connecting to port 7777 at the server side, and the connection is boosted by UDPspeeder.
##### Note
@@ -75,58 +86,52 @@ Now connecting to UDP port 3333 at the client side is equivalent to connecting t
`-k` enables simple XOR encryption
# Improves all traffic with OpenVPN + UDPspeeder
See [UDPspeeder + openvpn config guide](https://github.com/wangyu-/UDPspeeder/wiki/UDPspeeder-openvpn-config-guide).
To run stably, pay attention to MTU.
# Advanced Topic
### Full Options
```
UDPspeeder V2
git version: 6f55b8a2fc build date: Nov 19 2017 06:11:23
git version:8e7a8aed92 build date:Oct 25 2017 02:00:54
repository: https://github.com/wangyu-/UDPspeeder
usage:
run as client: ./this_program -c -l local_listen_ip:local_port -r server_ip:server_port [options]
run as server: ./this_program -s -l server_listen_ip:server_port -r remote_ip:remote_port [options]
run as client : ./this_program -c -l local_listen_ip:local_port -r server_ip:server_port [options]
run as server : ./this_program -s -l server_listen_ip:server_port -r remote_ip:remote_port [options]
common options, must be same on both sides:
-k,--key <string> key for simple xor encryption. if not set, xor is disabled
common option,must be same on both sides:
-k,--key <string> key for simple xor encryption. if not set,xor is disabled
main options:
-f,--fec x:y forward error correction, send y redundant packets for every x packets
--timeout <number> how long could a packet be held in queue before doing fec, unit: ms, default: 8ms
--report <number> turn on send/recv report, and set a period for reporting, unit: s
-f,--fec x:y forward error correction,send y redundant packets for every x packets
--timeout <number> how long could a packet be held in queue before doing fec,unit: ms,default :8ms
--mode <number> fec-mode,available values: 0,1 ; 0 cost less bandwidth,1 cost less latency(default)
--report <number> turn on send/recv report,and set a period for reporting,unit:s
advanced options:
--mode <number> fec-mode,available values: 0,1; mode 0(default) costs less bandwidth,no mtu problem.
mode 1 usually introduces less latency, but you have to care about mtu.
--mtu <number> mtu. for mode 0, the program will split packet to segment smaller than mtu value.
for mode 1, no packet will be split, the program just check if the mtu is exceed.
default value: 1250. you typically shouldnt change this value.
-q,--queue-len <number> fec queue len, only for mode 0, fec will be performed immediately after queue is full.
default value: 200.
-j,--jitter <number> simulated jitter. randomly delay first packet for 0~<number> ms, default value: 0.
--mtu <number> mtu. for mode 0,the program will split packet to segment smaller than mtu_value.
for mode 1,no packet will be split,the program just check if the mtu is exceed.
default value:1250
-j,--jitter <number> simulated jitter.randomly delay first packet for 0~<number> ms,default value:0.
do not use if you dont know what it means.
-i,--interval <number> scatter each fec group to a interval of <number> ms, to protect burst packet loss.
default value: 0. do not use if you dont know what it means.
--random-drop <number> simulate packet loss, unit: 0.01%. default value: 0.
--disable-obscure <number> disable obscure, to save a bit bandwidth and cpu.
-i,--interval <number> scatter each fec group to a interval of <number> ms,to protect burst packet loss.
default value:0.do not use if you dont know what it means.
--random-drop <number> simulate packet loss ,unit:0.01%. default value: 0
--disable-obscure <number> disable obscure,to save a bit bandwidth and cpu
developer options:
--fifo <string> use a fifo(named pipe) for sending commands to the running program, so that you
can change fec encode parameters dynamically, check readme.md in repository for
--fifo <string> use a fifo(named pipe) for sending commands to the running program,so that you
can change fec encode parameters dynamically,check readme.md in repository for
supported commands.
-j ,--jitter jmin:jmax similiar to -j above, but create jitter randomly between jmin and jmax
-i,--interval imin:imax similiar to -i above, but scatter randomly between imin and imax
--decode-buf <number> size of buffer of fec decoder,u nit: packet, default: 2000
--fix-latency <number> try to stabilize latency, only for mode 0
-j ,--jitter jmin:jmax similiar to -j above,but create jitter randomly between jmin and jmax
-i,--interval imin:imax similiar to -i above,but scatter randomly between imin and imax
-q,--queue-len <number> max fec queue len,only for mode 0
--decode-buf <number> size of buffer of fec decoder,unit:packet,default:2000
--fix-latency <number> try to stabilize latency,only for mode 0
--delay-capacity <number> max number of delayed packets
--disable-fec <number> completely disable fec, turn the program into a normal udp tunnel
--sock-buf <number> buf size for socket, >=10 and <=10240, unit: kbyte, default: 1024
--disable-fec <number> completely disable fec,turn the program into a normal udp tunnel
--sock-buf <number> buf size for socket,>=10 and <=10240,unit:kbyte,default:1024
log and help options:
--log-level <number> 0: never 1: fatal 2: error 3: warn
4: info (default) 5: debug 6: trace
--log-position enable file name, function name, line number in log
--log-level <number> 0:never 1:fatal 2:error 3:warn
4:info (default) 5:debug 6:trace
--log-position enable file name,function name,line number in log
--disable-color disable log color
-h,--help print this help message
@@ -140,19 +145,6 @@ echo timeout 5 > fifo.file
echo queue-len 100 > fifo.file
echo mode 0 > fifo.file
```
### Speed-Up any traffic with OpenVPN + UDPspeeder
# wiki
Check wiki for more info:
https://github.com/wangyu-/UDPspeeder/wiki
# Related repo
You can also try tinyfecVPN, a lightweight high-performance VPN with UDPspeeder's function built-in, repo:
https://github.com/wangyu-/tinyfecVPN
You can use udp2raw with UDPspeeder together to get better speed on some ISP with UDP QoS(UDP throttling), repo:
https://github.com/wangyu-/udp2raw-tunnel
Check [UDPspeeder + openvpn config guide](/doc/udpspeeder_openvpn.md).

View File

@@ -52,7 +52,7 @@ u64_t get_current_time()//ms
{
timespec tmp_time;
clock_gettime(CLOCK_MONOTONIC, &tmp_time);
return ((u64_t)tmp_time.tv_sec)*1000llu+((u64_t)tmp_time.tv_nsec)/(1000*1000llu);
return tmp_time.tv_sec*1000+tmp_time.tv_nsec/(1000*1000l);
}
u64_t get_current_time_us()

View File

@@ -64,14 +64,13 @@ typedef short i16_t;
typedef u64_t my_time_t;
const int max_data_len=3600;
const int max_data_len=2200;
const int buf_len=max_data_len+200;
//const u32_t timer_interval=400;
////const u32_t conv_timeout=180000;
//const u32_t conv_timeout=40000;//for test
const u32_t conv_timeout=180000;
const u32_t conv_timeout=40000;//for test
const int max_conv_num=10000;
const int max_conn_num=200;

View File

@@ -11,25 +11,23 @@
![image0](/images/Capture2.PNG)
[English](/README.md)
对于某些运营商UDPspeeder跟udp2raw配合可以达到更好的速度udp2raw负责把UDP伪装成TCP来绕过运营商的UDP限速。
[UDPspeeder Wiki](https://github.com/wangyu-/UDPspeeder/wiki)
udp2raw的repo:
##### 提示
https://github.com/wangyu-/udp2raw-tunnel
如果你嫌UDPspeeder+OpenVPN麻烦你可以尝试tinyfecVPN一个集成了UDPspeeder功能的VPN
如果你嫌UDPspeeder+OpenVPN麻烦你可以尝试tinyFecVPN一个集成了UDPspeeder功能的VPN
tinyfecVPN的repo:
tinyFecVPN的repo:
https://github.com/wangyu-/tinyfecVPN
https://github.com/wangyu-/tinyFecVPN
#### 效果
![image0](/images/cn/ping_compare_cn.PNG)
![image0](/images/cn/scp_compare.PNG)
#### 原理简介
主要原理是通过冗余数据来对抗网络的丢包发送冗余数据的方式支持FEC(Forward Error Correction)和多倍发包其中FEC算法是Reed-Solomon。
@@ -50,20 +48,14 @@ FEC方式的原理图:
client支持多个udp连接server也支持多个client
#### 关键词
UDP加速器、双边UDP加速、全流量加速、开源加速器、游戏加速、网游加速器
# 简明操作说明
### 环境要求
Linux主机可以是桌面版可以是android手机/平板可以是openwrt路由器也可以是树莓派。Release中提供了`amd64``x86``arm``mips_be``mips_le`的预编译binary.
对于windows和mac用户在虚拟机中可以稳定使用speeder跑在Linux里其他应用照常跑在window里桥接模式测试可用。可以使用[这个](https://github.com/wangyu-/udp2raw-tunnel/releases/download/20171108.0/lede-17.01.2-x86_virtual_machine_image.zip)虚拟机镜像大小只有7.5mb免去在虚拟机里装系统的麻烦虚拟机自带ssh server可以scp拷贝文件可以ssh进去可以复制粘贴root密码123456。
Linux主机可以是桌面版可以是android手机/平板可以是openwrt路由器也可以是树莓派。在windows和mac上配合虚拟机可以稳定使用speeder跑在Linux里其他应用照常跑在window里桥接模式测试可用可以使用[这个](https://github.com/wangyu-/udp2raw-tunnel/releases/download/20170918.0/lede-17.01.2-x86_virtual_machine_image_with_udp2raw_pre_installed.zip)虚拟机镜像大小只有7.5mb免去在虚拟机里装系统的麻烦虚拟机自带ssh server可以scp拷贝文件可以ssh进去可以复制粘贴root密码123456。
android版需要通过terminal运行。
##### 注意
###### 注意
在使用虚拟机时,建议手动指定桥接到哪个网卡,不要设置成自动。否则可能会桥接到错误的网卡。
### 安装
@@ -75,103 +67,100 @@ https://github.com/wangyu-/UDPspeeder/releases
假设你有一个serverip为44.55.66.77有一个服务监听在udp 7777端口。 假设你需要加速本地到44.55.66.77:7777的流量。
```
在server端运行:
./speederv2 -s -l0.0.0.0:4096 -r127.0.0.1:7777 -f20:10 -k "passwd" --mode 0
./speederv2 -s -l0.0.0.0:4096 -r127.0.0.1:7777 -f20:10 -k "passwd"
在client端运行:
./speederv2 -c -l0.0.0.0:3333 -r44.55.66.77:4096 -f20:10 -k "passwd" --mode 0
./speederv2 -c -l0.0.0.0:3333 -r44.55.66.77:4096 -f20:10 -k "passwd"
```
现在client和server之间建立起了tunnel。想要连接44.55.66.77:7777只需要连接 127.0.0.1:3333。来回的所有的udp流量会被加速。
##### 备注
###### 备注:
`-f20:10`表示对每20个原始数据发送10个冗余包。`-f20:10``-f 20:10`都是可以的空格可以省略对于所有的单字节option都是如此。对于双字节option例如后面会提到`--mode 0`,空格不可以省略。
`-f20:10` 表示对每20个原始数据发送10个冗余包。`-f20:10``-f 20:10`都是可以的空格可以省略对于所有的单字节option都是如此。对于双字节option例如后面的`--mode 0``--mtu 1200`,空格不可以省略。
`-k` 指定一个字符串,开启简单的异或加密
推荐使用`--mode 0`选项否则你可能需要考虑MTU问题
如果需要更省流量,请加上`--mode 0``--mode 0`模式会牺牲一点点的延迟(默认最多8ms可调)换取更低的流量消耗
这里推荐的参数是给日常/非游戏情况下使用的;玩游戏请用 [使用经验](https://github.com/wangyu-/UDPspeeder/wiki/使用经验) 里推荐的参数。
###### 注意
##### 提示
对于某些运营商UDPspeeder跟udp2raw配合可以达到更好的速度udp2raw负责把UDP伪装成TCP来绕过运营商的UDP限速。
udp2raw的repo:
https://github.com/wangyu-/udp2raw-tunnel
要为UDPspeeder加速的应用设置好MTU(不是在UDPspeeder中是在被加速的应用中)建议设置为1200。 另外如果被加速的应用不能调整MTU也可以在UDPspeeder中通过`--mode 0 --mtu 1200`设置MTU。关于`--mode 0``--mtu`的具体解释请看下文。
# 进阶操作说明
### 命令选项
```
UDPspeeder V2
git version: 6f55b8a2fc build date: Nov 19 2017 06:11:23
git version:8e7a8aed92 build date:Oct 25 2017 02:00:54
repository: https://github.com/wangyu-/UDPspeeder
usage:
run as client: ./this_program -c -l local_listen_ip:local_port -r server_ip:server_port [options]
run as server: ./this_program -s -l server_listen_ip:server_port -r remote_ip:remote_port [options]
run as client : ./this_program -c -l local_listen_ip:local_port -r server_ip:server_port [options]
run as server : ./this_program -s -l server_listen_ip:server_port -r remote_ip:remote_port [options]
common options, must be same on both sides:
-k,--key <string> key for simple xor encryption. if not set, xor is disabled
common option,must be same on both sides:
-k,--key <string> key for simple xor encryption. if not set,xor is disabled
main options:
-f,--fec x:y forward error correction, send y redundant packets for every x packets
--timeout <number> how long could a packet be held in queue before doing fec, unit: ms, default: 8ms
--report <number> turn on send/recv report, and set a period for reporting, unit: s
-f,--fec x:y forward error correction,send y redundant packets for every x packets
--timeout <number> how long could a packet be held in queue before doing fec,unit: ms,default :8ms
--mode <number> fec-mode,available values: 0,1 ; 0 cost less bandwidth,1 cost less latency(default)
--report <number> turn on send/recv report,and set a period for reporting,unit:s
advanced options:
--mode <number> fec-mode,available values: 0,1; mode 0(default) costs less bandwidth,no mtu problem.
mode 1 usually introduces less latency, but you have to care about mtu.
--mtu <number> mtu. for mode 0, the program will split packet to segment smaller than mtu value.
for mode 1, no packet will be split, the program just check if the mtu is exceed.
default value: 1250. you typically shouldnt change this value.
-q,--queue-len <number> fec queue len, only for mode 0, fec will be performed immediately after queue is full.
default value: 200.
-j,--jitter <number> simulated jitter. randomly delay first packet for 0~<number> ms, default value: 0.
--mtu <number> mtu. for mode 0,the program will split packet to segment smaller than mtu_value.
for mode 1,no packet will be split,the program just check if the mtu is exceed.
default value:1250
-j,--jitter <number> simulated jitter.randomly delay first packet for 0~<number> ms,default value:0.
do not use if you dont know what it means.
-i,--interval <number> scatter each fec group to a interval of <number> ms, to protect burst packet loss.
default value: 0. do not use if you dont know what it means.
--random-drop <number> simulate packet loss, unit: 0.01%. default value: 0.
--disable-obscure <number> disable obscure, to save a bit bandwidth and cpu.
-i,--interval <number> scatter each fec group to a interval of <number> ms,to protect burst packet loss.
default value:0.do not use if you dont know what it means.
--random-drop <number> simulate packet loss ,unit:0.01%. default value: 0
--disable-obscure <number> disable obscure,to save a bit bandwidth and cpu
developer options:
--fifo <string> use a fifo(named pipe) for sending commands to the running program, so that you
can change fec encode parameters dynamically, check readme.md in repository for
--fifo <string> use a fifo(named pipe) for sending commands to the running program,so that you
can change fec encode parameters dynamically,check readme.md in repository for
supported commands.
-j ,--jitter jmin:jmax similiar to -j above, but create jitter randomly between jmin and jmax
-i,--interval imin:imax similiar to -i above, but scatter randomly between imin and imax
--decode-buf <number> size of buffer of fec decoder,u nit: packet, default: 2000
--fix-latency <number> try to stabilize latency, only for mode 0
-j ,--jitter jmin:jmax similiar to -j above,but create jitter randomly between jmin and jmax
-i,--interval imin:imax similiar to -i above,but scatter randomly between imin and imax
-q,--queue-len <number> max fec queue len,only for mode 0
--decode-buf <number> size of buffer of fec decoder,unit:packet,default:2000
--fix-latency <number> try to stabilize latency,only for mode 0
--delay-capacity <number> max number of delayed packets
--disable-fec <number> completely disable fec, turn the program into a normal udp tunnel
--sock-buf <number> buf size for socket, >=10 and <=10240, unit: kbyte, default: 1024
--disable-fec <number> completely disable fec,turn the program into a normal udp tunnel
--sock-buf <number> buf size for socket,>=10 and <=10240,unit:kbyte,default:1024
log and help options:
--log-level <number> 0: never 1: fatal 2: error 3: warn
4: info (default) 5: debug 6: trace
--log-position enable file name, function name, line number in log
--log-level <number> 0:never 1:fatal 2:error 3:warn
4:info (default) 5:debug 6:trace
--log-position enable file name,function name,line number in log
--disable-color disable log color
-h,--help print this help message
```
### 包发送选项,两端设置可以不同。 只影响本地包发送。
##### `-f` 选项
设置fec参数影响数据的冗余度。
##### `--timeout` 选项
指定fec编码器在编码时候最多可以引入多大的延迟。越高fec越有效率调低可以降低延迟,但是会牺牲效率
指定fec编码器在编码时候最多可以引入多大的延迟。越高fec越有效率加速游戏时调低可以降低延迟。
##### `--mode` 选项 和 `--mtu`选项
fec编码器的工作模式。对于mode 0编码器会积攒一定数量的packet然后把他们合并再切成等长的片段切分长度由--mtu指定。对于mode 1编码器不会做任何切分而是会把packet按最大长度对齐fec冗余包的长度为对齐后的长度最大长度
简单来说`--mode 0`更省流量,没有mtu问题`--mode 1`可以稍微降低一点延迟需要考虑mtu另外还有个`--mode 0 -q1`模式多倍发包专用没有延迟也没有mtu问题适合游戏但是最耗流量
mode 0更省流量在丢包率正常的情况下效果和mode 1是一样的mode 1延迟更低在极高丢包的情况下表现更好
具体见https://github.com/wangyu-/UDPspeeder/wiki/mode和mtu选项
mode 0使用起来可以不用关注mtu因为fec编码器会帮你把包切分到合理的大小用mode 1时必须合理设置上层应用的mtu。mode 0模式中--mtu选项决定切分的片段的长度mode 1模式中--mtu选项只起检查作用如果超过了--mtu指定的值数据包会被丢弃。
对于新手,建议不要纠结这些参数的具体含义,就用我在`使用经验`里推荐的设置,不要乱改参数,尤其是不要改`--mtu`
mode 0模式的流量消耗基本完全透明。mode 1因为涉及到数据按最大长度对齐所以流量消耗不是完全可预期。<del>不过就实际使用来看mode 1消耗的额外流量不多。</del> mode 1一般会比mode 0多消耗零点几倍的流量对于在意流量的人推荐用mode 0
mode 0模式数据包一般不会乱序除非网络本身有严重乱序mode 1模式被恢复的数据包可能会乱序不过UDP本来就允许乱序对绝大多数应用没有影响。mode 0模式反而可以纠正一些乱序情况。
mode 0模式允许你发送的数据包大小超过物理接口的MTU而几乎不引起性能损失而普通的ip分片做不到这点目前最高支持到2000字节2000字节已经可以应对任何应用了因为一般网络的MTU只有1400多。之所以支持到2000字节是为了省程序内部开的静态buff(静态buff避免malloc提高性能)如果你是开发者通过重新编译支持到UDP协议的极限(
65507字节)也没问题。
##### `--report`  选项
数据发送和接受报告。开启后可以根据此数据推测出包速和丢包率等特征。`--report 10`表示每10秒生成一次报告。
数据发送和接受报告。开启后可以根据此数据推测出包速和丢包率等特征。
##### `-i` 选项
指定一个时间窗口长度为n毫秒。同一个fec分组的数据在发送时候会被均匀分散到这n毫秒中可以对抗突发性的丢包默认值是0(也就是不开启此功能)。 这个功能很有用,在推荐的参数效果不理想时可以尝试打开,比如用`-i 10``-i 20`。这个选项的跟通信原理上常说的`交错fec` `交织fec`的原理是差不多的。
指定一个时间窗口长度为n毫秒。同一个fec分组的数据在发送时候会被均匀分散到这n毫秒中可以对抗突发性的丢包默认值是0,因为这个功能需要用到时钟,在某些虚拟机里时钟不稳定,可能会导致个别包出现非常大的延迟,所以默认关掉了。这个功能很有用,默认参数效果不理想时可以尝试打开。这个选项的跟通信原理上常说的`交错fec` `交织fec`的原理是差不多的。
##### `-j` 选项
为原始数据的发送增加一个延迟抖动值。这样上层应用计算出来的RTT方差会更大以等待后续冗余包的到达不至于发生在冗余包到达之前就触发重传的尴尬。配合-t选项使用。正常情况下跨国网络本身的延迟抖动就很大可以不用设-j。这个功能也需要时钟默认关掉了不过一般情况应该不需要这个功能。
@@ -181,14 +170,11 @@ log and help options:
##### `--random-drop` 选项
随机丢包。模拟高丢包的网络环境时使用。 `--random-drop``-j`选项一起用可以模拟高延迟或者高延迟抖动高丢包的网络可用于测试FEC参数在各种网络环境下的表现。
##### `-q` 选项
仅对mode 0模式有用。设置fec编码器的最大队列长度。 比如`-q5`的意思是在编码器积攒了5个数据包后就立即发送。合理使用可以改善延迟。在下文的`使用经验`里有提到用`--mode 0 -q1` 来多倍发包。
##### `-k`选项
指定一个字符串server/client间所有收发的包都会被异或改变协议特征防止UDPspeeder的协议被运营商针对。
`-q``--timeout`的作用类似。`-q`决定fec编码器积攒了多少个数据包之后立即发送。`--timeout`决定编码器收到第一个数据包以后,最多延迟多少毫秒后发送。
默认值是200也就是尽可能多得积攒数据。
建议不要自己调整这个参数,除非是用我在`使用经验`里推荐给你的形式。
##### `--disable-obscure`
UDPspeeder默认情况下会对每个发出的数据包随机填充和异或一些字节(4~32字节)这样通过抓包难以发现你发了冗余数据防止VPS被封。这个功能只是为了小心谨慎即使你关掉这个功能基本上也没问题关掉可以省一些带宽和CPU。
#### `--fifo` option
用fifo(命名管道)向运行中的程序发送command。例如`--fifo fifo.file`可用的command有
@@ -201,30 +187,144 @@ echo mode 0 > fifo.file
```
可以动态改变fec编码器参数。可以从程序的log里看到command是否发送成功。
### 以下设置两端必须相同。
##### `-k`选项
指定一个字符串server/client间所有收发的包都会被异或改变协议特征防止UDPspeeder的协议被运营商针对。
##### `--disable-obscure`
UDPspeeder默认情况下会对每个发出的数据包随机填充和异或一些字节(4~32字节)这样通过抓包难以发现你发了冗余数据防止VPS被封。这个功能只是为了小心谨慎即使你关掉这个功能基本上也没问题关掉可以省一些带宽和CPU。`--disable-obscure`可以关掉这个功能。
# 推荐参数
https://github.com/wangyu-/UDPspeeder/wiki/推荐设置
# 使用经验
https://github.com/wangyu-/UDPspeeder/wiki/使用经验
### 在FEC和多倍发包之间如何选择
对于游戏游戏的流量本身不大延迟很重要多倍发包是最佳解决方案多倍发包不会引入额外的延迟。FEC编码器需要先积攒一些数据才可以做FEC延迟无法避免对于多倍发包没有这个问题所以没有延迟。
对于其他日常应用延迟要求一般在合理配置的情况下FEC的效果肯定好过多倍发包。不过需要根据网络的最大丢包来配置FEC参数才能有稳定的效果。如果配置不当对于--mode 1可能会完全没有效果对于--mode 0可能效果会比不用UDPspeeder还差。
对于游戏以外的应用推荐使用FEC。但是如果FEC版的默认参数在你那边效果很差而你又不会调可以先用多倍发包。
### V2版如何多倍发包
只要在设置-f参数时把x设置为1fec算法就退化为多倍发包了。例如-f1:1表示2倍发包-f1:2表示3倍发包以此类推。另外建议加上"--mode 1"参数防止fec编码器试图积攒和合并数据获得最低的延迟。
2倍发包的完整参数
```
./speederv2 -s -l0.0.0.0:4096 -r127.0.0.1:7777 -f1:1 -k "passwd" --mode 1
./speederv2 -c -l0.0.0.0:3333 -r44.55.66.77:4096 -f1:1 -k "passwd" --mode 1
```
使用了`--mode 1`以后,`--timeout`选项不起作用,所以不用调。
如果你只需要多倍发包可以直接用回V1版V1版配置更简单占用内存更小而且经过了几个月的考验很稳定。
### 根据网络丢包合理设置FEC参数
默认的FEC参数为-f20:10对每20个包额外发送10个冗余包也就是1.5倍发包。已经可以适应绝大多数的网络情况了对于10%的网络丢包可以降低到0.01%以下对于20%的网络丢包可以降低到2.5%。
如果你的网络丢包很低比如在3%以下,可以尝试调低参数。比如-f20:5也就是1.2倍发包这个参数已经足够把3%的丢包降低到0.01%以下了。
如果网络丢包超过20%,需要把-f20:10调大。
如果你实在不会配那么也可以用回V1版。
### 根据CPU处理能力来调整FEC参数
FEC算法很吃CPU初次使用建议关注UDPspeeder的CPU占用。如果CPU被打满可以在冗余度不变的情况下把FEC分组大小调小否则的话效果可能很差。
比如-f20:10和-f10:5都是1.5倍的冗余度,而-f20:10的FEC分组大小是30个包-f10:5的FEC分组大小是15个包。-f20:10更费CPU但是在一般情况下效果更稳定。把分组调小可以节省CPU。
另外fec分组大小不宜过大否则不但很耗CPU还有其他副作用建议x+y<50
### 改变FEC参数而不断线
`--fifo`选项可以在运行时改变FEC参数无需重启程序也不会断线如果你在使用过程中发现网络丢包突然变高可以动态地把冗余度调大反之也一样如果网络变好了把冗余度调小节省流量一切都是无缝进行不会断线也不会因为改FEC参数导致额外的丢包
### 为什么使用之后效果反而变差了?
有可能是你用了`--mode 0`参数而又没调好参数
如果你没有使用`--mode 0`而确实效果变差了那很可能是因为你的运营商对UDP有限制一般看视频和下载都是TCP流量而用UDPspeeder中转后流量变成了UDP流量如果运营商对UDP做了限制就可能导致效果比不用还差用udp2raw可以解决udp2raw: https://github.com/wangyu-/udp2raw-tunnel
### UDPspeeder和BBR/锐速配合
UDPspeeder和BBR/锐速可以配合使用UDPspeeder工作在IP层负责降低丢包率BBR/锐速工作在TCP层负责优化拥塞和重传这种情况下可以调低UDPspeeder的冗余度能把丢包率降低到5%以内就可以了剩下的交给BBR/锐速解决这样预计可以节省一些流量如果是UDPspeeder跟Linux默认的Cubic一起用最少也要把丢包率降低到1%以下才能流畅使用TCP
对下文的`UDPspeeder + openvpn``UDPspeeder + openvpn + $***`方法有效不过有一点区别具体见下文
### UDPspeeder和Kcptun配合
UDPspeeder和Kcptun配合UDPspeeder和Kcptun可以并联也可以串联
并联的情况下让kcptun负责加速TCPUDPspeeder负责加速UDP见下文的`UDPspeeder + kcptun + $*** 同时加速tcp和udp流量`
串联的情况UDPspeeder的FEC跟Kcptun自带的相比可以对两个方向设置不同的FEC参数有一个更省流量的mode 0模式可以动态改变FEC参数但是UDPspeeder本身不优化拥塞和重传算法所以UDPspeeder和Kcptun也可以配合使用结合两者的优点
串联时可以关掉Kcptun的FEC让UDPspeeder接管FEC功能这样UDPspeeder工作在UDP层负责降低丢包率Kcptun工作在应用层用kcp算法负责优化拥塞和重传能起到和`UDPspeeder+BBR/锐速`类似的效果
如果发Issue问Kcptun+UDPspeeder相关的问题一定要说明是并联还是串联
# 应用
#### UDPspeeder + OpenVPN加速任何流量也适用于其他VPN
![image0](/images/Capture2.PNG)
可以和BBR/锐速叠加不过BBR/锐速部署在VPS上只对从本地到VPS的流量有效对从本地到第三方服务器的流量无效
需要在服务端开启ipforward和NAT在客户端改路由表可以手动修改也可以由OpenVPN的redirect-gateway选项自动加好)。
Linux具体配置: [UDPspeeder + openvpn config guide](/doc/udpspeeder_openvpn.md).
Windows具体配置: [win10系统UDPspeeder+OpenVPN的完整设置](https://github.com/wangyu-/UDPspeeder/wiki/win10系统UDPspeeder-OpenVPN的完整设置)
如果UDPspeeder + OpenVPN对你来说显得太麻烦了你可以尝试一下tinyFecVPN,一个集成了UDPspeeder功能的VPN:
https://github.com/wangyu-/tinyFecVPN/
#### UDPspeeder + kcptun/finalspeed + $*** 同时加速tcp和udp流量
如果你需要用加速的tcp看视频和下载文件这样效果可能比没有BBR的UDPspeeder+vpn方案更好另外如果你需要玩游戏但是嫌配VPN麻烦也可以用这种方案
![image0](/images/cn/speeder_kcptun.PNG)
具体配置方法简介:
假设$\*\*\* server监听在在44.55.66.77的443端口(tcp和udp同时)。用kcptun把tcp 443映射到本地的tcp 1234用UDPspeeder把udp 443的映射到本地的udp 1234
然后让$\*\*\* client 去连127.0.0.1:1234就可以了tcp和udp都被加速了完整命令
```
run at server side:
./kcp_server -l ":4000" -t "127.0.0.1:443" -mode fast2
./speederv2 -s -l0.0.0.0:4001 -r127.0.0.1:443 -f20:10 -k "passwd"
run at client side:
./kcp_client -l ":1234" -r "44.55.66.77:4000" -mode fast2
./speederv2 -c -l0.0.0.0:1234 -r44.55.66.77:4001 -f20:10 -k "passwd"
```
这就是全部的命令了issue里有很多人困惑于怎么把tcp和udp流量"分开"其实很简单就可以做到
如果只需要加速UDP不需要加速TCP可以把kcptun换成其他的任意端口转发方式比如ncat/socat/ssh tunnel/iptables/[tinyPortMapper](https://github.com/wangyu-/tinyPortMapper/releases)
另外如果没有kcptun只有BBR/锐速的话也可以把kcptun换成ncat/socat/ssh tunnel/iptables/[tinyPortMapper](https://github.com/wangyu-/tinyPortMapper/releases)这样TCP流量由锐速/BBR加速UDP由UDPspeeder加速
#### UDPspeeder + openvpn + $*** 混合方案也适用于其他VPN
也是我正在用的方案优点是可以随时在vpn和$\*\*\*方案间快速切换
实际部署起来比图中看起来的还要简单不需要改路由表不需要写iptables规则和开启NAT需要做的只是用openvpn分配的ip访问$*** server
![image0](/images/cn/speeder_vpn_s.PNG)
(也可以把图中的$*** server换成其他的socks5 server这样就不需要$*** client了)
可以和BBR/锐速叠加BBR/锐速只要部署在VPS上就有效
也可以用[tinyFecVPN](https://github.com/wangyu-/tinyFecVPN/) + $\*\*\* 配置起来更简单
# 应用实例
#### win10系统UDPspeeder+OpenVPN的完整设置
https://github.com/wangyu-/UDPspeeder/wiki/win10系统UDPspeeder-OpenVPN的完整设置
#### 用树莓派做路由器,搭建透明代理,加速游戏主机的网络
https://github.com/wangyu-/UDPspeeder/wiki/用树莓派做路由器搭建透明代理加速游戏主机的网络
# 编译教程
暂时先参考udp2raw的这篇教程几乎一样的过程
https://github.com/wangyu-/udp2raw-tunnel/blob/master/doc/build_guide.zh-cn.md
# wiki
更多内容请看 wiki:
https://github.com/wangyu-/UDPspeeder/wiki

View File

@@ -16,7 +16,7 @@ int g_fec_redundant_num=10;
int g_fec_mtu=1250;
int g_fec_queue_len=200;
int g_fec_timeout=8*1000; //8ms
int g_fec_mode=0;
int g_fec_mode=1;
int dynamic_update_fec=1;
@@ -185,7 +185,7 @@ int fec_encode_manager_t::append(char *s,int len/*,int &is_first_packet*/)
{
mylog(log_trace,"counter=%d\n",counter);
assert(len<=65535&&len>=0);
//assert(len<=fec_mtu);//relax this limitation
assert(len<=fec_mtu);
char * p=input_buf[counter]+sizeof(u32_t)+4*sizeof(char);//copy directly to final position,avoid unnecessary copy.
//remember to change this,if protocol is modified
@@ -229,7 +229,7 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/)
}
if(fec_mode==1&&s!=0&&len>fec_mtu)
{
mylog(log_warn,"mode==1,message len=%d,len>fec_mtu,fec_mtu=%d,packet may not be delivered\n",len,fec_mtu);
mylog(log_warn,"mode==1,message len=%d,fec_mtu=%d,len>fec_mtu,packet may not be able to deliver\n",len,fec_mtu);
//return -1;
}
if(s==0&&counter==0)
@@ -282,10 +282,7 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/)
int best_data_num=fec_data_num;
for(int i=1;i<actual_data_num;i++)
{
u32_t shard_len=blob_encode.get_shard_len(i,0);
if(shard_len>(u32_t)fec_mtu) continue;
u32_t new_len=(shard_len+header_overhead)*(i+fec_redundant_num);
u32_t new_len=(blob_encode.get_shard_len(i,0)+header_overhead)*(i+fec_redundant_num);
if(new_len<best_len)
{
best_len=new_len;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -34,22 +34,19 @@ static void print_help()
printf("main options:\n");
printf(" -f,--fec x:y forward error correction, send y redundant packets for every x packets\n");
printf(" --timeout <number> how long could a packet be held in queue before doing fec, unit: ms, default: 8ms\n");
printf(" --mode <number> fec-mode,available values: 0, 1; 0 cost less bandwidth, 1 cost less latency(default)\n");
printf(" --report <number> turn on send/recv report, and set a period for reporting, unit: s\n");
printf("advanced options:\n");
printf(" --mode <number> fec-mode,available values: 0,1; mode 0(default) costs less bandwidth,no mtu problem.\n");
printf(" mode 1 usually introduces less latency, but you have to care about mtu.\n");
printf(" --mtu <number> mtu. for mode 0, the program will split packet to segment smaller than mtu value.\n");
printf(" --mtu <number> mtu. for mode 0, the program will split packet to segment smaller than mtu_value.\n");
printf(" for mode 1, no packet will be split, the program just check if the mtu is exceed.\n");
printf(" default value: 1250. you typically shouldnt change this value.\n");
printf(" -q,--queue-len <number> fec queue len, only for mode 0, fec will be performed immediately after queue is full.\n");
printf(" default value: 200. \n");
printf(" default value: 1250\n");
printf(" -j,--jitter <number> simulated jitter. randomly delay first packet for 0~<number> ms, default value: 0.\n");
printf(" do not use if you dont know what it means.\n");
printf(" -i,--interval <number> scatter each fec group to a interval of <number> ms, to protect burst packet loss.\n");
printf(" default value: 0. do not use if you dont know what it means.\n");
printf(" --random-drop <number> simulate packet loss, unit: 0.01%%. default value: 0.\n");
printf(" --disable-obscure <number> disable obscure, to save a bit bandwidth and cpu.\n");
printf(" --random-drop <number> simulate packet loss, unit: 0.01%%. default value: 0\n");
printf(" --disable-obscure <number> disable obscure, to save a bit bandwidth and cpu\n");
// printf(" --disable-xor <number> disable xor\n");
printf("developer options:\n");
@@ -58,6 +55,7 @@ static void print_help()
printf(" supported commands.\n");
printf(" -j ,--jitter jmin:jmax similiar to -j above, but create jitter randomly between jmin and jmax\n");
printf(" -i,--interval imin:imax similiar to -i above, but scatter randomly between imin and imax\n");
printf(" -q,--queue-len <number> max fec queue len, only for mode 0\n");
printf(" --decode-buf <number> size of buffer of fec decoder,u nit: packet, default: 2000\n");
printf(" --fix-latency <number> try to stabilize latency, only for mode 0\n");
printf(" --delay-capacity <number> max number of delayed packets\n");

View File

@@ -13,7 +13,7 @@ SOURCES=main.cpp log.cpp common.cpp lib/fec.c lib/rs.c packet.cpp delay_manager.
NAME=speederv2
TARGETS=amd64 arm mips24kc_be x86 mips24kc_le
TAR=${NAME}_binaries.tar.gz `echo ${TARGETS}|sed -r 's/([^ ]+)/speederv2_\1/g'` version.txt
TAR=${NAME}_binaries.tar.gz `echo ${TARGETS}|sed -r 's/([^ ]+)/speederv2_\1/g'`
all:git_version
rm -f ${NAME}
@@ -56,7 +56,6 @@ cross3:git_version
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -O3
release: ${TARGETS}
cp git_version.h version.txt
tar -zcvf ${TAR}
clean:

View File

@@ -140,6 +140,9 @@ int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,ch
}
}
}
mylog(log_trace,"from_normal_to_fec input_len=%d,output_n=%d\n",len,out_n);
if(out_n>0)
{
@@ -155,12 +158,6 @@ int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,ch
}
log_bare(log_trace,"\n");
}
mylog(log_trace,"from_normal_to_fec input_len=%d,output_n=%d\n",len,out_n);
//for(int i=0;i<n;i++)
//{
//delay_send(0,dest,s_arr[i],s_len);
@@ -579,7 +576,6 @@ void process_arg(int argc, char *argv[])
{"tun-mtu", required_argument, 0, 1},
{"disable-mssfix", no_argument, 0, 1},
{"keep-reconnect", no_argument, 0, 1},
{"interval", required_argument, 0,'i'},
{NULL, 0, 0, 0}
};
int option_index = 0;

View File

@@ -113,12 +113,12 @@ int tunnel_client_event_loop()
if (nfds < 0) { //allow zero
if(errno==EINTR )
{
mylog(log_info,"epoll interrupted by signal continue\n");
//myexit(0);
mylog(log_info,"epoll interrupted by signal\n");
myexit(0);
}
else
{
mylog(log_fatal,"epoll_wait return %d,%s\n", nfds,strerror(errno));
mylog(log_fatal,"epoll_wait return %d\n", nfds);
myexit(-1);
}
}
@@ -417,12 +417,12 @@ int tunnel_server_event_loop()
if (nfds < 0) { //allow zero
if(errno==EINTR )
{
mylog(log_info,"epoll interrupted by signal,continue\n");
//myexit(0);
mylog(log_info,"epoll interrupted by signal\n");
myexit(0);
}
else
{
mylog(log_fatal,"epoll_wait return %d,%s\n", nfds,strerror(errno));
mylog(log_fatal,"epoll_wait return %d\n", nfds);
myexit(-1);
}
}