Home > Specs > BitTorrent > DHT
Announce Peer
The purpose if this message is to put ourselves into the remote node's peer database for a particular torrent info hash ID. We must have already done a get peers query to the remote node to obtain a special token.
The announce 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
announce_peer
to indicate this is an announce query.
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:
info_hash
The value should be set to the 20-byte info hash ID that we are announcing.
token
This is the string token obtained in the
Get Peers query.
port
This is our incoming connection port for torrent peers.
implied_port
If this optional key is present, and set to the integer
1
, the
port
key will be ignored, and the source port for this query will be used.
id
The value should be set to the 20-byte local node ID.
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.