Esc
Type to search posts, tags, and more...
Skip to content

BGP message types

The four BGP-4 message types — OPEN, UPDATE, KEEPALIVE, and NOTIFICATION — their wire formats and semantics.

Contents

Message header

Every BGP message starts with a 19-octet fixed header.

FieldLengthDescription
Marker16 octetsAll ones (0xFF). Historical authentication hook, now compatibility only.
Length2 octetsTotal message length including header. Range: 19–4096.
Type1 octet1=OPEN, 2=UPDATE, 3=NOTIFICATION, 4=KEEPALIVE

The smallest valid message is a KEEPALIVE at exactly 19 octets (header only, no payload).

OPEN

Sent immediately after TCP connection establishment. Each side sends one OPEN; receipt of a valid OPEN is confirmed by a KEEPALIVE.

FieldLengthDescription
Version1 octetProtocol version (4)
My AS2 octetsSender’s AS number (2-octet; 4-octet via RFC 6793 capability)
Hold Time2 octetsProposed hold timer in seconds. Must be 0 or >= 3.
BGP Identifier4 octetsRouter ID — a unique IPv4 address assigned to the speaker
Opt Parm Len1 octetLength of Optional Parameters field
Optional ParametersvariableCapability advertisements (RFC 5492)

The negotiated Hold Time is the minimum of the two peers’ proposed values. If zero, neither side sends keepalives.

Capabilities

Optional Parameters carry capabilities (type 2 per RFC 5492). Common capabilities:

CapabilityCodePurpose
Multiprotocol Extensions1IPv6, VPNv4, EVPN address families
Route Refresh2Request full re-advertisement
4-octet AS65Support AS numbers > 65535
Graceful Restart64Maintain forwarding during restart
Enhanced Route Refresh70Bounded route refresh with ORF
Extended Message6Messages up to 65535 octets

UPDATE

Carries routing information — both route advertisements and withdrawals. A single UPDATE advertises at most one set of path attributes but may include multiple NLRI prefixes sharing those attributes.

FieldDescription
Withdrawn Routes Length2 octets. 0 means no withdrawals in this message.
Withdrawn RoutesList of <length, prefix> tuples being withdrawn
Total Path Attribute Length2 octets. 0 means no NLRI and no attributes.
Path AttributesVariable-length sequence of TLV-encoded attributes
NLRIList of <length, prefix> tuples being advertised

Each prefix is encoded as a 1-octet bit-length followed by the minimum octets needed to hold that many bits. A /24 takes 4 octets (1 length + 3 prefix). A /0 (default route) takes 1 octet (length=0, no prefix bytes).

UPDATE semantics

  • Advertising a prefix with new attributes implicitly replaces the previous advertisement for that prefix.
  • A message may carry only withdrawals (no attributes, no NLRI).
  • A message may carry only advertisements (Withdrawn Routes Length = 0).
  • The same prefix in both Withdrawn Routes and NLRI is treated as an advertisement (withdrawal is ignored).

KEEPALIVE

Header-only message (19 octets). Sent at intervals not exceeding one-third the negotiated Hold Time. Resets the peer’s Hold Timer upon receipt.

Keepalives serve dual duty:

  1. Confirm the OPEN (first KEEPALIVE after OPEN exchange)
  2. Detect peer liveness during the session

If Hold Time is 0, keepalives are never sent and the Hold Timer never expires.

NOTIFICATION

Signals a fatal error. The BGP connection closes immediately after sending.

FieldLengthDescription
Error Code1 octetCategory of error
Error Subcode1 octetSpecific error within category
DatavariableDiagnostic payload (depends on code/subcode)
Error CodeNameTypical trigger
1Message Header ErrorBad marker, length, or type
2OPEN Message ErrorVersion mismatch, bad AS, bad ID, bad hold time
3UPDATE Message ErrorMalformed attributes, missing mandatory attributes
4Hold Timer ExpiredNo KEEPALIVE/UPDATE within Hold Time
5FSM ErrorUnexpected event in current state
6CeaseAdministrative shutdown, prefix limit exceeded

See BGP error handling for full subcode tables and revised error handling (RFC 7606).

Message flow example

Sources

Last synthesized: 2026-05-07

AI-assisted synthesis from the RFCs and sources linked above.