Table of Contents
The Transport Layer
Transport Layer of the OSI model
This is the next layer in the OSI hierarchy; above the network and below the session layer. This layer bridges the layer above to the layer below (of course all of them do bridge the layer above to the layer below) in the sense it bridges the higher level application software to the lower layer driver software and associated hardware’s.
The transport layer ensures end-to-end process communication. What does this mean?
A process is an application program running on the source machine. Realistically speaking, there are going to be multiple processes running concurrently on a machine and each trying to communicate with the same program or a different one on the destination machine. This is where the transport layer plays its part in the networking web.
A network layers job is to ensure the packet it pushes down reaches the destination IP at any cost; it hardly knows what the packet is made of or which application it belongs to. This is how the transport layers defers to the network layer; in the sense, it ensure the same process on the destination machine receives the message, overseeing both error and flow control.
Thus, the transport layer ensures process-to-process delivery of its messages. A brief understanding of how this is achieved will be discussed later in the course of this article.
In addition, there are some dedicated responsibilities the layer withholds which will be discussed now
Let’s Dive in..
Responsibilities of the Transport Layer
Service-point Addressing
As discussed before, a machine will have many processes (programs) running concurrently. It is the responsibility of this layer to enable communication all the way to the same program on the destination machine. That being said, there needs to be a logical way it gets this done right?
Yes, there is an address associated with each application that runs in your PC, at least most of them do. This address is called the service point address or commonly referred to as the port address.
Typically every application has a port and a port number associated with; this is universal. For example a few are listed below
HTTPS –> runs on port 443.
HTTP –> Runs on 80.
SMTP –> Runs on 25.
What are ports?
Ports are virtual software entities through which network traffic is filtered. Ports are handled by the host machine’s operating system and the network stack in it. The ports thus act as a gateway for data flowing in and out of the transport layer.
Sine this is a layer 4 concept; the two protocols that can identify ports are the TCP and UDP protocols. The most commonly used terms in networking are TCP and UDP; it’s safe to say most of the internet and Ethernet communication hinges on the working of these protocols the way they do!
Thus, the Layer 4 packets will have a port number field to identify the port number it has to push the packet to. If you think about it, this is a very efficient way to filter huge amount of data going in and out of the system. You could say, the concepts of port creates a structure; a much needed one!
A port number is of 16 bits or 2 Bytes. This means it has a range from 0-65535 and there is an organization that governs the way these numbers are assigned, for the sake of commonality.
Internet Assigned Numbers Authority (IANA); this is an organization that regulates the use of these port numbers.
The port numbers are thus split into 3 categories
- System ports: These are the ports commonly used by your system for communication with the world outside it. ( 0-1023)
Examples are HTTP, TCP, UDP, SMTP, FTP etc.
- Reserved ports: They are reserved ports which must be sought by the application requesting it (1024-49151).
- Dynamic Ports: Port numbers above 49,152 are considered dynamic ports; that is, they can be used by laymen for a client server model or for any other desired purpose.
Now that ports have been explained in brief, there is one more concept worth discussing at this point and they are sockets!
Sockets are another important networking concept and are logical doors like ports through which an application pushes data to another device. More on sockets later.
Segmentation and Reassembly
So far, we have discussed what the transport layer is responsible for in terms of how far it governs the communication. How does it deal with the data it receives from the layer above?
The transport layer segments packets from above into chunks of packets each having a few mandatory identifiers within each of these packets.
Depending on the protocol used at this layer; the building of the packet will slightly vary. In the sense, a TCP packet will have different fields filling their packet Vis-à-vis a UDP packet. The common fields that will go into the packet irrespective of the protocols need to be discussed.
Common fields are discussed as below
- The source port number
- Destination Port number
- Sequence number
The reason for port number is already explained. Sequence number is used for a simple reason to reassemble the chunked packets at the source. The reassembly is done with the help of this field in the packet coming into the transport layer from the network on the destination machine.
This mechanism of having a sequence number to track this segmented packet and reassemble them at destination is one of the responsibilities of the transport layer.
Connection Control
There are two ways the packet is pushed to the destination machine. This is governed by the connection control mechanism of the layer and they are
- Connection Oriented
- Connection-less Oriented
Connection oriented
In this method a session is opened with the destination machine only after which data is transmitted; the session is then aborted.
This type of communication is used by the Transmission Control Protocol commonly referred to as TCP. This is a more secure way to communicate wherein handshakes and elegant error mechanisms are handled. More on the TCP protocol later..
Connection-less
In this method, the segments are continuously transmitted; i.e. each segment is transmitted as an individual packet to the destination machine.
UDP is a protocol that uses this connection-less technique to push its data. It is regarded as a leaky protocol as it provides no reliability in delivery. It thus is used when the application can afford to lose a few packets here and there. This form of communication ensures high speed delivery of packet and no other advantage over the other.
Flow Control
The flow control at this layer is done end to end unlike the data link that does link to link. For UDP there is no flow control done whereas for the TCP there is byte level flow control.
Flow control is nothing but, governing the bytes sent so as to prevent overwhelming of data at the receivers end.
Error Control
Error control as the name suggests is responsible to handle the situation in case of error in the transmission. How it does it, is beyond the scope of this article; but good to know it is capable of doing it 🙂
This brings us to the end of the responsibilities this layer withholds
In summary
This needs to be well understood and I hope this article is helping you get there.
Please note the responsibilities are discussed just to give you a rudimental understanding of what’s going on. On as how to how this is achieved, we’d need several sessions to cover and there is no covering everything. But this is a good place to start with absolute certainty!!
Sockets
Theoretically, a socket is a combination of a port number and an IP address. This would be the textbook definition of what a socket is. A socket is needed for processes to communicate with each other. It is a logical file descriptor, again handled by the host operating system.
There are different types of sockets based on their usage
- Stream Sockets –> TCP sockets
- Datagram Sockets –> UDP Packets
- Raw Sockets
- Sequenced Packet sockets
Note:
An application can create as many sockets as it wants; it would mostly communicate through the port the application is assigned to use.
A typical use case is a client server model wherein the server is supposed to run on a dedicated port number; that is listen for clients on a generic port number. The client is usually assigned a port number dynamically by the OS or a port number binding to the application can also be done.
More on socket programming and client server programs will be taken up in the future articles.
Transport Layer Devices
There aren’t many dedicated hardware devices operating out of this layer; but the two worth mentioning are as follows
- Firewalls –> Restricts access to the communication in and out of the system.
- Gateways –> Converts protocols into an understanding format in the layer used.
As always thanks for reading, reach out In case of doubts; leave me a comment on how you like the article!
Thanks for reading!
Related Posts