Layer 4 is the Transport layer. The transport layer creates virtual TCP or UDP connections between network hosts. TCP stands for Transfer Control Protocol and UDP stands for User Datagram Protocol.
This layer sends and receives data to and from the applications running on its host. The Transport layer assigns port numbers to the processes running in applications on the host, and adds a TCP or UDP header to the messages received from the applications detailing the source and destination port numbers.
Note that some of the applications, specifically Telnet, SMTP, and HTTP require TCP as the transport protocol while the others use UDP.
Some applications require reliable ordered delivery of packets. The TCP protocol provides this capability. It uses error detection, retransmissions and acknowledgements. This protocol cares about your data.
Other applications don’t care if every packet is received. These applications can take advantage UDP’s lower overhead to enable faster transmissions.
Typical TCP applications include email and web browsing and typical UDP applications include VoIP and music streaming.
TCP is strictly used for point to point or unicast transmissions while UDP can also be used for multicast and broadcast transmissions.
TCP and UDP Headers
The header added to messages by the Transport layer includes more than just the source and destination port numbers. Here we are showing all the information included in TCP and UDP headers.
Note how the TCP protocol requires more information and overhead to guarantee data delivery.