A Guide to the Transport Layer | OSI Model Layer 4
The OSI (Open System Interconnect) model has seven layers, each of which is assigned a set of functions. Layer 4, or the transport layer, is the layer used in end-to-end communication across a network. It's crucial to the transmission of data across network connections. In this article, gain an understanding of what the transport layer is and how it functions, as well as its two essential protocols, TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
What is the transport layer?
The transport layer is the fourth layer in the OSI model, which is responsible for point-to-point communication on the network. Put simply, the transport layer provides logical communication between the application processes running on different hosts.
The transport layer contains a set of documents describing how we digitally communicate with one another, essentially outlining everything required for computer systems to work better. It determines the amount of data to transport between end users on devices, as well as how fast data is transmitted to or from users. The layer also decides if data transmission should be a single or parallel path.
Essentially, the transport layer collects data from the upper layer, or session layer, and splits it into small units to transmit to the lower layer, or network layer, for delivery.
In the OSI model, the transport layer is positioned between the session layer and the network layer. This means, then, that the layer fundamentally makes sure the that the anticipated message is supplied.
What does the transport layer do?
In computing networking, OSI model layer 4 provides a lot of services ranging from segmentation of data streams to error checking and data flow controls. As mentioned above, the transport layer collects data from the session layer to transmit to the network layer. However, other transport layer tasks include multiplexing and demultiplexing using port numbers, congestion control, and bandwidth guarantees.
Layer 4 of the OSI model uses TCP and UDP protocols to create the end-to-end connection between hosts. TCP (Transmission Control Protocol) is the connection-oriented protocol that establishes a robust connection between two end hosts. UDP (User Datagram Protocol) is a a connectionless protocol that provides non-sequenced data transmission functionality. The transport layer uses either of these protocols to carry out its tasks.
The main purpose of the transport layer is to provide point-to-point communication on a network. Layer 4 is how data is transferred to the upper layers. While a couple of protocols are state- and connection-oriented, this layer comes in to keep track of the segments. Furthermore, it reassembles those that fail.
In addition to data tracking, the transport layer acknowledges successful data transmission and sends data packets to the next layer if no errors occur.
Transport layer protocols
As we've seen, the transport layer is responsible for the end-to-end delivery of a message. However, the transport layer's function involves different protocols that provide various functionalities depending on application requirements. Although many standard protocols exist, the transfer layer uses the Transmission Control Protocol and User Datagram Protocol to enhance its functionalities. These functionalities include data transfer and segmentation, multiplexing and demultiplexing, and message tracking.
The transport layer performs two types of services:
- Connection mode transmission (connection-oriented)
- Connectionless mode transmission
In a connection-oriented transmission scheme, data is sent in packets or data streams and each data unit takes the same route over a network. That means data packets are received the same way the sender has sent them. Connection-oriented transmission is done via TCP.
In contrast, connectionless-mode transmission doesn't require any connection establishment and termination when transferring data over a network. It needs no established links between processes at all. UDP is the most popular form of connectionless-oriented transmission today.
Both TCP and UDP use port numbers to track and identify data transmission streams. They also both determine how data will be delivered – reliably or unreliably. TCP provides reliable communication between two hosts whereas UDP provides unreliable communication between the same. It's up to the network application to choose between them.
Transmission Control Protocol (TCP)
TCP is the most reliable protocol used in a TCP/IP network. Its purpose is to guarantee the delivery of data (message). If the application chooses TCP, all data will stay intact and assembled in the correct order.
Whenever two or more host computers want to communicate with one another, the communication between them needs to be reliable to ensure data is received correctly. For instance, when you want to download a file, you'd expect to view the entire file rather than parts of a file because, if for any reason the data is out of order, it won't make sense to you. Similarly, you'd want to view a webpage without missing a portion of a text. Here is where TCP becomes necessary.
If you download a file, look into an email, or view a webpage without TCP, some data may be missing, rendering everything worthless. In fact, a single missing character on a webpage with a specific HTML code can break the entire content. With TCP, the data remains ordered and intact, ensuring an optimal interaction experience.
As a connection-oriented transport layer protocol, TCP acknowledges the sent data packets. TCP also resends any data packet that goes astray. Two Internet-connected devices (computers) must verify a connection before any communication takes place by using a TCP three-way handshake. Because of this, TCP is ideal for many Internet applications, including email, World Wide Web (WWW), peer-to-peer file sharing and Secure Shell Protocol.
Features of TCP
Features of TCP include:
- Reliable data delivery. TCP recovers missing, corrupt, and damaged data, then resends it to its destination.
- Connection management. TCP ensures connection management with a three-way handshake in data transportation and its termination.
- Operation in point-to-point mode.
- Data segmentation. The protocol breaks up data from the application layer into small units, called TCP segments, and reassembles them at the receiver's side.
- A connection-oriented focus. With TCP, two remote points must be established in order for data transmission to occur.
Transmission Control Protocol is used for many actions, including file transfers and text communication. It preserves data loss and keeps communications reliable. Hypertext Transfer Protocol (HTTP) also uses TCP for reliable data delivery.
User Datagram Protocol (UDP)
UDP is similar to TCP in that both are used for transporting data. But unlike TCP, UDP is a connectionless protocol that doesn't guarantee data delivery on the Internet.
The protocol doesn't require acknowledgment from the receiver's end. This shortcoming makes it a simpler and faster service, yet it also makes it an unreliable one. UDP attempts to send data, but there is no guarantee the receiver will get it.
Most network applications use UDP protocol whenever acknowledgement of all packets holds little to no significance. For example, UDP is perfect for video calls through platforms such as Skype or FaceTime because speed is more important than reliability.
Real-time videos require fast send times at any cost. In fact, it's beneficial for network apps that tolerate lost data.
Features of UDP
Features of UDP include:
- Process-to-process communication. UDP is responsible for two-ended communication just like TCP.
- Connectionless orientation. UDP provides no guarantee mechanism for users to indicate their data was received.
- Speed. User Datagram Protocol is faster and more lightweight than TCP. TCP adds some overhead that leads to additional delays.
- No function of data reliability. The protocol prioritizes speed, thus ensuring fast delivery of messages.
UDP contains no acknowledgements, no sequence numbers in segments, and no retransmission of missing data.
In terms of application, online games often use UDP in order to avoid significant delay. Because UDP is faster and the best protocol for immediate data transfer, it works well for online games. It's also used for videoconferencing applications like Zoom and Skype, as well as VoIP apps like WhatsApp that prefer speed over reliability.
Comparing TCP vs. UDP
Computer networks use both TCP and UDP frequently. However, they differ significantly in their operations.
The chart below assesses the differences between TCP and UDP protocols.
|Basis of comparison||TCP||UDP|
|Connection||Connection-oriented protocol||Connectionless protocol|
|Reliability||A reliable service that guarantees data delivery||Unreliable service with no guarantee mechanism|
|Retransmissions||Re-transmits lost, damaged, or corrupted data packets||Doesn't resend lost data packets; relies on other layers for the same|
|Feedback||Acknowledges data||Doesn't require acknowledgements of data|
|Data delivery||Delivers data in sequence order||Delivers data as it arrives; therefore, some packets encounter loss along the way|
|Speed||Slow data transmission||High and simple data transmission|
|Header size||20 bytes||8 bytes|
|Overhead||Higher than UDP||Very low|
Other transport layer protocols
Other transport layer protocols include QUIC (Quick UDP Internet Connections) and SCTP (Steam Control Transmission Protocol).
QUIC is a new, encrypted connection-oriented protocol intended to accelerate HTTP traffic and make it more secure and efficient. It also operates at the transport layer in ISO model. As an alternative to TCP, QUIC connections are designed to reduce connection times and improve user experience.
While this protocol is still in its beta phase, streamers and online gamers find it necessary to have it. Even Google has been championing the use of QUIC since its inception. In fact, Google bases all its functions on QUIC, from YouTube to Google Chrome Hangouts and Bloggers.
SCTP is another connection-oriented protocol in Transport Layer. It aims to transmit data segments between endpoints alongside providing a full-duplex association.
Understanding transport layer functions
Layer 4 - the transport layer - is essential to computer networking. But specifically, how does the transport layer serve its purpose? The following services are provided by the transport layer on a network.
The transport layer establishes a robust connection before data is exchanged between computers for which it mainly uses a 3-way handshake protocol. TCP is a connection-oriented protocol that guarantees reliable delivery of messages between two end hosts.
This method has one useful benefit: the receiver must acknowledge and verify with the sender that it indeed received the message in sequence order. Therefore, network applications that value flow control use TCP protocol because it retransmits the lost, damaged and corrupted data.
Multiplexing and demultiplexing
Multiplexing and demultiplexing involve transmission of data from unrelated applications and other sources over a network. The transport layer offers dedicated control mechanisms required to send data segments from different apps simultaneously.
Multiplexing improves efficiency when it comes to data transmission. It allows data packets from the same destination (differentiated by their port numbers) to transmit along the same path on a network.
On the other hand, demultiplexing service allows the receiver's side to obtain data streams coming from different processes. It splits a network connection among several paths to foster the throughput.
Notably, the use of port numbers helps achieve both services in the transport layer.
The transport layer controls the amount of data in transmission by imposing a range of flow control techniques between the adjacent layers of OSI model.
Sometimes a sending device may transmit data at an unacceptable rate. For example, it can send data at a faster rate, which is greater than the rate the receiving device can process. This then leaves the device overwhelmed with data.
Consider a computer connected to a server. Suppose a server can send data maximum at 80 Mbps while the receiver side processes data at 50 Mbps. With the help of the transport layer, the receiver can request a server to slow down data transmission rate up to 50 Mbps so that no data gets lost.
Similarly, if a server is sending data at 20 Mbps, the receiving device can request it to increase data transmission rate to 50 Mbps in order to maintain the system performance.
The well-known TCP protocol in the transport layer allows the acknowledgement of data as the receiver informs the sender of the size of data it can hold.
Flow control circumvents network congestion. Eventually, the data transmission process becomes efficient.
If some data doesn't arrive at its destination, Layer 4 uses automatic repeat request schemes to then retransmit or update data. The layer adds a group of codes called computing checksums to each segment by the transport layer to detect the discarded segments.
Data can get lost, corrupted, or delivered in the wrong order. So, the transport layer reciprocates by checking any errors in the data coming from other layers. It understands and locates undersubscribed links, among other remedies. The goal is to improve data integrity across all the delivery layers.
Segmentation is an important part of the transport layer. Transport layer protocols break application messages into small data units, or segments, before passing them to the network layer.
Each segment has:
- A source port number
- A sequence number
A source port number helps direct each segment to the correct application. On the other hand, a sequence number helps reassemble data units in the right order to ensure correct messages at the receiver's end.
Protocols split data into small chunks to avoid fragmentation. Note that Transmission Control Protocol supports this while User Datagram Protocol doesn't.
Frequently asked questions
What transport layer protocol does DNS normally use?
The domain name system (DNS) uses User Datagram Protocol on the transport layer because of its speed.
What are the other layers in OSI models?
Though the transport layer is an important layer in the OSI model, there are others. The other six layers in the OSI model include the application layer, the presentation layer, the session layer, the network layer, the data link layer, and the physical layer.
What is a TCP flow?
A TCP flow is how data packets flow over a network.
Why does the transport layer need flow control?
Flow control is necessary because it manages traffic on a network. Flow control allows the transfer of data from one host computer to another without packet loss. Apart from that, the mechanism prevents a sending device from overwhelming a slower receiving device.
What is an example of the transport layer?
The transport layer is a protocol, and the best examples of transport layer protocols are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
Where is the transport layer located?
The transport layer is the fourth layer in the OSI system. Therefore, it's located between the network layer and the session layer.