Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udp2raw如何在Docker 中使用? #54

Closed
jiangtiandao opened this issue Sep 17, 2017 · 32 comments
Closed

udp2raw如何在Docker 中使用? #54

jiangtiandao opened this issue Sep 17, 2017 · 32 comments

Comments

@jiangtiandao
Copy link
Contributor

jiangtiandao commented Sep 17, 2017

测试发现 --net=host 参数 不再需要 只需要开放tcp 监听端口 即可
镜像内安装 iptables 后 -a 也可用 需要 --cap-add=NET_ADMIN 以便添加 iptables

@wangyu-
Copy link
Owner

wangyu- commented Sep 17, 2017

跟不用docker比,没有明显区别。除了docker中一般不支持iptables,不能用-a选项。

#41 里有人用过,可以正常用。

@wangyu-
Copy link
Owner

wangyu- commented Sep 17, 2017

除了docker中一般不支持iptables,不能用-a选项。

如果对宿主机有控制权,iptables在宿主机上加。 如果对宿主机没控制权(比如docker的vps),那就只能尝试不加iptables规则直接用了,有的网络环境下不加iptables规则也可以稳定使用。

@jiangtiandao
Copy link
Contributor Author

去掉 -a 就正常了 多谢

@wangyu-
Copy link
Owner

wangyu- commented Sep 18, 2017

补充一点,网络模式要设成host,用--net=host参数,更多信息参考 #55

@jiangtiandao
Copy link
Contributor Author

测试发现 --net=host 参数 不再需要
安装 iptables 后 -a 也可用 需要 --cap-add=NET_ADMIN 以便添加 iptables

@jiangtiandao jiangtiandao reopened this Sep 23, 2017
@wangyu-
Copy link
Owner

wangyu- commented Sep 23, 2017

测试发现 --net=host 参数 不再需要

建议用--net=host,其他的网络模式也许会不稳定;如果用其他的网络模式的话,建议测试确认无误后使用(比如以虚拟机为例,在虚拟机NAT模式也可以连上,但是性能很低,虚拟机的NAT不是真正的NAT,连traceroute都有问题)。

安装 iptables 后 -a 也可用 需要 --cap-add=NET_ADMIN 以便添加 iptables

nice

@jiangtiandao
Copy link
Contributor Author

是用 iperf3 测试?

@wangyu-
Copy link
Owner

wangyu- commented Sep 23, 2017

iperf3可以,用iperf3 -P30iperf3 -P30 -R关注下吞吐率跟--net-host是否一样。

iperf3的udp有bug,我自己都是用udp2raw+openvpn+iperf3用tcp模式来测。用udp2raw+kcptun+iperf3应该也可以。

@jiangtiandao
Copy link
Contributor Author

iperf3 udp是正常的呀 只是默认一个线程限制1M带宽所以-P小了就跑不满 加个 -b 0 就行 help里讲UDP 带宽不重要看 jitter
初步测试阿里云vps里面直接运行跑满物理带宽50Gbps
docker内很奇怪两种网络没区别都是30Gbps吞吐量

@wangyu-
Copy link
Owner

wangyu- commented Sep 23, 2017

只是默认一个线程限制1M带宽所以-P小了就跑不满 加个 -b 0 就行

不是这个原因。

你看这个Issue,用iperf2和iperf3测出的结果千差万别。

esnet/iperf#296

@wangyu-
Copy link
Owner

wangyu- commented Sep 23, 2017

初步测试阿里云vps里面直接运行跑满物理带宽50Gbps
docker内很奇怪两种网络没区别都是30Gbps吞吐量

为什么结果会这么大,这个测的不是udp2raw中转后的速度吧。

@jiangtiandao
Copy link
Contributor Author

jiangtiandao commented Sep 23, 2017

用udp2raw中转后 iperf3 连不上
我开了4个 ssh 分别执行

docker run -it --rm --name=iperf3-server --net=host networkstatic/iperf3 -s

Server listening on 5201

