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

【开源自荐】Rust实现高性能UDP可靠传输协议 #2247

Open
alittlekami opened this issue Jun 13, 2022 · 0 comments
Open

【开源自荐】Rust实现高性能UDP可靠传输协议 #2247

alittlekami opened this issue Jun 13, 2022 · 0 comments

Comments

@alittlekami
Copy link

alittlekami commented Jun 13, 2022

推荐项目

  • 项目地址:https://github.com/b23r0/rust-raknet/

  • 类别:Rust

  • 项目标题:Rust实现高性能UDP可靠传输协议

  • 项目描述:Raknet是一个成熟的UDP可靠传输协议,知名游戏Minecraft采用该协议作为游戏客户端和服务器通信协议。本项目通过逆向工程和参考老版facebook的c++实现,使用Rust重新实现该协议,同时用异步IO替代老版c++协议的多线程模型,还解决了老版本c++实现存在的大量线程和内存泄漏问题。项目目前在生产环境中同时支撑数千玩家在线游戏,在小包高频的网络游戏场景下,遇到丢包率较高的情况,相比TCP能降低50%的平均网络延迟。项目同时兼容了Minecraft最新版本,可用于Minecraft中间件开发的底层协议库使用。

  • 亮点:

  • 异步
  • 快速重传&选择重传&无延迟ACK
  • 跨平台支持(Linux&Windows&OSX&FreeBSD)
  • 兼容Minecraft
  • 示例代码:
//server

async fn serve(){
    let mut listener = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
    listener.listen().await;
    loop{
        let mut socket = listener.accept().await.unwrap();
        let buf = socket.recv().await.unwrap();
        if buf[0] == 0xfe{
            //do something
        }
    }
}
//client

async fn connect(){
    let socket = RaknetSocket::connect("127.0.0.1:19132".parse().unwrap()).await.unwrap();
    socket.send(&[0xfe], Reliability::ReliableOrdered).await.unwrap();
    let buf = socket.recv().await.unwrap();
    if buf[0] == 0xfe{
        //do something
    }
}
  • 后续更新计划:
  • 持续优化性能
  • 为Python/Nodejs等提供绑定库
  • 支持更多参数选项
  • 支持纯ARQ调用
  • 流量控制
@alittlekami alittlekami changed the title 【开源自荐】高性能异步UDP可靠传输协议 【开源自荐】Rust高性能UDP可靠传输协议 Aug 8, 2022
@alittlekami alittlekami changed the title 【开源自荐】Rust高性能UDP可靠传输协议 【开源自荐】Rust实现高性能UDP可靠传输协议 Aug 8, 2022
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

2 participants