mirror of
https://github.com/wangyu-/UDPspeeder.git
synced 2025-09-17 20:54:33 +08:00
Compare commits
9 Commits
20170910.0
...
20170809.0
Author | SHA1 | Date | |
---|---|---|---|
|
2d26ae6d8d | ||
|
91a66cf5ad | ||
|
64473cfd11 | ||
|
7262e93623 | ||
|
1dfaafa90f | ||
|
235cd3dc99 | ||
|
3c82199303 | ||
|
3eeafa1cb9 | ||
|
8c7e5d3aff |
90
README.md
90
README.md
@@ -1,43 +1,34 @@
|
||||
# UDPspeeder
|
||||

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

|
||||
UDP加速器,降低UDP传输的丢包率。尤其适用于游戏和语音。
|
||||
|
||||
这个是我自己稳定用了一个月的项目,用来玩服务器在美国的brawl stars和服务器在亚洲国外的mobile legend,效果不错。
|
||||
|
||||
这个是我自己稳定用了一个月的项目,用来加速美服的Brawl Stars和亚服的Mobile Legend,效果不错。加速前卡得几乎没法玩,加速后就没怎么卡过了。
|
||||
#### 效果
|
||||

|
||||
#### 原理简介
|
||||
目前原理是多倍发包。以后会做各种优化,比如:对高频率的短包先合并再冗余;FEC(Forward Error Correction),在包速低的时候多倍发包,包速高时用FEC。
|
||||
目前原理就是简单粗暴的多倍发包(以后会做Reed–Solomon code)。
|
||||
|
||||
跟net-speeder比,优势在于client和server会把收到的多余包自动去掉,这个过程对上层透明,没有兼容性问题。而且发出的冗余数据包会做长度和内容的随机化,抓包是看不出发了冗余数据的,所以不用担心vps被封的问题。
|
||||
|
||||
每个冗余数据包都是间隔数毫秒(可配置)以后延迟发出的,可以避开中间路由器因为瞬时buffer长度过长而连续丢掉所有副本。
|
||||
|
||||
模拟一定的延迟抖动,这样上层应用计算出来的RTT方差会更大,以等待后续冗余包的到达,不至于发生在冗余包到达之前就触发重传的尴尬。
|
||||
可以模拟延迟抖动,这样上层应用计算出来的RTT方差会更大,以等待后续冗余包的到达,不至于过早重传。
|
||||
|
||||
#### 适用场景
|
||||
绝大部分流量不高的情况。程序本身加速udp,但是配合openvpn可以加速任何流量。网络状况不好时,游戏卡得没法玩,或者网页卡得没法打开,使用起来效果最好。对于解决语音通话的断断续续效果也不错。不适合大流量的场景,比如BT下载和在线看视频。 无论从自己使用效果的角度,还是从国际出口带宽占用的角度,都建议不要在大流量环境使用。
|
||||
绝大部分流量不高的情况。程序本身加速udp,但是配合openvpn可以加速任何流量。网络状况不好时,游戏卡得没法玩,或者网页卡得没法打开,使用起来效果最好。但是不适合大流量的场景,比如BT下载和在线看视频。
|
||||
|
||||
#### 其他功能
|
||||
输出UDP收发情况报告,可以看出丢包率。
|
||||
输出UDP收发情况报告,便于分析网络。
|
||||
|
||||
模拟丢包,模拟延迟,模拟jitter。便于通过实验找出应用卡顿的原因。
|
||||
|
||||
重复包过滤功能可以关掉,模拟网络本身有重复包的情况。用来测试应用对重复报的支持情况。
|
||||
|
||||
client支持多个udp连接,server也支持多个client
|
||||
|
||||
目前有amd64,x86,ar71xx,树莓派armv7和android的binary
|
||||
|
||||
如果你需要绕过UDP屏蔽/QoS,或者需要连接复用/连接保持功能,或者是加密。解决方案在另一个repo(可以跟UDPspeeder一起使用):
|
||||
|
||||
https://github.com/wangyu-/udp2raw-tunnel
|
||||
目前有amd64,x86,ar71xx的binary
|
||||
|
||||
# 简明操作说明
|
||||
|
||||
### 环境要求
|
||||
Linux主机,可以是桌面版,可以是android手机/平板,可以是openwrt路由器,也可以是树莓派。在windows和mac上配合虚拟机可以稳定使用(speeder跑在Linux里,其他应用照常跑在window里,桥接模式测试可用)。
|
||||
|
||||
android版需要通过terminal运行。
|
||||
Linux主机,可以使是openwrt路由器,也可以是树莓派。在windows和mac上可以开虚拟机(桥接模式测试可用)。
|
||||
|
||||
### 安装
|
||||
下载编译好的二进制文件,解压到本地和服务器的任意目录。
|
||||
@@ -45,22 +36,27 @@ android版需要通过terminal运行。
|
||||
https://github.com/wangyu-/UDPspeeder/releases
|
||||
|
||||
### 运行
|
||||
假设你有一个server,ip为44.55.66.77,有一个服务监听在udp 7777端口。 假设你需要加速本地到44.55.66.77:7777的流量。
|
||||
假设你有一个server,ip为44.55.66.77,有一个服务监听在udp 7777端口。 假设你需要加速本地到44.55.66.77:7777的流量
|
||||
|
||||
```
|
||||
在client端运行:
|
||||
./speeder_ar71xx -l0.0.0.0:3333 -r 44.55.66.77:8855 -c -d2 -k "passwd"
|
||||
./speeder_ar71xx -l0.0.0.0:3323 -r 44.55.66.77:8855 -c -d2
|
||||
|
||||
在server端运行:
|
||||
./speeder_amd64 -l0.0.0.0:8855 -r127.0.0.1:7777 -s -d2 -k "passwd"
|
||||
./speeder_amd64 -l0.0.0.0:8855 -r127.0.0.1:7777 -s -d2
|
||||
```
|
||||
|
||||
现在client和server之间建立起了tunnel。想要连接44.55.66.77:7777,只需要连接 127.0.0.1:3333。来回的所有的udp流量会被加速。
|
||||
|
||||
###### 注:
|
||||
# 效果
|
||||
在模拟丢包的网络环境下,架设了vpn服务器(udp模式)。收发各有10%的丢包率
|
||||
|
||||
-d2 表示除了本来的包以外,额外再发2个冗余包。可调。
|
||||
#### 使用前
|
||||
<img src="images/Capture4.PNG" width="500">
|
||||
#### 使用后
|
||||
3倍冗余数据。
|
||||
|
||||
-k 指定一个字符串,server/client间所有收发的包都会被异或,改变协议特征,防止UDPspeeder的协议被运营商针对。
|
||||
<img src="images/Capture6.PNG" width="500">
|
||||
|
||||
# 进阶操作说明
|
||||
|
||||
@@ -97,53 +93,13 @@ other options:
|
||||
-h,--help print this help message
|
||||
|
||||
```
|
||||
### 包发送选项,两端设置可以不同。 只影响本地包发送。
|
||||
##### -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连接。
|
||||
如果你只是需要玩游戏,效果(可能/大概)会比kcp/finalspeed方案更好。可以优化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 + ss 同时加速tcp和udp流量
|
||||
#### UDPspeeder + kcptun/finalspeed同时加速tcp和udp流量
|
||||
如果你需要用加速的tcp看视频和下载文件,这样效果比vpn方案更好。不论是速度,还是流量的耗费上。
|
||||

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

|
||||
(也可以把图中的ss server换成其他的socks5 server,这样连ss client也不需要了)
|
||||
# 编译教程
|
||||
暂时先参考udp2raw的这篇教程,几乎一样的过程。
|
||||
|
||||
https://github.com/wangyu-/udp2raw-tunnel/blob/master/doc/build_guide.zh-cn.md
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 66 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
Binary file not shown.
Before Width: | Height: | Size: 73 KiB |
Binary file not shown.
Before Width: | Height: | Size: 65 KiB |
16
main.cpp
16
main.cpp
@@ -1,6 +1,5 @@
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "git_version.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -709,8 +708,6 @@ int event_loop()
|
||||
|
||||
char data[buf_len];
|
||||
int data_len;
|
||||
|
||||
slen = sizeof(sockaddr_in);
|
||||
if ((data_len = recvfrom(local_listen_fd, data, max_data_len, 0,
|
||||
(struct sockaddr *) &local_other, &slen)) == -1) //<--first packet from a new ip:port turple
|
||||
{
|
||||
@@ -924,12 +921,8 @@ int event_loop()
|
||||
}
|
||||
void print_help()
|
||||
{
|
||||
char git_version_buf[100]={0};
|
||||
strncpy(git_version_buf,gitversion,10);
|
||||
|
||||
printf("UDPspeeder\n");
|
||||
printf("git version:%s ",git_version_buf);
|
||||
printf("build date:%s %s\n",__DATE__,__TIME__);
|
||||
printf("version: %s %s\n",__DATE__,__TIME__);
|
||||
printf("repository: https://github.com/wangyu-/UDPspeeder\n");
|
||||
printf("\n");
|
||||
printf("usage:\n");
|
||||
@@ -956,7 +949,7 @@ void print_help()
|
||||
printf(" 4:info (default) 5:debug 6:trace\n");
|
||||
printf(" --log-position enable file name,function name,line number in log\n");
|
||||
printf(" --disable-color disable log color\n");
|
||||
printf(" --sock-buf <number> buf size for socket,>=10 and <=10240,unit:kbyte,default:1024\n");
|
||||
printf(" --sock-buf <number> buf size for socket,>=10 and <=10240,unit:kbyte,default:512\n");
|
||||
//printf(" -p use multi-process mode instead of epoll.very costly,only for test,do dont use\n");
|
||||
printf(" -h,--help print this help message\n");
|
||||
|
||||
@@ -1231,10 +1224,7 @@ void process_arg(int argc, char *argv[])
|
||||
}
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
assert(sizeof(u64_t)==8);
|
||||
assert(sizeof(i64_t)==8);
|
||||
assert(sizeof(u32_t)==4);
|
||||
assert(sizeof(i32_t)==4);
|
||||
|
||||
dup2(1, 2); //redirect stderr to stdout
|
||||
int i, j, k;
|
||||
process_arg(argc,argv);
|
||||
|
77
makefile
Executable file → Normal file
77
makefile
Executable file → Normal file
@@ -1,63 +1,18 @@
|
||||
cc_cross=/home/wangyu/Desktop/arm-2014.05/bin/arm-none-linux-gnueabi-g++
|
||||
cc_local=g++
|
||||
#cc_mips34kc=/toolchains/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
|
||||
cc_mips24kc_be=/toolchains/lede-sdk-17.01.2-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-g++
|
||||
cc_mips24kc_le=/toolchains/lede-sdk-17.01.2-ramips-mt7621_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin/mipsel-openwrt-linux-musl-g++
|
||||
#cc_arm= /toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ -march=armv6 -marm
|
||||
cc_arm= /toolchains/arm-2014.05/bin/arm-none-linux-gnueabi-g++
|
||||
#cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
|
||||
FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers
|
||||
cross_cc=mips-openwrt-linux-g++
|
||||
FLAGS=-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -ggdb
|
||||
FLAGS2= -O3
|
||||
all:
|
||||
g++ main.cpp common.cpp log.cpp -I. -o speeder -static -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
release:
|
||||
g++ main.cpp common.cpp log.cpp -I. -o speeder_amd64 -static -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
g++ -m32 main.cpp common.cpp log.cpp -I. -o speeder_x86 -static -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
${cross_cc} main.cpp common.cpp log.cpp -I. -o speeder_ar71xx -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
tar -zcvf udp_speeder_binaries.tar.gz speeder_amd64 speeder_x86 speeder_ar71xx
|
||||
cross:
|
||||
${cross_cc} main.cpp common.cpp log.cpp -I. -o speeder_cross -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
|
||||
SOURCES=main.cpp log.cpp common.cpp
|
||||
debug:
|
||||
g++ main.cpp common.cpp log.cpp -I. -o speeder -static -lrt -std=c++11 ${FLAGS} -Wformat-nonliteral -D MY_DEBUG
|
||||
|
||||
NAME=speeder
|
||||
TARGETS=amd64 arm mips24kc_be x86 mips24kc_le
|
||||
|
||||
TAR=${NAME}_binaries.tar.gz `echo ${TARGETS}|sed -r 's/([^ ]+)/speeder_\1/g'`
|
||||
|
||||
all:git_version
|
||||
rm -f ${NAME}
|
||||
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O3
|
||||
fast: git_version
|
||||
rm -f ${NAME}
|
||||
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb
|
||||
debug: git_version
|
||||
rm -f ${NAME}
|
||||
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -Wformat-nonliteral -D MY_DEBUG
|
||||
debug2: git_version
|
||||
rm -f ${NAME}
|
||||
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -Wformat-nonliteral -ggdb
|
||||
|
||||
mips24kc_be: git_version
|
||||
${cc_mips24kc_be} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O3
|
||||
|
||||
mips24kc_le: git_version
|
||||
${cc_mips24kc_le} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O3
|
||||
|
||||
amd64:git_version
|
||||
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O3
|
||||
x86:git_version
|
||||
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O3 -m32
|
||||
arm:git_version
|
||||
${cc_arm} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O3
|
||||
|
||||
cross:git_version
|
||||
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -O3
|
||||
|
||||
cross2:git_version
|
||||
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -lgcc_eh -O3
|
||||
|
||||
cross3:git_version
|
||||
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -O3
|
||||
|
||||
release: ${TARGETS}
|
||||
tar -zcvf ${TAR}
|
||||
|
||||
clean:
|
||||
rm -f ${TAR}
|
||||
rm -f speeder speeder_cross
|
||||
rm -f git_version.h
|
||||
|
||||
git_version:
|
||||
echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > git_version.h
|
||||
|
||||
#g++ forward.cpp aes.c -o forward -static
|
||||
# ${ccarm} forward.cpp aes.c -o forwardarm -static -lgcc_eh
|
||||
|
Reference in New Issue
Block a user