Protect against a replay attack.
Anti-replay is a sub-protocol of IPSec and is part of the Internet
Engineering Task Force (IETF) Request for Comments (RFC) 6479. The
anti-replay protocol is used to prevent hackers from injecting or making
changes in packets that travel from a source to a destination and uses a
unidirectional security association in order to establish a secure
connection between two nodes in the network.
After a secure connection is established, the anti-replay protocol uses
packet sequence numbers to defeat replay attacks. When the source sends a
message, it adds a sequence number to its packet; the sequence number starts
at 0 and is incremented by 1 for each subsequent packet. The destination
maintains the sequence of numbers in a sliding window format,
maintains a record of the sequence numbers of validated received packets,
and rejects all packets that have a sequence number that is lower than the
lowest in the sliding window (packets that are too old) or packets that
already appear in the sliding window (duplicate or replayed packets).
Accepted packets, after they’re validated, update the sliding window,
displacing the lowest sequence number out of the window if it was already
full.