skip to content

networking

tinynet

a low-latency multiplayer networking stack built from scratch in c++20 on non-blocking udp.

timeline
aug 2026 — present
stack
c++20, udp, posix sockets

why build it

multiplayer games can’t wait for tcp to retransmit a lost packet. tinynet is a networking stack built directly on non-blocking udp, to understand from the ground up how reliability and ordering are layered on an unreliable transport.

foundations

a custom socket abstraction wraps posix sockets, and an endian-safe binary serialization layer keeps packets consistent across machines.

reliability without tcp

every packet carries a 16-byte protocol header. sequencing and selective acknowledgement use remote acks and a 32-bit ack bitfield, so one packet can acknowledge the 32 before it. fixed-size ring buffers track packets in constant time.

each ack carries the newest sequence number and 32 bits for the ones before it. a gap in those bits is how the sender learns a packet was lost. hover a number to trace it through every row.

an animation of packets moving from a sender to a receiver while acknowledgements move back. packets that will be lost are shown in red and fall off the lane. the receiver's ack field shows the newest sequence number received and a row of 32 bits for the packets before it; a dropped packet appears there as a gap, every later ack repeats that gap, and the sender marks the packet lost when one of those acks arrives.

try dropping a packet, or click one in flight. the receiver’s field keeps a hole where it should be, every later ack repeats that hole, and the sender only needs one of those acks to mark the packet lost.

connection lifecycle

on top of that sit protocol validation, rtt smoothing, packet-loss detection, and timeout-driven connection management.

testing

unit tests cover serialization, and client–server integration tests cover transport behaviour.