Big picture

OSPF helps routers find paths inside a routing domain. The Internet also joins independently administered networks with different costs, commercial agreements and policies. Border Gateway Protocol (BGP) exchanges reachability between those networks while giving operators control over which routes to accept, prefer and advertise.

BGP is a path-vector protocol: an advertisement carries a destination prefix and attributes, including an AS-level path. A longer path may be chosen because local policy prefers it. It is not a complete map of every router or a guarantee of the fastest route. Read BGP Sessions Paths and Attributes and BGP Policy Transit and Internet Exchange for deeper explanations.

Source and reading map

Alessio Sacco, Politecnico di Torino, Border Gateway Protocol, based on an earlier version by Fulvio Risso. Local source 06-BGP.pdf, 72 PDF pages. 06 follows the filename. References use PDF page order; the slides have gaps in printed numbering. The PDF and figures stay local. Worked examples are added explanations unless identified as source diagrams.

PDF pagesContent
1–16Inter-domain policy, IGP/EGP, BGP, TCP and path vector
17–32Peering, iBGP/eBGP, route reflection, propagation and aggregation
33–44Attributes, policy and conceptual BGP RIBs
45–52BGP message types and formats
53–64Autonomous systems, transit, peering and exchange points
65–72Cisco BGP/OSPF examples

1. Why external routing needs policy

An autonomous system (AS) is a group of networks presenting a coherent external routing policy, identified by an AS number. A network might prefer a cheaper provider over a shorter path, avoid carrying traffic between two other providers, or restrict which destinations a peer learns. A BGP route is a policy-controlled reachability advertisement, not permission to use every connection in an AS.

An interior gateway protocol (IGP), such as OSPF, typically manages internal reachability. BGP is used for external exchange and can also distribute external routing information within an AS. An AS can have several internal areas or routing processes; an OSPF area is not necessarily an Internet AS.

2. Follow one route

Added example: AS 65030 originates 203.0.113.0/24, announces it to AS 65020, and AS 65020 accepts and exports it to AS 65010. The latter receives a path such as 65020 65030. It knows an advertised AS-level direction, not the individual router path. Normally a router rejects an ordinary advertisement containing its own AS number, helping prevent AS-level loops. Export policy can prevent the route from being sent at all.

A session between different ASes is eBGP; a session inside one AS is iBGP. iBGP distributes BGP routes internally, but internal IP reachability to the selected BGP next hop is still required. OSPF can provide that reachability. An unresolved next hop can make an otherwise attractive BGP route unusable.

Ordinarily, an iBGP-learned route is not advertised onward to another iBGP peer. A full mesh or a route reflector provides distribution; route reflectors use additional loop-prevention information. The slide claim that iBGP does not propagate internal routes is too broad: locally originated BGP routes can be carried over iBGP. BGP Sessions Paths and Attributes

The source’s example on PDF pages 26–29 shows AS 30 learning external prefixes from AS 20, AS 10 and AS 40, sharing information internally, then advertising routes to external peers. R2’s omission of certain local prefixes from the advertisement toward AS 10 illustrates that internal IP routing knowledge and BGP route origination are separate; in the shown scenario those prefixes have not been introduced into BGP at R2, not simply filtered by an identified export policy.

3. How a route is chosen

A BGP route includes attributes. LOCAL_PREF expresses preference within the local AS; a higher value typically wins early and can steer outbound traffic. AS_PATH records AS-level path information and supports loop checks; a shorter path is often preferred only after higher-priority decisions. NEXT_HOP identifies where traffic should be sent and must be resolvable. MED can suggest a preferred entry point to a neighboring AS; lower is generally preferred among routes eligible for comparison, but the receiving AS controls its policy. ORIGIN describes how a route was introduced, not who is trusted.

For the same prefix, suppose a valid path with LOCAL_PREF 200 has three ASes and one with LOCAL_PREF 100 has two. A common decision order selects the first despite its longer AS path. Implementations and policy can change the details. Once routes are installed, forwarding still uses longest prefix matching: a matching /24 beats a matching /16 regardless of the /16’s BGP preference.

