TL;DR
When an IPSec tunnel’s receive window fills up, performance drops dramatically or connections stall. This usually means the receiving end can’t process data fast enough. We’ll cover how to identify this issue and steps to resolve it, focusing on both network and endpoint configurations.
Understanding the Problem
IPSec relies on TCP for reliable transport. TCP uses a ‘window size’ to control how much data is sent before requiring an acknowledgement (ACK). If the receiving end’s buffer is full – meaning it hasn’t processed previous packets – it advertises a window size of zero. This effectively stops new data from being transmitted until space becomes available.
Identifying a Full Receive Window
- Packet Captures: Use tools like Wireshark or tcpdump to capture traffic on both ends of the tunnel. Look for TCP retransmissions and zero window advertisements.
- Wireshark Filter:
ipsecor filter by the specific IPSec ESP/AH protocol. - Examine the TCP stream details. A consistently small receive window size (or zero) is a key indicator.
Troubleshooting Steps
- Increase Buffer Sizes (Receiving End): This is often the first and most effective step.
- Linux: Modify
/etc/sysctl.conf. Add or adjust these parameters:net.ipv4.tcp_rmem = 4096 87380 16777216 # Minimum, default, maximum receive buffer sizes net.core.rmem_max = 16777216 # Maximum socket receive buffer sizeApply the changes with:
sudo sysctl -p. - Windows: Use PowerShell to adjust registry settings (requires administrator privileges):
New-ItemProperty -Path "HKLM:SYSTEMCurrentControlSetServicesTcpipParameters" -Name MaxTCPReceiveBuffer -Value 65536 -PropertyType DWordRestart the network adapter or the system for changes to take effect.
- Linux: Modify
- Check CPU Usage: High CPU usage on the receiving end can prevent timely packet processing.
- Identify and resolve any processes consuming excessive CPU resources.
- Consider upgrading the hardware if CPU capacity is consistently insufficient.
- Review IPSec Configuration: Ensure the IPSec configuration isn’t overly complex or using unnecessary algorithms.
- Simpler configurations generally require less processing power.
- Check for any misconfigured security policies that might be causing excessive overhead.
- Network Congestion: Network congestion can lead to packet loss and retransmissions, exacerbating the problem.
- Use tools like ping or traceroute to identify network bottlenecks.
- Investigate potential issues with bandwidth limitations or excessive latency.
- MTU/MSS Issues: Incorrect Maximum Transmission Unit (MTU) or Maximum Segment Size (MSS) settings can cause fragmentation and performance problems.
- Ensure the MTU is consistent across the network path. A common value is 1500 bytes.
- Consider adjusting the MSS clamping setting on both ends of the tunnel to avoid fragmentation.
# Linux example (StrongSwan) mssfix=yes
- Firewall/IDS Interference: Firewalls or Intrusion Detection Systems (IDS) might be interfering with IPSec traffic.
- Temporarily disable any firewalls or IDS rules that could be affecting the tunnel.
- If interference is identified, adjust the firewall/IDS configuration to allow IPSec traffic without inspection.
cyber security Considerations
When making changes to buffer sizes or IPSec configurations, always prioritize cyber security best practices. Avoid excessively large buffers that could be exploited for denial-of-service attacks. Regularly review and update your IPSec policies to ensure they remain secure.