Kahibaro
Discord Login Register

4.3 Transport Layer

Introduction

The transport layer in the TCP/IP model is responsible for getting data from one application on a device to an application on another device, in a controlled and organized way. It sits above the Internet layer (which handles IP and routing) and below the Application layer (where user programs like web browsers live). In the TCP/IP model this is where protocols like TCP and UDP operate, and where concepts like ports, connections, and reliability are handled.

This chapter focuses on what the transport layer does in general. Specific transport protocols and mechanisms such as TCP, UDP, ports, the three way handshake, flow and congestion control are covered in later chapters, so they will appear here only as context, not in full detail.

Role of the Transport Layer

The key idea of the transport layer is end to end communication between applications. IP can get packets from one host to another, but it does not know which program on the machine should receive the data. The transport layer solves this by adding its own header on top of IP and by using port numbers to identify applications.

From the point of view of an application, the transport layer offers a service that looks like sending and receiving chunks of data across the network. It hides many details such as packet sizes, retransmissions, or out of order delivery. Different transport protocols offer different kinds of service. Some are connection oriented and reliable, others are connectionless and best effort.

The transport layer is also where hosts keep track of conversations. A single computer can have many applications communicating with many remote endpoints at the same time, and the transport layer must keep those conversations separate.

Multiplexing and Demultiplexing

A central function of the transport layer is multiplexing and demultiplexing. Multiplexing means combining data streams from different applications into a single stream of packets going out over the network interface. Demultiplexing means taking incoming packets from the network and delivering them to the correct application.

The transport layer uses port numbers for this purpose. An outgoing segment from an application gets a source port and a destination port. On the receiving side, the transport layer examines the destination port and passes the payload to the right application. This allows, for example, a web server and an email server to run on the same machine and still receive only the data meant for each one.

Because both sides use port numbers, and because the IP layer supplies source and destination IP addresses, each conversation between two endpoints is identified by a combination of addresses and ports, plus the transport protocol type.

Important: A transport layer conversation is uniquely identified by the 4 tuple
(source IP, source port, destination IP, destination port)
together with the transport protocol (for example TCP or UDP).

Segmentation and Reassembly

Applications do not need to worry about the maximum size of an IP packet. They can send large blocks of data to the transport layer. The transport layer splits this large data stream into smaller pieces that can fit into IP packets. This process is called segmentation. Each piece is placed into a transport layer segment, which then becomes the payload of an IP packet.

On the receiving side, the transport layer collects segments that belong to the same conversation and reassembles them into a continuous data stream for the application. When necessary, it also deals with issues such as missing pieces or pieces that arrive out of order, though the exact mechanisms depend on the specific protocol and are covered in chapters about reliable transmission.

It is important that the transport layer include enough information in each segment header for the receiver to know how the pieces fit together. For a reliable, connection oriented protocol this might include sequence numbers and acknowledgements. For a simple, connectionless protocol the transport layer may only include basic information like port numbers and a length field.

Connections and Connectionless Service

Different transport protocols can operate in either a connection oriented or a connectionless mode.

With a connection oriented service, the transport layer establishes a logical connection between two endpoints before data is exchanged. This connection exists only in the end hosts and is represented by state information such as sequence numbers, buffers, and timers. Data is then transmitted as part of this ongoing conversation, and when the communication is finished, the connection is closed. The exact process of setting up and tearing down such a connection is discussed later in the three way handshake chapter.

With a connectionless service, there is no formal connection setup or teardown. Each message, often called a datagram, is sent independently. The transport layer does not maintain long term state about the conversation. This mode is simpler and faster but does not by itself provide reliability or ordering guarantees.

Both styles of service are useful. For traffic that needs accuracy and ordered delivery, applications tend to use a connection oriented protocol. For traffic where speed and simplicity matter more, applications often choose a connectionless protocol.

Reliability, Ordering, and Error Handling

The transport layer is the first place in the stack where reliability and ordering can be offered as part of the service to applications. IP by itself does not guarantee that packets will arrive, that they will arrive only once, or that they will arrive in order. Some transport protocols choose to add mechanisms that compensate for this, while others do not and rely on the application to deal with any problems.

Reliability can include several features. A protocol can detect lost segments and trigger retransmission. It can use sequence numbers to put segments back in order if they arrive out of sequence. It can detect duplicates and discard them. It can provide acknowledgements from the receiver to the sender to confirm successful delivery.

Error detection is related but not identical. Most transport protocols include a checksum field that allows the receiver to check whether the segment was corrupted in transit. If a checksum fails, the segment is discarded. In a reliable, connection oriented protocol this loss may trigger a retransmission. In a connectionless protocol the loss may simply be left to the application to handle if it cares.

Ordering means that the receiver delivers data to the application in the same order it was sent. This can matter greatly for protocols like file transfer or web browsing. For media streaming or real time voice traffic, strict ordering is often less critical, so a simpler transport service may be sufficient.

Flow Control

Flow control at the transport layer protects the receiver from being overwhelmed by a sender that is sending data too quickly. Even if the network between them is perfectly fast, the receiving application or operating system may not be able to process incoming data fast enough. Without a control mechanism, buffers can fill up and data can be lost.

Transport layer flow control works by allowing the receiver to tell the sender how much data it is currently able to accept. The sender then limits the amount of unacknowledged data it has in flight so that it does not exceed this limit. The details and algorithms vary depending on the protocol and are described in depth in the later chapter on flow control, but the important idea is that the transport layer manages pacing between endpoints based on the capabilities of the receiver.

Flow control is distinct from congestion control. Flow control focuses on the speed of the endpoints themselves. Congestion control focuses on the state of the network in between.

Congestion Awareness

The transport layer can also help prevent congestion inside the network. If too many packets enter a network at once, routers and switches may start to drop them because their queues are full. This situation is called congestion. When this happens, a well designed transport protocol should react by sending less data, which gives the network time to recover.

To do this, the transport layer observes signals such as lost segments or unusual delays. Based on these signals, it adapts its sending rate. These adaptation strategies, such as increasing the sending window slowly when conditions are good and reducing it aggressively when loss is detected, are covered in detail in the chapter on congestion control.

The key point here is that the transport layer is where end hosts cooperate to share the network fairly. It is not only about correctness, but also about being a good citizen in a shared network.

Relationship with IP and the Application Layer

The transport layer sits between IP and applications and has a specific interaction with both.

On the downward path, an application hands data to the transport layer, together with information such as destination port. The transport layer wraps this data in a transport segment, adding its own header, then passes the result down to the Internet layer, which in turn encapsulates it inside an IP packet. The IP packet then moves across the network toward the destination.

On the upward path, an IP packet arrives at the destination host and is passed up to the transport layer. The transport protocol inspects its header, checks which conversation it belongs to, may verify integrity, reassemble data if needed, and finally passes the pure application data up to the correct program, identified by the destination port and local state.

This separation of roles has several benefits. Applications can choose the transport protocol that matches their needs. The transport layer can evolve without changing IP, and IP can evolve without breaking transport protocols, as long as the basic service of host to host packet delivery remains.

Summary

The transport layer in the TCP/IP model provides application to application communication over an IP network. It multiplexes and demultiplexes data using ports, segments and reassembles data for applications, and distinguishes between connection oriented and connectionless communication styles. It is also where mechanisms for reliability, ordering, error detection, flow control, and congestion awareness can be implemented. By sitting between IP and applications, the transport layer allows applications to exchange data in a structured, controlled way, while hiding most of the complexity of the underlying network.

Views: 55

Comments

Please login to add a comment.

Don't have an account? Register now!