Chion82 / kcptun-raw

Kcptun with raw socket and fake TCP headers.
GNU General Public License v3.0
416 stars 101 forks source link

在openwrt上无法工作? #10

Closed lanxianhui closed 7 years ago

lanxianhui commented 7 years ago

服务端已通过在VMWARE上ubuntu的客户端验证可以正常工作。在openwrt上客户端提示“KCP recv timeout”,tcpdump 在WAN口抓包没有看到RST报文,望大佬看一下 服务端log; fast2 mode enabled. [trans_packet]Server replying SYN+ACK. Remote notifies re-init KCP connection. [trans_packet]Server replying SYN+ACK. Remote notifies re-init KCP connection. [trans_packet]Server replying SYN+ACK. Remote notifies re-init KCP connection. Remote notifies re-init KCP connection. Remote notifies re-init KCP connection. Remote notifies re-init KCP connection. Remote notifies re-init KCP connection. 客户端log:

Re-init fake TCP connection. Trying port 36767 [trans_packet]Client sending SYN. [trans_packet]Client replying ACK. Request kcp init kcp ready. New connection conv 6952. Notifying remote new connection. conv=6952 KCP recv timeout. Re-init KCP connection. Closing connection. conv=6952 Request kcp init kcp ready. New connection conv 7046. Notifying remote new connection. conv=7046 KCP recv timeout. Re-init KCP connection. Closing connection. conv=7046 Request kcp init kcp ready. KCP recv timeout. Re-init KCP connection. Request kcp init kcp ready.

Chion82 commented 7 years ago

试试使用--noseq参数?服务端和客户端都要加

lanxianhui commented 7 years ago

试了,还是不行。客户端是在一个刷了openwrt的路由器上跑的,好像是客户发出了心跳包或者Notifying remote new connection,服务端没收到?

Chion82 commented 7 years ago

kcp ready的话底层packet应该已经互相连通,KCP会timeout这个比较谜。能否在虚拟机中用x86的openwrt试试?

lanxianhui commented 7 years ago

发现在on_packet_recv里面调用ikcp_input返回值是-2,导致调用ikcp_recv接收不到数据。

lanxianhui commented 7 years ago

在虚拟机中用x86的openwrt测试没有问题

lanxianhui commented 7 years ago

是处理器的大小端的问题。在ickp.h中添加#define IWORDS_BIG_ENDIAN 1,解决了KCP recv timeout的问题。在common.c 还有和处理器大小端相关的代码,就是fragment_header这个结构体。客户端发出Notifying remote new connection. conv=3633,服务端收到Remote notifies new connection. conv=823001088,然后就“Segmentation fault”退出了

Chion82 commented 7 years ago

问题明白了。确实struct fragment_header没有考虑到Endianness的问题。身边暂时没有big endian的机器不好测试,继续改改代码看看能否修复?另外trans_packet.c中应该也有很多逻辑涉及变动。

lanxianhui commented 7 years ago

搞定了,需要改的东西不多,具体看patch文件 kcp-raw.txt

Chion82 commented 7 years ago

十分感谢,之后会更新。