IPsec protects traffic at the IP layer based on policies, while IKEv2 is responsible for authenticating peers, negotiating algorithms, and maintaining security associations. Taking the example of headquarters 10.10.0.0/24 accessing branch 10.20.0.0/24: business hosts send packets to the gateway, which determines if protection is needed and encapsulates them using the established outbound SA; the peer gateway looks up the inbound SA, authenticates and decrypts, checks the policy, and then forwards the traffic to the internal network.
There are three independent things here: where system routing sends the packet, how the policy requires protection, and whether the SA has available keys and state. IKE showing "connected" only proves that part of this is true.
Quick Diagnosis
What to Check
IKE SA and Child SA
Control message status and business traffic status
ESP and AH
Whether encryption is used and which fields are authenticated
Tunnel and Transport
Whether the complete original IP packet is encapsulated
Can IKE_AUTH see the header?
Boundary between protected payloads and outer headers
Why are there two formats for UDP 4500?
Zero-marked IKE vs. non-zero SPI for ESP
Does rekeying re-verify the user?
Rekey vs. Reauthentication
SA exists but no traffic counters?
Routing, selectors, forwarding, and return path
Policies and Security Associations: Why They Are Stored Separately
The Security Policy Database (SPD) expresses whether traffic should be dropped, bypassed, or protected by IPsec; the Security Association Database (SAD) stores specific algorithms, keys, SPIs, sequence numbers, and lifecycle states. A policy can point to different generations of SAs at different times, and old and new SAs may coexist briefly during rekeying. IPsec Architecture RFC 4301
ESP SAs are unidirectional: A→B and B→A use their own SPIs, keys, and sequence numbers. One IKEv2 Child SA negotiation typically creates such a pair of SAs; management tools may display them collectively as a single CHILD_SA. The IKE SA protects subsequent control messages for both parties; its SPI and ESP's SPI do not belong to the same numbering space. strongSwan IPsec Introduction
Inbound ESP uses the SPI recognized by the receiving side to look up the security association; the SPI is not a password, nor is it a user identity. Even if a packet finds an SA, it must still pass authentication, replay checks, and policy constraints. You cannot treat a packet as legitimate business traffic just because it has the correct SPI.
How Traffic Selectors Restrict a Tunnel
Traffic Selectors include address ranges, protocols, and port ranges. The initiator can propose a broader range, and the responder accepts a narrower range based on policy. For example, if headquarters proposes accessing the entire branch 10.20.0.0/24 from 10.10.0.0/24, but the final policy only allows TCP 443 to branch server 10.20.0.8, you cannot interpret a successful negotiation as allowing access to any port on the entire branch subnet.
The following only demonstrates selector matching for one direction that has already been determined, without simulating full IKE negotiation or kernel SPD priority.
fromipaddressimportip_address,ip_networkdefprotected_flow(src,dst,protocol,dport):return(ip_address(src)inip_network('10.10.0.0/24')andip_address(dst)==ip_address('10.20.0.8')andprotocol==6anddport==443)assertprotected_flow('10.10.0.9','10.20.0.8',6,443)assertnotprotected_flow('10.10.0.9','10.20.0.8',6,22)assertnotprotected_flow('10.10.0.9','10.20.0.9',6,443)assertnotprotected_flow('10.11.0.9','10.20.0.8',6,443)print('Partial model with matching address, protocol, and port passed')
If you find the SPI, can you deliver the inner packet?
Replacing the correct SPI with the outbound SA's SPI, even if saved on the same device, does not constitute inbound state for this direction. After restoration, if you change the destination port, the cryptographic check may pass, but the packet could still be rejected due to selectors. The SPI is not a passcode.
Preparing the visual
If you find the SPI, can you deliver the inner packet?
SPI locates unidirectional key state; selectors constrain protected traffic. Finding the SA, successful authentication, and policy allowance are three sequential criteria.
{"id":"ipsec-sa-and-selector","title":"If you find the SPI, can you deliver the inner packet?","summary":"SPI locates unidirectional key state; selectors constrain protected traffic. Finding the SA, successful authentication, and policy allowance are three sequential criteria.","height":1000,"html":"<h2 data-i18n=\"heading\"></h2><p class=\"intro\" data-i18n=\"intro\"></p><label class=\"form-field\"><span data-i18n=\"spi\"></span><select id=\"spi\"><option value=\"258\">0x102 inbound</option><option value=\"513\">0x201 outbound</option><option value=\"999\">0x3e7 unknown</option></select></label><label class=\"check\"><input type=\"checkbox\" id=\"auth\" checked><span data-i18n=\"auth\"></span></label><div class=\"control\"><label for=\"dst\" data-i18n=\"dst\"></label><output for=\"dst\" id=\"dst-value\"></output><input id=\"dst\" type=\"range\" min=\"7\" max=\"9\" value=\"8\" step=\"1\"></div><label class=\"form-field\"><span data-i18n=\"port\"></span><select id=\"port\"><option value=\"443\">TCP443</option><option value=\"22\">TCP22</option></select></label><div class=\"track-row\"><span data-i18n=\"trace\"></span><div id=\"trace\" class=\"track\"></div></div><div class=\"metrics\"><div><span data-i18n=\"result\"></span><strong id=\"result\"></strong></div></div><details class=\"scope\"><summary data-i18n=\"scopeLabel\"></summary><p data-i18n=\"scope\"></p></details>","css":".intro{margin:8px 0 18px;color:var(--muted);font-size:14px}.caption,.hint{font-size:12px;color:var(--muted);margin-top:12px}.control{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 12px;align-items:center;margin:14px 0;font-size:13px}.control label{font-size:13px}.control output{color:var(--accent);min-width:5em;text-align:right;font-variant-numeric:tabular-nums}.control input{grid-column:1/-1;width:100%;margin:0}.presets{display:flex;gap:4px;align-items:stretch}.presets button{flex:1 1 0;min-width:0;overflow-wrap:anywhere;font-size:13px}.actions{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0}.actions button{flex:1;min-width:0;font-size:13px;min-height:42px}.copy{display:grid;font-size:14px;margin:16px 0}.copy>*{grid-area:1/1;margin:0}.reserve{visibility:hidden}.scope{margin-top:14px;color:var(--muted);font-size:12px}.scope summary{padding:8px 0;cursor:pointer}.scope p{margin-top:10px}.two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:16px 0}.card{border:1px solid var(--rule);border-radius:9px;padding:14px;min-width:0}.card header{font-size:14px;font-weight:600;margin-bottom:10px}.card button{font-size:12px;width:100%;min-width:0}.card small{display:block;font-size:12px;color:var(--muted)}.card code{font-size:12px;overflow-wrap:anywhere}.metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:16px 0}.metrics>div{border-left:2px solid var(--accent);padding-left:10px;min-width:0}.metrics span{display:block;min-height:3.2em;color:var(--muted);font-size:12px}.metrics strong{font-size:23px;display:block;font-weight:500;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.formula{border-top:1px solid var(--rule);padding-top:12px;margin-top:14px;font-size:13px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.value{font:500 20px var(--viz-font-ui)}.legend{display:flex;flex-wrap:wrap;gap:6px 14px;font-size:12px;color:var(--muted);margin:12px 0}.legend span:before{content:'';display:inline-block;width:8px;height:8px;border-radius:2px;background:var(--accent);margin-right:6px}.legend .second:before{background:var(--second)}.check{display:flex;align-items:center;gap:8px;font-size:13px;margin:12px 0}.check input{width:16px;height:16px;flex-shrink:0;accent-color:var(--accent)}select,input[type=text],input[type=number]{background:var(--paper);color:var(--ink);font:inherit;font-size:13px;padding:10px;border:1px solid var(--rule);border-radius:7px;max-width:100%;min-width:0}select{width:100%;min-height:42px}.band{height:20px;display:flex;background:var(--surface);border-radius:4px;overflow:hidden}.band i{height:100%;display:block;background:var(--accent);transition:width .25s}.band i.second{background:var(--second)}button:disabled{cursor:default}.status{font-size:13px;min-height:4.8em}.mono{font-family:var(--viz-font-mono);font-variant-numeric:tabular-nums}.muted{color:var(--muted)}\n@media(max-width:480px){.two{gap:8px}.card{padding:12px 9px}.actions button,.presets button{font-size:12px}.metrics strong{font-size:20px}.metrics{gap:8px}}\n@media(prefers-reduced-motion:reduce){*,*::before,*::after{transition:none!important;animation:none!important}}\n.track-row{margin:16px 0}.track-row>span{display:block;font-size:12px;color:var(--muted);margin-bottom:7px}.track{display:flex;gap:5px;min-width:0}.cell{flex:1;min-width:0;min-height:48px;border:1px solid var(--rule);border-radius:5px;background:var(--surface);display:flex;align-items:center;justify-content:center;text-align:center;padding:5px 3px;font-size:12px;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.cell.on{background:var(--accent-soft);border-color:var(--accent)}.cell.gold{background:var(--second-soft);border-color:var(--second)}.cell.empty{border-style:dashed;color:var(--muted)}.cell.error{border-color:var(--second);text-decoration:line-through}.choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin:14px 0}.choices button{min-width:0;padding:10px 4px;font-size:12px;overflow-wrap:anywhere}.choices button[aria-current=true]{border-color:var(--accent);background:var(--accent-soft)}.relation{display:grid;grid-template-columns:minmax(0,1fr) 28px minmax(0,1fr);align-items:center;gap:6px;margin:12px 0}.relation .cell{min-height:72px}.relation>i{text-align:center;font-style:normal;color:var(--accent)}.readout{font-size:13px;white-space:pre-line;min-height:6.4em;overflow-wrap:anywhere}.plot{position:relative;border-left:1px solid var(--rule);border-bottom:1px solid var(--rule);padding:8px 0;margin:18px 0}.plot-row{height:28px;position:relative;margin:4px 0;background:var(--surface)}.plot-row i{position:absolute;inset-block:5px;background:var(--accent);min-width:2px;transition:width .2s,left .2s}.plot-row b{position:relative;padding:4px 6px;font:11px/28px var(--viz-font-ui);background:var(--paper);border-radius:3px}.axis{display:flex;justify-content:space-between;font-size:11px;color:var(--muted)}\n\n/* Action labels must remain readable across locales and narrow embeds. */\n.actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}\n.actions button{overflow-wrap:anywhere;white-space:normal;min-height:58px;padding:8px}\nbutton{overflow-wrap:anywhere}\n@media(min-width:640px){.actions{grid-template-columns:repeat(3,minmax(0,1fr))}}\n\n.metrics span{overflow-wrap:anywhere}\n.panel{border:1px solid var(--rule);border-radius:9px;padding:12px;margin:14px 0;min-width:0}.panel h3{font-size:13px;margin:0 0 10px;color:var(--muted)}.source{font:13px/1.8 var(--viz-font-mono);white-space:pre-wrap;overflow-wrap:anywhere;margin:12px 0}.source mark{background:var(--accent-soft);color:var(--ink);border-bottom:2px solid var(--accent)}.source .fault{background:var(--second-soft);border-color:var(--second)}.diagram{display:block;width:100%;height:auto;max-height:320px;margin:14px 0;overflow:visible}.diagram text{fill:var(--ink);font:12px var(--viz-font-ui)}.diagram .edge{stroke:var(--muted);stroke-width:1.5;fill:none}.diagram .edge.on{stroke:var(--accent);stroke-width:3}.diagram .node{fill:var(--surface);stroke:var(--rule);stroke-width:1.5}.diagram .node.on{fill:var(--accent-soft);stroke:var(--accent)}.diagram .node.gold{fill:var(--second-soft);stroke:var(--second)}.log{font:12px/1.8 var(--viz-font-mono);white-space:pre-line;overflow-wrap:anywhere;min-height:7.2em}.table{display:grid;gap:5px;margin:14px 0}.table .tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}.table .tr>*{padding:8px 5px;background:var(--surface);border-radius:4px;min-width:0;overflow-wrap:anywhere;font-size:12px}.table .tr .on{background:var(--accent-soft)}.table .tr .gold{background:var(--second-soft)}.choices button{min-height:44px}.metrics strong{min-height:1.6em}.code-line{display:block}.code-line.on{background:var(--accent-soft);border-left:2px solid var(--accent);padding-left:6px}.status-badge{font-size:12px;color:var(--accent)}.tile-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}.tile-grid .cell{min-height:40px}.actions button{min-height:48px}.form-field{display:grid;gap:8px;margin:14px 0;font-size:13px}.form-field input{width:100%;font-family:var(--viz-font-ui)}.metrics.three{grid-template-columns:repeat(3,minmax(0,1fr))}.formula{min-height:3.2em}.presets{flex-wrap:wrap}.presets button{flex-basis:25%;min-height:44px}\n\n.budget{display:flex;height:28px;margin:16px 0;background:var(--surface);border-radius:5px;overflow:hidden}.budget i{display:block;background:var(--accent);transition:width .2s}.budget i.gold{background:var(--second)}.intervals{margin:16px 0}.interval{position:relative;height:36px;background:var(--surface);margin:6px 0;border-radius:4px;overflow:hidden}.interval i{position:absolute;height:100%;background:var(--accent-soft);border-left:2px solid var(--accent)}.interval i.gold{background:var(--second-soft);border-color:var(--second)}.interval span{position:relative;z-index:1;font:12px/36px var(--viz-font-ui);padding-left:7px}.table .tr>*{min-height:4.8em}.formula{white-space:pre-line;min-height:7.2em}.actions:has(>button:only-child){grid-template-columns:1fr}.metrics strong{min-height:3.2em}.rangegrid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:3px;margin:14px 0}.rangegrid .cell{min-height:30px;padding:3px 1px;font-size:10px}.message{min-height:7.2em;white-space:pre-line;font:13px/1.8 var(--viz-font-ui);overflow-wrap:anywhere}\n/* Allow CJK hanging punctuation without overflowing a metric's border box. */\n.metrics>div{padding-right:4px}.metrics span{line-break:anywhere}\n\n.metrics strong{font-size:17px}","js":"const $=s=>document.querySelector(s);const set=(id,v)=>$('#'+id).textContent=v;const t=k=>viz.t(k);function cells(id,values){$('#'+id).replaceChildren(...values.map(v=>{const e=document.createElement('div');e.className='cell '+(v.cls||'');e.textContent=v.text;e.title=v.title||v.text;return e;}));}function pressed(mode){document.querySelectorAll('[data-mode]').forEach(e=>e.setAttribute('aria-pressed',String(e.dataset.mode===mode)));}const esc=s=>String(s).replace(/[&<>\"']/g,c=>({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[c]));const fmt=s=>'{'+[...s].sort().join(', ')+'}';function graph(id,nodes,edges){const el=$('#'+id);el.setAttribute('viewBox','0 0 360 200');el.innerHTML='<defs><marker id=\"arrow-'+id+'\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"5\" markerHeight=\"5\" orient=\"auto-start-reverse\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"var(--muted)\"/></marker></defs>'+edges.map(e=>{const a=nodes[e[0]],b=nodes[e[1]],dx=b.x-a.x,dy=b.y-a.y,d=Math.hypot(dx,dy)||1;if(edges.some(r=>r[0]===e[1]&&r[1]===e[0])){const nx=-dy/d,ny=dx/d;return '<path class=\"edge '+(e[2]?'on':'')+'\" d=\"M '+(a.x+dx/d*22+nx*12)+' '+(a.y+dy/d*22+ny*12)+' Q '+((a.x+b.x)/2+nx*38)+' '+((a.y+b.y)/2+ny*38)+' '+(b.x-dx/d*25+nx*12)+' '+(b.y-dy/d*25+ny*12)+'\" marker-end=\"url(#arrow-'+id+')\"/>';}return '<line class=\"edge '+(e[2]?'on':'')+'\" x1=\"'+(a.x+dx/d*25)+'\" y1=\"'+(a.y+dy/d*25)+'\" x2=\"'+(b.x-dx/d*28)+'\" y2=\"'+(b.y-dy/d*28)+'\" marker-end=\"url(#arrow-'+id+')\"/>';}).join('')+nodes.map(n=>'<g><circle class=\"node '+(n.cls||'')+'\" cx=\"'+n.x+'\" cy=\"'+n.y+'\" r=\"25\"/><text x=\"'+n.x+'\" y=\"'+(n.y+4)+'\" text-anchor=\"middle\">'+esc(n.name)+'</text>'+(n.sub?'<text x=\"'+n.x+'\" y=\"'+(n.y+43)+'\" text-anchor=\"middle\">'+esc(n.sub)+'</text>':'')+'</g>').join('');}function table(id,rows){$('#'+id).classList.add('table');$('#'+id).replaceChildren(...rows.map(r=>{const row=document.createElement('div');row.className='tr';r.forEach(x=>{const c=document.createElement('div');if(typeof x==='object'){c.textContent=x.text;c.className=x.cls||'';}else c.textContent=x;row.append(c)});return row;}));}function band(id,parts,total){$('#'+id).replaceChildren(...parts.map((p,i)=>{const e=document.createElement('i');e.style.width=(100*p.value/total)+'%';e.className=i%2?'gold':'on';e.title=p.name+': '+p.value;return e}));}function intervals(id,items,total){$('#'+id).replaceChildren(...items.map(p=>{const row=document.createElement('div');row.className='interval';const bar=document.createElement('i');bar.style.left=(100*p.start/total)+'%';bar.style.width=(100*(p.end-p.start)/total)+'%';bar.className=p.cls||'';const label=document.createElement('span');label.textContent=p.label;row.append(bar,label);return row;}));}function draw(){const sa=+$('#spi').value===258,auth=sa&&$('#auth').checked,policy=auth&&+$('#dst').value===8&&+$('#port').value===443;set('dst-value','10.20.0.'+$('#dst').value);cells('trace',[{text:'SAD',cls:sa?'on':'error'},{text:'AEAD/replay',cls:auth?'on':'empty'},{text:'selector',cls:policy?'on':'empty'}]);set('result',!sa?'DROP: no inbound SA':!auth?'DROP: authentication':!policy?'DROP: selector':'DELIVER');$('#result').dataset.deliver=String(policy);}document.querySelectorAll('input,select').forEach(e=>e.oninput=draw);draw();","audio":false,"strings":{"auth":"Authentication and replay check passed","dst":"Inner destination last byte","heading":"If you find the SPI, can you deliver the inner packet?","intro":"Modify the inbound SPI, authentication result, and inner destination to trace checks executed after SAD lookup.","port":"Inner destination port","reset":"Reset","result":"Processing result","scope":"Fixed inbound SA SPI 0x102, outbound SA 0x201; only allows source 10.10.0.9 to 10.20.0.8 TCP 443. Authentication switch includes integrity and replay prerequisites; no real decryption or SPD priority.","scopeLabel":"Model Scope and Conventions","spi":"Received SPI","trace":"Inbound check chain"}}
ESP: Visible Fields, Encrypted Content, and Authentication
ESP uses IP protocol number 50, and AH uses 51; these numbers are protocol numbers, not TCP/UDP ports. ESP can provide confidentiality and integrity, determined by negotiated transforms; AH provides authentication without encryption and covers selected IP header fields, making it more sensitive to NAT address rewriting. Not all ESP combinations can be described as using a single fixed encryption algorithm.
Part
Visibility and Function
SPI 4 B, Sequence Number 4 B
Plaintext header, helps locate SA and replay check
Explicit IV
Algorithm-dependent; 8 B for AES-GCM-ESP
Payload, Padding, Pad Length, Next Header
Content protected under the encryption transform
ICV / Tag
Integrity check, length determined by the transform
Transport mode typically protects the upper-layer content after the original IP header; Tunnel mode treats the complete original IP packet as inner payload, adding a new outer IP header. The former does not mean the original IP header is completely immutable, nor does the latter equal end-to-end business encryption: the gateway-to-gateway tunnel terminates at the peer gateway. ESP RFC 4303
Don't Confuse the Three Lengths of AES-GCM
The nonce for AES-GCM-ESP consists of a 4 B salt and an 8 B explicit IV. The salt is allocated with key material; it is not sent as a 4 B field in the ESP header for each packet; the explicit IV appears in the packet and must not repeat under the same key. The SPI and sequence number participate in the Additional Authenticated Data (AAD), so they cannot be arbitrarily rewritten.
Tag support length is determined by the specific transform identifier: RFC 4106 requires support for 16 B, and allows 8 B or 12 B; you cannot uniformly write "GCM's ICV is 12 B". The example below selects a 16 B Tag, minimum four-byte alignment, IPv4 without options, and UDP NAT-T; there is no additional traffic-hiding padding. AES-GCM-ESP RFC 4106
defesp_tunnel_size(inner,outer_ip=20,udp=True):padding=(-(inner+2))%4total=outer_ip+(8ifudpelse0)+8+8+inner+padding+2+16returntotal, paddingassertesp_tunnel_size(1000)==(1064,2)assertesp_tunnel_size(1000,udp=False)==(1056,2)assertesp_tunnel_size(1000,outer_ip=40)==(1084,2)assertmax(nforninrange(1501)ifesp_tunnel_size(n)[0]<=1500)==1438assertesp_tunnel_size(1438)==(1500,0)assertesp_tunnel_size(1439)[0]==1504print('ESP length budget under clear algorithm and encapsulation assumptions passed')
1438 B is the maximum complete inner IP packet under this set of assumptions, not TCP application payload. Inner IPv4/TCP must also deduct its own header; calculations should be redone if algorithms, outer IPv6, IP options, or other tunnels change.
Sequence numbers and the receive replay window allow a certain degree of out-of-order packets while rejecting duplicates. ESN uses extended sequence numbers, but the online ESP sequence number field remains the lower 32 bits, with the high bits inferred from state and participating in authentication. The replay window is not a reliable transmission window: lost ESP packets will not be automatically retransmitted by ESP.
IKEv2: Derive Protection Keys First, Then Complete Identity Authentication
Without additional challenges, EAP, or extended exchanges, initial establishment typically involves two request-response exchanges: IKE_SA_INIT and IKE_AUTH, i.e., approximately two network RTTs, plus computation time. Cookies, failed DH group retries, authentication methods, and packet loss can all increase time; you cannot write that all connections consist of a constant four packets. IKEv2 Initial Exchange
The IKE_SA_INIT exchange proposes algorithms, temporary DH public keys, and nonces. Obtaining a shared secret at this stage does not mean the other party's identity has been proven: identity verification must bind to the negotiation record to prevent establishing an encrypted channel shared only with an attacker.
The encrypted payload of IKE_AUTH contains identity, authentication material, and parameters required for the first Child SA; the outer IP/UDP and IKE headers remain visible. AUTH can be based on mechanisms such as signatures or shared keys; it cannot be limited to "signing the first message with a certificate private key." The input for basic signature authentication also includes the other party's nonce and identity payloads processed with SK_pi/SK_pr, establishing a binding between the handshake and identity. RFC 7296 §2.15
EAP authentication may require multiple IKE_AUTH round trips; declaring IDi does not mean EAP identity authentication is complete. Even after authentication passes, you must still check if that identity is authorized to request the corresponding selectors.
Order and Purpose in Key Derivation
In the basic DH flow, let g^ir be the shared secret calculated by both parties using "their own private key and the other party's public key"; it is not a direct DH operation on two public KE values.
Stage
Basic Derivation Expression
Initial IKE Seed
SKEYSEED = prf(Ni | Nr, g^ir)
IKE Key Expansion
prf+(SKEYSEED, Ni | Nr | SPIi | SPIr)
First Child / Child without new DH
KEYMAT = prf+(SK_d, Ni | Nr)
CREATE_CHILD_SA with new DH
KEYMAT = prf+(SK_d, g^ir_new | Ni | Nr)
prf+ is the iterative expansion function defined by IKE, not infinitely repeating an HMAC result. The expanded IKE material sequentially serves SK_d, integrity/encryption for both directions, and identity authentication auxiliary purposes; AEAD combinations do not require additional keys for traditional integrity algorithms. SK_pi/SK_pr are not certificate private keys. RFC 7296 §2.13–2.17
The first Child uses the nonce from IKE_SA_INIT; subsequent creations use nonces from corresponding new exchanges. When there is a new DH, the shared secret comes before Ni/Nr, not as an additional field that can be arbitrarily placed at the end. The basic first Child having no additional KE exchange does not mean the entire connection has no temporary DH.
NAT-T: Distinguishing IKE and ESP on UDP 4500
Native ESP has no TCP/UDP ports, making it difficult for many NATs to correctly maintain multi-client ESP mappings. NAT-T encapsulates ESP in UDP, commonly using 4500; IKE usually establishes from UDP 500 first, detecting NAT or switching to 4500 based on functional conditions. Seeing 4500 alone is insufficient to assert NAT is present; behaviors like MOBIKE also affect port usage. strongSwan NAT Traversal
UDP 4500 Payload
Judgment Method
IKE Message
Preceded by four zero-byte Non-ESP Marker, followed by IKE header
UDP Encapsulated ESP
Starts directly from non-zero SPI, without adding these four zeros
NAT Keepalive
Specific single byte 0xff, used to maintain mapping
Therefore, the previous ESP length budget only adds an 8 B UDP header, without adding the 4 B IKE-specific marker. NAT keepalives maintain the mapping, while protected IKE liveness checks confirm peer response; the two cannot replace each other. UDP Encapsulation RFC 3948
Rekeying, Reauthentication, and Address Migration
CREATE_CHILD_SA can establish additional Children, replace existing Children, and can also be used for IKE SA rekeying. The basic exchange is one request plus one response, approximately one RTT; "negotiation completed in less than 0.5 RTT" has no corresponding protocol guarantee.
Rekeying updates keys and associations, but does not equal re-verifying the current status of certificates or re-executing user authentication. Reauthentication retraces the authentication process, affecting different states. Implementations typically allow old and new SAs to overlap briefly, receiving in-flight old packets; expiration, byte/packet counts, replay sequence numbers, and simultaneous rekeying initiation by both parties all require handling. strongSwan SA Renewal
MOBIKE is an IKEv2 extension requiring support and negotiation from both parties, allowing the tunnel to update its path as the outer address changes; you cannot assert migration support just because a device says "IKEv2". It does not create new identities for applications, nor does it guarantee zero packet loss during switching. MOBIKE RFC 4555
When certificate chains are large, IKE messages may be limited by MTU and fragmentation. IKEv2's encrypted message fragmentation extension is different from IP-layer fragmentation, and does not mean ESP packets can ignore PMTU. IKE Fragmentation RFC 7383
From IKE Success to Business Success
Linux's policy-based IPsec captures matching traffic based on policies; route-based methods like the XFRM interface make routing management more intuitive, but still rely on correct association of policies, SAs, and interfaces. Creating an interface or adding a route does not itself establish a cryptographic session. strongSwan Route-based VPN
Both parties' algorithm proposals and matched connection configurations
AUTHENTICATION_FAILED
Actual identity, credentials, trust chain, and authentication method
IKE SA exists but Child fails
ESP proposals, TS, address allocation, and authorization
Child established but outbound counter not increasing
Whether business packets reach the gateway, and if routing/policy match
Outbound increasing but inbound not
Peer counters, return path, filtering, NAT-T, and SA state
Small packets work, large transfers stall
PMTU, encapsulation budget, ICMP feedback, and fragmentation
You can check actual negotiation results with swanctl --list-sas, then compare with business flows and routing; Linux ip -s xfrm policy can observe policies. When exporting SA state, be aware that some raw state commands may contain key material; diagnostic sharing should prioritize summaries that do not output keys. Performance judgments should also be based on actual traffic and whether offloading is effective, rather than directly deriving throughput limits from terms like "enterprise-grade" or "kernel implementation."