Attributes are classified as well-known or optional and as transitive or non-transitive under BGP rules. Unknown optional transitive attributes have special propagation behavior. The slides’ attribute flag and numbering descriptions contain errors: MED is attribute type 4, LOCAL_PREF type 5, and withdrawals are carried in UPDATE messages rather than being a separate “unreachable” path attribute. RFC 4271 defines the base attributes.

BGP’s conceptual Adj-RIB-In contains received information, Loc-RIB selected BGP routes, and Adj-RIB-Out routes selected for advertisement. Exact storage is implementation-specific. Selection in BGP and installation in the forwarding table are related but distinct.

4. Sessions and messages

BGP peers establish a TCP connection, normally to port 179. Once TCP is established, OPEN exchanges session parameters and capabilities; KEEPALIVE maintains the session; UPDATE advertises or withdraws routes; NOTIFICATION reports an error and closes the session. Updates are normally incremental rather than complete periodic dumps. Session failure can also make routes unavailable; graceful restart and implementation behavior qualify timing.

The slide’s depiction of OPEN as opening TCP or carrying its illustrated authentication fields, and its description of the marker as a negotiated checksum, should not be treated as the BGP-4 base format. Transport security and authentication are separate considerations. See RFC 4271 section 4.

5. Relationships and exchange points

A transit provider carries a customer’s traffic toward destinations covered by their agreement. Peering lets networks exchange agreed traffic directly; it may be settlement-free or paid and does not automatically include transit to all third parties. An Internet exchange point (IXP) commonly provides a shared Ethernet fabric on which networks can establish sessions. Sharing the fabric alone does not create a BGP session or commercial agreement with every participant. BGP Policy Transit and Internet Exchange

Aggregation can reduce announcements, but the aggregate must correspond to a workable forwarding plan, including unused space. The deck’s AS_SET example is historical teaching context, not a universal current recommendation. BGP does not itself prove that an origin is authorized; validation and filtering are separate controls and do not automatically authenticate every AS hop.

6. Reading the source configuration examples

The final slides show Cisco BGP peers and redistribution with OSPF. A BGP network statement commonly originates a prefix only when the exact matching route exists in the local routing table, subject to platform behavior; it does not enable BGP on an interface. A configured peer also needs working IP reachability and compatible settings. A passive OSPF interface normally stops neighbor formation while still allowing the connected network to be advertised. Syntax and defaults vary by version.

OSPF can provide the internal path to a BGP next hop. Importing external routes into OSPF is a design choice, not a universal requirement; uncontrolled redistribution can cause scale and feedback problems. A default route can be useful for a simple edge but needs a viable upstream and appropriate return routing.

7. Why a different protocol from OSPF? (PDF pages 2–8)

OSPF and BGP both help routers select routes, but the routing problem changes at an administrative boundary. A university and two providers may have different operators, prices, contracts and internal routing designs. The university may prefer a longer AS-level path because it buys transit from a particular provider, or may refuse to carry traffic between two other providers. A shortest internal link cost cannot express all these independent choices by itself.

OSPF builds a link-state view within its areas and uses its route categories and costs to calculate paths. BGP exchanges selected prefix reachability and path attributes between ASes, with import and export policies. Operators do not need to share a complete internal topology with every external neighbor. An AS can run several internal protocols or areas. An OSPF area is not the same thing as an Internet autonomous system.

Historically, BGP did not replace an already mature OSPF. The early BGP proposal built on experience with EGP; early specifications of BGP and OSPF appeared in 1989. They addressed complementary inter-domain and intra-domain problems. RFC 1105 and RFC 1131 provide historical context.

8. One prefix across three ASes (PDF pages 15–16)

Assume AS 65030 originates 203.0.113.0/24, AS 65020 accepts the route and is willing to export it, and AS 65010 accepts the result. The following are added teaching examples, not claims about real operators:

  1. AS 65030 advertises the prefix to AS 65020 with AS_PATH 65030.
  2. AS 65020 advertises it to AS 65010 with AS_PATH 65020 65030.
  3. AS 65010 can select the route if its import policy permits it, its next hop is reachable, and it wins the relevant route comparisons.
  4. If AS 65010 exports the route to AS 65040, the path normally becomes 65010 65020 65030. If AS 65040 later advertises that path to AS 65020, AS 65020 sees its own number and normally rejects it, preventing the illustrated AS-level loop.

