TCP Port

FREE Online Courses: Your Passport to Excellence - Start Now

What is a TCP Port?

The TCP port is a unique number that is issued to each application. For example, we have launched the email and games apps on our computer; we want to send messages to the host using the email application, or we want to play online games using the games application.

Different unique numbers are issued to these programmes in order for them to do all of these duties. Each protocol and address has a port, which is denoted by a port number. The port numbers are primarily used by the TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) protocols.

A port number is a unique identifier that is used in conjunction with an IP address. A port is a 16-bit unsigned integer, and there are 65,535 ports accessible under the TCP/IP architecture. As a result, the port number range is 0 to 65535. The zero-port number is reserved in TCP and cannot be utilised, but the zero port is not accessible in UDP. The Internet Assigned Numbers Authority (IANA) is the standard agency in charge of assigning port numbers.

Need for TCP Ports:

A single client might have many connections to the same or different servers. Multiple programmes may be executed on the client at the same time. When the client attempts to contact a service, the IP address is insufficient to gain access to the service. The port number is necessary to access the service from a server. As a result, by allocating a port number to the apps, the transport layer plays a significant role in enabling different communication channels between these applications.

Classification of port numbers:

1. Well-known ports:

The well-known port number range is 0 to 1023. The well-known ports are associated with protocols that provide common applications and services, such as HTTP (hypertext transfer protocol), IMAP (Internet Message Access Protocol), SMTP (Simple Mail Transfer Protocol), and so on.

For example, if we want to access certain websites on the internet, we use the http protocol; the http protocol is available with a port number of 80, which means that when we use the http protocol with an application, it receives port number 80. It is specified that anytime the HTTP protocol is utilised, port 80 will be used.

Similarly, well-known ports are specified for other protocols such as SMTP and IMAP. The remaining port numbers are assigned to apps at random.

2. Registered ports:

The registered port ranges from 1024 to 49151. The user processes utilise the registered ports. Individual apps, as opposed to standard applications with a well-known port, are used in these operations.

3. Dynamic ports:

The dynamic port has a range of 49152 to 65535. Ephemeral ports are another term for dynamic ports. When a client makes a connection, these port numbers are dynamically given to the client application. When the client begins the connection, the dynamic port is identified, whereas the well-known port is known before the connection. Also, when the client connects to the service, it is unaware of this port.

Working of TCP Ports:

1. Client Side:

  • Source Port:

The source port identifies the program to which the TCP segment belongs, and the port number is assigned dynamically by the client. This is essentially the procedure through which the port number is assigned.

  • Destination Port:

The destination port indicates the location of the service on the server, allowing the server to serve the client’s request.

2. Server Side:

  • Source Port:

It specifies the program from which the TCP segment originated.

  • Destination Port:

It specifies the application to which the TCP segment will be routed.

3. Processes Used:

  • Encapsulation:

The transmitter uses port numbers to notify the recipient which program to utilize for the data.

  • Decapsulation:

The receiver uses port numbers to determine which program to transfer data to.

Procedure according to different categories of TCP ports:

well known port and registered port

a. Well Known port:

The well-known ports are those that serve common services and applications such as HTTP, FTP, SMTP, and so on. In this case, the client uses a well-known port as the destination port, while the server uses a well-known port as the source port. For example, if the client submits a HTTP request, the destination port is 80, and the HTTP server is serving the request, therefore the source port number is 80.

b. Registered port:

Non-common apps are allocated to the registered port. This port is used by a large number of vendor programs. This port, like the well-known port, is used by the client as a destination port, while the server uses it as a source port.

2. Dynamic port:

dynamic port

The dynamic port is the port that is assigned dynamically to the client application when it initiates a connection. The client uses a dynamic port as the source port in this example, whereas the server uses a dynamic port as the destination port.

For example, if the client submits a HTTP request, the destination port will be 80 because it is a HTTP request, and the source port will be set solely by the client. When the server delivers the request, the source port is 80 since it is a HTTP server, and the destination port is the same as the client’s source port. In addition, the registered port can be used in place of a dynamic port.

Summary:

In this article we covered the concept of TCP ports and the need for them. We also looked at the various different categories of TCP ports and the method of functioning of each. Lastly, we also looked at the two processes used by these TCP ports at the client and server end.

Your opinion matters
Please write your valuable feedback about DataFlair on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *