erigon-pulse/p2p
subtly 7473c93668 UDP Interop. Limit datagrams to 1280bytes.
We don't have a UDP which specifies any messages that will be 4KB. Aside from being implemented for months and a necessity for encryption and piggy-backing packets, 1280bytes is ideal, and, means this TODO can be completed!

Why 1280 bytes?
* It's less than the default MTU for most WAN/LAN networks. That means fewer fragmented datagrams (esp on well-connected networks).
* Fragmented datagrams and dropped packets suck and add latency while OS waits for a dropped fragment to never arrive (blocking readLoop())
* Most of our packets are < 1280 bytes.
* 1280 bytes is minimum datagram size and MTU for IPv6 -- on IPv6, a datagram < 1280bytes will *never* be fragmented.

UDP datagrams are dropped. A lot! And fragmented datagrams are worse. If a datagram has a 30% chance of being dropped, then a fragmented datagram has a 60% chance of being dropped. More importantly, we have signed packets and can't do anything with a packet unless we receive the entire datagram because the signature can't be verified. The same is true when we have encrypted packets.

So the solution here to picking an ideal buffer size for receiving datagrams is a number under 1400bytes. And the lower-bound value for IPv6 of 1280 bytes make's it a non-decision. On IPv4 most ISPs and 3g/4g/let networks have an MTU just over 1400 -- and *never* over 1500. Never -- that means packets over 1500 (in reality: ~1450) bytes are fragmented. And probably dropped a lot.

Just to prove the point, here are pings sending non-fragmented packets over wifi/ISP, and a second set of pings via cell-phone tethering. It's important to note that, if *any* router between my system and the EC2 node has a lower MTU, the message would not go through:

On wifi w/normal ISP:
localhost:Debug $ ping -D -s 1450 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1450 data bytes
1458 bytes from 52.6.250.242: icmp_seq=0 ttl=42 time=104.831 ms
1458 bytes from 52.6.250.242: icmp_seq=1 ttl=42 time=119.004 ms
^C
--- 52.6.250.242 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 104.831/111.918/119.004/7.087 ms
localhost:Debug $ ping -D -s 1480 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1480 data bytes
ping: sendto: Message too long
ping: sendto: Message too long
Request timeout for icmp_seq 0
ping: sendto: Message too long
Request timeout for icmp_seq 1


Tethering to O2:
localhost:Debug $ ping -D -s 1480 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1480 data bytes
ping: sendto: Message too long
ping: sendto: Message too long
Request timeout for icmp_seq 0
^C
--- 52.6.250.242 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss
localhost:Debug $ ping -D -s 1450 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1450 data bytes
1458 bytes from 52.6.250.242: icmp_seq=0 ttl=42 time=107.844 ms
1458 bytes from 52.6.250.242: icmp_seq=1 ttl=42 time=105.127 ms
1458 bytes from 52.6.250.242: icmp_seq=2 ttl=42 time=120.483 ms
1458 bytes from 52.6.250.242: icmp_seq=3 ttl=42 time=102.136 ms
2015-05-13 19:03:00 +02:00
..
discover UDP Interop. Limit datagrams to 1280bytes. 2015-05-13 19:03:00 +02:00
nat p2p/nat: less confusing error logging 2015-05-06 22:58:03 +02:00
handshake_test.go p2p: fix disconnect at capacity 2015-05-08 16:09:54 +02:00
handshake.go p2p: fix disconnect at capacity 2015-05-08 16:09:54 +02:00
message_test.go p2p: use package rlp to encode messages 2015-03-19 15:11:02 +01:00
message.go p2p: added received at to peer message 2015-04-29 22:49:58 +02:00
peer_error.go p2p: make DiscReason bigger than byte 2015-04-17 14:45:10 +02:00
peer_test.go p2p: fix Peer shutdown deadlocks 2015-04-10 13:26:27 +02:00
peer.go p2p: drop connections with no matching protocols 2015-05-08 16:09:55 +02:00
protocol.go p2p: print Cap as name/version 2015-02-13 23:54:34 +01:00
rlpx_test.go p2p: use package rlp to encode messages 2015-03-19 15:11:02 +01:00
rlpx.go p2p: reject messages that cannot be written as simple RLPx frames 2015-03-04 16:42:01 +01:00
server_test.go p2p: fix disconnect at capacity 2015-05-08 16:09:54 +02:00
server.go p2p: drop connections with no matching protocols 2015-05-08 16:09:55 +02:00
testlog_test.go fix p2p/testlog_test 2015-03-23 16:41:41 +00:00