An AS_PATH is advertised AS-level information, not a list of every router. A packet may cross R1 and R2 in AS 65010, R3–R5 in AS 65020 and R6 in AS 65030. The AS path and router hops count different things. AS-path prepending can deliberately repeat an AS number without causing the packet to visit that AS multiple times. AS_PATH alone also does not prove authorization or establish a measured physical route.

9. Peer sessions and route propagation (PDF pages 17–30)

A BGP speaker is configured with its local AS and a peer’s address and expected AS. A BGP router using AS 30 is typically configured as such; an internal router that runs only OSPF need not have a BGP AS number configured. The routers first need IP reachability between the session endpoints. That bootstrap path must not depend solely on an advertisement that the not-yet-established session is expected to deliver.

eBGP connects peers in different ASes; iBGP connects BGP speakers in the same AS. A session is a logical TCP relationship, not necessarily a direct physical cable. A multihop eBGP session can traverse other networks if configured and permitted, though its data may still use a transit provider. A BGP peer is a router at the other end of a session; a network-peering agreement is a separate agreement about which traffic operators exchange.

In the source’s topology, AS 30 has R1 peering externally with AS 20, R2 with AS 10, and R3 with AS 40. R3 learns 130.192.40.0/24 from AS 40 with AS_PATH 40. If accepted, selected and permitted, it can advertise the route to R1 over iBGP without adding 30 merely for that internal exchange. R1 can advertise it to AS 20 over eBGP with path 30 40 if export policy permits. This is route-information flow; the physical data path depends on installed forwarding routes.

Two successive iBGP sessions can exist: R1—R2—R3. The normal restriction is that R2 does not re-advertise a route learned from R1 over ordinary iBGP to R3 over ordinary iBGP. It can advertise eligible eBGP-learned or locally originated routes to iBGP peers. A full mesh lets R1 advertise directly to R3, although that TCP session can physically pass through R2. Alternatively a configured route reflector can reflect eligible routes under additional loop-prevention rules. BGP Sessions Paths and Attributes

On PDF pages 26–29, R2 knows the internal AS 30 networks in its ordinary routing table but, in the shown scenario, they have not been introduced into its BGP process in the same way as at the other routers. Its advertisement to AS 10 omits those networks. This illustrates that a route in the IP routing table does not automatically become a BGP advertisement. The source’s broad claim that iBGP never carries internal prefixes is incorrect: a BGP route originated for a local prefix can be distributed by iBGP under the normal advertisement rules.

10. Sessions, messages and timers (PDF pages 45–52)

BGP peers normally first establish TCP to port 179. Reliable ordered delivery from TCP does not authenticate a prefix or guarantee a working end-to-end destination. After TCP is up, OPEN exchanges BGP version, AS information, BGP identifier, hold time and capabilities. KEEPALIVE confirms and maintains the session. UPDATE advertises or withdraws routes. NOTIFICATION reports an error or closing condition and closes the session.

For a simple trace, B advertises prefix X and AS_PATH 20 to A in an UPDATE. A applies import policy, checks route eligibility and next-hop resolution, and compares alternatives. Later B may withdraw X in another UPDATE. A’s route from B disappears subject to processing, but A may still have a route from C. A session failure or unresolved next hop can also make a route unusable; a withdrawal is not the only possible cause. Hold timers and graceful restart affect failure handling.

An UPDATE can advertise multiple prefixes with common attributes and can carry withdrawals. A withdrawal-only UPDATE need not carry the mandatory attributes required for an advertised route. The slide’s labels “unreachable attribute,” OPEN authentication fields and marker as a negotiated checksum do not match the BGP-4 base format; see RFC 4271 sections 4–5.

11. Attributes and an exam-style route choice (PDF pages 33–41)

