What Is The Difference Between TCP and UDP are one of the most common interview questions in any network job interview question? đ¤ Yes. Apart from job interview if you are doing port forwarding for your online gaming then also you will find the option to both TCP and UDP in your router.
With this guide, I will try to give the answer to the Difference Between TCP and UDP in both the full technical way and also try to explain for non-technical userâs questions regarding this topic.
Without any further delay, letâs get started.
TCP (Transmission Control Protocol) is the best known and most common protocol, and it works by assigning each packet a unique identifier and a sequence number. This tells the receiver which packet has arrived, and which one to expect next.Â
When a packet reaches its destination, the receiver checks that everything is as intended and then fires off an acknowledgment to the sender.
When the sender receives this, it sends the next packet. If a packet fails to arrive or arrives in the wrong order, the receiver wonât acknowledge it, so the sender tries again.
This two-way communication makes TCP very reliable but not particularly fast. UDP (User Datagram Protocol) doesnât bother with unique identifiers or sequence numbers â it simply uses checksums to make sure the data it receives hasnât been corrupted en route. This makes it much faster but also less reliable.
Letâs understand the Process of TCP communication with the below-mentioned diagram.
Here Sender (Your PC) wants to establish a communication with a remote server (Ex:- gaming server or any other server or another PC) then it sends a synchronize (SYN) request to the receiver.
Once the receiver is seeing someone wants to establish a connection then it will also try to negotiate the connection with the sender then the sender will acknowledge the connection which will help to establish the connection.
After establishing the connection, data transfer will start from both the end, and this whole process is called a TCP-Three way handshake.
Before moving forward, I want to explain some important terms that are important to know.
Protocol:- A Set of a rule that allows how data communication will occur between two electronic devices.
Routing:- To define the path where data has to be sent.
Synchronization Number:- The first packet sent by a source device to establish the connection.
TCP Three-Way handshake:- A process to establish the connection between the client and the server.
Port number:- A way to identify a specific process to forward the messages.
Is it Possible to View the TCP/UDP communication happening on your PC?
Till now we have learned about the theoretical point of TCP but we can also able to view the TCP communication happening on your PC.
Windows comes with an inbuilt command ânetstatâ to view the connection. Open the command prompt and enter the command netstat.
it will show you the status of active sessions with the Protocol being used, Local address, Foreign address, and the status of the connection.
As you saw in the below diagram my pc is connected with technicalustad server and the session is established on the protocol TCP.
if you want to know from which website your PC is secretly connecting then use the command
netstat -abf
If you are looking for a GUI tool for this purpose then I will recommend you yo use the Currports tool (Download Here) from Nirsoft.
it will show you the same netstat information in the GUI view along with the command to kill it.
if you want to close the connection then just right-click on the particular connection select the kill connection option.
if you want to view the send and receive bytes of data by each connection then LiveTcpUdpWatch (Download Here) is your tool.
What Is The Difference Between TCP and UDP?
TCP | UDP |
Sequenced | Unsequenced |
Reliable | Unreliable |
Connection-oriented | Connectionless |
Virtual circuit | Low Overhead |
Acknowledgments | No Acknowledgments |
Windowing flow control | No windowing or flow control |
Letâs break down the TCP and UDP in the simple language, TCP is like your mobile phone communication where you are calling a person and the receiver acknowledge the call by accepting it and after the acceptance, you start talking.
TCP is a mostly used communication protocol for web-browsing, email, Client-server communications.
But UDP is like a Postcard where you send the message to the address but you donât know when itâs reached.
UDP is mostly used in the Voice call and gaming where you need speed.
In our Difference Between TCP and UDP chart, all terms are self-explanatory except the virtual circuit.
letâs understand this, Most of us know that before you speak to someone on a phone, you must first establish a connection with that other personâwherever they are. This is like a virtual circuit with the TCP protocol.
Is TCP better than UDP?
It completely depends upon application requirement, If the application required fast connection like a Video call or gaming then UDP is better then TCP but where you need a reliable connection like web-browsing then TCP is better then UDP.
Where TCP and UDP are used?
Why UDP is faster than TCP?
What is the major difference between TCP and UDP packets Quizlet?
Is UDP secure?
Does Netflix use TCP or UDP?
What is the difference between the TCP and UDP Header?
The TCP header is 20 bytes long, or up to 24 bytes with options. You need to understand what each field in the TCP segment is:-
Source port:- The port number of the application on the host sending the data. (Port numbers will be explained a little later in this section.)
Destination port:- The port number of the application requested on the destination host.
Sequence number:- A number used by TCP that puts the data back in the correct order or retransmits missing or damaged data, a process called sequencing.
Acknowledgment number:- The TCP octet that is expected next.
Header length:- The number of 32-bit words in the TCP header. This indicates where the data begins. The TCP header (even one including options) is an integral number of 32 bits in length.
Reserved Always set to zero.
Code bits Control functions used to set up and terminate a session.
Window The window size the sender is willing to accept, in octets.
Checksum The cyclic redundancy check (CRC), because TCP doesnât trust the lower layers and checks everything. The CRC checks the header and data fields.
Urgent A valid field only if the Urgent pointer in the code bits is set. If so, this value indicates the offset from the current sequence number, in octets, where the first segment of non-urgent data begins.
Letâs first look at the UDP packet header,
Itâs important for you to understand what each field in the UDP segment is:
Source port Port number of the application on the host sending the data
Destination port Port number of the application requested on the destination host
Length Length of UDP header and UDP data
Checksum of both the UDP header and UDP data fields Data Upper-layer data
Is it Possible to View the TCP Packet Header?
Yes, you can view the TCP packet header on your PC with the help of packet sniffer like WireShark (Download Here), after installation launch the application and select the interface that you are using.
now it will start capturing your interface traffic. under the filter, option enters the TCP. Select any packet that you want to view the packet.
after selection, you will see the âTransparent Control Protocolâ option.
it will show you the TCP header information.
same way, you are able to view the UDP header.
Conclusion
With our guide on What Is The Difference Between TCP and UDP protocol, we tried to cover up all the aspects of both the protocol that a technical and normal user needs to know.
Overall TCP is a connection-oriented, Full-duplex, reliable, and secure protocol in comparison to the UDP protocol.
With this post, we didnât only cover the differences but also you are able to view both the connection on your PC with Wireshark and other small nifty programs like currports and also you are able to view the connection with the netstat commmand.