TCP Retransmission

How does TCP determine that a segment needs to be retransmitted?