Home > Specs > BitTorrent > DHT
Ping

The purpose of this message is to check if the remote node is online.  It is used for maintaining the node table.

Query


The ping query is sent as a plain BEncoded map, in a single UDP packet.  It has the following keys:

y
Set the value of this key to the string q because this is a query.

q
Set the value of this to the string ping to indicate this is a ping.

t
Set the value of this to a random 4-byte transaction ID.

a
This value is an inner map that represents the query arguments.  It contains the following keys:

id
The value should be set to the 20-byte local node ID.

Response


The ping response is also a plain BEncoded map, in a single UDP packet.  It has the following keys:

y
Set the value of this key to the string r because this is a response.

t
Set the value of this to the transaction ID from the original query that we are responding to.

r
This value is an inner map that represents the response to the query.  It contains the following keys:

id
The value should be set to the 20-byte node ID of the responding node.


This web site is powered by Super Simple Server