ValveSoftware /GameNetworkingSockets

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

★ 10,029⑂ 771👁 284⑃ 126● 266▤ 10
C++Created 2018-03-22
TA的项目
10,029
stars
+0+6+58
771
forks
284
watchers
126
prs
266
issues
10
releases
–
discussions

README

GameNetworkingSockets
     

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.
   ISteamNetworkingSockets is the
    most important interface.
   steamnetworkingtypes.h has misc
    types and declarations.
 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

Snapshot: 2026-11-04T14:00:00Z · Data license Apache-2.0 · JSON