TCP handles packet loss by using a technique called “automatic repeat request” (ARQ). When a packet is sent, the receiving device sends an acknowledgement (ACK) back to the sender. If the sender does not receive an ACK within a certain time frame, it assumes that the packet was lost and retransmits it.
In addition, TCP uses a sliding window protocol to control the flow of packets between the sender and receiver. This means that the sender can only send a certain number of packets at a time, and must wait for acknowledgement before sending more.
Finally, TCP also implements “congestion control” to prevent network congestion and reduce the likelihood of packet loss. When congestion is detected, TCP reduces the rate at which packets are sent to avoid overloading the network.