Lightweight Peer-to-Peer networking engine for real time applications

Overview

Build Status PayPal donate button Bitcoin donate button

Club

A lightweight Peer-to-Peer networking engine for real time applications written in C++14.

Motivation

Real time applications such as Online games, VoIP, Instant Messaging or Videoconference apps need a way to communicate and synchronize state among interested peers. The traditional way of doing so is to have a dedicated server that receives commands from clients while assigning an implicit order (order in which messages are received) to those commands.

Such centralized structure is relatively easy to implement and works great for many aplications, but comes with drawbacks in the form of server bandwidth, maintenance and attack protection costs. This renders the centralized approach infeasible for applications with a smaller budget.

On the other hand, decentralization adds another layers of complexity on top of already complex matter. There are problems such as not every node can connect to every other node directly, packets from different sources may be received by other nodes in different order, and in cases of network partition, there is no central authority that says who is in the game and who is not.

Club implements solutions to such problems and hides this complexity behind a simple to use API.

Dependencies

  • Cmake (version >= 3.2)
  • Decent C++14 compiler. Tested on g++5.4
  • Boost (version >= 1.58)

Build & run

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release
# To make everything (the library, tests, benchmark and a demo) run
# make without arguments. Alternatively use these targets:
#  club                  : Builds the libclub.a library
#  club-tests            : Builds tests
#  transport-speed-bench : Builds a not-so-complete transport benchmark
#  rendezvous-server     : Builds the rendezvous server
make

Run tests

# The stun_client test expects stun servers (not part of Club) to run on localhost.
stunserver --primaryport=3478 &
stunserver --primaryport=3480 &
stunserver --primaryport=3482 &
stunserver --primaryport=3484 &
stunserver --primaryport=3486 &
./club-tests --run_test="*" --log_level=test_suite

Run chat demo

To run the club-chat demo, invoke ./club-chat from multiple teminals. The terminals need not be on the same PC nor LAN but the app does need an internet acess.

API Description

There are essentially only two classes that developers need to know about: Socket and Hub. Socket can be seen as a cross between the traditional TCP and UDP socket, in that it is connection oriented, provides both reliable and unreliable message delivery and congestion control.

Hub is an interface to the network of connected nodes. It provides an interface to send messages and merge networks together. Hub currently provides two types of send operations.

  • unreliable broadcast - fast - can be used e.g. for sending player position updates or voice data.
  • reliable-totally-ordered (RTO) broadcast - slow - to make decisions about a global state. E.g. in games: is a particular switch on or off, who is the owner of an item,...

The total-order property makes this guarantee: If a node received a message M1 before a message M2, then every node that received both of those messages shall receive them in the same order.

Demos

  • club-chat - A simple CLI chat application. Demonstrates how to merge networks and send RTO broadcast.
  • sicoop - A silly coop multiplayer game for Android phones where Club can be seen in action.

Features

  • Network membership consensus - Information about who is in the network is also totally ordered
  • Implicit packet routing - Full graph topology is not necessary
  • Totally ordered reliable message broadcast
  • Fast unreliable broadcast
  • NAT traversal through UDP hole punching
  • Implicit full graph formation - TODO
  • STUN client - See implementation and tests
  • LEBDAT congestion control for low latency message transmission
  • Small number of dependencies
  • Rendezvous server - A simple server where nodes find each other.
Issues
  • reserved identifier violation

    reserved identifier violation

    opened by elfring 3
  • Duplicate copy constructors for binary::decode and binary::encode

    Duplicate copy constructors for binary::decode and binary::encode

    MSVC trips up here giving a warning that there are duplicate copy constructors for both decode and encode.

    decoder(const decoder&); decoder(decoder&);

    inline decoder::decoder(const decoder& d) : _was_error(d._was_error) { _current.begin = d._current.begin; _current.end = d._current.end; }

    inline decoder::decoder(decoder& d) : _was_error(d._was_error) { _current.begin = d._current.begin; _current.end = d._current.end; } They are identical so we can remove the non-const versions-- and the problem goes away

    EDIT: I see why you were doing this-- the compiler is invoking the wrong copy constructor in encode(encode), and calling the Sequence instead..

    Guess the only solution is to disable this warning.

    opened by Niadb 0
  • .template

    .template

    There are a number of places in the code that use syntax such as..

    e.template put(mid.timestamp);

    This does not compile on MSVC(vs2017 with C++14 enabled), the compiler does not understand this syntax

    I removed the .template and does compile--

    e.put(mid.timestamp);

    opened by Niadb 0
Owner
Peter
Peter
Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Filament Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows, and WebGL. It is designed to be as small a

Google 14.4k Aug 11, 2022
My first Real-Time 3D Game Engine learning project written in C++.

