bw_dev
bw_dev

Reputation: 795

P2P Networking. UDP vs TCP

I write P2P system based on Kadelmia approach. My question is related to type of transport to use: UDP or TCP.

The Kadelmia documentation defines UDP, but my concern is payload size. As far as I know, UDP grantees delivery of 548 bytes. But there are messages, which are defined by documentation, with length greater then 548 bytes (for example response on FIND_NODE). The question: should I use TCP instead of UDP?

Upvotes: 3

Views: 8800

Answers (1)

the8472
the8472

Reputation: 43052

with length greater then 548 bytes

That's the RFC-defined MTU for ipv4, but in practice almost all nodes support more, at least 1400 and some cases can be covered by fragmentation too. For IPv6 the guaranteed MTU is higher.

The question: should I use TCP instead of UDP?

You should use UDP, see this Q&A for reasons. If you need to transfer larger data at the end of a lookup you can still use TCP as next layer protocol, but that is beyond the scope of kademlia's routing algorithm.

for example response on FIND_NODE

Assuming 256bit node IDs (32 bytes) and 18byte contacts (IPv6) you can fit 10 ID, address pairs into 548 bytes with a few bytes to spare for headers. It's crammed but doable.

Upvotes: 4

Related Questions