Routing between networks
Border Gateway Protocol (BGP) lets independently administered networks exchange reachability information. An autonomous system (AS) is a collection of networks operated with a coherent external routing policy and identified by an AS number. Unlike an internal shortest-path protocol, BGP lets operators accept, prefer and advertise routes according to policy. Hierarchical Routing and Route Redistribution supplies the background.
BGP is a path-vector protocol: an advertisement carries a prefix and attributes, including the AS path. It does not provide a complete physical map or guarantee that the shortest AS path is fastest, cheapest or selected.
One advertisement, step by step
Added example: AS 65030 originates 203.0.113.0/24 and announces it to AS 65020. AS 65020 accepts the route and, if export policy permits, announces it to AS 65010 with AS_PATH 65020 65030. AS 65010 understands the advertised direction. If a router receives an ordinary route containing its own AS number, it normally rejects it to prevent an AS-level loop. Policy and protocol features can modify propagation; the AS_PATH is not a router-by-router trace.
A session between different ASes is eBGP; a session within an AS is iBGP. iBGP shares BGP information internally, while an interior gateway protocol such as OSPF often supplies reachability to the BGP next hop. A route is unusable for forwarding if its next hop cannot be resolved. iBGP peers need not be directly connected, but IP connectivity and session configuration are needed.
Normally an iBGP-learned route is not re-advertised to another iBGP peer; full-mesh sessions or route reflectors address distribution at scale. Route reflectors add loop-prevention rules. The slides’ statement that iBGP does not propagate “internal routes” is too broad: iBGP can distribute locally originated BGP routes. What matters is how the route entered BGP and the advertisement rules.
Main attributes
| Attribute | Meaning |
|---|---|
| AS_PATH | AS-level path information and a key loop check; shorter paths are considered at a particular decision step after higher-priority policy decisions |
| NEXT_HOP | Address that must be reachable; may be preserved or changed depending on session and configuration |
| LOCAL_PREF | Preference distributed within an AS; larger is normally preferred and influences that AS’s outbound exit |
| MED | Hint to a neighboring AS about a preferred entry; lower is generally preferred when routes are eligible for comparison |
| ORIGIN | How the route was introduced into BGP: IGP, EGP or incomplete; not simply a measure of trust |
| Communities | Tags that policy may use to classify or influence handling of routes |
Example: AS 65010 receives two valid routes for the same prefix. One has LOCAL_PREF 200 and AS_PATH length 3; the other has LOCAL_PREF 100 and AS_PATH length 2. In a common decision order the first wins on local preference despite its longer AS path. Vendor rules, configuration and eligibility checks matter. More-specific installed prefixes still win ordinary IP longest-prefix matching.
MED is not LOCAL_PREF: an operator’s LOCAL_PREF steers its own outbound choice, while MED can suggest which connection a neighbor should use when entering. The neighbor may disregard or rewrite it. Neither guarantees the entire path traffic takes.
Announcements, withdrawals and messages
BGP peers use TCP, normally destination port 179. After TCP is established, OPEN exchanges session parameters and capabilities; KEEPALIVE maintains the session; UPDATE advertises or withdraws routes; NOTIFICATION reports a serious error and closes the session. Session failure also makes associated routes unavailable subject to protocol and graceful-restart rules; withdrawals are not the only way a route disappears.
TCP provides reliable ordered delivery while the connection works, but does not prove route authorization. BGP OPEN does not itself open TCP or generally provide the password authentication field shown on the slides. The BGP marker is not a general-purpose negotiated checksum. The slides also confuse withdrawal with an attribute and MED with LOCAL_PREF: withdrawal is part of UPDATE; MED is type 4, LOCAL_PREF type 5. See RFC 4271 sections 4 and 5.
Conceptually, Adj-RIB-In holds received information, Loc-RIB selected BGP routes, and Adj-RIB-Out routes chosen for advertisement. Implementations may optimize storage. A selected BGP route must still be eligible and installed in the system forwarding table to carry packets.
AS_PATH is not the list of router hops
Suppose AS 65010 receives AS_PATH 65020 65030 for prefix 203.0.113.0/24. The advertised AS-level direction is through 65020 toward 65030. A packet might physically traverse routers R1 and R2 in 65010, R3–R5 in 65020, then R6 in 65030. One AS can contain many router hops, so two AS numbers do not mean two router hops. An operator can also prepend its own AS number to AS_PATH more than once, so a repeated number does not necessarily mean the packet re-enters that AS.
In ordinary eBGP propagation, an AS adds its own number to the path it sends externally. If AS 65020 receives a path that already contains 65020, it normally rejects it to avoid an AS-level loop. This is a simplified default rule; special configurations and path types exist. AS_PATH is an advertised attribute, not proof that every listed network authorized the route.
Sessions and route distribution: a trace
Suppose AS 30 contains BGP speakers R1, R2 and R3. R3 learns 130.192.40.0/24 from AS 40 over eBGP with AS_PATH 40. If selected and permitted, R3 advertises it to R1 over iBGP without adding AS 30 simply for the internal exchange. If R1 then exports it over eBGP to AS 20, the ordinary advertised path is 30 40. Each step is subject to eligibility, next-hop reachability and policy. Route information can follow different paths from the data packet.
Two consecutive iBGP sessions can exist: R1—R2—R3. The ordinary rule is that R2 does not re-advertise an iBGP-learned route from R1 to R3 through another ordinary iBGP session. R2 can normally advertise eligible eBGP-learned or locally originated routes to iBGP peers. A full mesh gives R1 and R3 their own session; that logical TCP session can physically cross R2. A route reflector is an explicitly configured exception that reflects eligible routes under additional loop-prevention rules, including originator and cluster information. It need not be on the data path.
NEXT_HOP and internal forwarding
Imagine R1 learns 203.0.113.0/24 from R3 over iBGP with NEXT_HOP 10.0.0.3. OSPF supplies R1 a route to 10.0.0.3 through internal router R2. If R1 selects and installs the BGP route, it can forward a packet for 203.0.113.50 toward R2 on the way to R3. The final IP destination remains 203.0.113.50; 10.0.0.3 is a BGP next hop, not the final destination. iBGP can preserve an eBGP next hop or a router can change it using appropriate configuration; do not assume it always becomes R3.
Crucially R2 must also have a forwarding route for 203.0.113.50, for example a suitable BGP route or default, or use an applicable forwarding design. R1’s ability to resolve 10.0.0.3 does not automatically give R2 routes to external prefixes. Session endpoint reachability, BGP NEXT_HOP reachability and each data-path router’s destination lookup are separate checks.
One selection worked carefully
Compare two accepted, eligible routes for the same prefix; assume equal local-only weight and neither is locally originated. Route A has LOCAL_PREF 100 and AS_PATH 20 30. Route B has LOCAL_PREF 200 and AS_PATH 40 50 30. In a common decision order, B wins on higher LOCAL_PREF before AS_PATH length is compared. If both LOCAL_PREFs were 100, A would normally win on the shorter AS_PATH, assuming all preceding relevant criteria tie.
A common teaching sequence is: ensure eligibility and reachable next hop; compare local preference; consider local origination; compare AS_PATH length; compare ORIGIN (IGP before EGP before incomplete); compare MED where applicable; then apply other criteria such as eBGP versus iBGP and internal distance to the next hop. This is not a universal complete algorithm: vendor implementations, route eligibility, policy and settings can change comparisons. MED is generally compared only under the implementation’s applicable conditions, often between paths from the same neighboring AS; never assume lower MED always wins against every route.
Cisco weight is a local-only vendor selection value, not a standard BGP path attribute sent in UPDATEs. Higher weight is typically compared before LOCAL_PREF on Cisco; it is not shared with another router, including an iBGP peer. For the same prefix, weight 500 on route A beats weight 100 on B in Cisco’s usual selection even when B’s LOCAL_PREF is higher. In the documented Cisco defaults, learned routes ordinarily have weight 0 and locally sourced routes 32768; versions/configuration matter. The supplied PDF does not teach weight; this is an added clarification. Cisco BGP case studies.
Understanding message flow and attribute categories
Peers need a working IP path and normally establish TCP to port 179 first. OPEN exchanges session parameters and capabilities; KEEPALIVE confirms or maintains liveness; UPDATE advertises or withdraws routes; NOTIFICATION reports an error or closing condition and terminates the session. Updates are incremental after exchange, but withdrawal is not the only way a route can become unusable: a session can fail or the next hop can become unreachable. Hold-time behavior and graceful restart have additional conditions.
An UPDATE advertising one or more prefixes carries applicable path attributes. A withdrawal-only UPDATE need not include the mandatory attributes required for advertised routes. Well-known attributes must be recognized; well-known mandatory attributes are required for applicable advertised routes, while well-known discretionary attributes need not be in every applicable update. Optional attributes need not be recognized by every implementation. Unknown optional transitive attributes can be propagated following BGP rules; unknown optional non-transitive attributes are not. The Optional flag is 0 for well-known and 1 for optional; the slide reverses this wording. RFC 4271 sections 4–5.
ORIGIN describes how the route was introduced to BGP, with values IGP, EGP and incomplete; IGP is an attribute value, not proof that OSPF directly supplied the route. The slide mislabels MED and LOCAL_PREF: MED is type 4, LOCAL_PREF is type 5; withdrawal is carried in UPDATE’s withdrawn-routes portion, not a separate “unreachable” path attribute. The BGP marker is not the negotiated checksum described in the slide, and OPEN is exchanged after TCP, not the operation that creates TCP.
Review with answers
Can two consecutive iBGP sessions exist? Yes. What is normally restricted is advertising an iBGP-learned route from one ordinary iBGP peer to another. A route reflector can reflect eligible routes under its rules, or peers can form a full mesh.
The BGP session is up, but the advertised NEXT_HOP is not reachable. Can the router use that path? Not as a usable forwarding route until next-hop resolution succeeds. A separate route to the peer address can keep the TCP session up.
Which is preferred: LOCAL_PREF 200 and AS_PATH length three, or LOCAL_PREF 100 and length two? Under the stated common order and equal earlier criteria, 200 wins before AS_PATH is considered. A local Cisco weight difference could change the result; other implementations can differ.
Do AS_PATH entries count the routers crossed by the data packet? No. An AS can contain many routers; AS_PATH is AS-level advertised information and can contain repetitions caused by prepending.
Related
Lecture 06 - BGP · BGP Policy Transit and Internet Exchange · OSPF Areas Costs and External Routes