TCP uses sequence numbers to avoid duplicate packets. Each segment in a TCP connection consists of a sequence number and an acknowledgement number.
When a sender sends a packet, it assigns a unique sequence number to each packet. The receiver acknowledges each packet by sending an acknowledgement number to the sender. If the sender receives an acknowledgement number for a packet, it knows that the packet was received successfully and it can proceed to send the next packet.
If a packet is lost or delayed in transit, the sender will not receive an acknowledgement number for that packet. In this case, the sender will re-transmit the packet with the same sequence number until the receiver acknowledges the receipt of the packet.
In summary, TCP uses sequence numbers and acknowledgement numbers to ensure that packets are not duplicated. If a packet is lost or delayed, the sender will re-transmit the packet until the receiver acknowledges the receipt of the packet.