4 KCP Benchmark
wangcong edited this page 2018-01-18 21:07:11 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

如果网络从来不丢包,那么你直接用 TCP就行了甚至直接裸UDP都没关系但是网络因为丢包造成卡顿特别是高峰时期丢包会上到10%的情况,移动设备上这个情况更糟糕。

我自己评测过很多,asio_kcp 的作者做过比较详细的评测在网络变糟糕的情况下KCP的延迟比 libenet低三倍以上

worst network lag happen:
asio: 10:51.21
291  295   269   268   231   195   249   230   225   204

enet: 10:51.21
1563   1520    1470    1482    1438    1454    1412    1637    1588    1540

更详细的评测可以看这里:benchmark,感谢 asio_kcp 的作者 zhangyuan 详细对比了 UDT, libenet和 kcp并给出结论如下

  • ASIO-KCP has good performance in wifi and phone network(3G, 4G).
  • The kcp is the first choice for realtime pvp game.
  • The lag is less than 1 second when network lag happen. 3 times better than enet when lag happen.
  • The enet is a good choice if your game allow 2 second lag.
  • UDT is a bad idea. It always sink into badly situation of more than serval seconds lag. And the recovery is not expected.

其他可以左右你选择的情况:

  • enet has the problem of lack of doc. And it has lots of functions that you may have interest in.
  • kcp's doc is in Chinese.
  • Good thing is the function detail which is written in code is English. And you can use asio_kcp which is a good wrap.
  • The kcp is a simple thing. You will write more code if you want more features.
  • UDT has a perfect doc. UDT may have more bug than others as I feeling.

我当年主要测试了 KCP和 TCP/UDT的比较扫了一眼 libenet觉得协议实现中规中矩缺乏很多现代传输协议的技术所以并没有详细测试。而 asio-kcp的作者同时给出了KCP/enet/udt三者的详细比较为犹豫选择的人提供了更多指引。