docker run -it --rm --cap-add=NET_ADMIN --net=host daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -s -l 0.0.0.0:10999 -r 127.0.0.1:5201 --cipher-mode xor --auth-mode simple -a -k "passwd" --lower-level auto

changed state to server_ready
docker run -it --rm --cap-add=NET_ADMIN --net=host daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -c -l 0.0.0.0:3333 -r 127.0.0.1:10999 --cipher-mode xor --auth-mode simple -a -k "passwd"
[INFO]changed state from to client_handshake2 to client_ready

iperf3 -c 127.0.0.1 -P30 -p 3333 -u -b 0

iperf3: error - unable to connect to server: Connection refused

@wangyu-
Copy link
Owner

wangyu- commented Sep 23, 2017

iperf3同时监听在一个tcp端口和一个udp,端口。即使只测udp也需要连那个tcp端口。你这样只映射了udp端口,所以不能测。

这个issue里跟你一样的问题,https://github.com/wangyu-/udp2raw-tunnel/issues/46

另外,即使你解决了这个问题,也不建议用iperf3的udp模式,结果完全不可靠。你看下我给你的连接,同样的网络,用Iperf2测出来丢包0.3%,用iperf3测出来丢包99%.

@jiangtiandao
Copy link
Contributor Author

用udp2raw+kcptun+iperf3 host mode 和本机直接运行都在 10 Mbits/sec左右
iperf3 的 client端速度不稳定经常在10Mbits/sec 和 0 之间波动 server端 比较平均就是 10/连接数
iperf3 -s -B 127.0.0.1
./server -t "127.0.0.1:5201" -l "127.0.0.1:4000" -mode default --crypt none --nocomp --mtu 1100
./udp2raw_amd64_hw_aes -s -l 127.0.0.1:10999 -r 127.0.0.1:4000 --cipher-mode xor --auth-mode simple -a -k "passwd" --lower-level auto
./udp2raw_amd64_hw_aes -c -l 127.0.0.1:3333 -r 127.0.0.1:10999 --cipher-mode xor --auth-mode simple -a -k "passwd"
./client -r 127.0.0.1:3333 -l 127.0.0.1:8388 --conn 10 -mode default --crypt none --nocomp --mtu 1100
iperf3 -c 127.0.0.1 -P30 -p 8388 -b 0 -t 240
iperf3 -c 127.0.0.1 -P30 -p 8388 -b 0 -t 240 -R

host模式:
docker run -d --rm --cap-add=NET_ADMIN --net=host xtaci/kcptun server -t "127.0.0.1:5201" -l "127.0.0.1:4000" -mode default --crypt none --nocomp --mtu 1100
docker run -d --rm --cap-add=NET_ADMIN --net=host daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -s -l 0.0.0.0:10999 -r 127.0.0.1:4000 --cipher-mode xor --auth-mode simple -a -k "passwd" --lower-level auto
docker run -d --rm --cap-add=NET_ADMIN --net=host daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -c -l 0.0.0.0:3333 -r 127.0.0.1:10999 --cipher-mode xor --auth-mode simple -a -k "passwd"
docker run -d --rm --cap-add=NET_ADMIN --net=host xtaci/kcptun client -r "127.0.0.1:3333" -l "127.0.0.1:8388" -mode default --crypt none --nocomp --mtu 1100
iperf3 -c 127.0.0.1 -P30 -p 8388 -b 0 -t 240 -R
iperf3 -c 127.0.0.1 -P30 -p 8388 -b 0 -t 240

@jiangtiandao
Copy link
Contributor Author

jiangtiandao commented Sep 24, 2017

