Port Numbers – How does Transport layer identifies the Conversations

Port Numbers – How does Transport layer identifies the Conversations

Computers are today equipped with the whole range of different applications. Almost all of these applications are able in some way to communicate across the network and use Internet to send and get information, updates or check the correctness of user purchase. Consider they all these applications are in some cases simultaneously receiving and sending e-mail, instant messages, web pages, and a VoIP phone calls. In this situation the computer is using one network connection to get all this communication running. But how is it possible that this computer is never confused about choosing the right application that will receive a particular packet? We are talking about the computer that processes two or more communications in the same time for two or more applications running.

The TCP and UDP transport layer protocols based services have the possibility to keep track of the applications that are communicating in real time. To be able to differentiate the segments and datagrams of each separate application that is using connection in the same time, TCP and UDP have header fields that can identify these applications. These unique identifiers are the port numbers.

Header of each segment or datagram is made of different fields; two of these fields are source and destination port. The source port number is the number for one particular communication and is associated with the originating application on the local computer. The destination port number is the number for the same communication associated with the destination application on the remote host that is receiving the application. It can be for example port 80 on the web server that is open by deamon application and is waiting for GET request for html web page.

Port numbers are assigned in several ways, depending on whether the message is a request from local host or a response from remote host. While server processes have static port numbers assigned to them, clients dynamically choose a port number for each conversation to be sure that is not some port that is already used.

When a client application sends a request to a server, the destination port that is in the header of the request frame is the port number that is assigned to the service daemon running on the remote host. The client application must be configured to know what port number is associated with the server process on the remote host. This destination port number is usually configured by default but can also be changed manually. Let’s take an example in which user wishes to open a webpage. In that case web browser wants to open a webpage and makes a request to a web server, the browser uses TCP protocol and port number 80 because port number 80 is well-known port number used by Hypertext Transfer Protocol (http). Because TCP port 80 is the default port assigned to web-serving applications the server will receive request from web browser and it will know they this is a webpage request. Many common applications have default port assignments.

In the clients request segment or datagram header, the second port number is source port. This port number is a randomly generated port number greater than 1023. As long as it does not conflict with other ports in use on the system at that moment,  the client can choose any port number from the range of default port numbers used by the operating system. This port number acts like a return address for the requesting application. The Transport layer keeps track of this port and the application that initiated the request so that when a response is returned, it can be forwarded to the correct application. The requesting application port number is used as the destination port number in the response coming back from the server.

The combination of the Transport layer port number and the Network layer IP address assigned to the host uniquely identifies a particular process running on a specific host device and is called a socket. Term socket refers to the unique combination of IP address and port number. A socket pair, consisting of the source and destination IP addresses and port numbers, is also unique and identifies the conversation between the two hosts.

For example, If we want to open a webpage from the server on the address an HTTP web page request being sent to that web server to destination port 80. This request for the webpage will be destined to socket Let’s say that our computer has a Layer 3 IPv4 address of In the moment when the web browser requests the web page, the computer will also generate a dynamic port number 49152 assigned to the web browser instance (it can be one for every open tab). Dynamically generated port will be used by the server to uniquely describe the web browser instance with the socket to respond with the webpage content to the host.

So when our computer receives the page from server, the server has destinated the webpage to our host computer on socket

This is the use of port numbers.



  1. Chathura Madushan March 9, 2014
    • Valter Popeskic March 10, 2014
  2. showkat July 14, 2017
  3. LJ May 19, 2018

Leave a Reply