10

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.

Ratatouille
  • 1,372
  • 5
  • 23
  • 50
  • This is why many BitTorrent clients recommend some sort of port forwarding. In addition, seeding clients will usually actively connect out to other clients, though this cannot happen if both are behind a NAT. – Tyzoid May 17 '17 at 12:01
  • What is your actual issue, reachability from the outside or from the inside of your home network? If it's from the inside of your network then it is of less concern to bittorrent since most peers will have the outside view. – the8472 May 17 '17 at 18:06
  • @the8472 well its both inside and outside first how would i connect to an outside peer which is behind the NAT and if that can be answered i guess then inside one is self explanatory as in how the peer from outside connect to my torrent server which is behind the NAT. – Ratatouille May 21 '17 at 02:45
  • Have you considered building a private tracker that operates inside your NAT? If all devices are behind the NAT, the tracker should be able to use the internal IPs. – Tyzoid May 23 '17 at 03:17
  • @Tyzoid point I'm trying to understand how to build a minimistic Bitorrent Client (that support Public ) – Ratatouille May 24 '17 at 14:48

1 Answers1

2

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.

the8472
  • 40,999
  • 5
  • 70
  • 122