IPSec uses two protocols to provide security for IP packets: the Encapsulating Security Payload (ESP) and Authentication Header (AH). ESP provides both encryption and authentication, and can operate in either transport or tunnel mode. AH provides authentication through cryptographic integrity checks on packet headers and data. Internet Key Exchange (IKE) negotiates the security associations (SAs) needed to implement IPSec by using either pre-shared keys or digital certificates. IKE has two phases - main mode negotiates the IKE SA while quick mode establishes IPSec SAs to protect data transmission.