birdge 模式直接连不上
docker run -d --rm --name=iperf3-server -p 5201:5201 networkstatic/iperf3 -s
docker run -d --rm --cap-add=NET_ADMIN --name=kcptun_server xtaci/kcptun server -t "172.17.132.43:5201" -l "0.0.0.0:4000" -mode default --crypt none --nocomp --mtu 1100
docker run -d --rm --cap-add=NET_ADMIN --name=udp2raw_server daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -s -l 0.0.0.0:10999 -r $(docker inspect --format "{{ .NetworkSettings.IPAddress }}:4000" $(docker ps -l | grep kcptun_server | awk '{print $1}')) --cipher-mode xor --auth-mode simple -a -k "passwd" --lower-level auto
docker run -d --rm --cap-add=NET_ADMIN --name=udp2raw_client daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -c -l 0.0.0.0:3333 -r $(docker inspect --format "{{ .NetworkSettings.IPAddress }}:10999" $(docker ps -l | grep udp2raw_server | awk '{print $1}')) --cipher-mode xor --auth-mode simple -a -k "passwd"
docker run -d --rm --cap-add=NET_ADMIN --name=kcptun_client xtaci/kcptun client -r $(docker inspect --format "{{ .NetworkSettings.IPAddress }}:3333" $(docker ps -l | grep udp2raw_client | awk '{print $1}')) -l "0.0.0.0:8388" -mode default --crypt none --nocomp --mtu 1100
iperf3 -c $(docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -l | grep kcptun_client | awk '{print $1}')) -P30 -p 8388 -b 0 -t 240

iperf3 -c $(docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -l | grep kcptun_client | awk '{print $1}')) -P30 -p 8388 -b 0 -t 240 -R

@wangyu-
Copy link
Owner

wangyu- commented Sep 24, 2017

iperf3 的 client端速度不稳定经常在10Mbits/sec 和 0 之间波动 server端 比较平均就是 10/连接数

有多不稳定,能不能发下log。现在你的CPU是瓶颈还是带宽是瓶颈?另外 10/连接数是什么意思?

如果你对这个不稳定的原因有兴趣,可以试下不通过udp2raw,只用kcptun+iperf3测下是否有类似不稳定现象。我觉得不稳定有可能是kcptun的fec造成的,fec会带来cliff effect,可以尝试看一下开启和关闭FEC是否造成了明显区别。

我这边udp2raw+udpspeeder+vpn的测试结果:

