Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to peers in obtained from bittorrent

Tags:

bittorrent

nat

I'm looking to build a bittorrent client in Ruby (although language is not important over here).

I read a BEP specification which says querying at /announce (without DHT support) to tracker would give a list of peers currently connected for a given info-hash.

To examine this. I created a torrent file and I found that tracker return the IP of my machine along with the port (which i confirmed is the running port of Bittorrent client on my machine i.e Utorrent)

But here is the problem the Peers info returned the IP of my ISP i.e 111.125.209.41 (the public facing IP since I'm behind the NAT).

Now I cant connect (via TCP) to the Process running on my machine with the public facing IP of my ISP.

Can anyone suggest how does bitorrent work on this and what should I do to solve this.

It could that over UDP Bittorrent would be using UDP hold punching not sure what happen on TCP.

like image 233
Ratatouille Avatar asked May 17 '17 11:05

Ratatouille


1 Answers

There are two separate concerns.

  1. How do peers on the internet (aka 99.99999% of the world) connect to your NATed node
  2. How do peers inside your network connect to a node on the same network.

The first is achieved by various nat traversal methods, including negotiating with the nat device or manually configuring it.

The second issue either requires a router capable of hairpin routing in combination with a forwarded port or local peers discovering the internal address through other means, such as LSD.

like image 59
the8472 Avatar answered Jan 04 '23 06:01

the8472