The transfer of data is dominated by two mechanisms, acknowledgements of data and sequence numbers in a segment to allow for re-assembly.
When a segment of data is transmitted, the host that transmitted it expects to receive an acknowledgement within a certain time period. If the acknowledgement is not forthcoming, the host retransmits the data. This is how TCP ensures that the data is delivered.
Sequence numbers allow the receiving host to reassemble any out of order packets received from a host. The sender sets the sequence field to a predetermined value (figure 3.1). The receiver takes this sequence number, and adds to it the number of bytes in the segment, this is calculated from the amount of data received, plus one byte for each of the SYN or FIN flags that are set. This is the next sequence number the receiver expects to see in a packet from the sender. This is also the acknowledgement number the receiver sends to the other host. If a packet arrives that doesn't have the correct sequence number, the receiver can determine whether it is an old duplicate or if it is a packet that has been delayed in the network. The receipt of a duplicate packet allows the host to discard it, thus making sure that the receiving process only gets the data once.