UDPspeeder Documentation

A Tunnel which Improves your Network Quality on a High-latency Lossy Link by using Forward Error Correction, possible for All Traffics(TCP/UDP/ICMP)

5,156 stars C++ C++ 1 file · ~3,590 tokens #ecc#fec#proxy#reed-solomon#tunnel#udp#udp-tunnel
RAW Doc

File: README.md

UDPspeeder

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。

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

简体中文

Efficacy

tested on a link with 100ms latency and 10% packet loss at both direction

Ping Packet Loss

SCP Copy Speed

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 7.5mb virtual machine image.

How does it work

UDPspeeder uses FEC(Forward Error Correction) to reduce packet loss rate, at the cost of additional bandwidth. The algorithm for FEC is called Reed-Solomon.

Reed-Solomon

In coding theory, the Reed–Solomon code belongs to the class of non-binary cyclic error-correcting codes. The Reed–Solomon code is based on univariate polynomials over finite fields.

It is able to detect and correct multiple symbol errors. By adding t check symbols to the data, a Reed–Solomon code can detect any combination of up to t erroneous symbols, or correct up to ⌊t/2⌋ symbols. As an erasure code, it can correct up to t known erasures, or it can detect and correct combinations of errors and erasures. Reed–Solomon codes are also suitable as multiple-burst bit-error correcting codes, since a sequence of b + 1 consecutive bit errors can affect at most two symbols of size b. The choice of t is up to the designer of the code, and may be selected within wide limits.

Check wikipedia for more info, https://en.wikipedia.org/wiki/Reed–Solomon_error_correction

Getting Started

Installing

Download binary release from https://github.com/wangyu-/UDPspeeder/releases

Running (improves UDP traffic only)

Assume your server ip is 44.55.66.77, you have a service listening on udp port 7777.

bash
# Run at server side:
./speederv2 -s -l0.0.0.0:4096 -r 127.0.0.1:7777  -f20:10 -k "passwd"

# Run at client side
./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.

Note

-f20:10 means sending 10 redundant packets for every 20 original packets.

-k enables simple XOR encryption

Improves all traffic with OpenVPN + UDPspeeder

See UDPspeeder + openvpn config guide.

Advanced Topic

Full Options

text
/* Detailed source-code truncated for AI context efficiency. */

`--fifo` option

Use a fifo(named pipe) for sending commands to the running program. For example --fifo fifo.file, you can use following commands to change parameters dynamically:

text
echo fec 19:9 > fifo.file
echo mtu 1100 > fifo.file
echo timeout 5 > fifo.file
echo queue-len 100 > fifo.file
echo mode 0 > fifo.file

wiki

Check wiki for more info:

https://github.com/wangyu-/UDPspeeder/wiki

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


File: doc/README.zh-cn.md

UDPspeeder

双边网络加速工具,软件本身的功能是加速UDP;不过,配合vpn可以加速全流量(包括TCP/UDP/ICMP)。通过合理配置,可以加速游戏,降低游戏的丢包和延迟;也可以加速下载和看视频这种大流量的应用。用1.5倍的流量,就可以把10%的丢包率降低到万分之一以下。跟 kcptun/finalspeed/BBR 等现有方案比,主要优势是可以加速 UDP 和 ICMP,现有方案几乎都只能加速 TCP。

我自己稳定用了几个月,用来加速美服的Brawl Stars和亚服的Mobile Legend,效果不错,加速前卡得几乎没法玩,加速后就没怎么卡过了。用来看视频也基本满速。

最新的版本是v2版,在v1版的基础上增加了FEC功能,更省流量。如果你用的是v1版(路由器固件里自带的集成版很可能是v1版的),请看v1版主页

配合vpn加速全流量的原理图(已测试支持VPN的有OpenVPN、L2TP、$***VPN):

English

UDPspeeder Wiki

提示

