Update README.zh-cn.md ,tcptun_step_by_step.md,finalspeed_step_by_step.md
19
README.md
@ -2,6 +2,8 @@
|
||||
![image2](images/image2.PNG)
|
||||
|
||||
An Encrpyted,Anti-Replay,Multiplexed Udp Tunnel,tunnels udp traffic through raw socket
|
||||
|
||||
[简体中文](/doc/README.zh-cn.md)
|
||||
### Send/Recv Udp Packet as Raw Packet with TCP header,ICMP header
|
||||
Which can help you bypass udp blocking or udp QOS or just poorly supported udp NAT behavior by some ISP. Raw packet with UDP header is also supported,in this way you can just make use of the encrpyting and anti-replay feature.
|
||||
### Encrpytion and Anti-Replay
|
||||
@ -84,7 +86,7 @@ the faketcp mode doest not behave 100% like a real tcp connection.ISP may be abl
|
||||
# Peformance Test
|
||||
#### test method:
|
||||
iperf3 tcp via openvpn + udp2raw
|
||||
(iperf3 udp mode is not used bc of bug mentioned in this issue: https://github.com/esnet/iperf/issues/296 ,instead,we turn iperf3 's tcp traffic into udp by using openvpn,to test udp2raw 's peformance )
|
||||
(iperf3 udp mode is not used bc of bug mentioned in this issue: https://github.com/esnet/iperf/issues/296 ,instead,we turn iperf3 's tcp traffic into udp by using openvpn,to test udp2raw 's peformance. Read [Application](https://github.com/wangyu-/udp2raw-tunnel#application) for detail )
|
||||
#### iperf3 command:
|
||||
```
|
||||
iperf3 -c 10.222.2.1 -P40
|
||||
@ -109,23 +111,20 @@ raw_mode: faketcp cipher_mode: aes128cbc auth_mode: md5
|
||||
(reverse speed is simliar and not uploaded)
|
||||
|
||||
# Application
|
||||
### tunneling openvpn
|
||||
1. bypass tcp ovr tcp problem when udp is not avaliable.
|
||||
(tcp over tcp problem http://sites.inka.de/bigred/devel/tcp-tcp.html)
|
||||
2. openopvn via icmp
|
||||
### tunneling any traffic via raw traffic by using udp2raw +openvpn
|
||||
![image_vpn](images/openvpn.PNG)
|
||||
1. bypasses UDP block/UDP QOS
|
||||
|
||||
//todo
|
||||
2. no TCP ovr tcp problem (tcp over tcp problem http://sites.inka.de/bigred/devel/tcp-tcp.html )
|
||||
|
||||
3. openvpn over icmp also becomes a choice
|
||||
### tunneling kcptun
|
||||
make kcptun support tcp mode.
|
||||
(kcptun, https://github.com/xtaci/kcptun)
|
||||
|
||||
//todo
|
||||
### tunneling finalspeed
|
||||
finalspeed 's tcp mode doesnt work on openvz VPS.you can use finalspeed 's udp mode,and tunnel udp through tcp with this tunnel.
|
||||
|
||||
//todo
|
||||
|
||||
|
||||
# Related work
|
||||
### kcptun-raw
|
||||
this project was inspired by kcptun-raw,which modified kcptun to support tcp mode.
|
||||
|
@ -2,24 +2,31 @@ Udp2raw-tunnel
|
||||
![image2](/images/image2.PNG)
|
||||
加密、防重放攻击的、信道复用的udp tunnel,利用raw socket中转udp流量
|
||||
|
||||
[English](/README.md)
|
||||
|
||||
[udp2raw+kcptun step_by_step教程](kcptun_step_by_step.md)
|
||||
|
||||
[udp2raw+finalspeed step_by_step教程](finalspeed_step_by_step.md)
|
||||
### 把udp流量伪装成tcp /icmp
|
||||
可以突破udp流量限制或Udp QOS。或者在udp nat有问题的环境下,提升稳定性。 另外也支持用raw 发udp包,这样流量不会被伪装,只会被加密。
|
||||
用raw socket给udp包加上tcp/icmp包头,可以突破udp流量限制或Udp QOS。或者在udp nat有问题的环境下,提升稳定性。 另外也支持用raw 发udp包,这样流量不会被伪装,只会被加密。
|
||||
|
||||
### 加密 防重放攻击
|
||||
用aes128cbc加密,md5/crc32做数据完整校验。用类似ipsec/openvpn的 replay windows机制来防止重放攻击。
|
||||
|
||||
设计目标是,即使攻击者可以监听到tunnel的所有包,可以选择性丢弃tunnel的任意包,可以重放任意包;攻击者也没办法获得tunnel承载的任何数据,也没办法向tunnel的数据流中通过包构造/包重放插入任何数据。
|
||||
|
||||
### 模拟TCP3次握手
|
||||
模拟TCP3次握手,模拟seq ack过程。另外还模拟了一些tcp option:MSS,sackOk,TS,TS_ack,wscale,用来使流量看起来更像是由普通的linux tcp协议栈发送的。
|
||||
|
||||
### 连接快速恢复
|
||||
心跳机制检查连接是否中断,一旦心跳超时。client会立即换raw socket的端口重连,重连成功后会恢复之前中断的连接。虽然raw端的端口变了,但是udp端的所有连接都会继续有效。udp这边感觉不到raw端的重连,只会感觉到短暂断流。
|
||||
心跳机制检查连接是否中断,一旦心跳超时。client会立即换raw socket的端口重连,重连成功后会恢复之前中断的连接。虽然raw端的端口变了,但是udp端的所有连接都会继续有效。udp这边感觉不到raw端的重连,只会感觉到短暂断流,这跟普通的短暂丢包是类似的,不会导致上层应用重连。
|
||||
|
||||
另一个优化是,重连只需要client发起,就可以立即被server处理,不需要等到server端的连接也超时。
|
||||
另一个优化是,重连只需要client发起,就可以立即被server处理,不需要等到server端的连接超时后。
|
||||
|
||||
### 其他特性
|
||||
信道复用,client的udp端支持多个连接。
|
||||
|
||||
server支持多个client,也能正确处理多个连接的重连和连接回复。
|
||||
server支持多个client,也能正确处理多个连接的重连和连接恢复。
|
||||
|
||||
NAT 穿透 ,tcp icmp udp模式都支持nat穿透。
|
||||
|
||||
@ -111,10 +118,10 @@ iperf3 -c 10.222.2.1 -P40
|
||||
iperf3 -c 10.222.2.1 -P40 -R
|
||||
```
|
||||
#### client主机
|
||||
vultr $2.5/monthly plan(single core 2.4ghz cpu,512m ram,日本东进机房),
|
||||
vultr 2.5美元每月套餐(single core 2.4ghz cpu,512m ram,日本东京机房),
|
||||
#### server主机
|
||||
bandwagonhost $3.99/annually(single core 2.0ghz cpu,128m ram,美国洛杉矶机房)
|
||||
### Test1
|
||||
bandwagonhost 3.99美元每年套餐(single core 2.0ghz cpu,128m ram,美国洛杉矶机房)
|
||||
### 测试1
|
||||
raw_mode: faketcp cipher_mode: xor auth_mode: simple
|
||||
|
||||
![image4](/images/image4.PNG)
|
||||
@ -123,14 +130,14 @@ raw_mode: faketcp cipher_mode: xor auth_mode: simple
|
||||
|
||||
测试中cpu被打满。其中有30%的cpu是被openvpn占的。 如果不用Openvpn中转,实际达到100+Mb/S 应该没问题。
|
||||
|
||||
### Test2
|
||||
### 测试2
|
||||
raw_mode: faketcp cipher_mode: aes128cbc auth_mode: md5
|
||||
|
||||
![image5](/images/image5.PNG)
|
||||
|
||||
(反向的速度几乎一样,所以只发正向测试的图)
|
||||
|
||||
|
||||
测试中cpu被打满。绝大多数cpu都是被udp2raw占用的(主要消耗在aes加密)。即使不用Openvpn,速度也不会快很多了。
|
||||
# 应用
|
||||
### 中转 kcptun
|
||||
|
||||
|
69
doc/finalspeed_step_by_step.md
Normal file
@ -0,0 +1,69 @@
|
||||
# udp2raw+finalspeed 加速tcp流量 Step by Step 教程
|
||||
![image](finalspeed_step_by_step/Capture0.PNG)
|
||||
|
||||
##### 背景
|
||||
国内有些ISP会对UDP做QOS或屏蔽,这时候加速协议对TCP发包模式的支持就很重要。finalspeed虽然本身支持在底层用TCP发包,但是其依赖的libpcap不支持openvz架构,即使不是openvz架构的主机,也存在不稳定的问题。
|
||||
|
||||
|
||||
##### 摘要
|
||||
udp2raw是一个把udp流量通过raw socket包装成tcp流量的工具。通过用udp2raw配合udp模式的 finalspeed一样可以达到在底层发tcp包,绕过QOS的效果。支持openvz,稳定性也好很多。原理上相当于在finalspeed外面再包了一层tunnel。
|
||||
|
||||
本教程会一步一步演示用udp2raw+kcptun加速http流量的过程。加速任何其他tcp流量也一样。
|
||||
|
||||
udp2raw也支持把udp流量包装成Icmp发送,本教程不做演示。
|
||||
|
||||
### 环境要求
|
||||
服务器主机都是linux,有root权限。 可以是openvz架构的vps。 也可以是openwrt路由器。
|
||||
|
||||
本地主机是windows,安装了wmware,安装了linux虚拟机(网卡设置为桥接模式)。
|
||||
|
||||
(如果嫌给虚拟机安装linux麻烦,可以下载别人提供好的linux虚拟机镜像,比如https://www.kali.org/downloads/ ,不过我没有测试过这个镜像,我用的是debian 7)
|
||||
|
||||
### 安装
|
||||
下载好udp2raw的压缩包,解压分别解压到服务器和本地的虚拟机。
|
||||
|
||||
https://github.com/xtaci/kcptun/releases
|
||||
|
||||
在服务器端安装好finalspeed服务端,在本地windows安装好finalspeed的客户端。服务端我以前是用91yun的一键安装脚本安装的,没装过的可以去网上搜一键安装脚本。
|
||||
|
||||
### 运行
|
||||
1.先在服务器主机运行如下命令,确定finalspeed服务端已经正常启动了。
|
||||
|
||||
```
|
||||
netstat -nlp|grep java
|
||||
```
|
||||
![image](finalspeed_step_by_step/Capture5.PNG)
|
||||
|
||||
如果显示了150端口,就表示服务端启动好了。
|
||||
|
||||
2.在服务器启动udp2raw server
|
||||
```
|
||||
./udp2raw_amd64 -s -l0.0.0.0:8855 -r 127.0.0.1:150 -a -k "passwd" --raw-mode faketcp
|
||||
```
|
||||
![image](finalspeed_step_by_step/Capture2.PNG)
|
||||
|
||||
3.在本地的虚拟机上启动udp2raw client ,假设服务器ip是45.66.77.88
|
||||
```
|
||||
./udp2raw_amd64 -c -r45.66.77.88:8855 -l0.0.0.0:150 --raw-mode faketcp -a -k"passwd"
|
||||
```
|
||||
如果一切正常,client端会显示client_ready:
|
||||
|
||||
![image](finalspeed_step_by_step/Capture3.PNG)
|
||||
|
||||
记下红框中的ip,这是虚拟机的网卡ip
|
||||
|
||||
在server端也会显示server_reay
|
||||
![image](finalspeed_step_by_step/Capture4.PNG)
|
||||
|
||||
4.在本地windows,按图配置好finalspeed的客户端。注意,192.168.205.8改成你刚才记下来的IP,带宽也要按实际的填。传输协议要选UDP.
|
||||
![image](finalspeed_step_by_step/Capture.PNG)
|
||||
|
||||
5.所有准备工作已经完成了,在本地访问本地的8012端口,相当于访问服务器的80端口。
|
||||
|
||||
来试一下通过http://127.0.0.1:8012/ 下载文件 ,1.5M/s:
|
||||
![image](finalspeed_step_by_step/Capture6.PNG)
|
||||
|
||||
再试一下只接通过服务器的ip访问,http://45.66.77.88:80/ ,速度只有600K/s
|
||||
![image](finalspeed_step_by_step/Capture7.PNG)
|
||||
|
||||
教程就到这里了,用来加速其他的tcp服务也是一样的,只要再第三步那里设置其他的端口。
|
1
doc/finalspeed_step_by_step/11
Normal file
@ -0,0 +1 @@
|
||||
11
|
BIN
doc/finalspeed_step_by_step/Capture.PNG
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
doc/finalspeed_step_by_step/Capture0.PNG
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
doc/finalspeed_step_by_step/Capture2.PNG
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
doc/finalspeed_step_by_step/Capture3.PNG
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
doc/finalspeed_step_by_step/Capture4.PNG
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
doc/finalspeed_step_by_step/Capture5.PNG
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
doc/finalspeed_step_by_step/Capture6.PNG
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
doc/finalspeed_step_by_step/Capture7.PNG
Normal file
After Width: | Height: | Size: 69 KiB |
53
doc/kcptun_step_by_step.md
Normal file
@ -0,0 +1,53 @@
|
||||
# udp2raw+kcptun 加速tcp流量 Step by Step 教程
|
||||
![image](kcptun_step_by_step/Capture00.PNG)
|
||||
|
||||
本教程会一步一步演示用udp2raw+kcptun加速SSH流量的过程。加速任何其他tcp流量也一样。
|
||||
|
||||
### 环境要求
|
||||
两边的主机都是linux,有root权限。 (windows上桥接模式的虚拟机可用)
|
||||
|
||||
|
||||
### 安装
|
||||
下载好kcptun和udp2raw的压缩包,解压分别解压到client端和server端。
|
||||
|
||||
https://github.com/xtaci/kcptun/releases
|
||||
https://github.com/wangyu-/udp2raw-tunnel/releases
|
||||
|
||||
解压好后,如图:
|
||||
![image](kcptun_step_by_step/Capture0.PNG)
|
||||
|
||||
### 运行
|
||||
1.在远程服务器运行 udp2raw_amd64 server模式:
|
||||
```
|
||||
./udp2raw_amd64 -s -l0.0.0.0:8855 -r 127.0.0.1:4000 -k "passwd" --raw-mode faketcp -a
|
||||
```
|
||||
![image](kcptun_step_by_step/Capture.PNG)
|
||||
|
||||
2.在本地运行udp2raw_amd64 client模式,假设server ip是45.66.77.88:
|
||||
```
|
||||
./udp2raw_amd64 -c -r45.66.77.88:8855 -l0.0.0.0:4000 --raw-mode faketcp -a -k"passwd"
|
||||
```
|
||||
如果一切正常client端输出如下,显示client_ready:
|
||||
![image](kcptun_step_by_step/Capture2.PNG)
|
||||
|
||||
server端也会有类似输出,显示server_ready:
|
||||
![image](kcptun_step_by_step/Capture3.PNG)
|
||||
|
||||
3.在远程服务器运行 kcp server
|
||||
```
|
||||
./server_linux_amd64 -t "127.0.0.1:22" -l ":4000" -mode fast2 -mtu 1300
|
||||
```
|
||||
![image](kcptun_step_by_step/Capture6.PNG)
|
||||
|
||||
4.在本地运行
|
||||
```
|
||||
./client_linux_amd64 -r "45.66.77.88:4000" -l ":3322" -mode fast2 -mtu 1300
|
||||
```
|
||||
![image](kcptun_step_by_step/Capture7.PNG)
|
||||
|
||||
5.所有准备工作已经做好,在本地运行
|
||||
```
|
||||
ssh -p 3322 root@127.0.0.1
|
||||
```
|
||||
已经连进去了,而且是经过kcptun加速的:
|
||||
![image](kcptun_step_by_step/Capture8.PNG)
|
BIN
doc/kcptun_step_by_step/Capture.PNG
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
doc/kcptun_step_by_step/Capture0.PNG
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
doc/kcptun_step_by_step/Capture00.PNG
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
doc/kcptun_step_by_step/Capture2.PNG
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
doc/kcptun_step_by_step/Capture3.PNG
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
doc/kcptun_step_by_step/Capture6.PNG
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
doc/kcptun_step_by_step/Capture7.PNG
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
doc/kcptun_step_by_step/Capture8.PNG
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
images/openvpn.PNG
Normal file
After Width: | Height: | Size: 44 KiB |