UDP

User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of Internet Protocol suite, referred as UDP/IP suite.

UDP uses a simple connectionless communication model with a minimum of protocol mechanisms.

UDP provides checksums for data integrity, and port numbers for addressing different functions at the source and destination of the datagram.

It has no handshaking dialogues, and thus exposes the user’s program to any unreliability of the underlying network; there is no guarantee of delivery, ordering, or duplicate protection.

Where we can use UDP Protocol ?

After sending a packet, UDP protocol does not say sender will wait for acknowledgment and will send another packet.

Use cases are

When one server in Distributed server sends time token/living life time token to another server. In this case if packet lost in between server should not wait for acknowledgment and resend packet since time is updated now so sending new packet here will be helpful.

Udp packet is small, so it can be used in very small bandwidth.

Difference between TCP and UDP ?

UDP header is 8-bytes fixed and simple header, while for TCP it may vary from 20 bytes to 60 bytes.

In TCP protocol, after a packet is send, sender will wait for acknowledgment. If acknowledgment will not come, sender has to resend the packet.

TCP protocol is more reliable and must be used if we can’t bear packet loss. UDP needs to be used if packet need to be send fast even in small bandwidth and if some packets get’s lost there must be no issue.