Must know basics for Software Engineers :[OSI Model: What Is the Transport Layer? — PART-1]
By: Paritosh Pradeep
Tags: Software Development, Software Engineering, Osi Model, Programming, Computer Science

I am starting a series with the title “Must know basics for Software Engineers” and will be covering loads of topics ranging from info on bits to designing complete scalable systems.

What could be a better start than understanding how any n/w works. Let’s start from the Transport layer of the OSI model as its really interesting.

Where Transport Layer lies in Big Picture :

The OSI Model

Responsibilities of Transport Layer:

Extends network to the applications: the transport layer takes messages from the network to applications. In other words, while the network layer (directly below the transport layer) transports messages from one end-system to another, the transport layer delivers the message to and from the relevant application on an end-system.

The Post Analogy:

Imagine you post a package across the world. Presumably, a ship or an airplane would carry the message to the relevant country. However, the post system of that country would take it to the relevant address. The plane/ship is the network layer and the post system is the transport layer.

Here are some other responsibilities of the transport layer.

Logical application-to-application delivery , the transport layer makes it so that applications can address other applications on other end-systems directly. This is true even if it exists halfway across the world. So it provides a layer of abstraction .

, the transport layer makes it so that applications can address other applications on other end-systems directly. This is true even if it exists halfway across the world. So it provides a layer of . Segments data . The transport layer also divides the data into manageable pieces called ‘segments’ or ‘datagrams.’

. The transport layer also divides the data into manageable pieces called ‘segments’ or ‘datagrams.’ It can allow multiple conversations . Tracks each application to application connection or ‘conversation’ separately, which can allow multiple conversations to occur at once.

. Tracks each application to application connection or ‘conversation’ separately, which can allow multiple conversations to occur at once. Multiplexes & demultiplexes data. It ensures that the data reaches the relevant application within an end-system. So if multiple packets get sent to one host, each will end up at the correct application.

Where It Exists

The transport layer does not have anything to do with the core of the network . Its only responsibility is to take messages from an application on a machine and hand them off to the network layer. The network layer transfers messages from one host to another.

. Its only responsibility is to take messages from an application on a machine and hand them off to the network layer. The network layer transfers messages from one host to another. The transport layer also receives messages from the network layer and transports them to the correct application.

Therefore, the transport layer and its protocols reside on end-systems! It is also the first layer in the OSI reference model (from the bottom) that distinguishes between applications.

Transport Layer Protocols

TCP

Delivers messages that we call ‘segments’ reliably and in order.

Detects any modifications that may have been introduced in the packets during delivery and corrects them.

Handles the volumes of traffic at one time within the network core by sending only an appropriate amount of data at one time.

Examples of applications/application protocols that use TCP are: HTTP, E-mail, File Transfers.

UDP

It does not ensure in-order delivery of messages that we call ‘datagrams.’

Detects any modifications that may have been introduced in the packets during delivery but do not correct them by default.

It does not ensure reliable delivery.

Generally faster than TCP because of the reduced overhead of ensuring uncorrupted delivery of packets in order.

Applications that use UDP include: Domain Name System (DNS), live video streaming, and Voice over IP (VoIP).

What are Multiplexing & Demultiplexing?

End-systems typically run a variety of applications at the same time. For example, at any given time a browser, a music streaming service, and an email agent could be running.

So how does the end-system know which process to deliver packets to? Well, that’s where the transport layer’s demultiplexing comes in.

What is Demultiplexing?

Demultiplexing is the process of delivering the correct packets to the correct applications from one stream.

Here’s a useful analogy: deciphering the mail that should be delivered to which houses after a large shipment of packages are received at a post office.

What is Multiplexing?

Also, multiplexing allows messages to be sent to more than one destination host via a single medium.

An analogy would be when several packages to several different locations are mailed out from one house.

Multiplexing and demultiplexing are usually a concern when one protocol (TCP for example) is used by many others (HTTP, SMTP, FTP) in an upper layer.

How Do They Work in the Transport Layer?

Recall that sockets are gateways between applications and the network, i.e., if an application wants to send something over to the network, it will write the message to its socket.

Sockets have an associated port number with them. Here’s a quick overview

Port numbers are 16-bit long and range from 0 and 65,535.

The first 1023 ports are reserved for certain applications and are called well-known ports. For example, port 80 is reserved for HTTP.

The transport layer labels packets with the port number of the application a message is from and the one it is addressed to. This is what allows the layer to multiplex and demultiplex data.

Multiplexing & Demultiplexing in UDP:

Connectionless refers to multiplexing and demultiplexing with UDP. Let’s dive right in.

Ports

Here’s a quick refresher on what ports are because that needs to be crystal clear for you to understand multiplexing and demultiplexing.

Sockets, which are gateways to applications, are identified by a combination of an IP address and a 16-bit port number. That means 2^{16}= 65536 port numbers exist. However, they start from port 0 so they exist in the range of 0–65535.

Out of these, some ports are reserved for certain standard protocols. Port 8080, for instance, is reserved for HTTP whereas port 22 is reserved for SSH.

Refer to page 16 of RFC 1700 for more details regarding what port number is assigned to what protocol.

Multiplexing & Demultiplexing in UDP

When a datagram is sent out from an application, the port number of the associated source and destination application is appended to it in the UDP protocol header.

and application is appended to it in the UDP protocol header. When the datagram is received at the receiving host, it sends the datagram off to the relevant application’s socket based on destination port number .

. If the source port and source IP address of two datagrams are different but the destination port and IP address are the same, the datagrams will still get sent to the same application.

On Port Assignment in UDP

It’s far more common to let the port on the client-side of an application be assigned dynamically instead of choosing a particular port. This is because, for communication, both parties must be able to identify each other. Since the client initiates communication with the server, it must know the port number of the application on the server. However, the server doesn’t need to know the client application’s port number in advance. When the first datagram from the client reaches the server, it will carry the client port number, which the server can use to send datagrams back to the client.

However, server-side applications generally do not use dynamically allocated ports! This is because they are running well-known protocols like HTTP and need to be bound to specific ports.

_________________________________________________________________

Part-2 :

https://medium.com/@paritosh.9423/must-know-basics-for-software-engineers-osi-model-what-is-the-transport-layer-part-2-43a307a9ddae

Thanks !!!