Giter VIP home page Giter VIP logo

shorthair's Introduction

Shorthair Low-Latency Networking

Shorthair is a portable C++ library uses the Longhair library to provide low-latency loss-recovery, which uses extra bandwidth to make almost any unreliable packet channel suitable for real-time communication.

Erasure codes in software are fast with low-overhead.

Advantages of using erasure codes in online games:

  • 50% faster delivery over UDP than over TCP

  • 50% less bandwidth used than naive redundancy

  • 50% better recovery rate than parity redundancy

Improves the experience for multiplayer mobile apps.

Please take a look at my presentation on Erasure codes for more motivation: Erasure Codes in Software

Building: Quick Setup

The shorthair-mobile directory contains an easy-to-import set of C code that also builds properly for mobile devices and Windows-based computers.

API

This library is only available in C++ code, which you can wrap for your favorite language.

Your C++ code should have a class instance that derives from IShorthair and implements its interface:

	// Called with the latest data packet from remote host
	virtual void OnPacket(u8 *packet, int bytes);

	// Called with the latest OOB packet from remote host
	virtual void OnOOB(u8 *packet, int bytes);

	// Send raw data to remote host over UDP socket
	virtual void SendData(u8 *buffer, int bytes);

Thread-Safety

It is safe to call Send and SendOOB from any thread.

The same thread that calls Recv should also be calling Tick.

Features:

  • Uses fastest, smallest Reed-Solomon codec available (Longhair).
  • Full-duplex communication over a lossy channel.
  • Adds a dial to control packet loss to any acceptable rate for applications over UDP.
  • Calculates and generates precisely the amount of redundancy required to achieve the target loss rate.
  • It supports variable-length data packets.
  • Overhead is 5 bytes/packet.
  • Does not require multiple threads.
  • Library has a clean platform-independent interface with minimal configuration required.

Credits

This software was written entirely by myself ( Christopher A. Taylor [email protected] ). If you find it useful and would like to buy me a coffee, consider tipping.

shorthair's People

Contributors

chris-gc avatar catid avatar

Watchers

kevinswat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.