Protocol 18 of 81Layer 3FrameAssembly v3.1.2
llms-full.txt
ahIPsec Authentication Header

Old-School Cleartext Integrity Headers (ah IP Proto 51)

Default Port / Protocol
IP Proto 51
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
ah
Standards & Specs
RFC 4302
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6IPsec AH (IP Proto 51)

What It Does on the Wire

Rare in the wild because NAT breaks it on sight, yet still lurking in compliance checklists and OSPFv3 auth: ah builds IP Protocol 51 headers with aligned 32-bit Payload Len math.

IPsec Authentication Header (ah, RFC 4302) provides connectionless integrity, data-origin authentication, and anti-replay protection across the outer IP header and upper-layer payload without encrypting the payload (IP Protocol 51 / IPv6 Extension Header 51).

RFC 4302 has a subtle wire length formula: Payload Len is encoded in 32-bit words minus 2, while the total AH header must be padded to a multiple of 32 bits on IPv4 or 64 bits on IPv6. FrameAssembly computes Payload Len and aligns the icv field automatically across both IPv4 and IPv6.

OSPFv3 & Control-Plane IPsec AH Authentication

Test router control-plane policies that authenticate routing updates with cleartext-inspectable IPsec ah (proto 51) rather than encrypted esp.

Firewall & NAT Gateway Protocol 51 Drop Verification

Verify perimeter security policies and test NAT behavior (since AH authenticates outer IP addresses, NAPT breaks AH integrity by design).

IPv6 Extension Header Chain Dissector Testing

Exercise packet parsers walking IPv6 Next Header 51 (ah) with nextheader 59 (No Next Header) or nextheader 6 (TCP).

Minimal Quickstart (ah_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

ah_quickstart.frasm6 lines
Open in Playground
host rtr_core1 { ip 10.0.51.1 }
host rtr_core2 { ip 10.0.51.2 }
compile {
rtr_core1 -> rtr_core2 ah spi 0x00002001 seq 1
}

What the Compiler Calculates So You Don't Have To

  • Sets outer IPv4 Protocol or IPv6 Next Header to 51 (Authentication Header).
  • Computes RFC 4302 Payload Len = (total_ah_bytes / 4) - 2 automatically and zero-pads icv to 4-byte (IPv4) or 8-byte (IPv6) alignment.
  • Populates 16-bit Reserved (0x0000), 32-bit spi (default 0x00000200), 32-bit seq (default 1), and 96-bit default icv.
Multi-Frame Lab · Ready to Compile

Authenticated Dual-Stack Router Peering Using IPsec AH (Protocol 51)

Emits bidirectional IPv4 and IPv6 RFC 4302 Authentication Header packets demonstrating 32-bit vs 64-bit ICV alignment.

ah_authenticated_peering.frasm12 lines
Open in Playground
host core_a_v4 { ip 172.16.51.1 }
host core_b_v4 { ip 172.16.51.2 }
host core_a_v6 { ip 2001:db8:51::1 }
host core_b_v6 { ip 2001:db8:51::2 }
compile {
// IPv4 AH (24-byte header: Payload Len = 4, 12-byte 96-bit ICV)
core_a_v4 -> core_b_v4 ah spi 0x00002001 seq 1 nextheader 59 icv "00112233445566778899aabb" payload "cleartext-signed-v4" wait 2ms
core_a_v4 <- core_b_v4 ah spi 0x00002002 seq 1 nextheader 59 icv "aabbccddeeff001122334455" payload "cleartext-ack-v4" wait 3ms
// IPv6 AH (aligned to 8-octet boundary per RFC 4302 §2.2)
core_a_v6 -> core_b_v6 ah spi 0x00062001 seq 1 nextheader 59 icv "0102030405060708090a0b0c" payload "cleartext-signed-v6"
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show ah_authenticated_peering.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly ah_authenticated_peering.frasm ah_authenticated_peering.pcap
frameassembly ah_authenticated_peering.frasm ah_authenticated_peering.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse ah_authenticated_peering.pcap ah_authenticated_peering_edited.frasm

All ah Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after ah:

src_host -> dst_host ah [spi <number>] [seq <number>] [icv "<hex>"] [nextheader <0..255>]
Keyword / OptionAccepted ValueDefaultEffect on Packet
spi <number>Whole number (decimal or 0x hex)0x00000200Sets the 4-byte Security Parameters Index.
seq <number>Whole number1Sets the 4-byte RFC 4302 Sequence Number.
icv "<hex>"Double-quoted even-length hex string12-byte (96-bit) ICVSets the Integrity Check Value bytes (padded automatically to 32-bit alignment on IPv4 or 64-bit alignment on IPv6).
nextheader <0..255>8-bit IP protocol number6 (TCP) or 59 (No Next Header)Sets the first byte of the AH header identifying the payload immediately following the ICV.

Cross-Layer Wrappers Valid with ah

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

9 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority.
qinq <0..4095> [innervlan <0..4095>]Outer S-VLAN 0..4095, Inner C-VLAN 0..4095Untagged (innervlan 1 when qinq is set)Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100).
mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.
ttl <0..255> [dscp <0..63>] [ecn <0..3>]TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3ttl 64, dscp 0, ecn 0Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings.
ipid <0..65535> [df] [mf] [fragoffset <0..8191>]IPv4 ID, DF/MF flags, fragment offset 0..8191ipid 1, flags 0, fragoffset 0Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts).

Gotchas & Quick Fixes

ah Does Not Take an iv (Initialization Vector) Modifier

Avoid
a -> b ah spi 0x2001 iv "0102030405060708"
Valid v3.1.2 Syntax
a -> b ah spi 0x2001 seq 1 icv "00112233445566778899aabb"

Authentication Header (ah) signs packets in cleartext without cipher encryption, so there is no Initialization Vector on the wire (iv applies to esp/ipsec).

Choose Valid Inner nextheader Codes for Wireshark Dissection

Valid v3.1.2 Syntax
a -> b ah spi 0x2001 nextheader 59 payload "raw-test"

If you attach an arbitrary ASCII payload, set nextheader 59 (IPv6 No Next Header / raw data) so Wireshark does not try to dissect the ASCII text as a truncated TCP (6) header.

Field Guide 05
VLANs, QinQ, MPLS, Tunnel Soup & Dual-Stack IPv6