Giter Club home page Giter Club logo

rmnp's Introduction

RMNP - Realtime Multiplayer Networking Protocol

RMNP aims to combine all the advantages of TCP and the speed of UDP in order to be fast enough to support modern realtime games like first person shooters. It is basically an extension for UDP.

Features

  • Connections (with timeouts and ping calculation)
  • Error detection
  • Small overhead (max 15 bytes for header)
  • Simple congestion control (avoids flooding nodes between sender/receiver)
  • Optional reliable and ordered packet delivery

How it works

The bad thing about TCP is that once a packet is dropped it stops sending all other packets until the missing one is delivered. This can be a huge problem for games that are time sensitive because it is not uncommon for devices to encounter packet-loss. Therefore RMNP facilitates UDP to guarantee fast delivery without any restrictions. Because UDP is stateless RMNP implements an easy way to handle connection and to distinguish between "connected" clients. Every packet contains a small header mainly containing a CRC32 hash to ensure that all received packets were transmitted correctly.

To guarantee reliability the receiver sends acknowledgment packets back to tell the sender which packets it received. The sender resends each packet until it received an acknowledgment or the maximum timeout is reached. Because of that RMNP is not 100% reliable but it can be assumed that a packet will be delivered unless a client has a packet-loss of about 100% for a couple seconds.

Getting started

Installation

go get github.com/obsilp/rmnp

Basic Server

Example Pong Server

package main

import "github.com/obsilp/rmnp"

func main() {
	server := rmnp.NewServer(":10001")
	server.Start() // non-blocking

	// other code ...
}

Basic Client

Example Ping Client

package main

import "github.com/obsilp/rmnp"

func main() {
	client := rmnp.NewClient("127.0.0.1:10001")
	client.Connect() // non-blocking

	// other code ...
}

Callbacks

Events and received packets can be received by setting callbacks. Look at the respective classes for more information.

Client callbacks | Server callbacks

Send types

  • Unreliable - Fast delivery without any guarantee on arrival or order
  • Unreliable Ordered - Same as unreliable but only the most recent packet is accepted
  • Reliable - Packets are guaranteed to arrive but not in order
  • Reliable Ordered - Packets are guaranteed to arrive in order

Ports

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

rmnp's People

Contributors

sonarbeserk avatar

Watchers

 avatar  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.