LearnBitcoin

Bitcoin Dev Archive 2012

Adding a pong message

4 messages, 13 Mar 2012. Started by Mike Hearn.

Mike Hearn (2), Luke Dashjr, Matt Corallo

Permalink Original thread on gnusha.org

Mike Hearn permalink original

https://github.com/bitcoin/bitcoin/pull/932 adds a "pong" message that echoes back a 64 bit nonce contained in the ping, if the protocol version is new enough.

The goal of this is to make it easier for clients, especially mobile clients, to quickly check if a connection is stale, and also to see if a remote node is overloaded so we can avoid talking to it. A common case where this happens is if the remote node is itself downloading the block chain or doing something equally intensive.

Any objections?

Luke Dashjr in reply to Mike Hearn permalink original

On Tuesday, March 13, 2012 2:06:38 PM Mike Hearn wrote:

Quoted text (11 lines)
> https://github.com/bitcoin/bitcoin/pull/932 adds a "pong" message that
> echoes back a 64 bit nonce contained in the ping, if the protocol
> version is new enough.
>
> The goal of this is to make it easier for clients, especially mobile
> clients, to quickly check if a connection is stale, and also to see if
> a remote node is overloaded so we can avoid talking to it. A common
> case where this happens is if the remote node is itself downloading
> the block chain or doing something equally intensive.
>
> Any objections?

Not really an objection per se, but what's wrong with TCP keepalives?

Matt Corallo in reply to Luke Dashjr permalink original

On Tue, 2012-03-13 at 14:45 -0400, Luke-Jr wrote:

Quoted text (15 lines)
> On Tuesday, March 13, 2012 2:06:38 PM Mike Hearn wrote:
> > https://github.com/bitcoin/bitcoin/pull/932 adds a "pong" message that
> > echoes back a 64 bit nonce contained in the ping, if the protocol
> > version is new enough.
> >
> > The goal of this is to make it easier for clients, especially mobile
> > clients, to quickly check if a connection is stale, and also to see if
> > a remote node is overloaded so we can avoid talking to it. A common
> > case where this happens is if the remote node is itself downloading
> > the block chain or doing something equally intensive.
> >
> > Any objections?
>
> Not really an objection per se, but what's wrong with TCP keepalives?
>

It wont tell you if the node itself is overloaded (not just the OS' network stack).

Looks good to me.

Matt

Mike Hearn in reply to Luke Dashjr permalink original

TCP keep-alives aren't reliably implemented.

I've got reports that sometimes we struggle to keep connection to the network on mobile, eg, because we roam into an area with poor connectivity but not poor enough for the network stack to drop access entirely. Being able to quickly check if the connection is really there with some kind of bounded, app layer deadline is probably useful and besides, it's cheap.