GithubHelp home page GithubHelp logo

hhy5277 / gamenetworkingsockets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from valvesoftware/gamenetworkingsockets

0.0 1.0 0.0 13.38 MB

Reliable & unreliable messages over UDP. Robust message fragmentation & reassembly. P2P networking / NAT traversal. Encryption.

License: BSD 3-Clause "New" or "Revised" License

C++ 91.53% C 4.10% CMake 2.84% Shell 0.63% Python 0.65% Batchfile 0.01% Roff 0.24%

gamenetworkingsockets's Introduction

GameNetworkingSockets Build Status

GameNetworkingSockets is a basic transport layer for games. The features are:

  • Connection-oriented API (like TCP)
  • ... but message-oriented (like UDP), not stream-oriented.
  • Supports both reliable and unreliable message types
  • Messages can be larger than underlying MTU. The protocol performs fragmentation, reassembly, and retransmission for reliable messages.
  • A reliability layer significantly more sophisticated than a basic TCP-style sliding window. It is based on the "ack vector" model from DCCP (RFC 4340, section 11.4) and Google QUIC and discussed in the context of games by Glenn Fiedler. The basic idea is for the receiver to efficiently communicate to the sender the status of every packet number (whether or not a packet was received with that number). By remembering which segments were sent in each packet, the sender can deduce which segments need to be retransmitted.
  • Encryption. AES-GCM-256 per packet, Curve25519 for key exchange and cert signatures. The details for shared key derivation and per-packet IV are based on the design used by Google's QUIC protocol.
  • Tools for simulating packet latency/loss, and detailed stats measurement
  • IPv6 support
  • Peer-to-peer networking:
    • NAT traversal through google WebRTC's ICE implementation.
    • Plug in your own signaling service.
    • Unique "symmetric connect" mode.
    • ISteamNetworkingMessages is an interface designed to make it easy to port UDP-based code to P2P use cases. (By UDP-based, we mean non-connection-oriented code, where each time you send a packet, you specify the recipient's address.)
    • See README_P2P.md for more info

What it does not do:

  • Higher level serialization of entities, delta encoding of changed state variables, etc
  • Compression

Quick API overview

To get an idea of what the API is like, here are a few things to check out:

  • The include/steam folder has the public API headers.
  • The Steamworks SDK documentation offers web-based documentation for these APIs. Note that some features are only available on Steam, such as Steam's authentication service, signaling service, and the SDR relay service.
  • Look at these examples:
    • example_chat.cpp. Very simple client/server program using all reliable messages over ordinary IPv4.
    • test_p2p.cpp. Shows how to get two hosts to connect to each other using P2P connectivity. Also an example of how to write a signaling service plugin.

Building

See BUILDING for more information.

Language bindings

The library was written in C++, but there is also a plain C interface to facilitate binding to other languages.

Third party language bindings:

Why do I see "Steam" everywhere?

The main interface class is named SteamNetworkingSockets, and many files have "steam" in their name. But Steam is not needed. If you don't make games or aren't on Steam, feel free to use this code for whatever purpose you want.

The reason for "Steam" in the names is that this provides a subset of the functionality of the API with the same name in the Steamworks SDK. Our main reason for releasing this code is so that developers won't have any hesitation coding to the API in the Steamworks SDK. On Steam, you will link against the Steamworks version, and you can get the additional features there (access to the relay network). And on other platforms, you can use this version, which has the same names for everything, the same semantics, the same behavioural quirks. We want you to take maximum advantage of the features in the Steamworks version, and that won't happen if the Steam code is a weird "wart" that's hidden behind #ifdef STEAM.

The desire to match the Steamworks SDK also explains a somewhat anachronistic coding style and weird directory layout. This project is kept in sync with the Steam code here at Valve. When we extracted the code from the much larger codebase, we had to do some relatively gross hackery. The files in folders named tier0, tier1, vstdlib, common, etc have especially suffered trauma. Also if you see code that appears to have unnecessary layers of abstraction, it's probably because those layers are needed to support relayed connection types or some part of the Steamworks SDK.

gamenetworkingsockets's People

Contributors

aiusepsi avatar arseniyshestakov avatar bobsayshilol avatar cjhutchi avatar claushellsing avatar dedmen avatar elizagamedev avatar helloer avatar ienapliss avatar janisozaur avatar kkukshtel avatar lorry-lee avatar maximegmd avatar msinilo avatar nielsad avatar nxrighthere avatar poliwrath avatar seriouslynottom avatar silentbaws avatar superusercode avatar thelovinator1 avatar tycho avatar zcube avatar zpostfacto avatar

Watchers

 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.