Assume router R in AS 10 learns two eligible routes to the same prefix. Both next hops resolve, both have equal Cisco weight if that feature exists, and neither route is locally originated:

CandidateLOCAL_PREFAS_PATHResult
A10020 30Shorter path
B20040 50 30Preferred in a common order because LOCAL_PREF is higher

If both LOCAL_PREF values become 100 and preceding relevant comparisons tie, A normally wins on shorter AS_PATH. The selection order is implementation- and configuration-dependent. ORIGIN is generally compared after AS_PATH, with IGP preferred to EGP and then incomplete; its IGP label does not simply mean that OSPF supplied the route. NEXT_HOP must be resolvable; its internal cost can also be a later tie-breaker. eBGP versus iBGP and additional tie-breakers can matter.

MED is a hint that an advertising AS can use to suggest an entry link to its neighbor. Where the routes qualify for MED comparison, lower MED is generally preferred; comparison across routes from different neighboring ASes is not guaranteed. LOCAL_PREF instead influences the local AS’s preferred outbound path and higher is normally better. The neighboring AS controls its own policy and may disregard the MED.

Cisco weight is an added, vendor-specific comparison, not a standard path attribute carried in an UPDATE. It is local to one router and typically checked before LOCAL_PREF; higher wins. Equal weights were assumed in the table. A weight change on R1 does not automatically reach R2, unlike LOCAL_PREF communicated inside an AS. Weight is not discussed in this PDF. Cisco’s documented defaults and behavior are described in its BGP case studies.

Well-known attributes must be recognized; mandatory ones are required on applicable route advertisements, while discretionary ones need not appear on every applicable UPDATE. Optional transitive attributes can be passed onward according to protocol rules when unrecognized; unknown optional non-transitive attributes are not. The Optional flag is 0 for well-known and 1 for optional, reversing the source’s wording. MED is type 4 and LOCAL_PREF type 5; the slide’s numbering is wrong. BGP Sessions Paths and Attributes

12. Import, selection and export: follow the information (PDF pages 42–44)

Suppose a router receives route A from provider P and route B from customer C. Its import policy can reject a route or set an internal preference. The BGP decision process compares the remaining eligible routes for the same prefix and selects one. Export policy then decides what to advertise to each peer. A route may be known locally without being selected, and selected without being exported to every neighbor.

The conceptual Adj-RIB-In holds received routing information, Loc-RIB contains selected BGP routes, and Adj-RIB-Out represents what is selected for advertisement to each peer. These are conceptual roles; implementation storage and policy details vary. A selected BGP route must also be eligible for installation into the system’s routing and forwarding information. A router knowing a route is not the same as its neighbor receiving it.

13. What peering, transit and an IXP mean (PDF pages 53–64)

Consider a customer of network A accessing a server hosted by a customer of network B. Under an appropriate direct peering agreement, A carries the packet across A, hands it to B at their interconnection, and B carries it to the server. The reply requires a usable reverse route. Their agreement defines the traffic and prefixes covered; it may cover their own and customer networks without giving A transit to every third party B can reach. Direct handoff does not mean customer devices have a direct cable or that there are no internal routers.

Transit is a service in which a provider carries customer traffic to destinations covered by their contract. Peering may be settlement-free or paid. An IXP commonly supplies an Ethernet fabric where networks can interconnect; physical presence at the IXP does not automatically establish sessions or business agreements with everyone. A route server is an additional possible service.

For policy, imagine A learns a route from provider P and also has peer Q. A may use P’s route for its own traffic yet decline to advertise it to Q, avoiding an unwanted transit path Q → A → P. Conversely, A and B may form a BGP session through a transit provider when they have IP reachability and suitable multihop configuration. They are BGP peers, but the connection does not thereby become a direct physical peering handoff or eliminate the provider’s role. BGP Policy Transit and Internet Exchange

14. Aggregation versus longest-prefix forwarding (PDF pages 31–32)

