bgpBorder Gateway Protocol 4 & 4-Byte ASN CapabilityTCP 179 Peering & Automatic 4-Byte ASN Magic (spine <-> leaf bgp)
What It Does on the Wire
Pass asn 4200000001 on bgp open and the compiler automatically drops AS_TRANS (23456) into the legacy 16-bit slot plus RFC 6793 Capability 65, riding right on top of stateful TCP port 179.
Border Gateway Protocol 4 (bgp, RFC 4271) exchanges inter-domain and data-center leaf-spine routes over TCP port 179. Every BGP message starts with a 16-byte all-ones (ff..ff) marker, 16-bit Message Length (19..4096), and 8-bit Type (1 open, 2 update, 3 notification, 4 keepalive).
FrameAssembly tracks TCP sequence and acknowledgment numbers automatically across tcp and bgp packets—and when you pass a 4-byte ASN (asn > 65535, e.g. 4200000001) on bgp open, it automatically sets AS_TRANS (23456) in the 16-bit header field and adds RFC 6793 Capability Code 65 with the full 4-byte ASN.
Data-Center Private 4-Byte eBGP (4200000000+) Validation
Test RFC 6793 4-byte ASN OPEN negotiation (AS_TRANS 23456 + Optional Parameter Capability 65) across SONiC, FRR, Arista EOS, and Cisco NX-OS parsers.
BGP Prefix Hijack & Route-Leak Detection Engineering
Synthesize bgp update packets carrying specific prefix / nlri CIDRs and nexthop attributes for BGP monitoring and NDR alert testing.
GTSM (ttl 255) & BGP Session Reset (notification) Audits
Verify Generalized TTL Security Mechanism (ttl 255 RFC 5082) firewall filters and bgp notification session teardown alerts.
Minimal Quickstart (bgp_quickstart.frasm)
Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.
host spine_01 { ip 10.255.0.1 }host leaf_01 { ip 10.255.0.2 }compile { spine_01 -> leaf_01 bgp open asn 65001 holdtime 90 bgpid 10.255.0.1 wait 2ms spine_01 <- leaf_01 bgp open asn 65101 holdtime 90 bgpid 10.255.0.2 wait 2ms spine_01 -> leaf_01 bgp keepalive}What the Compiler Calculates So You Don't Have To
- Tracks TCP sequence and acknowledgment numbers automatically on port
179(psh ackflags set by default) and prepends the 16-byteff..ffBGP marker. - On
bgp openwithasn > 65535, writesAS_TRANS(23456) in the 16-bit My AS field and encodes Optional Parameter2(Capabilities) -> Capability65(4-octet AS) with the full 32-bitasn. - On
bgp update, encodes well-known mandatory Path Attributes (ORIGIN = IGP,AS_PATH,NEXT_HOP) and bit-packed CIDRNLRI(prefix/nlri).
Stateful TCP Handshake + 4-Byte ASN eBGP Peering & Route Advertisement
Establishes a GTSM-protected (ttl 255) TCP 179 session between two 4-byte ASN switches (4200000001 and 4200000101), exchanges OPEN + KEEPALIVE, and advertises 10.100.0.0/16.
host leaf_tor { ip 172.16.255.1 }host spine_agg { ip 172.16.255.2 }compile { // 1. Stateful TCP 3-way handshake on port 179 with GTSM (ttl 255) and CS6 (dscp 48) leaf_tor -> spine_agg tcp syn srcport 53179 dstport 179 win 65535 mss 1460 ttl 255 dscp 48 wait 1ms leaf_tor <- spine_agg tcp syn ack win 65535 mss 1460 ttl 255 dscp 48 wait 1ms leaf_tor -> spine_agg tcp ack ttl 255 dscp 48 wait 1ms // 2. 4-Byte ASN OPEN negotiation (auto-encodes AS_TRANS 23456 + Capability 65) leaf_tor -> spine_agg bgp open asn 4200000101 holdtime 90 bgpid 10.0.1.1 ttl 255 dscp 48 wait 2ms leaf_tor <- spine_agg bgp open asn 4200000001 holdtime 90 bgpid 10.0.0.1 ttl 255 dscp 48 wait 2ms leaf_tor -> spine_agg bgp keepalive ttl 255 dscp 48 wait 1ms leaf_tor <- spine_agg bgp keepalive ttl 255 dscp 48 wait 2ms // 3. Advertise tenant CIDR 10.100.0.0/16 via BGP UPDATE leaf_tor -> spine_agg bgp update asn 4200000101 prefix "10.100.0.0/16" nexthop 172.16.255.1 ttl 255 dscp 48}# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show bgp_4byte_asn_session.frasm
# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly bgp_4byte_asn_session.frasm bgp_4byte_asn_session.pcap
frameassembly bgp_4byte_asn_session.frasm bgp_4byte_asn_session.pcapng
# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse bgp_4byte_asn_session.pcap bgp_4byte_asn_session_edited.frasmAll bgp 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 bgp:
src_host -> dst_host bgp [open | update | notification | keepalive] [asn <number>] [holdtime <0..65535>] [bgpid <ipv4>] [prefix|nlri <str|ip>] [nexthop <ip>]| Keyword / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| open | update | notification | keepalive | BGP message type keyword | keepalive (Type 4) | Selects Type 1 OPEN, Type 2 UPDATE, Type 3 NOTIFICATION (Cease error), or Type 4 19-byte KEEPALIVE. |
| asn <number> | 16-bit or 32-bit Autonomous System Number | 65001 | Sets the Autonomous System in open (<= 65535 direct; > 65535 AS_TRANS 23456 + Capability 65) and AS_PATH in update. |
| holdtime <0..65535> | Whole number (0..65535) (seconds) | 180 | Sets the BGP Hold Time in open (0 or >= 3 seconds per RFC 4271). |
| bgpid <ipv4> | 32-bit dotted-quad identifier | Source IPv4 (or 1.1.1.1 on IPv6) | Sets the 4-byte BGP Identifier in open messages (always 32-bit dotted-quad on both v4 and v6). |
| prefix <str|ip> | nlri <str|ip> | CIDR string ("10.20.0.0/16") or IP literal | "10.0.0.0/24" | Encodes Network Layer Reachability Information (nlri is an exact alias for prefix) in update messages. |
| nexthop <ip> | IPv4 or IPv6 address literal | Source host IP | Sets the NEXT_HOP path attribute inside bgp update messages. |
Cross-Layer Wrappers Valid with bgp
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
11 options
Cross-Layer Wrappers Valid with bgp
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
| Option | Range / Format | Default | Effect on Packet |
|---|---|---|---|
| wait <number><ns|us|ms|s|m> | Time gap (ns, us, ms, s, m) | 10ms | Advances 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) | Omitted | Appends 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 MAC | Host MAC / RFC multicast MAC | Overrides 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..1 | Untagged | Wraps 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..4095 | Untagged (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..255 | Unlabeled (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..3 | ttl 64, dscp 0, ecn 0 | Sets 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..8191 | ipid 1, flags 0, fragoffset 0 | Sets 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) | 0 | Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts). |
| srcport <0..65535> | dstport <0..65535> | Port number 0..65535 | srcport 49152 (remembered), TCP 179 | Overrides source or destination port and remembers the port pair automatically on <- replies. |
| seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rst | TCP sequence/ack numbers, window size, flags & RFC 7323 options | psh ack, win 65535, automatic TCP seq/acknum | Overrides automatic TCP sequence tracking, flags, or RFC 7323 options (mss, wscale, sackperm, tsval, tsecr). |
Gotchas & Quick Fixes
Quote CIDR Prefixes in bgp update (Never Put /24 in host Blocks)
host r1 { ip 10.0.0.1/24 }
r1 -> r2 bgp update prefix 10.20.0.0/16host r1 { ip 10.0.0.1 }
r1 -> r2 bgp update prefix "10.20.0.0/16"host declarations take plain IP literals without CIDR slashes, while CIDR strings in bgp update prefix "10.20.0.0/16" must be wrapped in double quotes.
bgpid Is Always 32-Bit Dotted-Quad Even Over IPv6 eBGP
r6_a -> r6_b bgp open asn 65001 bgpid 2001:db8::1r6_a -> r6_b bgp open asn 65001 bgpid 10.0.0.1Per RFC 4271 and RFC 6286, the BGP Identifier is always a 4-octet 32-bit dotted-quad (10.0.0.1) regardless of whether TCP 179 runs over IPv4 or IPv6.