UDP

General

Introduction

UDP is the other major protocol in the internet world at layer 4. While TCp has elaborate mechanisms to support order, recover from lost packets and avaoid overloading the network, UDP has none of these. It ia basically a thin layer above IP, adding the concept of ports from the sending and receiving ends, allowing the packets to be directed to the correct application.

UDP does not guarantee that packets arrive in order - it doesn't guarantee that packets arrive at all. This doesn't work well for applications that rely on messages and responses arriving and in order. A typical client-server reliance on


	  prepare and send msg
	  receive msg and react
      
must be modified to

	  prepare and send msg
	  try to receive
	      if received, then react
	      if timeout, decide how to handle it
      

So why use UDP? It's faster and more lightweight. It is good for broadcast situations where responses are not required. It is good for multimedia streaming where a light protocol is best.

It is also good for building new protocols that rely on getting messages through most of the time, but don't need or require the particular guarantees (and overheads) of TCP. QUIC is a good example of this.


Copyright © Jan Newmarch, jan@newmarch.name
Creative Commons License
" Network Programming using Java, Go, Python, Rust, JavaScript and Julia" by Jan Newmarch is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License .
Based on a work at https://jan.newmarch.name/NetworkProgramming/ .

If you like this book, please contribute using PayPal