root@raspberrypi:/home/pi# iperf3 -c 10.222.2.1 -P5
Connecting to host 10.222.2.1, port 5201
[  4] local 10.222.2.10 port 49134 connected to 10.222.2.1 port 5201
[  6] local 10.222.2.10 port 49136 connected to 10.222.2.1 port 5201
[  8] local 10.222.2.10 port 49138 connected to 10.222.2.1 port 5201
[ 10] local 10.222.2.10 port 49140 connected to 10.222.2.1 port 5201
[ 12] local 10.222.2.10 port 49142 connected to 10.222.2.1 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   951 KBytes  7.79 Mbits/sec    0    194 KBytes
[  6]   0.00-1.00   sec   194 KBytes  1.59 Mbits/sec    0   35.6 KBytes
[  8]   0.00-1.00   sec   262 KBytes  2.15 Mbits/sec    0   35.6 KBytes
[ 10]   0.00-1.00   sec   249 KBytes  2.04 Mbits/sec    0   35.6 KBytes
[ 12]   0.00-1.00   sec   228 KBytes  1.87 Mbits/sec    2   32.2 KBytes
[SUM]   0.00-1.00   sec  1.84 MBytes  15.4 Mbits/sec    2
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   1.00-2.00   sec   697 KBytes  5.71 Mbits/sec   36    151 KBytes
[  6]   1.00-2.00   sec   169 KBytes  1.38 Mbits/sec    1   31.1 KBytes
[  8]   1.00-2.00   sec   152 KBytes  1.25 Mbits/sec    0   45.6 KBytes
[ 10]   1.00-2.00   sec  92.2 KBytes   756 Kbits/sec    4   30.0 KBytes
[ 12]   1.00-2.00   sec   169 KBytes  1.38 Mbits/sec    0   35.6 KBytes
[SUM]   1.00-2.00   sec  1.25 MBytes  10.5 Mbits/sec   41
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   2.00-3.00   sec   633 KBytes  5.19 Mbits/sec    0    174 KBytes
[  6]   2.00-3.00   sec   161 KBytes  1.32 Mbits/sec    0   35.6 KBytes
[  8]   2.00-3.00   sec   386 KBytes  3.16 Mbits/sec    0   57.8 KBytes
[ 10]   2.00-3.00   sec   223 KBytes  1.83 Mbits/sec    0   36.7 KBytes
[ 12]   2.00-3.00   sec   161 KBytes  1.32 Mbits/sec    0   38.9 KBytes
[SUM]   2.00-3.00   sec  1.53 MBytes  12.8 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   3.00-4.00   sec   697 KBytes  5.71 Mbits/sec    3   92.2 KBytes
[  6]   3.00-4.00   sec   153 KBytes  1.26 Mbits/sec    1   28.9 KBytes
[  8]   3.00-4.00   sec   253 KBytes  2.08 Mbits/sec    7   51.1 KBytes
[ 10]   3.00-4.00   sec   158 KBytes  1.29 Mbits/sec    9   30.0 KBytes
[ 12]   3.00-4.00   sec   211 KBytes  1.73 Mbits/sec    2   33.3 KBytes
[SUM]   3.00-4.00   sec  1.44 MBytes  12.1 Mbits/sec   22
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   4.00-5.00   sec   633 KBytes  5.19 Mbits/sec    0    101 KBytes
[  6]   4.00-5.00   sec   231 KBytes  1.89 Mbits/sec    0   34.5 KBytes
[  8]   4.00-5.00   sec   253 KBytes  2.08 Mbits/sec    0   58.9 KBytes
[ 10]   4.00-5.00   sec   151 KBytes  1.24 Mbits/sec    0   36.7 KBytes
[ 12]   4.00-5.00   sec   217 KBytes  1.78 Mbits/sec    0   38.9 KBytes
[SUM]   4.00-5.00   sec  1.45 MBytes  12.2 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   5.00-6.00   sec   380 KBytes  3.11 Mbits/sec    5   57.8 KBytes
[  6]   5.00-6.00   sec  92.2 KBytes   756 Kbits/sec    6   22.2 KBytes
[  8]   5.00-6.00   sec   253 KBytes  2.08 Mbits/sec    2   45.6 KBytes
[ 10]   5.00-6.00   sec   153 KBytes  1.26 Mbits/sec    4   24.4 KBytes
[ 12]   5.00-6.00   sec   142 KBytes  1.17 Mbits/sec    4   25.6 KBytes
[SUM]   5.00-6.00   sec  1021 KBytes  8.37 Mbits/sec   21
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   6.00-7.00   sec   317 KBytes  2.59 Mbits/sec    0   60.0 KBytes
[  6]   6.00-7.00   sec   127 KBytes  1.04 Mbits/sec    0   23.3 KBytes
[  8]   6.00-7.00   sec   380 KBytes  3.11 Mbits/sec    0   51.1 KBytes
[ 10]   6.00-7.00   sec   139 KBytes  1.14 Mbits/sec    0   24.4 KBytes
[ 12]   6.00-7.00   sec   127 KBytes  1.04 Mbits/sec    1   18.9 KBytes
[SUM]   6.00-7.00   sec  1.06 MBytes  8.92 Mbits/sec    1
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   7.00-8.00   sec   317 KBytes  2.59 Mbits/sec    0   63.3 KBytes
[  6]   7.00-8.00   sec   199 KBytes  1.63 Mbits/sec    0   25.6 KBytes
[  8]   7.00-8.00   sec   253 KBytes  2.08 Mbits/sec    0   51.1 KBytes
[ 10]   7.00-8.00   sec   190 KBytes  1.56 Mbits/sec    0   25.6 KBytes
[ 12]   7.00-8.00   sec   127 KBytes  1.04 Mbits/sec    0   21.1 KBytes
[SUM]   7.00-8.00   sec  1.06 MBytes  8.89 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   8.00-9.00   sec   633 KBytes  5.19 Mbits/sec    0   63.3 KBytes
[  6]   8.00-9.00   sec   142 KBytes  1.17 Mbits/sec    0   28.9 KBytes
[  8]   8.00-9.00   sec   380 KBytes  3.11 Mbits/sec    1   38.9 KBytes
[ 10]   8.00-9.00   sec   127 KBytes  1.04 Mbits/sec    1   22.2 KBytes
[ 12]   8.00-9.00   sec   127 KBytes  1.04 Mbits/sec    2   17.8 KBytes
[SUM]   8.00-9.00   sec  1.38 MBytes  11.5 Mbits/sec    4
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   9.00-10.00  sec   317 KBytes  2.59 Mbits/sec    0   65.6 KBytes
[  6]   9.00-10.00  sec   149 KBytes  1.22 Mbits/sec    1   28.9 KBytes
[  8]   9.00-10.00  sec   253 KBytes  2.08 Mbits/sec    0   48.9 KBytes
[ 10]   9.00-10.00  sec   127 KBytes  1.04 Mbits/sec    2   17.8 KBytes
[ 12]   9.00-10.00  sec   127 KBytes  1.04 Mbits/sec    0   22.2 KBytes
[SUM]   9.00-10.00  sec   972 KBytes  7.97 Mbits/sec    3
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  5.44 MBytes  4.57 Mbits/sec   44             sender
[  4]   0.00-10.00  sec  4.84 MBytes  4.06 Mbits/sec                  receiver
[  6]   0.00-10.00  sec  1.58 MBytes  1.33 Mbits/sec    9             sender
[  6]   0.00-10.00  sec  1.48 MBytes  1.24 Mbits/sec                  receiver
[  8]   0.00-10.00  sec  2.76 MBytes  2.32 Mbits/sec   10             sender
[  8]   0.00-10.00  sec  2.56 MBytes  2.15 Mbits/sec                  receiver
[ 10]   0.00-10.00  sec  1.57 MBytes  1.32 Mbits/sec   20             sender
[ 10]   0.00-10.00  sec  1.46 MBytes  1.23 Mbits/sec                  receiver
[ 12]   0.00-10.00  sec  1.60 MBytes  1.34 Mbits/sec   11             sender
[ 12]   0.00-10.00  sec  1.47 MBytes  1.23 Mbits/sec                  receiver
[SUM]   0.00-10.00  sec  13.0 MBytes  10.9 Mbits/sec   94             sender
[SUM]   0.00-10.00  sec  11.8 MBytes  9.91 Mbits/sec                  receiver

