Transmission Control Protocol (TCP) – is a connection-oriented communications protocol that is used to ensure reliable transmission of packets between computing devices in a network.
User Datagram Protocol (UDP) – is a connection-less communications protocol that is used especially for time-sensitive and low latency transmissions across the network.
Here’s a table of comparison:
|Header Size||20 bytes||Static header 8 bytes|
|Overhead||Heavy as it needs 3 packets to setup a socket connection||Lightweight as no connections and message ordering tracking|
|Speed||Slower speed due to re-transmission and reordering||Faster as integrity is checked at the arrival time (via checksum)|
|Reliability||Guaranteed messages will be delivered in order and no errors||No guarantee that messages will be delivered in order and no errors|
|Connection||Connection is made before application messages are exchanged||Connection is not made before application messages are exchanged|
|Acknowledgment||Use handshake protocol (SYN,SYN-ACK,ACK)||No handshake|
|Data Segments||Rearranged in required order||Independent thus no inherent order specification|
|Flow Control||Has congestion control mechanism||No flow control|
|Error Checking||Performs error checking and resends erroneous packets||Performs basic error checking and discards erroneous packets (no error recovery attempt)|
|Use||Priority for more reliability and less speed||Priority for more speed and less reliability|
|Performance||Jitter and Throughput is Good||Jitter is Best and Througput is Worst|