When it comes to computer networking, there are various protocols and technologies that are used to establish communication between devices. Layer 4 of the OSI model is one such technology that plays a crucial role in this communication. In this article, we will discuss the two primary protocols used at Layer 4 – Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) – and how they work using different ports.
TCP Port
Transmission Control Protocol is a reliable, stream-oriented protocol that is used to send data between applications. In other words, TCP is used to ensure that the data sent from one device to another is received in the correct order and without any errors.
When data is sent using TCP, it is first divided into small packets, which are then transmitted to the recipient. The recipient device then reassembles the packets to form the original data. To ensure that the data is transmitted correctly, TCP uses a system of acknowledgements, retransmission of lost packets, and flow control.
TCP Ports work as follows
When an application on a device wants to send data to another application on another device, it sends a request to the operating system to establish a connection. The operating system then sends a request to the recipient’s device to establish a connection. The recipient device then acknowledges the request and the connection is established.
Once the connection is established, the two devices use a unique number called a “port number” to identify the connection. The port number is used to ensure that the data is sent to the correct application on the recipient’s device.
There are two types of port numbers in TCP – well-known ports and dynamic ports. Well-known ports are reserved for specific services and are usually assigned numbers between 0 and 1023. For example, port 80 is used for HTTP, port 443 is used for HTTPS, and port 22 is used for SSH.
Dynamic ports, on the other hand, are used for temporary connections and are usually assigned numbers between 1024 and 65535. When a connection is established using a dynamic port, the port number is used only for the duration of that connection and is then released for use by another connection.
Examples of TCP Ports
- Port 80: HTTP (Hypertext Transfer Protocol) is the most commonly used protocol for transmitting web pages over the internet. When you enter a URL into your browser, your browser sends a request to the web server on port 80 to retrieve the web page.
- Port 443: HTTPS (Hypertext Transfer Protocol Secure) is a secure version of HTTP that is used to transmit sensitive information over the internet. When you enter a URL into your browser that starts with “https://”, your browser sends a request to the web server on port 443 to retrieve the web page.
- Port 22: SSH (Secure Shell) is a protocol used to securely access remote computers. When you use an SSH client to connect to a remote computer, the client sends a request to the remote computer on port 22 to establish a secure connection.
UDP Ports
User Datagram Protocol is a connectionless, unreliable protocol that is used to send data between applications. Unlike TCP, UDP does not guarantee that the data will be received in the correct order or without errors. However, UDP is faster than TCP because it does not spend time acknowledging the receipt of packets or retransmitting lost packets.
UDP Ports work as follows
When an application on a device wants to send data to another application on another device, it sends the data directly to the recipient’s device without first establishing a connection. The data is then received by the recipient’s device and processed by the correct application using the port number.
Just like with TCP, UDP uses port numbers to identify the connection between the two applications. The port numbers used with UDP are the same as the ones used with TCP, with well-known ports being assigned numbers between 0 and 1023 and dynamic ports being assigned numbers between 1024 and 65535.
Examples of UDP Ports
- Port 53: DNS (Domain Name System) is a protocol used to translate domain names into IP addresses. When you enter a URL into your browser, your computer sends a request to a DNS server on port 53 to resolve the domain name into an IP address.
- Port 67: DHCP (Dynamic Host Configuration Protocol) is a protocol used to automatically assign IP addresses to devices on a network. When a device connects to a network, it sends a request to the DHCP server on port 67 to obtain an IP address.
- Port 69: TFTP (Trivial File Transfer Protocol) is a simple file transfer protocol that is used to transfer files over a network. When you use TFTP to transfer a file, your device sends a request to the TFTP server on port 69 to retrieve the file.
Conclusion
In conclusion, TCP and UDP ports play a crucial role in the communication between devices in computer networks. Understanding the differences between TCP and UDP and the different ports they use can help you troubleshoot network issues and optimize network performance. Whether you’re a network administrator, a developer, or just someone who wants to learn more about how networks work, understanding Layer 4 and the role of TCP and UDP ports is an important step in your journey.
0 Comments