protocol-diver / go-gossip

Go implementation of the Gossip protocol
BSD 3-Clause "New" or "Revised" License
10 stars 0 forks source link

Use TCP instead of UDP #3

Open dbadoy opened 1 year ago

dbadoy commented 1 year ago

UDP is sufficient If the communication is simply sending a PullRequest to a random peer. However, this library's PullResponse payload size is unpredictable and will likely exceed the safe from packet fragmentation UDP size of 508 bytes(The minimum size of IPv4 datagram every device has to be able to receive(i.e. MTU) is 576 byte. And IP header(with fully option field) is 60 byte, UDP header is 8 byte. so I guess safety maximum UDP packet size from packet fragmentation is 508(576 - 60 - 8) byte).

The current implementation cuts packets at the application level and sends them over UDP to avoid packet fragmentation. I realized there is no clear reason to use UDP When I asked myself Why use UDP and not TCP?.

All communication in the library will use TCP instead of UDP.

dbadoy commented 1 year ago

However, I still don't know if preventing packet fragmentation is absolutely necessary or if it has a significant performance impact. The MTU of modern routers is stable, and if a packet is lost, it is likely to be recovered on the next pull request.