IPSec provides authentication, integrity, and confidentiality services to secure IP communications. It operates in either transport or tunnel mode, with transport mode securing only the IP payload and tunnel mode securing the entire packet. The Authentication Header (AH) provides authentication and integrity while the Encapsulating Security Payload (ESP) provides the same in addition to encryption/confidentiality. A replay attack occurs when a valid data transmission is maliciously or fraudulently repeated, and IPSec is commonly used for VPNs, remote access, and secure email.