8 unstable releases (3 breaking)

0.3.2 Sep 24, 2019
0.3.1 Sep 16, 2019
0.3.0 Jun 29, 2019
0.2.3 Jun 13, 2019
0.0.0 Oct 2, 2018

#3 in Game dev

Download history 559/week @ 2020-05-30 536/week @ 2020-06-06 527/week @ 2020-06-13 445/week @ 2020-06-20 446/week @ 2020-06-27 479/week @ 2020-07-04 499/week @ 2020-07-11 583/week @ 2020-07-18 712/week @ 2020-07-25 1130/week @ 2020-08-01 1528/week @ 2020-08-08 1882/week @ 2020-08-15 1370/week @ 2020-08-22 1149/week @ 2020-08-29 1001/week @ 2020-09-05 700/week @ 2020-09-12

2,791 downloads per month
Used in 13 crates (5 directly)


4.5K SLoC


Build Status Latest Version docs.rs Join us on Discord MIT/Apache Lines of Code Coverage

Laminar is a semi-reliable UDP-based protocol for multiplayer games. This library implements wrappers around the UDP-protocol, and provides a lightweight, message-based interface which provides certain guarantees like reliability and ordering.

Laminar was designed to be used within the Amethyst game engine but is usable without it.

If you are new to laminar or networking in general, We strongly recommend taking a look at the laminar book


This library is loosely based off of Gaffer on Games and shares features similar as RakNet, Steam Socket, netcode.io. The idea is to provide an in rust written, low-level UDP-protocol which supports the use of cases of video games that require multiplayer features. The library itself provides a few low-level types of packets that provide different types of guarantees. The most basic are unreliable and reliable packets. Also ordering, sequencing can be done on multiple streams. For more information, read the projects README.md, book, docs or examples.

Table of contents:


These are the features this crate provides:

  • Fragmentation
  • Unreliable packets
  • Unreliable sequenced packets
  • Reliable unordered packets
  • Reliable ordered packets
  • Reliable sequenced packets
  • Fragmentation
  • Rtt estimations
  • Protocol version monitoring
  • Basic connection management
  • Heartbeat
  • Basic DoS mitigation
  • High Timing control
  • Protocol Versioning
  • Well-tested by integration and unit tests
  • Can be used by multiple threads (Sender, Receiver)


  • Handshake Protocol
  • Advanced Connection Management
  • Cryptography
  • Congestion Control

Getting Stated

Add the laminar package to your Cargo.toml file.

laminar = "0.3"

Useful Links


Please check out our examples for more information.

UDP API | see more

This is an example of how to use the UDP API.

Send packets

use laminar::{Socket, Packet};

// create the socket
let mut socket = Socket::bind("")?;
let packet_sender = socket.get_packet_sender();
// this will start the socket, which will start a poll mechanism to receive and send messages.
let _thread = thread::spawn(move || socket.start_polling());

// our data
let bytes = vec![...];

// You can create packets with different reliabilities
let unreliable = Packet::unreliable(destination, bytes);
let reliable = Packet::reliable_unordered(destination, bytes);

// We can specify on which stream and how to order our packets, checkout our book and documentation for more information
let unreliable = Packet::unreliable_sequenced(destination, bytes, Some(1));
let reliable_sequenced = Packet::reliable_sequenced(destination, bytes, Some(2));
let reliable_ordered = Packet::reliable_ordered(destination, bytes, Some(3));

// send the created packets

Receive Packets

use laminar::{SocketEvent, Socket};

// create the socket
let socket = Socket::bind("")?;
let event_receiver = socket.get_event_receiver();
// this will start the socket, which will start a poll mechanism to receive and send messages.
let _thread = thread::spawn(move || socket.start_polling());

// wait until a socket event occurs
let result = event_receiver.recv();

match result {
    Ok(socket_event) => {
        match  socket_event {
            SocketEvent::Packet(packet) => {
                let endpoint: SocketAddr = packet.addr();
                let received_data: &[u8] = packet.payload();
            SocketEvent::Connect(connect_event) => { /* a client connected */ },
            SocketEvent::Timeout(timeout_event) => { /* a client timed out */},
    Err(e) => {
        println!("Something went wrong when receiving, error: {:?}", e);



This library is not fully stable yet, and there may be breaking changes to the API. For more advanced examples of using laminar, you can check out the Amethyst-Network crate.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


Licensed under either of


~27K SLoC