如果你嫌UDPspeeder+OpenVPN麻烦,你可以尝试tinyfecVPN,一个集成了UDPspeeder功能的VPN:

tinyfecVPN的repo:

https://github.com/wangyu-/tinyfecVPN

效果

原理简介

主要原理是通过冗余数据来对抗网络的丢包,发送冗余数据的方式支持FEC(Forward Error Correction)和多倍发包,其中FEC算法是Reed-Solomon。

FEC方式的原理图:

其他功能

对包的内容和长度做随机化(可以理解为混淆),从抓包看不出你发送了冗余数据,不用担心vps被封。

在多个冗余包之间引入延迟(时间可配)来对抗突发性的丢包,避开中间路由器因为瞬时buffer长度过长而连续丢掉所有副本。

模拟一定的延迟抖动(时间可配),这样上层应用计算出来的RTT方差会更大,以等待后续冗余包的到达,不至于发生在冗余包到达之前就触发重传的尴尬。

输出UDP收发情况报告,可以看出丢包率。

模拟丢包,模拟延迟,模拟jitter。便于通过实验找出应用卡顿的原因。

client支持多个udp连接,server也支持多个client

关键词

UDP加速器、双边UDP加速、全流量加速、开源加速器、游戏加速、网游加速器

简明操作说明

环境要求

Linux主机,可以是桌面版,可以是android手机/平板,可以是openwrt路由器,也可以是树莓派。Release中提供了amd64、x86、arm、mips_be、mips_le的预编译binary.

Windows、MacOS、BSD也已经原生支持。

对于windows和mac用户,在虚拟机中可以稳定使用(speeder跑在Linux里,其他应用照常跑在window里,桥接模式测试可用)。可以使用这个虚拟机镜像,大小只有7.5mb,免去在虚拟机里装系统的麻烦;虚拟机自带ssh server,可以scp拷贝文件,可以ssh进去,可以复制粘贴,root密码123456。

android版需要通过terminal运行。

注意

在使用虚拟机时,建议手动指定桥接到哪个网卡,不要设置成自动。否则可能会桥接到错误的网卡。

安装

下载编译好的二进制文件,解压到本地和服务器的任意目录。

https://github.com/wangyu-/UDPspeeder/releases

运行

假设你有一个server,ip为44.55.66.77,有一个服务监听在udp 7777端口。 假设你需要加速本地到44.55.66.77:7777的流量。

text
在server端运行:
./speederv2 -s -l0.0.0.0:4096 -r127.0.0.1:7777  -f20:10 -k "passwd" --mode 0

在client端运行:
./speederv2 -c -l0.0.0.0:3333 -r44.55.66.77:4096 -f20:10 -k "passwd" --mode 0

现在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,空格不可以省略。

-k 指定一个字符串,开启简单的异或加密

推荐使用--mode 0选项,否则你可能需要考虑MTU问题。

这里推荐的参数是给日常/非游戏情况下使用的;玩游戏请用 使用经验 里推荐的参数。

提示

对于某些运营商,UDPspeeder跟udp2raw配合可以达到更好的速度,udp2raw负责把UDP伪装成TCP,来绕过运营商的UDP限速。

udp2raw的repo:

https://github.com/wangyu-/udp2raw-tunnel

进阶操作说明

命令选项

text
/* Detailed source-code truncated for AI context efficiency. */

包发送选项,两端设置可以不同。 只影响本地包发送。

`-f` 选项

设置fec参数,影响数据的冗余度。

`--timeout` 选项

指定fec编码器在编码时候最多可以引入多大的延迟。越高fec越有效率,调低可以降低延迟,但是会牺牲效率。

`--mode` 选项 和 `--mtu`选项

简单来说--mode 0更省流量,没有mtu问题;--mode 1可以稍微降低一点延迟,需要考虑mtu;另外还有个--mode 0 -q1模式,多倍发包专用,没有延迟,也没有mtu问题,适合游戏,但是最耗流量。

