Many people have heard that installing a firewall is a good way to protect the PC, since it controls the use of the ports. On the other hand, there are people who discover that it is necessary to release a certain port on their computer for a given program to work. When someone speaks of these ports, they are referring to the TCP and UDP ports , which are means used by software and operating system services for network communication and, consequently, on the internet.
We present explanations below that will help you to better understand the concepts and uses of these doors. For that, it is convenient to present a description of the TCP and UDP protocols first.
The TCP protocol
The internet communication is done basically through protocols, and TCP (Transmission Control Protocol) one of the most important of them. That’s because TCP is included in the set of protocols that make up TCP/IP, the basis for communication via data from across the internet. According to the definition given by abbreviationfinder.org, the main characteristics of TCP are:
:: Ensuring the delivery of IP datagrams: this is perhaps the main function of TCP, that is, ensuring that packets are delivered without changes, without being corrupted and in the correct order. TCP has a number of mechanisms to guarantee this delivery;
:: Execute the segmentation and regrouping of large blocks of data sent by the programs, guarantee the proper sequencing and the orderly delivery of segmented data: this feature refers to the ability to divide large files into smaller data packages and transmit each package separately . Packages can be sent in different ways and arrive out of order. TCP has mechanisms to ensure that, at the destination, the packets are ordered correctly, before being delivered to the destination program.
:: Check the integrity of the transmitted data using checksum calculations: TCP checks to ensure that the data has not been altered or corrupted during transport between the source and the destination.
:: Send positive messages depending on the successful receipt of the data. When using selective acknowledgments, negative acknowledgments are also sent for data that has not been received: at the destination, TCP receives the data packets, checks whether they are ok and, if so, sends a message to the origin, confirming each packet that was received correctly. If a packet has not been received or has been received with problems, TCP sends a message to the originating computer, requesting a retransmission of the packet. With this mechanism, only packages with problems will have to be resent, which reduces traffic on the network and speeds up the sending of packages.
:: Offer a preferred method of transporting programs that must use reliable session-based data transmission, such as client/server databases and e-mail programs: TCP is much more reliable than protocols such as UDP (explained below) and is suitable for programs and services that rely on reliable data delivery.
The functioning of TCP is based on connections. Thus, for a client computer to initiate a “conversation” with a server, it is necessary to send a signal called SYN to the latter. The server then responds by sending a SYN signal combined with an ACK signal to confirm the connection. The client responds with another ACK signal, making the connection established and ready for data exchange. Because it is done in three transmissions, this process is known as a three-way handshake.
UDP (Ube Datagram Protocol) is considered a “sibling” protocol of TCP, but it is simpler and also less reliable. This is because the functioning of TCP is, as already said, based on connections, which is not the case with UDP. As a consequence, there are no verification procedures in sending and receiving data (however, there may be an integrity check) and if a packet is not received, the destination computer does not make a new request, as with TCP. All of this makes UDP a little faster, but unusable in certain applications.
For these characteristics, it may seem that UDP is useless, but it is not. There are applications where it is preferable to deliver data as quickly as possible, even if some information is lost along the way. This is the case, for example, of video transmissions over the internet (streaming), where the loss of a data packet will not interrupt the transmission. On the other hand, if the packages do not arrive or take too long to arrive, there will be freezes in the image, causing irritation to the user.
TCP ports and UDP ports
Now that you know some characteristics of the TCP and UDP protocols, you are now able to understand the concept of ports. For an easier understanding, we will use the following example: suppose that, at this moment, you are using a web browser, an e-mail client and instant communication software. All of these applications make use of your internet connection, but how does the computer do to know what data belongs to each program? Simple, by the port number that each one uses. For example, if you are using an FTP program (File Transfer Protocol), the internet connection is made through TCP port 21, which is a port agreed to this protocol. If you are downloading files through BitTorrent, one of the ports ranging from 6881 to 6889 will be used for this activity.
Compare your computer to a building. When a correspondence arrives, it is necessary to know which apartment to deliver it to. If the envelope says that the destination is apartment number 123, where so-and-so lives, just make the delivery. On your computer, the concept is the same: just replace the correspondence with the data package, the apartment with the door and the guy with the program. However, it is important to note that an application can use more than one port.
Altogether, it is possible to use 65536 TCP and UDP ports, starting at 1. In both the TCP and UDP protocol, it is common to use ports 1 to 1024, since their application is standardized by the IANA (Internet Assigned Numbers Authority). According to this entity, here are some of the most used TCP ports:
:: 21 – FTP;
:: 23 – Telnet;
:: 25 – SMTP;
:: 80 – HTTP;
:: 110 – POP3;
:: 143 – IMAP;
:: 443 – HTTPS.
IANA provides a complete and updated list of the use of TCP and UDP ports on this page .
Depending on the case, an application does not necessarily have to be restricted to a given set of ports. It is possible to use others, but this needs to be specified. That is why, for example, there are certain addresses on the internet that are made available as follows: http://www.site.com:abcd, where abcd is the port number. In this case, your computer is being instructed to access the address through the abcd port.
It is thanks to the concept of doors that you can use several services at the same time on the internet. However, this can also pose a danger, which is why it is important to have control over data traffic on both TCP and UDP ports. The use of firewalls, for example, helps prevent malicious applications from using open ports on your computer for harmful activities. In addition, a network administrator can make manual settings so that certain ports are blocked, preventing applications that use them from connecting.
If you want to go deeper into the subject, it is recommended to study the following subjects: TCP/IP and OSI layers.