iperf Done.

root@raspberrypi:/home/pi# iperf3 -c 10.222.2.1 -P5 -R
Connecting to host 10.222.2.1, port 5201
Reverse mode, remote host 10.222.2.1 is sending
[  4] local 10.222.2.10 port 49146 connected to 10.222.2.1 port 5201
[  6] local 10.222.2.10 port 49148 connected to 10.222.2.1 port 5201
[  8] local 10.222.2.10 port 49150 connected to 10.222.2.1 port 5201
[ 10] local 10.222.2.10 port 49152 connected to 10.222.2.1 port 5201
[ 12] local 10.222.2.10 port 49154 connected to 10.222.2.1 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   240 KBytes  1.97 Mbits/sec
[  6]   0.00-1.00   sec   202 KBytes  1.66 Mbits/sec
[  8]   0.00-1.00   sec   206 KBytes  1.68 Mbits/sec
[ 10]   0.00-1.00   sec   200 KBytes  1.64 Mbits/sec
[ 12]   0.00-1.00   sec   178 KBytes  1.46 Mbits/sec
[SUM]   0.00-1.00   sec  1.00 MBytes  8.40 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   1.00-2.00   sec   392 KBytes  3.21 Mbits/sec
[  6]   1.00-2.00   sec   329 KBytes  2.69 Mbits/sec
[  8]   1.00-2.00   sec   410 KBytes  3.36 Mbits/sec
[ 10]   1.00-2.00   sec   373 KBytes  3.06 Mbits/sec
[ 12]   1.00-2.00   sec   323 KBytes  2.65 Mbits/sec
[SUM]   1.00-2.00   sec  1.78 MBytes  15.0 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   2.00-3.00   sec  46.7 KBytes   382 Kbits/sec
[  6]   2.00-3.00   sec   180 KBytes  1.48 Mbits/sec
[  8]   2.00-3.00   sec   102 KBytes   838 Kbits/sec
[ 10]   2.00-3.00   sec  6.67 KBytes  54.6 Kbits/sec
[ 12]   2.00-3.00   sec  10.0 KBytes  81.9 Kbits/sec
[SUM]   2.00-3.00   sec   346 KBytes  2.83 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   3.00-4.00   sec   213 KBytes  1.75 Mbits/sec
[  6]   3.00-4.00   sec   114 KBytes   938 Kbits/sec
[  8]   3.00-4.00   sec   542 KBytes  4.44 Mbits/sec
[ 10]   3.00-4.00   sec  0.00 Bytes  0.00 bits/sec
[ 12]   3.00-4.00   sec  28.9 KBytes   237 Kbits/sec
[SUM]   3.00-4.00   sec   899 KBytes  7.37 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   4.00-5.00   sec   663 KBytes  5.43 Mbits/sec
[  6]   4.00-5.00   sec   262 KBytes  2.15 Mbits/sec
[  8]   4.00-5.00   sec   577 KBytes  4.72 Mbits/sec
[ 10]   4.00-5.00   sec  1.17 MBytes  9.78 Mbits/sec
[ 12]   4.00-5.00   sec  61.1 KBytes   501 Kbits/sec
[SUM]   4.00-5.00   sec  2.69 MBytes  22.6 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   5.00-6.00   sec   273 KBytes  2.24 Mbits/sec
[  6]   5.00-6.00   sec   262 KBytes  2.15 Mbits/sec
[  8]   5.00-6.00   sec   280 KBytes  2.29 Mbits/sec
[ 10]   5.00-6.00   sec   260 KBytes  2.13 Mbits/sec
[ 12]   5.00-6.00   sec   167 KBytes  1.37 Mbits/sec
[SUM]   5.00-6.00   sec  1.21 MBytes  10.2 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   6.00-7.00   sec   385 KBytes  3.15 Mbits/sec
[  6]   6.00-7.00   sec   152 KBytes  1.25 Mbits/sec
[  8]   6.00-7.00   sec   506 KBytes  4.14 Mbits/sec
[ 10]   6.00-7.00   sec   350 KBytes  2.87 Mbits/sec
[ 12]   6.00-7.00   sec   148 KBytes  1.21 Mbits/sec
[SUM]   6.00-7.00   sec  1.50 MBytes  12.6 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   7.00-8.00   sec   212 KBytes  1.74 Mbits/sec
[  6]   7.00-8.00   sec   134 KBytes  1.10 Mbits/sec
[  8]   7.00-8.00   sec   463 KBytes  3.80 Mbits/sec
[ 10]   7.00-8.00   sec   433 KBytes  3.55 Mbits/sec
[ 12]   7.00-8.00   sec   112 KBytes   919 Kbits/sec
[SUM]   7.00-8.00   sec  1.32 MBytes  11.1 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   8.00-9.00   sec   273 KBytes  2.24 Mbits/sec
[  6]   8.00-9.00   sec   174 KBytes  1.43 Mbits/sec
[  8]   8.00-9.00   sec   352 KBytes  2.89 Mbits/sec
[ 10]   8.00-9.00   sec   278 KBytes  2.28 Mbits/sec
[ 12]   8.00-9.00   sec   193 KBytes  1.58 Mbits/sec
[SUM]   8.00-9.00   sec  1.24 MBytes  10.4 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   9.00-10.00  sec   348 KBytes  2.85 Mbits/sec
[  6]   9.00-10.00  sec   264 KBytes  2.17 Mbits/sec
[  8]   9.00-10.00  sec   250 KBytes  2.05 Mbits/sec
[ 10]   9.00-10.00  sec   403 KBytes  3.30 Mbits/sec
[ 12]   9.00-10.00  sec   138 KBytes  1.13 Mbits/sec
[SUM]   9.00-10.00  sec  1.37 MBytes  11.5 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  3.87 MBytes  3.25 Mbits/sec  674             sender
[  4]   0.00-10.00  sec  2.98 MBytes  2.50 Mbits/sec                  receiver
[  6]   0.00-10.00  sec  3.01 MBytes  2.53 Mbits/sec  546             sender
[  6]   0.00-10.00  sec  2.15 MBytes  1.81 Mbits/sec                  receiver
[  8]   0.00-10.00  sec  5.61 MBytes  4.71 Mbits/sec  876             sender
[  8]   0.00-10.00  sec  3.60 MBytes  3.02 Mbits/sec                  receiver
[ 10]   0.00-10.00  sec  4.44 MBytes  3.72 Mbits/sec  921             sender
[ 10]   0.00-10.00  sec  3.42 MBytes  2.87 Mbits/sec                  receiver
[ 12]   0.00-10.00  sec  2.39 MBytes  2.01 Mbits/sec  298             sender
[ 12]   0.00-10.00  sec  1.33 MBytes  1.11 Mbits/sec                  receiver
[SUM]   0.00-10.00  sec  19.3 MBytes  16.2 Mbits/sec  3315             sender
[SUM]   0.00-10.00  sec  13.5 MBytes  11.3 Mbits/sec                  receiver

