Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable transport layer SACKs (for node-datachannel) #247

Closed
reececomo opened this issue Feb 7, 2023 · 4 comments
Closed

Configurable transport layer SACKs (for node-datachannel) #247

reececomo opened this issue Feb 7, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@reececomo
Copy link

Summary

When sending packets @ 60Hz from Chrome, our Geckos.io server is responding at the transport layer ~40Hz, at about 107 bytes each.

  • Presumably these are SCTP SACKs (see libdatachannel/sctptransport.cpp#L135).
  • As we're going for unordered, unreliable - is it possible to reduce that rate (or eliminate entirely)?
  • Chrome also responds to server sends, but at roughly half the receive rate. i.e. 30 SACKs @ 60Hz, or 15 SACKs @ 30Hz. Also 107 bytes each.

Configuring delayedSackTime?

There's a comment in node-datachannel with settings to increase the SACK delay window via delayedSackTime=, see murat-dogan/node-datachannel#34 (comment) - although I'm a little out of my depth here. Based on the comments in libdatachannel it looks like they've increased the default delay from 200ms to 20ms.

Example chrome://webrtc-internals/ output:

transport-snippet

@yandeu yandeu added enhancement New feature or request help wanted Extra attention is needed labels Oct 3, 2023
@reececomo
Copy link
Author

reececomo commented Jan 29, 2024

Edit: See #247 (comment), probably don't do this.

Turns out its as easy as setting:

import * as NodeDataChannel from "node-datachannel";

// Force SCTP settings.
NodeDataChannel.setSctpSettings({
  delayedSackTime: 1_000,
});

In this example the server is sending at about ~29Hz:

Before:

The default SACK setting from libdatachannel adds a slight transport layer overhead of ~10 additional packets per second per client (39-43 recvs per second):

Screenshot 2024-01-29 at 11 45 52 pm

After:

Setting delayedSackTime arbitrarily high appears to drop that to a negligible amount. Here is the same connection running (28-31 recvs per second):

Screenshot 2024-01-29 at 11 29 48 pm

@reececomo
Copy link
Author

Edit: After hastily rolling this out to staging server I can now see, in fact, under real world conditions this absolutely wrecks net performance.

See the netgraphs below, latency variance / jitter goes to through the roof.

This could be because we're running a separate reliable datachannel on the same connection (SCTP settings apply to all channels), and that channels buffering frames block the main thread, etc.

Not going to spend too much time on this, just going to revert for now and assume libnodechannel knew what they were doing when they set their defaults 😆

@jebarpg
Copy link

jebarpg commented Jan 30, 2024

What tool were you using for the second network stream image? @reececomo

@reececomo
Copy link
Author

No tool unfortunately - it's just a lil debugging overlay we added 🙈

Stats log from the netcode wrapper into gameserverConnection.stats, and then are just dumped with PIXI.Graphics and PIXI.BitmapText into an overlay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants