Closed kwxiaozhu closed 6 years ago
配置没什么问题。我目前能想到的是有可能服务器上的防火墙没开7777这个端口。
你加上--log-level 5 --log-position
,贴一下UDPspeeder的log
[2017-10-24 17:44:06][INFO]argc=15 ./speederv2_amd64 -s -l0.0.0.0:7777 -r 127.0.0.1:1195 -f20:10 --mode 0 --mtu 1200 -k password --log-level 5 --log-position [2017-10-24 17:44:06][DEBUG]key=password [2017-10-24 17:44:06][INFO][main.cpp,func:process_arg,line:1584]jitter_min=0 jitter_max=0 output_interval_min=0 output_interval_max=0 fec_pending_time=8 fec_data_num=20 fec_redundant_num=10 fec_mtu=1200 fec_pending_num=200 fec_type=0 [2017-10-24 17:44:06][DEBUG][main.cpp,func:init_listen_socket,line:93]local_listen_fd=5 ,[2017-10-24 17:44:06][DEBUG][main.cpp,func:server_event_loop,line:644] delay_manager.get_timer_fd() =3 [2017-10-24 17:44:06][INFO][main.cpp,func:server_event_loop,line:646]now listening at 0.0.0.0:7777 [2017-10-24 17:44:06][DEBUG][main.cpp,func:server_event_loop,line:654] timer.get_timer_fd() =7 [2017-10-24 17:44:24][DEBUG][main.cpp,func:server_event_loop,line:742]fec_fd64=4294967396 [2017-10-24 17:44:24][DEBUG][main.cpp,func:server_event_loop,line:752]conn_info.timer.get_timer_fd64()=4294967397 [2017-10-24 17:44:24][INFO][main.cpp,func:server_event_loop,line:757]new connection from 39.151.206.190:55199 [2017-10-24 17:44:24][DEBUG][main.cpp,func:new_connected_socket,line:118][127.0.0.1:1195]created new udp_fd 10 [2017-10-24 17:44:24][INFO][main.cpp,func:server_event_loop,line:808][39.151.206.190:55199]new conv f482fe01,fd 10 created,fd64=4294967398 [2017-10-24 17:44:25][DEBUG][main.cpp,func:new_connected_socket,line:118][127.0.0.1:1195]created new udp_fd 11 [2017-10-24 17:44:25][INFO][main.cpp,func:server_event_loop,line:808][39.151.206.190:55199]new conv edb11c38,fd 11 created,fd64=4294967399
[2017-10-24 17:44:19][INFO]argc=15 ./speederv2_amd64 -c -l0.0.0.0:3333 -r 45.77.88.99:7777 -f20:10 --mode 0 --mtu 1200 -k password --log-level 5 --log-position [2017-10-24 17:44:19][DEBUG]key=password [2017-10-24 17:44:19][INFO][main.cpp,func:process_arg,line:1584]jitter_min=0 jitter_max=0 output_interval_min=0 output_interval_max=0 fec_pending_time=8 fec_data_num=20 fec_redundant_num=10 fec_mtu=1200 fec_pending_num=200 fec_type=0 [2017-10-24 17:44:19][DEBUG][main.cpp,func:init_listen_socket,line:93]local_listen_fd=7 ,[2017-10-24 17:44:19][DEBUG][main.cpp,func:new_connected_socket,line:118][45.76.192.22:7777]created new udp_fd 9 [2017-10-24 17:44:19][DEBUG][main.cpp,func:client_event_loop,line:346]remote_fd64=4294967397 [2017-10-24 17:44:19][DEBUG][main.cpp,func:client_event_loop,line:360]delay_manager.get_timer_fd()=3 [2017-10-24 17:44:19][DEBUG][main.cpp,func:client_event_loop,line:371]conn_info.fec_encode_manager.get_timer_fd64()=4294967395 [2017-10-24 17:44:19][DEBUG][main.cpp,func:client_event_loop,line:382]conn_info.timer.get_timer_fd()=6 [2017-10-24 17:44:24][INFO][main.cpp,func:client_event_loop,line:497]new packet from 127.0.0.1:49821,conv_id=f482fe01 [2017-10-24 17:44:25][INFO][main.cpp,func:client_event_loop,line:497]new packet from 127.0.0.1:50435,conv_id=edb11c38 [2017-10-24 17:45:04][INFO][connection.cpp,func:clear_inactive0,line:166]conv f482fe01 cleared [2017-10-24 17:45:31][INFO][main.cpp,func:client_event_loop,line:497]new packet from 127.0.0.1:49196,conv_id=ae177ea8 [2017-10-24 17:45:37][INFO][connection.cpp,func:clear_inactive0,line:166]conv edb11c38 cleared
先用netstat -nlp看一下OPENVPN server有没有bind到127.0.0.1:1195
然后用netcat测试一下通过UDPspeeder能不能正常收发数据。
netstat -nlp 已经bind到0.0.0.0:1195 服务端用nc -ul -p 1196 监听udp 1196端口 ./speederv2_amd64 -s -l0.0.0.0:7777 -r 127.0.0.1:1196 -f20:10 --mode 0 --mtu 1200 -k "password" --log-level 5 --log-position 客户端运行 ./speederv2_amd64 -c -l0.0.0.0:3333 -r 45.77.88.99:7777 -f20:10 --mode 0 --mtu 1200 -k "password" --log-level 5 --log-position 用nc -u 127.0.0.1 3333连接输入test在服务端可以收到test,证明可以正常通信。
在nc服务端也输入一下数据,测试下反向的通信有没有问题
刚测试反向通信收不到数据
能提供一下环境吗?wangyucn@gmail.com
现在这个情况,需要用tcpdump看一下了,看一下反向不通是因为server没有把数据发出来,还是server发了client没有收到。
如果你有能力可以自己看一下。
我想到个问题,你刚才说:
又重试了一下,现在正向通信也不行,nc连上以后输入测试数据就直接退出了,而直接连接服务端IP就没有问题
nc的服务端只能接受一个client连接一次,可能是这个问题导致的。你把nc client和server都杀掉重启,重新试一下双向的传输有没有问题。
客户端和服务器端同时运行tcpdump -i eth0 -vv 'udp and port 7777'抓包,nc测得 客户端——>服务端 第一次数据正常传输,第2次以后server端nc收不到数据,但是tcpdump抓server端7777端口有数据,speeder日志提示 [DEBUG][main.cpp,func:server_event_loop,line:900]udp fd,recv_len<0 continue,Connection refused 服务端——>客户端 服务端收到数据回复时,客户端收不到回复,tcpdump抓server端7777端口没有数据。
直接用nc连接server端正向和反向通信都没有问题,可以重复多次传输数据。
Connection refused
这个(可能)是我刚才说的那个问题导致的。nc 的server只能被一个client连一次。
服务端——>客户端 服务端收到数据回复时,客户端收不到回复,tcpdump抓server端7777端口没有数据。
这个是把nc的 client和server都kill后测的吗?
==update==
可以重复多次传输数据。
是可以重复多次传输,只是一个sever只能接受client的一次连接。 ==update==
客户端——>服务端 第一次数据正常传输,第2次以后server端nc收不到数据,但是tcpdump抓server端7777端口有数据,speeder日志提示
这个第一次和第二次是说,同一连接,多次发送数据吗?从你的表述上看,应该是同一连接多次发送数据,可是从测试出的现象看,貌似是client重新连接了一次,然后连接被拒绝了。
我想到个问题,你刚才说: 又重试了一下,现在正向通信也不行,nc连上以后输入测试数据就直接退出了,而直接连接服务端IP就没有问题 nc的服务端只能接受一个client连接一次,可能是这个问题导致的。你把nc client和server都杀掉重启,重新试一下双向的传输有没有问题。
这个是我之前测试时输入了错误的端口导致的,更正后正向通信也是只限于第一次。
这个是把nc的 client和server都kill后测的吗?
是的,每次测试都是先kill掉nc的server和client
这个第一次和第二次是说,同一连接,多次发送数据吗?
是同一连接,测试过程是nc的client连上后先发送数据,server端可以收到,client端再发数据,server端nc收不到数据,但是tcpdump有数据,server端向client端发送数据,client端收不到,并且server端和client端的tcpdump都没有数据,我想应该是server端收到一次数据就关闭连接了,但是直接连接server端IP的话是可以一个连接多次发送数据的。
服务端用nc -ul -p 1196 监听udp 1196端口 ./speederv2_amd64 -s -l0.0.0.0:7777 -r 127.0.0.1:1196 -f20:10 --mode 0 --mtu 1200 -k "password" --log-level 5 --log-position 客户端运行 ./speederv2_amd64 -c -l0.0.0.0:3333 -r 45.77.88.99:7777 -f20:10 --mode 0 --mtu 1200 -k "password" --log-level 5 --log-position
我用了一样的命令测试,测试了几次,双向通信多次都是正常的,没办法复现。
你再尝试一下在两边加上--report 5,再测试一次,测试完贴下两边UDPspeeder的完整log。
还有在两边执行一下./speederv2_amd64 --help,贴出结果,我看下是哪个版本。
server端
root@kwxiaozhu:~/speederv2# ./speederv2_amd64 -s -l0.0.0.0:7777 -r 127.0.0.1:1196 -f20:10 --mode 0 --mtu 1200 -k "password" --log-level 5 --log-position --report 5 [2017-10-24 19:35:58][INFO]argc=17 ./speederv2_amd64 -s -l0.0.0.0:7777 -r 127.0.0.1:1196 -f20:10 --mode 0 --mtu 1200 -k password --log-level 5 --log-position --report 5 [2017-10-24 19:35:58][DEBUG]key=password [2017-10-24 19:35:58][INFO][main.cpp,func:process_arg,line:1584]jitter_min=0 jitter_max=0 output_interval_min=0 output_interval_max=0 fec_pending_time=8 fec_data_num=20 fec_redundant_num=10 fec_mtu=1200 fec_pending_num=200 fec_type=0 [2017-10-24 19:35:58][DEBUG][main.cpp,func:init_listen_socket,line:93]local_listen_fd=5 ,[2017-10-24 19:35:58][DEBUG][main.cpp,func:server_event_loop,line:644] delay_manager.get_timer_fd() =3 [2017-10-24 19:35:58][INFO][main.cpp,func:server_event_loop,line:646]now listening at 0.0.0.0:7777 [2017-10-24 19:35:58][DEBUG][main.cpp,func:server_event_loop,line:654] timer.get_timer_fd() =7 [2017-10-24 19:36:36][DEBUG][main.cpp,func:server_event_loop,line:742]fec_fd64=4294967396 [2017-10-24 19:36:36][DEBUG][main.cpp,func:server_event_loop,line:752]conn_info.timer.get_timer_fd64()=4294967397 [2017-10-24 19:36:36][INFO][main.cpp,func:server_event_loop,line:757]new connection from 39.151.206.190:34539 [2017-10-24 19:36:36][DEBUG][main.cpp,func:new_connected_socket,line:118][127.0.0.1:1196]created new udp_fd 10 [2017-10-24 19:36:36][INFO][main.cpp,func:server_event_loop,line:808][39.151.206.190:34539]new conv edc4dff,fd 10 created,fd64=4294967398 [2017-10-24 19:36:36][INFO][connection.h,func:report_as_server,line:97][report][39.151.206.190:34539]client-->server:(original:1 pkt;9 byte) (fec:2 pkt;32 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:41][INFO][connection.h,func:report_as_server,line:97][report][39.151.206.190:34539]client-->server:(original:1 pkt;9 byte) (fec:12 pkt;192 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:47][INFO][connection.h,func:report_as_server,line:97][report][39.151.206.190:34539]client-->server:(original:1 pkt;9 byte) (fec:12 pkt;192 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:52][INFO][connection.h,func:report_as_server,line:97][report][39.151.206.190:34539]client-->server:(original:1 pkt;9 byte) (fec:12 pkt;192 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:56][DEBUG][main.cpp,func:server_event_loop,line:900]udp fd,recv_len<0 continue,Connection refused [2017-10-24 19:36:58][INFO][connection.h,func:report_as_server,line:97][report][39.151.206.190:34539]client-->server:(original:2 pkt;18 byte) (fec:24 pkt;384 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:37:03][INFO][connection.h,func:report_as_server,line:97][report][39.151.206.190:34539]client-->server:(original:2 pkt;18 byte) (fec:24 pkt;384 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte)
client端
130 root@debian9 ~/speederv2 # ./speederv2_amd64 -c -l0.0.0.0:3333 -r 45.76.192.21:7777 -f20:10 --mode 0 --mtu 1200 -k "password" --log-level 5 --log-position --report 5 :( [2017-10-24 19:36:13][INFO]argc=17 ./speederv2_amd64 -c -l0.0.0.0:3333 -r 45.76.192.21:7777 -f20:10 --mode 0 --mtu 1200 -k password --log-level 5 --log-position --report 5 [2017-10-24 19:36:13][DEBUG]key=password [2017-10-24 19:36:13][INFO][main.cpp,func:process_arg,line:1584]jitter_min=0 jitter_max=0 output_interval_min=0 output_interval_max=0 fec_pending_time=8 fec_data_num=20 fec_redundant_num=10 fec_mtu=1200 fec_pending_num=200 fec_type=0 [2017-10-24 19:36:13][DEBUG][main.cpp,func:init_listen_socket,line:93]local_listen_fd=7 ,[2017-10-24 19:36:13][DEBUG][main.cpp,func:new_connected_socket,line:118][45.76.192.22:7777]created new udp_fd 9 [2017-10-24 19:36:13][DEBUG][main.cpp,func:client_event_loop,line:346]remote_fd64=4294967397 [2017-10-24 19:36:13][DEBUG][main.cpp,func:client_event_loop,line:360]delay_manager.get_timer_fd()=3 [2017-10-24 19:36:13][DEBUG][main.cpp,func:client_event_loop,line:371]conn_info.fec_encode_manager.get_timer_fd64()=4294967395 [2017-10-24 19:36:13][DEBUG][main.cpp,func:client_event_loop,line:382]conn_info.timer.get_timer_fd()=6 [2017-10-24 19:36:13][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:0 pkt;0 byte) (fec:0 pkt,0 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:19][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:0 pkt;0 byte) (fec:0 pkt,0 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:24][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:0 pkt;0 byte) (fec:0 pkt,0 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:30][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:0 pkt;0 byte) (fec:0 pkt,0 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:35][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:0 pkt;0 byte) (fec:0 pkt,0 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:36][INFO][main.cpp,func:client_event_loop,line:497]new packet from 127.0.0.1:48936,conv_id=edc4dff [2017-10-24 19:36:41][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:1 pkt;9 byte) (fec:12 pkt,192 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:46][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:1 pkt;9 byte) (fec:12 pkt,192 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:51][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:1 pkt;9 byte) (fec:12 pkt,192 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:36:57][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:2 pkt;18 byte) (fec:24 pkt,384 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte) [2017-10-24 19:37:02][INFO][connection.h,func:report_as_client,line:83][report]client-->server:(original:2 pkt;18 byte) (fec:24 pkt,384 byte) server-->client:(original:0 pkt;0 byte) (fec:0 pkt;0 byte)
同样的测试
会不会是7777这个端口号的问题,把这个端口换成一个已知可以正常通信的端口(比如1196)试下?
刚才我又在我局域网内的nas和香蕉派两台机器上实验,还是同样的问题,无法双向通信。
更换端口也不行。
在两边执行一下./speederv2_amd64 --help,贴出结果,我看下是哪个版本。
130 root@bananapi ~/speederv2 # ./speederv2_arm --help :( UDPspeeder V2 git version:39f2ead0af build date:Oct 21 2017 11:10:36 repository: https://github.com/wangyu-/UDPspeeder
130 root@debian9 ~/speederv2 # ./speederv2_amd64 --help :( UDPspeeder V2 git version:39f2ead0af build date:Oct 21 2017 11:10:20 repository: https://github.com/wangyu-/UDPspeeder
刚下的最新release版,这两台机器在同一局域网内
我之前用的不是这个版本,但是我刚才下载了这个版本反复测试了好几次,都没能复现这个问题。
然后我尝试client和server都跑在单机上,也没问题。
麻烦你在单机上测试一下,看是否正常。
刚才我又在我局域网内的nas和香蕉派两台机器上实验,还是同样的问题,无法双向通信。
这个真的很诡异。同样的版本,在你的多个环境下稳定复现,在我这边多个环境下无法复现。
麻烦你在单机上测试一下,看是否正常。
既然能这么稳定的复现的话,应该能在某台单机上也稳定复现。
你找台不重要的机器测试一下,如果单机还是能复现这个问题,把这个环境提供给我,我上去测试一下。如果有公网ip,我可以直接ssh上去。如果没有公网ip也没关系,一会我告诉你个办法,也能让我连上去。
如果是VPS,你把VPS快照一下,把需要保密的东西都删掉,然后改密码,把新密码发到我邮箱,之后你再还原VPS快照,这是绝对安全的。 或者开一个受限的ssh账号也行。
测试环境已经发到你的邮箱,感谢!
你好,我看你client端连的是45.77.88.99,本地测试应该连127吧
看到了哈哈,忘改了
echo "你可以这样和我聊天" >/dev/pts/1
我目前发现你这机器,不使用udpspeeder也有一样的问题:
nc -l -p 3334 -u
nc -u 127.0.0.1 3334
貌似只要通过127.0.0.1通信就有问题。具体原因我也很好奇,我在排查。
2017-10-24 5:40 GMT-07:00 wang yu wangyu.cn@gmail.com:
你好,我看你client端连的是45.77.88.99,本地测试应该连127吧
看到了哈哈,忘改了
echo "你可以这样和我聊天" >/dev/pts/1
这样有点乱 = =
貌似跟我机器上的一条iptables规则有关 iptables -t nat -A POSTROUTING -j MASQUERADE 删掉nc 127可以通信 我的NAS上没有这条命令,用nc 127测试正常,但是套上udpspeeder还是不行
iptables -t nat -A POSTROUTING -j MASQUERADE
这条我可以删吗?如果127不能连的话,我就没法测试了。
可以,已经帮你删掉,测试本地nc是正常的
可以,已经帮你删掉,测试本地nc是正常的
删了以后UDPspeeder也正常了。
我的NAS上没有这条命令,用nc 127测试正常,但是套上udpspeeder还是不行
只要有一端127不通,就没法正常通信了,你排查下各个机器的127.0.0.1通不通吧
如果还是不行的话,提供一个nc能通UDPspeeder不通的环境。
确实是这样,但是相同的原理我用kcptun都正常,而udpspeeder就不行,我加这条命令主要是为了VPN连上以后做NAT访问内网用的,也不能不用呀
一般NAT不都这么写吗:
iptables -t nat -A POSTROUTING -s 10.222.0.0/16 -o eth0 -j MASQUERADE
或者
iptables -t nat -A POSTROUTING -s 10.222.0.0/16 -j SNAT --to-source 44.55.66.77
但是相同的原理我用kcptun都正常
kcptun一端是tcp连接,一端是udp连接,udp端是公网上的,tcp端才用到了127.0.0.1; UDPspeeder两端都是udp连接。
iptables -t nat -A POSTROUTING -j MASQUERADE
你这个写法127.0.0.1的udp挂了,是有问题的。也许因为netfilter实现细节的原因,TCP侥幸没出问题。
好吧,这是我偷懒的写法,我的内网环境有点复杂,为了不每个vpn网段都写一条命令,我就写一个命令了,没想到还会有这问题,非常感谢你的帮助,谢谢!
非常感谢你的帮助,谢谢!
没事。
openVPN server.conf
openvpn client.conf
run on openvpn server side
./speederv2_amd64 -s -l0.0.0.0:7777 -r 127.0.0.1:1195 -f20:10 --mode 0 --mtu 1200 -k "password"
run on openvpn client side
./speederv2_amd64 -c -l0.0.0.0:3333 -r 45.77.88.99:7777 -f20:10 --mode 0 --mtu 1200 -k "password"
如果直连openVPN服务器一切正常,如果通过speederv2 的127.0.0.1:3333 连接,则提示
我的openVPN配置了用户名密码认证,不过应该跟这没关系吧