Update README.zh-cn.md ,tcptun_step_by_step.md,finalspeed_step_by_step.md

This commit is contained in:
wangyu-
2017-08-06 00:46:25 -07:00
committed by wangyu
parent 8271cce383
commit 45b7ab6285
22 changed files with 148 additions and 19 deletions

View File

@@ -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 optionMSS,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

View 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服务也是一样的只要再第三步那里设置其他的端口。

View File

@@ -0,0 +1 @@
11

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View 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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB