• Stars
    star
    7,681
  • Rank 4,693 (Top 0.1 %)
  • Language
    C++
  • License
    BSD 3-Clause "New...
  • Created about 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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
  • Head-of-line blocking control and bandwidth sharing of multiple message streams ("lanes") on the same connection. You can use strict priority values, softer weight values that control how bandwidth is shared, or some combination of the two methods. See ISteamNetworkingSockets::ConfigureConnectionLanes.
  • 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
  • Cross platform. This library has shipped on consoles, mobile platforms, and non-Steam stores, and has been used to facilitate cross-platform connectivity. Contact us to get access to the code. (We are not allowed to distribute it here.)

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 access the additional services provided by the Steam Datagram Relay network. On other platforms and stores, as long as you ship a version of your game on Steam, you might be able to take advantage of these services. See the Steamworks documentation for more information. Because this is a live service, and we need to control our security and backward compatibility burden, at this time we are not able to offer access to SDR on other platforms to all partners.

If you aren't a Steam partner, or don't have a version of your game on Steam, then use this opensource version of the API and take advantage of the permissive license to do whatever you want. We want you to take maximum advantage of the features in the Steamworks version. That won't happen if this API is a weird "wart" that's hidden behind #ifdef STEAM, which is why we're making this opensource version available.

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.

Security

Did you find a security vulnerability? Please inform us responsibly; you may be eligible for a bug bounty. See the security policy for more information.

More Repositories

1

Proton

Compatibility tool for Steam Play based on Wine and additional components
C++
22,477
star
2

openvr

OpenVR SDK
C++
5,946
star
3

steam-for-linux

Issue tracking for the Steam for Linux beta client
4,034
star
4

source-sdk-2013

The 2013 edition of the Source SDK
C++
3,591
star
5

halflife

Half-Life 1 engine based games
C++
2,971
star
6

steam-audio

Steam Audio
C++
2,055
star
7

ToGL

Direct3D to OpenGL abstraction layer
C++
2,009
star
8

SteamOS

SteamOS community tracker
1,465
star
9

vogl

OpenGL capture / playback debugger.
C++
1,415
star
10

Dota2-Gameplay

Public Bug Tracker for Dota2
1,388
star
11

steam-runtime

A runtime environment for Steam applications
Shell
1,133
star
12

wine

Wine with a bit of extra spice
C
1,093
star
13

steamvr_unity_plugin

SteamVR Unity Plugin - Documentation at: https://valvesoftware.github.io/steamvr_unity_plugin/
C#
1,010
star
14

SteamVR-for-Linux

Issue tracker for the Linux port of SteamVR
901
star
15

csgo-osx-linux

Counter-Strike: Global Offensive
750
star
16

Source-1-Games

Source 1 based games such as TF2 and Counter-Strike: Source
572
star
17

Fossilize

A serialization format for various persistent Vulkan object types.
C++
510
star
18

IndexHardware

474
star
19

csgo-demoinfo

CS:GO demo parsing tool
C++
472
star
20

Dota-2

Tracker for issues specific to Linux and Mac in the Reborn client. If you have a general issue or non-system-specific feature request please go to dev.dota2.com
454
star
21

steamlink-sdk

450
star
22

counter-strike

CS:GO
JavaScript
430
star
23

steamos_kernel

SteamOS kernel branches
C
388
star
24

dxvk

dxvk tree containing branches used by Proton
C++
342
star
25

unity-xr-plugin

OpenVR plugin for Unity's XR API
C#
298
star
26

ArtifactDeckCode

Reference code and documentation for Artifact deck codes
PHP
276
star
27

the_lab_renderer

Valve’s VR renderer used in The Lab (Valve’s VR launch title for the HTC Vive).
C#
272
star
28

voglperf

Benchmarking tool for Linux OpenGL games. Spews frame information, logs frametimes.
C
198
star
29

steamvr_unreal_plugin

SteamVR Input Unreal Plugin - Documentation at: https://github.com/ValveSoftware/steamvr_unreal_plugin/wiki Sample project (UE4.15-4.23): https://github.com/ValveSoftware/steamvr_unreal_plugin/wiki/sample/SteamVRInputPlugin.zip Sample Project (UE.424+): https://github.com/ValveSoftware/steamvr_unreal_plugin/wiki/sample/SteamVRInputPlugin_UEIntegrated.7z
C++
164
star
30

steamos_mesa

Patched branches of Mesa used in SteamOS
C
157
star
31

Moondust

C#
155
star
32

portal2

Issues for the Linux port of Portal 2
136
star
33

steamworks-vr-api

Source for the Steamworks VR API
136
star
34

steam-devices

List of devices Steam and SteamVR will want read/write permissions on, to help downstream distributions create udev rules/etc
128
star
35

vkd3d

C
120
star
36

steamos-compositor

SteamOS session compositing window manager
C
109
star
37

driver_hydra

OpenVR Driver for Razer Hydra using Sixense SDK
C++
99
star
38

Dota-2-Vulkan

Tracker for issues specific to the Vulkan version of Dota 2 on Windows, Linux, and macOS
93
star
39

virtual_display

An example OpenVR driver for demonstrating the IVRVirtualDisplay interface.
C++
80
star
40

openxr_engine_plugins

Contains Valve-provided plugins for using OpenXR extensions with various game engines
Mathematica
46
star
41

linux

SteamOS fork of the Debian kernel packaging repository at https://anonscm.debian.org/git/kernel/linux.git/
45
star
42

eigen

Fork of Eigen release version 3.4. Adds ability to use alternate threading systems from Open MP.
C++
22
star
43

Dota-Underlords

Tracker for issues specific to the Linux and macOS client of Dota Underlords
22
star
44

OpenXR-Canonical-Pose-Tool

A tool to help OpenXR runtime developers match their poses to other runtimes' poses.
C
10
star
45

VR-Community-Bugs

Repository for VR Bugs reported through tickets and community outreach
9
star