[bittorrent] Connecting tp Peers Via TCP Handshake

Brian Dessent brian at dessent.net
Mon May 8 17:08:01 EDT 2006

> Sebastian Hellmann wrote:

> I'm implementing a tool to gahter statistic data about the
> bittorrent-network. ( it's a student project)
> My problem  is to connect to a peer via TCP.
> The trackers I connect to only anwers in compact mode and so i don't
> get the peerID. The specs on bittorrent.org says that the handshake
> requires the peerID
> to authenticate the peer: "If the receiving side's peer id doesn't
> match the one the initiating side expects, it severs the connection."
> First I thought I would get the peer id by using the DHT protocol to
> connect to the ip's I get from the tracker as nodes an send a get_peer
> request but this also returns only ips ( and ports) in compact mode?
> is there a way to connect to peers without the id ? i found nothing in
> the spec and on other sites.

I think you're reading too much into that.  As the initiating side, you
don't have the remote's peer_id, so you can't validate it.  This means
that the sentence just doesn't apply.  You connect to the peer and as
long as the two of you exchange the same info_hash everything's fine.

As you've seen most trackers these days use exclusively compact mode to
save bandwidth, and so the peer_id presented by one peer to the other is
mostly just a formality and doesn't serve much of a purpose.  It does
allow for fingerprinting the type and version of client used, though.


More information about the BitTorrent mailing list