TCP: Reliability Guaranteed
If we want to define the Internet in the simplest way, we can say: A network of networks is called the Internet. > When various networks connect through a common medium, they create a public network. However, if every network used its own unique rules (protocols) to communicate, they wouldn't understand each other. To solve this, protocols were standardized so everyone speaks the same language.
At the Transport Layer, two major protocols are used to move data: TCP and UDP.
UDP (User Datagram Protocol)
UDP is one of the most common protocols used for streaming data. Unlike TCP, UDP is unreliable. It does not guarantee that data will reach its destination, nor does it use a handshake process.

So, why do we use it? Efficiency. UDP is extremely fast. In certain scenarios, it works beautifully. For example, if you are watching a live cricket match, speed is everything. If 2 or 3 packets are missed, we can tolerate a tiny skip in the video to keep the stream live. In these cases, it is better to ignore the missing data than to pause the match to wait for it.
TCP:
“The guarantor” ensures that data packets reach their destination without fail. It not only checks the data delivery but also checks its integrity, ensuring the data is received in the same order as it is sent from the sender. To achieve this, it uses a 3-way handshake.
The TCP 3-Way Handshake
Think of this as a phone call. Before you start sharing secrets, you make sure the other person is listening.
SYN (Synchronize): The client sends a "Hello" packet with a unique sequence number. "I want to connect."
SYN-ACK (Synchronize-Acknowledge): The server replies, "I hear you! I’m ready to talk, and here is my sequence number."
ACK (Acknowledge): The client says, "Got it! Let’s start sending data."

How it Guarantees Reliability
Once the connection is established, TCP uses three main tricks to ensure your data is perfect:
Sequence Numbers (Ordering): TCP breaks data into small segments and numbers them. If they arrive out of order (e.g., 1, 3, 2), TCP puts them back in the right order (1, 2, 3).
Acknowledgements (Reliability): For every packet the receiver gets, it sends back an ACK. If the sender doesn't get an ACK for packet #2, it assumes it was lost and re sends it automatically.
Flow Control: TCP is smart. If the receiver’s computer is slow, TCP slows down the speed of data so it doesn't overwhelm the device.
Closing the Connection
When the data transfer is finished, TCP doesn't just hang up. It follows a graceful shutdown process:
FIN: "I'm done."
ACK: "Understood."
FIN: "I'm also done."
ACK: "Goodbye!"
To understand better some of the example for TCP and even for UDP so that you can differentiate with both
TCP : Websit, emails, some kind of downloads.
UDP = Video streaming, Video Call, etc.