# How does AH header in IPSec prevents replay attacks?

According to Tanenbaum's Modern operating systems,

The purpose of this field is to detect replay attacks. These sequence numbers may not wrap around. If all $$2^{32}$$ are exhausted, a new security association must be established to continue communication.

According to Forouzan's Data communications and networking,

In both protocols, replay attacks are prevented by using sequence numbers and a sliding receiver window. Each IPsec header contains a unique sequence number when the security association (SA) is established. It ranges from $$0$$ to $$2^{32}-1$$. When the sequence number reaches its maximum, it is reset to 0, the old SA is deleted, and a new one is established. To prevent duplicate packets, IPsec mandates the use of a fixed size window at receiver.

Can someone elaborate this with an example?