0

I heard a UDP payload of 508 bytes will be safe from fragments. I heard the real MTU is 1500 but people should use a payload of 1400 because headers will eat the rest of the bytes, I heard many packets will be fragmented so using around 64K is fine. But I want to forget about all of these and programmatically detect what's gets me good latency and throughput from my local machine to my server.

I was thinking about implementing something like a sliding window that TCP has. I'll send a few UDP packets then more and more until packets are lost. I'm not exactly sure how to tell if a packet was delayed VS lost and I'm not sure how to slide by down without going to far back. Is there an algorithm typically used for this? If I know the average hop between my machine and server or the average ping is there a way to estimate the maximum delay time of a packet?

  • 1
    *"I heard the real MTU is 1500"* - that's only for Ethernet. See [here](https://en.wikipedia.org/wiki/Maximum_transmission_unit#MTUs_for_common_media) for common MTU values. *"Is there an algorithm typically used for this? "* - [Path MTU Discovery](https://en.wikipedia.org/wiki/Path_MTU_Discovery) – Steffen Ullrich Oct 17 '22 at 04:59
  • 1
    Does this answer your question? [How to send packets according to the MTU value](https://stackoverflow.com/questions/38817023/how-to-send-packets-according-to-the-mtu-value) – Steffen Ullrich Oct 17 '22 at 05:06
  • @SteffenUllrich somewhat, I'm still not sure how to figure out throughput (and how to balance speed and stability) – Andrew Benor Oct 18 '22 at 01:51
  • You get the best throughput and lowest latency if datagrams do not need to be fragmented (because one fragment lost would mean the whole datagram lost) and otherwise have the maximum size, hence the maximum path MTU. Apart from that note that UDP is an unreliable protocol, i.e. packet loss, duplication and reordering are not handled. Therefore the question on how to pack as much data as possible into a datagram is usually only relevant if you implement your own TCP like (byte stream) reliable layer on top of UDP. – Steffen Ullrich Oct 18 '22 at 03:30

0 Answers0