Skip to content

Implement generic incoming UDP packet rate limiter (Issue #17) - #450

Open
FouL06 wants to merge 1 commit into
ValveSoftware:masterfrom
FouL06:recv-packet-rate-limit
Open

FouL06 wants to merge 1 commit into
ValveSoftware:masterfrom
FouL06:recv-packet-rate-limit

Conversation

@FouL06

@FouL06 FouL06 commented Oct 14, 2026

Copy link
Copy Markdown

Resolves #17

Implements a generic incoming packet rate limiter for direct UDP connections using TokenBucketRateLimiter, protecting basic UDP connections against packet flooding and DoS attacks.

Overview

  • include/steam/steamnetworkingtypes.h / src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp:
    • Added connection-level configuration values:
      • k_ESteamNetworkingConfig_RecvRateLimit_PacketRate: Steady-state rate in packets/sec (default 0 = disabled).
      • k_ESteamNetworkingConfig_RecvRateLimit_PacketBurst: Max burst allowed (default 0 = defaults capacity to RecvRateLimit_PacketRate).
  • src/steamnetworkingsockets/clientlib/steamnetworkingsockets_udp.h / steamnetworkingsockets_udp.cpp:
    • Added m_rateLimiterRecvPackets to CConnectionTransportUDPBase.
    • Rate limiting is enforced in Received_Data() immediately following cryptographic validation (DecryptDataChunk()). This ensures unauthenticated or spoofed packets fail decryption and cannot consume tokens of legitimate peers.
  • tests/test_connection.cpp:
    • Added Test_recv_rate_limit and registered in suite-quick.
    • Validates that bursts beyond the limit are dropped, and subsequent packets succeed once tokens replenish after a pause.
  • Verified cleanly with ./build/bin/test_connection suite-quick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add general rate limit

1 participant