What Is The Difference Between TCP And UDP Protocols?
You may have encountered TCP and UDP while setting up port forwarding on the router or configuring firewall software. But do you know what these two protocols are and what their differences are?
TCP and UDP are two protocols used for different types of data. Devices and computers connected to the Internet communicate with each other using a protocol called TCP / IP. TCP / IP is a set of protocols used by devices to communicate over the Internet and most local area networks.
TCP / IP is derived from two main protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP).
TCP provides applications with a way to deliver and receive packets sorted and reviewed over the network. Applications use the User Datagram Protocol (UDP) to provide faster data flow by eliminating error checking.
When configuring home Network hardware or software, you may need to know the difference between the TCP and UDP protocols. TCP and UDP protocols to understand the differences and what each is with Zvmyt. Stay tuned.
Features of TCP and UDP protocols
When a computer in New York wants to send data to a laptop in Tehran, it must know the IP address of the destination computer (the computer in Tehran). This information is often sent via UDP and TCP. TCP and UDP are protocols used to send bits of data or packets over the Internet. Both protocols are IP-dependent.
In other words, it does not matter if you send a packet via TCP or UDP; in any case, the packet will be sent to an IP address.
TCP protocol
Using the Transfer Control Protocol (TCP), the data sender’s computer connects directly to the computer to which the data is being sent and stays there for as long as the transfer occurs. This method allows these two computers to disconnect after ensuring the data entry is safe and correct.
This data transfer method is faster and more secure, but it puts more load on the computer because it has to control the connection and the data. For example, suppose you pick up the phone and call your friend. When both are done, you hang up and release the connection.
TCP tracks sent packets, so no data is lost or corrupted during transmission. This is why files downloaded will not be interrupted even if the Network is down.
However, if the receiver is completely offline, your computer will stop sending the packet, and you will see an error message saying it cannot communicate with the host. TCP achieves this in two ways:
- Order packages by numbering them
- Check for an error by sending a response from the recipient to the sender stating that he has received the message.
If the sender does not receive the correct response, the packets can be resended to ensure the recipient received them correctly.
Process Explorer and other System processing tools can show the type of communication a process creates. The image below shows the Chrome browser with open TCP connections to all web servers.
UDP protocols
Using the User Datagram Protocol (UDP), the computer that sends the information stores the data in small packets and releases them over the Network in the hope that they will reach their destination. This means that UDP, like TCP, does not connect directly to the receiving computer; Instead, it sends the data abroad and relies on devices between the sender’s and receiver’s computers to receive the data at the intended destination.
This transfer method does not guarantee that the transmitted data will reach its destination. However, it has very little overhead, making it useful for services that do not care about the successful receipt and transmission of data on the first try.
An example is the use of older postal services; You put your letter in the mailbox and hope the postal service will get it to the right place.
This is done most of the time, but sometimes, it gets lost.
Data transfer using UDP is faster because the sender does not wait to make sure the recipient has received the package but continues to send subsequent packages.
If the receiver loses several UDP packets, they are lost, and the sender does not resend them. UDP is used when speed is the main criterion and error correction is not required. UDP is often used in live video broadcasts and online games.
For example, suppose you are watching a live video stream that is playing using UDP. The server only sends a steady stream of UDP packets to the viewer compute, soo when your connection is lost for a few seconds, the video may pause or ski, butt then it goes to the current bit.
If you miss a portion of the package, the video or audio will be distorted momentarily, and the movie will continue playing without missing tracks.
This is what happens in online games. If you have some UDP packages whilplayingngthe playingaracter appears to be teleported to the map. When you receive newer UDP packages, older packages requesting to get them back are useless because the game goes on without you. All that matters is what is currently happening on the game server (not what happened a few seconds ago). Failure to correct the error in TCP will help speed up the game connection and reduce latency.
TCP or UDP port
Every computer or device on the Internet is identified by a unique number called an IP address. This address is used to identify your computer among millions of other computers connected to the Internet. When information is sent over the Internet, your computer receives this information using TCP or UDP ports.
You have one IP address and many ports in this IP address, including 65535 TCP ports and 65535 UDP ports. When a program on your computer receives or sends information over the Internet, it sends the data to an IP address and a specific port on the destination computer. It gets on a random port on your computer.
The TCP protocol uses the TCP port to send and receive data, and the UDP protocol uses the UDP port to send and receive data.
The image below represents an IP address divided into several TCP and UDP ports. Note that no other program can use that port whenever it connects to a specific port.
Since this is a bit difficult to understand, we will give you a simple example: We use web servers. A web server is a computer that runs a program and allows other computers to connect to it and access web pages stored there.
A web server must connect the web server application to a local port to accept a remote computer connection request.
The web server then uses this port to listen and accept remote computer communication.
Web servers typically connect to port 80 TC, the same port that the HTTP protocol uses by default, and then wait for remote computers to connect. After a device is connected, it sends the requested web pages to the device remotely and disconnects when it is one.
On the other hand, if you are a remote user who wants to connect to a web server, the opposite is true. Your web browser selects a random TCP port from a specific range of port numbers and tries to connect to port 80 at the web server’s IP address.
Once connected, the web browser sends the request to a specific web page and receives it from the web server. After this, both computers will disconnect.
But how do you set up an FTP server (which allows you to transfer and download files from remote computers to the same web server)? FTP servers use TCP 20 and TCP 21 ports to send and receive information, so there will be no conflicts with the web server running on the TCP 80 port.
As a result, when the FTP server program is running, it connects to TCP 20 and TCP 21 ports and waits for the connection to send and receive data.
Use of protocols
Applications use TCP or UDP depending on their needs and the decision of their developers. Most programs require TCP error correction and stability, but some programs need to speed up and reduce UDP overhead. This should not affect your business much unless you are a Network administrator or software developer.
A network analysis tool such as Wireshark can help you see the different types of packets being transmitted.
If you have configured your router or firewall software and are unsure if an application uses TCP or UDP, you can simply select Both to have your router or firewall apply the same Rule to TCP and UDP traffic.