EyeEngine-Cpp FOA, sry for my poor English. What is Eye Engine? Eye Engine is my first Real-Time 3D Game Engine learning project. There are two editio

F-seeeye 5 Apr 6, 2022
Improved version of real-time physics engine that couples FEM-based deformables and rigid body dynamics

Enhanced version of coupled FEM and constrained rigid body simulation Description This little playground aimed to test our Conjugate Gradients based M

Andrey Voroshilov 25 Apr 11, 2022
Real-time oriented physics engine and library that's currently best suited for 2D games.

PlayRho A way to play with physical behaviors like the conservation of momentum. PlayRho is a real-time oriented physics engine and library that's cur

Louis Langholtz 87 Jul 29, 2022
Real-time 2D fluid simulator with lots of visualization options.

Fluid Simulator Building Start by cloning the program and all submodules using the following command: git clone --recursive https://github.com/linusmo

Linus Mossberg 26 Jun 20, 2022
Analytics In Real-time (AIR) is a light-weight system profiling tool

Analytics In Real-time Analytics In Real-time (AIR) is a light-weight system profiling tool that provides a set of APIs for profiling performance, lat

null 2 Mar 3, 2022
Final Assignment for Embedded Real Time Operating Systems at UCSD Extension.

Final Assignment for Embedded Real Time Operating Systems at UCSD Extension. This program is for a certificate in Embedded Software Engineering at UCSD. We used FreeRTOS running on a STM32L475G Microcontroller.

Max Guerrero 2 Jun 26, 2022
Real-time application of DIVeR

DIVeR: Real-time CUDA Application This repo contains the code for the real-time application of DIVeR implemented in Python+CUDA. Setup python 3.8 pyto

null 40 Jul 19, 2022
A proof-of-oncept module adding real-time Wren support to Godot

Godot Wren Module This module adds a new node, called WrenManager, that allows for executing Wren code in Godot during runtime! Wren is a cool lightwe

null 3 Nov 28, 2021
Real-time tractogram computer and visualizer

Dependencies CMake (min version 3.15) libzip QT6 VTK 9.1 ACVD* (https://github.com/valette/ACVD) Trekker* (https://github.com/dmritrekker/trekker) *AC

Dogu Baran Aydogan 13 Aug 8, 2022
tiny_csg is a C++ library that generates meshes from brush-based level data and supports incremental updates (real-time CSG).

tiny_csg is a C++ library that generates meshes from brush-based level data and supports incremental updates (real-time CSG). It is intended to be used as a backend in 3d level editors and/or generators.

Luka Aleksić 28 Jul 14, 2022
An easy to build CO2 Monitor/Meter with Android and iOS App for real time visualization and charting of air data, data logger, a variety of communication options (BLE, WIFI, MQTT, ESP-Now) and many supported sensors.

CO2-Gadget An easy to build CO2 Monitor/Meter with cell phone App for real time visualization and charting of air data, datalogger, a variety of commu

Mariete 22 Aug 5, 2022
Real Time, High performance BOT detection and protection

REAL-TIME BOT PROTECTION CHALLENGE IronFox https://innovera.ir IronFox is a real-time and high performance bot protection, that using Nginx as a reve

Khalegh Salehi 3 Jun 5, 2022
This repository provides the implementation of a ADC real-time viewer for an analog sound sensor.

Real-time sound analysing using microcontroller FRDM-KL25Z Acest cod este realizat pentru o platforma autonoma realizata cu kitul de la NXP care are r

null 5 Jan 20, 2022
Flutter real-time magnifying glass lens widget with Barrel/Pincushion distortion

MagnifyingGlass Flutter plugin Flutter real-time magnifying glass lens widget with Barrel/Pincushion distortion. Works on Android, iOS and desktop. Do

Marco Bavagnoli 9 Apr 26, 2022
TencentOS tiny is a real-time operating system developed by Tencent for the Internet of Things

TencentOS tiny is a real-time operating system developed by Tencent for the Internet of Things. It features low power consumption, low resource consumption, modularity, security and reliability, and can effectively improve the development efficiency of IoT terminal products.

OpenAtomFoundation 5.6k Aug 9, 2022
Fugu/fg is a system for procedurally generating animated geometric forms in real-time

Fugu/fg is a system for procedurally generating animated geometric forms in real-time. Fugu can be downloaded from http://bp.io/fugu, an online refere

Benjamin Porter 1 Sep 18, 2019
Real-Time Rendering with Lighting Grid Hierarchy I3D 2019 Demo

Real-Time Rendering with Lighting Grid Hierarchy I3D 2019 Demo Daqi Lin This demo is for the I3D 2019 paper Real-Time Rendering with Lighting Grid Hie

Lin Daqi 109 Jul 23, 2022