iperf Done.

还算稳定,如果用-P30会更稳定一些,基本都是10Mbit/Sec左右

@jiangtiandao
Copy link
Contributor Author

jiangtiandao commented Sep 24, 2017

iperf3 -c 127.0.0.1 -P30 -p 8388 -b 5M -t 240
10/连接数 就是 sum 是10 Mbits/sec 每个链接就是10/连接数
iperf经常100% 其他正常
这是client端的日志
https://hastebin.com/pedusabocu
server 端日志
https://hastebin.com/oqarebojap

@wangyu-
Copy link
Owner

wangyu- commented Sep 24, 2017

@jiangtiandao
这个结果也太不稳定了吧。

iperf经常100% 其他正常,这个说的是CPU吗。你的client和server有几个CPU(核数),是不是CPU已经被打满了。

我怀疑是CPU被打满了,或者是FEC造成的。

@jiangtiandao
Copy link
Contributor Author

jiangtiandao commented Sep 24, 2017

client server 都是在阿里云2c4g的vps上 测试的时候cpu 5%
-P128 的话 iperf会100% 占用

@jiangtiandao
Copy link
Contributor Author

jiangtiandao commented Sep 24, 2017

只用kcptun 关闭fec的话 -P 增加之后 一样不稳定
https://hastebin.com/wucawohime

