Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are both protocols of the transport layer (layer – 4) of the OSI reference model.
TCP is connection-oriented and reliable protocol where as UDP is connection-less and best effort protocol. TCP employs three-way handshake (SYN – SYN/ACK – ACK) to establish connection between communicating hosts. Unlike UDP, TCP provides error-checking mechanisms through sequence numbers and acknowledgements to guarantee delivery of packets. However, it is slower than UPD due to the requirements of connection establishments and terminations overheads through three-way handshake and four-way handshake respectively.
In UDP connection, there is no overhead associated with establishing, maintaining and terminating connections. It is simpler, efficient and faster than TCP. Further, UDP provides no flow control, no error detection and correction, no sequencing of packets and thus it is unreliable protocol. However, UDP is more appropriate for real-time audio and video streaming demands.
To remember the layers of the OSI Reference model, you can “All People Seem To Need Data Process” to represent all layers from Application to Physical layers. This is my favorite analogy to retain the stack.