Giter VIP home page Giter VIP logo

Comments (7)

skywind3000 avatar skywind3000 commented on July 16, 2024

先回答 ikcp_recv 返回值问题:
-1 代表完全没有数据,可以理解成 EAGAIN
-2 代表数据不全(需要后续数据才能作为一个完整包),也可以理解成 EAGAIN
-3 代表你传入的缓存长度不够
你发送的时候少发送点,分多次,或者接受缓存开大点即可解决。

from kcp.

skywind3000 avatar skywind3000 commented on July 16, 2024

具体参数设置可以参考项目 kcptun,他们做的似乎和你们类似,
按照你的情况,推荐128,128的窗口大小
另kcp快速模式的话:

ikcp_nodelay(kcp1, 1, 10, 2, 1);
kcp1->rx_minrto = 10;
kcp1->fastresend = 1;

from kcp.

bitkevin avatar bitkevin commented on July 16, 2024

将需要发送的数据先放入一个buf里,然后从buf把数据通过ikcp_send()进行发送,在调用ikcp_send()前检查ikcp_waitsnd()是否超过阀值。这样去尝试解决 ikcp_recv()返回0-1/-2/-3的问题。

from kcp.

skywind3000 avatar skywind3000 commented on July 16, 2024
  1. 把 ikcp_recv的buffersize调大。
  2. ikcp_send的时候一次性少send点东西,for循环几次send,
  3. kcp->stream = 1 发送端和接收端,流模式。

from kcp.

bitkevin avatar bitkevin commented on July 16, 2024

测试的时候,遇到一种网络现象是,突然流量被掐断,就像所有IP层的包均被丢弃一样,但只要停止一秒,流量又能立即恢复。好像是某个层面做了流量控制,如果遇到这种现象,而kcp依然不停发送大量包,则导致无法通信无法恢复。

  1. 如何通过ikcp_xxxx()检测此现象
  2. 如何暂停包发送,是否暂停 ikcp_update() 即可?

from kcp.

fancl20 avatar fancl20 commented on July 16, 2024

@bitkevin 是否两台机器之间有多个 KCP 链接,我这边测试下来 KCP 链接多了就会出现这种现象,加个 mux 就好了

from kcp.

horsley avatar horsley commented on July 16, 2024

@skywind3000 流模式是双边的吗?需要收发双方同时开启?

from kcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.