Messages and path attributes
The five message types
| Message | Purpose |
|---|---|
| OPEN | First message after TCP comes up: version, ASN, hold time, router ID, capabilities. |
| KEEPALIVE | Confirms an OPEN and keeps the session alive when idle. |
| UPDATE | Advertises new paths (NLRI + path attributes) and/or withdraws old ones. |
| NOTIFICATION | Reports an error and closes the session. |
| ROUTE-REFRESH | Asks the peer to resend its routes so new inbound policy can be applied without a reset (RFC 2918). |
Path attributes
An UPDATE carries a set of path attributes that describe the route. These are what policy matches on and what the best-path algorithm compares.
| Attribute | Category | What it does |
|---|---|---|
| ORIGIN | well-known mandatory | How the route entered BGP: i IGP (network statement), e EGP (historic), ? incomplete (redistributed). |
| AS_PATH | well-known mandatory | The ordered list of ASes the route has traversed. Used for loop prevention and as a path-length metric. |
| NEXT_HOP | well-known mandatory | The IP address to forward traffic to for this prefix. |
| LOCAL_PREF | well-known discretionary | iBGP only. Higher wins. The primary tool for choosing your outbound exit. |
| MED | optional non-transitive | "Multi-Exit Discriminator". A hint to a neighbouring AS about which of your entry points to use. Lower wins. |
| COMMUNITY | optional transitive | 32-bit tags (ASN:value) used to signal policy, e.g. "do not export" or "prepend toward peers". Large communities (RFC 8092) extend this for 32-bit ASNs. |
AS_PATH is the loop-prevention mechanism. When a router receives an UPDATE whose AS_PATH already contains its own ASN, it discards it. Follow a prefix across the internet below.
- Origination. AS 64499 originates 203.0.113.0/24. Inside its own AS the AS_PATH is empty; ORIGIN is set to IGP (i) because it came from a network statement.
- First hop: prepend the origin AS. When sending to an eBGP peer, a router prepends its own ASN. Both ISPs receive AS_PATH "64499" and NEXT_HOP set to the content network's link address.
- Second hop: the path grows. Each ISP prepends its own ASN when advertising to you. You now hold two paths, both two ASes long.
- ISPs peer with each other. ISP A also advertises to ISP B. ISP B now has two paths: direct (64499) and via A (64497 64499). The direct path is shorter, so it stays best.
- Loop prevention. Suppose ISP B's link to the origin fails and it now uses the path via A. B would advertise "64498 64497 64499" back to A. A sees its own ASN in the path and drops the UPDATE — no loop.
Check your understanding
AS 64497 receives an UPDATE for 203.0.113.0/24 with AS_PATH "64498 64497 64499". What does it do?
- Installs it, because a longer AS_PATH is only a tie-breaker
- Discards it, because its own ASN appears in the AS_PATH
- Strips its own ASN and re-advertises the route
- Sends a NOTIFICATION and resets the session