There are two types of the ports used in a transport layer, the source ports, and destination ports. The source ports related to the originating application on the local host. The destination ports related to the destination application on the remote host.
The source ports are dynamic ports, generated by the originating device to identify a conversation between two devices. This process allows multiple conversations to take place at the same time. It is common for a device to send multiple HTTP service requests to a web server at the same time. Each separate HTTP conversation tracked based on the number of source ports.
The client can attach a destination port number in the segment to tell the destination server about requested service. For example, when a client specifies port 21 in the destination port, the server receives the message telling requested service is FTP. A server can offer more than one service simultaneously such as FTP services on port 21 and web services on port 80 at the same time. The figure below illustrates both requests at the same time.
Both source and destination ports placed within the segment and then the segments encapsulated within an IP packet. The IP packet has both the source and destination IP addresses. The combination of the source IP address and source port number, or the destination IP address and destination port number is known as a socket. We can use the socket to recognize the server and service requested the user. A user socket might look like this, with 1124 representing the source port number: 192.168.10.200:1124 and the socket on a web server might be: 192.168.10.50:80
Together, these two sockets combine to form a socket pair: 192.168.10.200:1124, 192.168.10.50:80. The Figure below illustrates the connection and socket of web and FTP ports.
The sockets enabled multiple processes, running on a client, to differentiate themselves from each other, and multiple connections to a server process to differentiate from each other. The source port number used as a return address for the requesting application. The transport layer keeps a track record of this port and the application that initiated the request so that when a reply returned, it can be forwarded to the right application.
Ports Number Groups
The Internet Assigned Numbers Authority (IANA) is the authority for assigning various addressing standards and ports numbers. There are three different types of ports.
Well-known Ports (Numbers 0 to 1023)
These are service and application reserved ports. The applications such as web browsers, email clients, and remote access clients use these ports. These well-known ports can be programmed for server applications and client applications to request a connection to that specific ports and its associated service.
Registered Ports (Numbers 1024 to 49151)
The Internet Assigned Numbers Authority (IANA) assigned these ports on requesting the person to use with particular processes or applications. These processes are mostly individual applications that a user has selected to install and use; rather than common applications that would receive a well-known port number.
Dynamic or Private Ports (Numbers 49152 to 65535)
These ports are also known as ephemeral ports; these are generally assigned dynamically to the client’s operating system when a connection to a service is initiated. We can use dynamic ports to identify the client’s application during communication. Some client operating systems also use registered port numbers instead of dynamic ports numbers for assigning source ports.