@wangyu-
Copy link
Owner

wangyu- commented Sep 24, 2017

只用kcptun 关闭fec的话 -P 增加之后 一样不稳定

也许你kcptun的参数没调好,590 Mbits/sec199 Mbits/sec94.3 Mbits/sec,前3秒client端发送了过多数据,后面很多时间一直都在重传,无法发送新数据。

@jiangtiandao
Copy link
Contributor Author

iperf3 的 -b 调小之后还挺稳定的
-b 1m 开十几个链接 就还好

@wangyu-
Copy link
Owner

wangyu- commented Sep 24, 2017

iperf3 的 -b 调小之后还挺稳定的
-b 1m 开十几个链接 就还好

这样只是掩盖了问题;现在的问题是,如果你不限制每个连接的带宽,上层的tcp会错误地估计了带宽,瞬时发送了过多的数据,导致连接不稳定。

@jiangtiandao
Copy link
Contributor Author

docker bridge 模式吞吐量在 5 Mbits/sec左右 是 host模式的一半
重传是不是 send window size 和 receive window size 引起的呢?

@wangyu-
Copy link
Owner

wangyu- commented Sep 25, 2017

重传是不是 send window size 和 receive window size 引起的呢?

我猜主要和kcp的send windows size有关。

@jiangtiandao
Copy link
Contributor Author

