Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/b23r0/rust-raknet
RakNet Protocol implementation by Rust.
https://github.com/b23r0/rust-raknet
minecraft networking raknet reliable-udp udp udp-protocol
Last synced: 3 months ago
JSON representation
RakNet Protocol implementation by Rust.
- Host: GitHub
- URL: https://github.com/b23r0/rust-raknet
- Owner: b23r0
- License: mit
- Created: 2022-03-11T10:46:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-29T12:08:12.000Z (7 months ago)
- Last Synced: 2024-06-19T03:12:15.304Z (5 months ago)
- Topics: minecraft, networking, raknet, reliable-udp, udp, udp-protocol
- Language: Rust
- Homepage:
- Size: 315 KB
- Stars: 215
- Watchers: 3
- Forks: 18
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust - b23r0/rust-raknet - raknet/Rust)](https://github.com/b23r0/rust-raknet/actions/workflows/rust.yml) (Libraries / Network programming)
- awesome-rust-cn - b23r0/rust-raknet
README
# rust-raknet [![Build Status](https://img.shields.io/github/workflow/status/b23r0/rust-raknet/Rust)](https://github.com/b23r0/rust-raknet/actions/workflows/rust.yml) [![ChatOnDiscord](https://img.shields.io/badge/chat-on%20discord-blue)](https://discord.gg/ZKtYMvDFN4) [![Crate](https://img.shields.io/crates/v/rust-raknet)](https://crates.io/crates/rust-raknet) [![Crate](https://img.shields.io/docsrs/rust-raknet/latest)](https://docs.rs/rust-raknet/latest/rust_raknet/)
RakNet Protocol implementation by Rust.Raknet is a reliable udp transport protocol that is generally used for communication between game clients and servers, and is used by Minecraft Bedrock Edtion for underlying communication.
Raknet protocol supports various reliability options, and has better transmission performance than TCP in unstable network environments. This project is an incomplete implementation of the protocol by reverse engineering.
Requires >= *Tokio 1.x* asynchronous runtime support.
Reference : http://www.jenkinssoftware.com/raknet/manual/index.html
_This project is not affiliated with Jenkins Software LLC nor RakNet._
# Features
* Async
* MIT License
* Pure Rust implementation
* Fast Retransmission
* Selective Retransmission (TCP/Full Retransmission)
* Non-delayed ACK (TCP/Delayed ACK)
* RTO Not Doubled (TCP/RTO Doubled)
* Linux/Windows/Mac/BSD support
* Compatible with Minecraft# Get Started
```toml
# Cargo.toml
[dependencies]
rust-raknet = "*"
```Documentation : https://docs.rs/rust-raknet/latest/rust_raknet/
# Reliability
- [x] unreliable
- [x] unreliable sequenced
- [x] reliable
- [x] reliable ordered
- [x] reliable sequenced# Example
```rs
//serverasync fn serve(){
let mut listener = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
listener.listen().await;
loop{
let socket = listener.accept().await.unwrap();
let buf = socket.recv().await.unwrap();
if buf[0] == 0xfe{
//do something
}
}
listener.close().await.unwrap();
}```
```rs
//clientasync 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
}
socket.close().await.unwrap();
}
```# Benchmark
Use Tcp to compare with this project. Set the server packet loss rate to 50%, the client connects to the server, and the server sends an 800-byte packet every 30ms, a total of 100 times. The client counts the delay time of each received data, and calculates the average time of receiving 100 times. The following results are obtained.
Test code: https://github.com/b23r0/rust-raknet/blob/main/example/test_benchmark/src/main.rs
Result:
![image]( https://github.com/b23r0/rust-raknet/blob/main/images/benchmark20220612.jpg)
(June 12, 2022)
In the network environment with high packet loss rate, this project can reduce the delay time by about 50% compared with TCP.
# Contributing
Options :
* Report a BUG
* Submit an ISSUE about suggestion
* Submit a improved PR
* Add an example of using rust-raknet
* Supplement the documentation about using rust-raknetThanks go to these wonderful people.
Contributions of any kind are welcome! If you've ever wanted to contribute to open source, and a great cause, now is your chance!
# Donation
BTC : 1HeroYcNYMhjsq8RYCx1stSaRZnQd9B9Eq
ETH : 0x9999997B3deF7b69c09D7a9CA65E5242fb04a764