Guideline on how to make it work for real torrents

Hi,

I’ve finished the challenge and it works correctly with the sample torrent and passes all the tests available.
However, it won’t work for any actual torrent file on the internet. I’m not asking about making it production-ready as I understand that it’s out of the scope of a simple learning material and indeed requires lots of time and investment to prepare something production-ready but simple guidelines on how to make it useable on actual files would help it, otherwise it feels like an incomplete project.

as an example, I’m facing 2 issues with real torrent files

  1. it’s not properly parsing torrent info for multifile torrents
  2. I can’t connect to any peer, always getting connection timeout, so probably some additional network magic is needed

It would be helpful to have simple guidelines on how those problems could be tackled for people who are interested to go beyond :slight_smile:
Very similar to optimization and download speed tips at the end of the project

Regards,
Arsen.

5 Likes

@ArsenAghajanyan Sorry for the delayed response. I’m not fully qualified to provide guidelines.

Just wanted to let you know that we’ve recently added a new extension, Magnet Links, to the BitTorrent challenge, which might be of interest to you!

Feel free to vote on how we should extend the BitTorrent challenge.

After a bit of tinkering I managed to get my implementation to download Ubuntu’s ISO.
I don’t know much more than you do but though I’d just share what I observed.
I have only tried this specific download, maybe if you were to try another file you would observe something entirely different.

The main thing I had to work on is tracking which pieces a peer has using the have and bitfield messages.
If you request a piece your peer does not have there is a good chance it will close your tcp connection.

The challenge implies that the flow of messages is

  1. Send interested
  2. Receive bitfield
  3. Get unchocked
  4. Request pieces

When in practice I have noticed the flow is:

  1. Peer optimistically unchokes me
  2. Send interested
  3. Peer periodically sends have messages to notify me a piece is available for download
  4. You can now request this piece that has been made available

Note there is no bitfield message.

In practice the download is very slow:

  • I don’t have many peers (sometimes only 1)
  • I don’t have a list of pieces to request so I’m stuck waiting for pieces to trickle through

Let me know if it helps or if you find anything on your end.

2 Likes

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.