docker run -d --rm --name=iperf3-server -p 5201:5201 networkstatic/iperf3 -s
docker run -d --rm --cap-add=NET_ADMIN --name=kcptun_server xtaci/kcptun server -t "172.17.132.43:5201" -l "0.0.0.0:4000" --rcvwnd 256 --ds 0 --ps 0 --sndwnd 256 -mode default --crypt none --nocomp --mtu 1100
docker run -d --rm --cap-add=NET_ADMIN --name=udp2raw_server daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -s -l 0.0.0.0:10999 -r $(docker inspect --format "{{ .NetworkSettings.IPAddress }}:4000" $(docker ps -l | grep kcptun_server | awk '{print $1}')) --cipher-mode xor --auth-mode simple -a -k "passwd" --lower-level auto
docker run -d --rm --cap-add=NET_ADMIN --name=udp2raw_client daocloud.io/rheinmetal/udp2raw ./udp2raw_dynamic -c -l 0.0.0.0:3333 -r $(docker inspect --format "{{ .NetworkSettings.IPAddress }}:10999" $(docker ps -l | grep udp2raw_server | awk '{print $1}')) --cipher-mode xor --auth-mode simple -a -k "passwd"
docker run -d --rm --cap-add=NET_ADMIN --name=kcptun_client xtaci/kcptun client -r $(docker inspect --format "{{ .NetworkSettings.IPAddress }}:3333" $(docker ps -l | grep udp2raw_client | awk '{print $1}')) -l "0.0.0.0:8388" --rcvwnd 256 --ds 0 --ps 0 --sndwnd 256 -mode default --crypt none --nocomp --mtu 1100
iperf3 -c $(docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -l | grep kcptun_client | awk '{print $1}')) -p 8388 -b 0 -t 60 -P30
iperf3 -c $(docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -l | grep kcptun_client | awk '{print $1}')) -p 8388 -b 0 -t 60 -P30 -R

改了window 好多了 可以到 10 M 两种模式性能差不多

@jiangtiandao
Copy link
Contributor Author

@daoye
Copy link

daoye commented Oct 18, 2017

我也同问这个问题, 我本机macOS,在docker中运行了udp2raw,客户端和服务端建立的通道看起来没毛病,然鹅,openvpn就是不通。 不过我直接连接vpn是没有问题的。
1
Uploading 2.png…
Uploading 3.png…
Uploading 4.png…

@wangyu-
Copy link
Owner

wangyu- commented Oct 18, 2017

我也同问这个问题, 我本机macOS,在docker中运行了udp2raw,客户端和服务端建立的通道看起来没毛病,然鹅,openvpn就是不通。 不过我直接连接vpn是没有问题的。

macos上的docker不是原生的,是用虚拟机虚拟了个Linux,然后在linux上运行的docker。为了能正常使用,需要把docker带的虚拟机的网卡设成桥接的,然后在docker里把网络模式设成host。这样理论上可以,不过我没有在mac上实机测试过。

既然mac上的docker底层都是运行在虚拟机里的,还不如直接用虚拟机。release里的那个7.5mb的虚拟机镜像里已经自带了udp2raw,开机即用,是最简单的方法。

@daoye
Copy link

daoye commented Oct 19, 2017 via email

@wangyu-
Copy link
Owner

wangyu- commented Oct 19, 2017

以我有限的认识,我认为一旦通过facktcp伪造了udp数据包之后,即使没有通过加速工具加速,理论上也能够提升连接速度的吧? 怎么我感觉速度并没有任何起色呢?

如果你的运营商对udp做了限制,那么伪装成tcp以后相当于绕过了限制,才会有提升。如果运营商没做限制,那么就不会提升了。

@daoye
Copy link

daoye commented Oct 19, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants