Repository navigation
Description
Currently, active peers heartbeat with each other every 2 seconds.
(@danderson and I had discussed this and considered several options; the overall constraint is we want to only ever be without a network connection for 5 seconds max, before failing back to DERP, so we need a heartbeat at least half that, ideally.)
Unfortunately, every 2 seconds is in both directions, and each ping also involves a pong.
So every 2 seconds:
srv: 8.9M/0.0M magicsock: disco: d:de3ee729b55e7f2f<-d:c9b9fc10e4b34938 ([MINwg], 167.71.156.251:41641) got ping tx=0ada6c80d510
srv: 8.9M/0.0M magicsock: disco: d:de3ee729b55e7f2f->d:c9b9fc10e4b34938 ([MINwg], 167.71.156.251:41641) sent pong tx=0ada6c80d510
srv: 8.9M/0.0M magicsock: disco: d:de3ee729b55e7f2f->d:c9b9fc10e4b34938 ([MINwg], 167.71.156.251:41641) sent ping tx=764870a09f60
srv: 8.9M/0.0M magicsock: disco: d:de3ee729b55e7f2f<-d:c9b9fc10e4b34938 ([MINwg], 167.71.156.251:41641) got pong tx=764870a09f60 latency=23ms pong.src=209.180.207.193:49249
Which works out to 2 packets per second.
I think we can get that down to 1/4 that.
We can have a bit in the Ping frame that says "I'm a heartbeat ping, no need to reply right away." (a ping frame used for health, not latency). Then the response Pong can both say 1) how long it was delay (so the pinger can still compute pretty accurate ping time, less the delay time), and 2), can carry its own Ping challenge for its direction along with the Pong response.
Then we'd be back down to just 1 packet every 2 seconds, with the pings from each direction 1 second out of phase.
Alternatively, we do something like elect the lexicographically lesser disco endpoint as the heartbeat pinger and only ping in one direction. The ponger then just trusts the path if it got pings from it. That optimization would only come into play when the path is symmetric, which I imagine it is almost always (I haven't analyzed logs yet, but it seems to be).
Activity
DentonGentry commentedon Feb 8, 2021
I think this is done in 1.4.
bradfitz commentedon Feb 8, 2021
This is a different optimization.
DentonGentry commentedon Oct 13, 2021
Related:
corp PR 2874 suppressed sending certain map poll updates to mobile clients
Tailscale 1.16 disabled TCP keepalives
DentonGentry commentedon Dec 18, 2021
There is more to be done about radio management to reduce power consumption, but do we believe that 1.16 did enough about heartbeat ping to consider this part done?
bradfitz commentedon Dec 18, 2021
No, this should stay open.
wgengine/magicsock: reduce disco ping heartbeat aggressiveness a bit
wgengine/magicsock: reduce disco ping heartbeat aggressiveness a bit
[-]Reduce heartbeat ping rate[/-][+]Remove magicsock heartbeat pings entirely[/+]bradfitz commentedon Sep 16, 2022
Update: the plan is to remove the heartbeats entirely. Magicsock should never transmit unless it has something to transmit anyway, in which case it can send an extra disco packet(s) at that time (or shortly thereafter).
After certain time cliffs, confidence of a NAT-traversed path decrease (e.g. after 15 or 30 or 60 seconds: might've hit a UDP NAT mapping timeout) so at that point we can switch doing concurrent DERP + copy of packet directly over UDP (hope for the best) + disco refresh.
{tailcfg,wgengine}: add client flag and envknob to disable heartbeat
{tailcfg,wgengine}: add client flag and envknob to disable heartbeat
28 remaining items
wgengine/magicsock: move trustBestAddrUntil forward on non-disco rx
wgengine/magicsock: move trustBestAddrUntil forward on non-disco rx (#…
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime
wgengine/magicsock: implement probing of UDP path lifetime (#10844)
N (#4)
wgengine/magicsock: implement probing of UDP path lifetime (tailscale…