Occasionally trackers, DHT nodes, and PEX peers offer peer addresses with a port of 0. What does this mean? In the context of submitting one's own port to a tracker, or in DHT, sending a port of 0 means that the recipient should use the sender's apparent port, due to NAT or similar. But when receiving a list of possible peers for a torrent, how do you interpret a port of 0 then?
Asked
Active
Viewed 314 times
2 Answers
0
In the context of submitting one's own port to a tracker, or in DHT, sending a port of 0 means that the recipient should use the sender's apparent port
I am curious from which specification you're deriving that.
But when receiving a list of possible peers for a torrent, how do you interpret a port of 0 then?
Have you considered that it simply might be bogus data, not sanitized by the sender?
Rejecting port zero is not a requirement, since it's technically a valid port (although in practice not really usable) and even if it were you cannot rely on others to sanitize data for you.

the8472
- 40,999
- 5
- 70
- 122
-
For example, in http://www.bittorrent.org/beps/bep_0005.html, look for "implied_port". I have found a longer write up on PEX that suggests sanitisation should not be assumed. – Matt Joiner Aug 19 '15 at 04:51
-
yes, but implied_port is a separate field, it doesn't say that port=0 indicates NAT. – the8472 Aug 19 '15 at 08:06
-
This is not a productive tangent. – Matt Joiner Aug 20 '15 at 03:28
0
I suspect you've stumbled on a bug in your tracker or other. You will not be able to connect to a peer's port 0 so reject those peers as not actually legit.

sandymac
- 21
- 4
-
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). - [From Review](/review/low-quality-posts/10141776) – worldofjr Nov 10 '15 at 02:02
-
How is this not an answer? The questioner asks how to interpret a message to connect to an address and port of 0. I advise to interpret as something he cannot make use of and reject said peer address. When you open a socket for listening with port 0, the operating system picks a random port for you. Guessing random ports to connect to will not be fruitful most of the time. – sandymac Nov 16 '15 at 21:05