The adjacent prefixes 203.0.112.0/24 and 203.0.113.0/24 can be covered by 203.0.112.0/23. Advertising a /23 aggregate can reduce the number of entries a neighbor sees. But if a more-specific 203.0.113.0/24 is also installed via another next hop, a packet to 203.0.113.50 uses that /24. A packet to 203.0.112.50 uses the /23 if no more-specific route applies. Longest-prefix matching compares installed prefixes during forwarding; BGP best-path selection compares eligible alternatives for a particular prefix.

If the /23 remains advertised while one /24 becomes unreachable, it can still attract packets for the failed range. Aggregate origination and withdrawal are configuration-dependent. A discard route can prevent a routing loop for unused aggregate space, but it does not make that space reachable. The slides’ AS_SET example is historical context, not a blanket recommendation for current Internet announcements.

15. OSPF, BGP next hops and the data path

Assume R1 and R3 are BGP speakers in one AS, with internal R2 between them. R3 advertises destination 203.0.113.0/24 to R1 over iBGP with BGP NEXT_HOP 10.0.0.3. OSPF tells R1 how to reach 10.0.0.3 through R2. R1 can use that information to resolve the BGP next hop and, if the route is selected and installed, send a destination packet toward R2 and R3. Depending on configuration, the BGP next hop might instead remain an external address; it is not automatically the advertising router.

R2 receives a packet addressed to 203.0.113.50, so it also needs a suitable route for that destination, such as a BGP route, default, or another applicable forwarding design. Knowing how to reach 10.0.0.3 does not by itself give R2 a route to every external network. The peer IP address, BGP NEXT_HOP, final destination and forwarding instructions at each intermediate router are distinct.

16. Walk the source configuration (PDF pages 66–72)

The source uses a Cisco-style process in AS 23 with neighbor 10.1.5.5 in AS 23 and neighbor 20.2.2.5 in AS 33. The key statements are:

router bgp 23
 network 10.1.0.0 mask 255.255.0.0
 neighbor 10.1.5.5 remote-as 23
 neighbor 20.2.2.5 remote-as 33

The first line sets the BGP local AS, unlike an OSPF process ID, which is locally significant. The first neighbor is iBGP; the second is eBGP. Both peers need reciprocal compatible configuration and prior IP reachability. The network line specifies a prefix to originate into BGP: on typical Cisco platforms it requires an exact matching route in the local routing table. Merely having a 10.1.1.0/24 route does not establish the required 10.1.0.0/16 exact match, nor prove all addresses in the /16 are reachable.

In the source’s OSPF configuration, a network statement instead selects matching interfaces and their area. Redistribution copies selected information between processes and needs careful metric, filtering and feedback design. A passive OSPF interface normally does not form OSPF neighbors there while its connected network can still be advertised. The source’s default-information originate always example can originate a default without verifying a working external destination, so its use must be matched to failure detection and design. Syntax and default settings are version-specific.

17. Independent review with answers

R receives AS_PATH 20 30 and AS_PATH 40 50 30 for the same prefix. Must it use the first? No. A higher LOCAL_PREF or an earlier applicable comparison can select the second. The shorter AS path is only one criterion.

R1 has a BGP route with next hop R3. OSPF reaches R3 through R2. Is R2 automatically able to forward the external packet? No. R2 also needs a suitable forwarding route for the packet’s destination or another forwarding mechanism.

Can a router have two consecutive iBGP sessions? Yes. The normal restriction is forwarding a route learned from one ordinary iBGP peer to another ordinary iBGP peer; a route reflector can reflect eligible routes under its rules.

Does a BGP peering session through transit mean the networks exchange data directly? No. It can be a multihop session, while packets still cross the provider. The session and the commercial peering agreement are separate.

A router learns a /23 and a /24 that both match a packet. Does the /23 win because it has a higher LOCAL_PREF? No, if both are installed and match, longest-prefix matching chooses the /24. LOCAL_PREF compares BGP paths for the same prefix, not different prefix lengths.

Does a Cisco BGP network statement assign an IP address to an interface? No. It identifies a prefix to originate when the applicable route requirements are met. Interface addressing is separate.

Internet Architecture and Technologies · Lecture 04 - Forwarding and Routing Algorithms · Lecture 05 - OSPF · Hierarchical Routing and Route Redistribution