Security Parameter Index

The Security Parameter Index (SPI) is an identification tag added to the header while using IPsec for tunneling the IP traffic.

This tag helps the kernel discern between two traffic streams where different encryption rules and algorithms may be in use.

The SPI (as per RFC 2401) is a required part of an IPsec Security Association (SA) because it enables the receiving system to select the SA under which a received packet will be processed.

However, the creator of an SA may interpret the bits in an SPI to facilitate local processing.

This works like port numbers in TCP and UDP connections.