具体见,https://github.com/wangyu-/UDPspeeder/wiki/mode和mtu选项

对于新手,建议不要纠结这些参数的具体含义,就用我在使用经验里推荐的设置,不要乱改参数,尤其是不要改--mtu。

`--report`  选项

数据发送和接受报告。开启后可以根据此数据推测出包速和丢包率等特征。--report 10表示每10秒生成一次报告。

`-i` 选项

指定一个时间窗口,长度为n毫秒。同一个fec分组的数据在发送时候会被均匀分散到这n毫秒中,可以对抗突发性的丢包,默认值是0(也就是不开启此功能)。 这个功能很有用,在推荐的参数效果不理想时可以尝试打开,比如用-i 10、-i 20。这个选项的跟通信原理上常说的交错fec 交织fec的原理是差不多的。

`-j` 选项

为原始数据的发送,增加一个延迟抖动值。这样上层应用计算出来的RTT方差会更大,以等待后续冗余包的到达,不至于发生在冗余包到达之前就触发重传的尴尬。配合-t选项使用。正常情况下跨国网络本身的延迟抖动就很大,可以不用设-j。这个功能也需要时钟,默认关掉了,不过一般情况应该不需要这个功能。

-j选项不但可以模拟延迟抖动,也可以模拟延迟。

`--random-drop` 选项

随机丢包。模拟高丢包的网络环境时使用。 --random-drop和-j选项一起用,可以模拟高延迟(或者高延迟抖动)高丢包的网络,可用于测试FEC参数在各种网络环境下的表现。

`-q` 选项

仅对mode 0模式有用。设置fec编码器的最大队列长度。 比如-q5的意思是,在编码器积攒了5个数据包后,就立即发送。合理使用可以改善延迟。在下文的使用经验里有提到用--mode 0 -q1 来多倍发包。

-q和 --timeout的作用类似。-q决定fec编码器积攒了多少个数据包之后,立即发送。--timeout决定编码器收到第一个数据包以后,最多延迟多少毫秒后发送。

默认值是200,也就是尽可能多得积攒数据。

建议不要自己调整这个参数,除非是用我在使用经验里推荐给你的形式。

`--fifo` option

用fifo(命名管道)向运行中的程序发送command。例如--fifo fifo.file,可用的command有:

text
echo fec 19:9 > fifo.file
echo mtu 1100 > fifo.file
echo timeout 5 > fifo.file
echo queue-len 100 > fifo.file
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/使用经验

编译教程

暂时先参考udp2raw的这篇教程,几乎一样的过程。

https://github.com/wangyu-/udp2raw-tunnel/blob/master/doc/build_guide.zh-cn.md

wiki

更多内容请看 wiki:

https://github.com/wangyu-/UDPspeeder/wiki


File: doc/README.zh-cn.v1.md

UDPspeeder (v1)

UDP双边加速工具,降低丢包率,配合vpn可以加速任何协议,尤其适用于加速游戏和网页打开速度;同时也是一个UDP连接的调试和统计工具。

这个是我自己稳定用了一个月的项目,用来加速美服的Brawl Stars和亚服的Mobile Legend,效果不错。加速前卡得几乎没法玩,加速后就没怎么卡过了。

注:目前最新版是v2版,这个是v1版的主页

效果

原理简介

目前原理是多倍发包。以后会做各种优化,比如:对高频率的短包先合并再冗余;FEC(Forward Error Correction),在包速低的时候多倍发包,包速高时用FEC(这些功能在v2版里已经实现)。

跟net-speeder比,优势在于client和server会把收到的多余包自动去掉,这个过程对上层透明,没有兼容性问题。而且发出的冗余数据包会做长度和内容的随机化,抓包是看不出发了冗余数据的,所以不用担心vps被封的问题。

每个冗余数据包都是间隔数毫秒(可配置)以后延迟发出的,可以避开中间路由器因为瞬时buffer长度过长而连续丢掉所有副本。

