btdht icon indicating copy to clipboard operation
btdht copied to clipboard

Make sure GetPeers response always fits within a single UDP datagram

Open madadam opened this issue 4 years ago • 0 comments

The spec says:

A node obeying this specification must not send UDP datagrams with a payload larger than 1024 octets,

We need to calculate the maximum number of values we can put into the response so the total message size is <= 1024 bytes. Call this number N. If we have more than N peers, we should take only N of them, but we should randomize which N to pick.

Note that N depend on whether we are sending ipv4 or ipv6 contacts and also on the number of ipv4 and/or ipv6 nodes we include in the message.

madadam avatar Nov 11 '21 12:11 madadam