模拟一定的延迟抖动,这样上层应用计算出来的RTT方差会更大,以等待后续冗余包的到达,不至于发生在冗余包到达之前就触发重传的尴尬。

适用场景

绝大部分流量不高的情况。程序本身加速udp,但是配合openvpn可以加速任何流量。网络状况不好时,游戏卡得没法玩,或者网页卡得没法打开,使用起来效果最好。对于解决语音通话的断断续续效果也不错。不适合大流量的场景,比如BT下载和在线看视频。 无论从自己使用效果的角度,还是从国际出口带宽占用的角度,都建议不要在大流量环境使用。

其他功能

输出UDP收发情况报告,可以看出丢包率。

模拟丢包,模拟延迟,模拟jitter。便于通过实验找出应用卡顿的原因。

重复包过滤功能可以关掉,模拟网络本身有重复包的情况。用来测试应用对重复报的支持情况。

client支持多个udp连接,server也支持多个client

目前有amd64,x86,ar71xx,树莓派armv7和android的binary

如果你需要绕过UDP屏蔽/QoS,或者需要连接复用/连接保持功能,或者是加密。解决方案在另一个repo(可以跟UDPspeeder一起使用):

https://github.com/wangyu-/udp2raw-tunnel

简明操作说明

环境要求

Linux主机,可以是桌面版,可以是android手机/平板,可以是openwrt路由器,也可以是树莓派。在windows和mac上配合虚拟机可以稳定使用(speeder跑在Linux里,其他应用照常跑在window里,桥接模式测试可用)。

android版需要通过terminal运行。

安装

下载编译好的二进制文件,解压到本地和服务器的任意目录。

https://github.com/wangyu-/UDPspeeder/releases

运行

假设你有一个server,ip为44.55.66.77,有一个服务监听在udp 7777端口。 假设你需要加速本地到44.55.66.77:7777的流量。

text
在client端运行:
./speeder_ar71xx -l0.0.0.0:3333 -r 44.55.66.77:8855 -c  -d2 -k "passwd"

在server端运行:
./speeder_amd64 -l0.0.0.0:8855 -r127.0.0.1:7777 -s -d2 -k "passwd"

现在client和server之间建立起了tunnel。想要连接44.55.66.77:7777,只需要连接 127.0.0.1:3333。来回的所有的udp流量会被加速。

注:

-d2 表示除了本来的包以外,额外再发2个冗余包。可调。

-k 指定一个字符串,server/client间所有收发的包都会被异或,改变协议特征,防止UDPspeeder的协议被运营商针对。

进阶操作说明

命令选项

text
/* Detailed source-code truncated for AI context efficiency. */

包发送选项,两端设置可以不同。 只影响本地包发送。

-d 选项

设置冗余包数量。

-t 选项

为冗余包的发送,增加一个延迟.对中间路由buffer做优化,应对瞬时Buffer过长导致的连续丢包.对于多个冗余包,依次在前一个包的基础上增加这个延迟。

-j 选项

为原始数据的发送,增加一个延迟抖动值。这样上层应用计算出来的RTT方差会更大,以等待后续冗余包的到达,不至于发生在冗余包到达之前就触发重传的尴尬。配合-t选项使用。正常情况下跨国网络本身的延迟抖动就很大。可以不用设-j

--report  选项

数据发送和接受报告。开启后可以根据此数据推测出包速和丢包率等特征。

加强版 -t 选项

跟普通-t类似,允许设置最大值最小值,用随机延迟发送冗余包。

加强版 -j 选项

允许给jitter选项设置最大值最小值。在这个区间随机化jitter。如果最大值最小值一样就是模拟延迟。可以模拟高延迟、高jitter的网络环境。

--random-drop 选项

随机丢包。模拟恶劣的网络环境时使用。

包接收选项,两端设置可以不同。只影响本地包接受

--disable-filter

关闭重复包过滤器。这样配合-d 选项可以模拟有重复包的网络环境。

应用

UDPspeeder + openvpn加速任何流量

如果你只是需要玩游戏,效果预期会kcp/finalspeed方案更好。可以优化tcp游戏的延迟(通过冗余发包,避免了上层的重传)。比如魔兽世界用的是tcp连接。

跟openvpn via kcptun方式的对比:

kcptun在udp层有RS code,也是一种冗余传输,通过openvpn把流量转成tcp,再通过kcptun加速是有一定效果的。但是tcp只支持按序到达。按序到达的意思是,如果你发了1 2 3 4 5 6,6个包,如果第一个包丢了,那么必须等第一个包重传成功以后 2 3 4 5 6 才能到达;只要有一个包不到,后续数据包就要一直等待。用tcp承载udp流量会破坏udp的实时性。会造成游戏卡顿更严重。

udp协议本身是ip协议加上了端口之后的直接封装,udp继承了ip协议的实时/乱序到达特性,更适合中转vpn。

UDPspeeder + kcptun/finalspeed + $*** 同时加速tcp和udp流量

如果你需要用加速的tcp看视频和下载文件,这样效果比vpn方案更好。不论是速度,还是流量的耗费上。

UDPspeeder + openvpn + $*** 混合方案

也是我正在用的方案。优点是可以随时在vpn和$*** 方案间快速切换。
实际部署起来比图中看起来的还要简单。不需要改路由表,需要做的只是用openvpn的ip访问$*** server。

(也可以把图中的$*** server换成其他的socks5 server,这样连$*** client也不需要了)

编译教程

暂时先参考udp2raw的这篇教程,几乎一样的过程。

https://github.com/wangyu-/udp2raw-tunnel/blob/master/doc/build_guide.zh-cn.md


File: doc/udpspeeder_openvpn.md

UDPspeeder + openvpn config guide

UDPspeeder command

run at server side

text
./speederv2 -s -l0.0.0.0:8855 -r 127.0.0.1:7777 -f20:10

run at client side

assume server ip is 45.66.77.88

text
./speederv2 -c -l0.0.0.0:3333 -r 45.66.77.88:8855 -f20:10

openvpn config

client side config

text
client
dev tun100
proto udp

remote 127.0.0.1 3333
resolv-retry infinite 
nobind 
persist-key 
persist-tun  

ca /root/add-on/openvpn/ca.crt
cert /root/add-on/openvpn/client.crt
key /root/add-on/openvpn/client.key

keepalive 3 20
verb 3
mute 20

comp-lzo no

fragment 1200       ##### very important    you can turn it up a bit. but, the lower the safer
mssfix 1200         ##### very important

sndbuf 2000000      ##### important
rcvbuf 2000000      ##### important
txqueuelen 4000     ##### suggested

server side config

text
local 0.0.0.0
port 7777 
proto udp
dev tun 

ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem

server 10.222.2.0 255.255.255.0 
ifconfig 10.222.2.1 10.222.2.6

client-to-client
duplicate-cn 
keepalive 10 60 

max-clients 50

persist-key
persist-tun

status /etc/openvpn/openvpn-status.log

verb 3
mute 20  

comp-lzo no

fragment 1200       ##### very important    you can turn it up a bit. but, the lower the safer
mssfix 1200         ##### very important

sndbuf 2000000      ##### important
rcvbuf 2000000      ##### important
txqueuelen 4000     ##### suggested

Note:

If you use the redirect-gateway option of OpenVPN, you may need to add a route exception for your remote server ip at client side.Otherwise OpenVPN may hijack UDPspeeder 's traffic.

For example, depend on your network environment, the command may looks like:

text
ip route add 44.55.66.77 via 44.55.66.1

or

text
ip route add 44.55.66.77 dev XXX

(run at client side)

Other Info

You can also use tinyFecVPN,a lightweight VPN with build-in FEC support:

https://github.com/wangyu-/tinyFecVPN