SEN2008 · Week 6 · Network Layer Concepts (II): Routing Protocols OSPF, BGP, multicasting

OSPF, BGP and multicast

OSPF inside an AS (cost calculation, areas), BGP between ASes (eBGP/iBGP, AS-PATH, NEXT-HOP, route selection, hot potato) and multicast (IGMP, trees, multicast MAC mapping). The page for concept questions and small calculations.

autonomous system (AS)intra-AS routinginter-AS routingOSPFareabackboneBGPeBGPiBGPAS-PATHNEXT-HOPlocal preferencehot potato routingmulticastIGMPreverse path forwardingPIM

The algorithms on the previous page were on paper. In the real Internet there are protocols that run them: OSPF inside an organization, BGP between organizations. There is also multicast, the way to send a packet to many receivers at once. From this page the exam mostly asks concept questions and small calculations. Golden rules:

  1. Inside an AS = performance, between ASes = policy.
  2. OSPF is link-state and runs directly over IP (protocol 89).
  3. BGP is path-vector and runs over TCP 179.
  4. BGP selection is ordered: LOCAL_PREF, then AS-PATH length, then hot potato.
  5. Multicast MAC = 01:00:5e + the low 23 bits of the IP.

Autonomous systems (AS)

The Internet is not a single network but a union of thousands of autonomous systems (AS). Each AS has a number (ASN) and manages its own routers itself. There are two reasons for two-level routing:

  • Scale: it is impossible for all routers to know all links. Link-state packets would eat all the bandwidth.
  • Administrative autonomy: each organization wants to choose its own algorithm and hide its topology inside its network.
Intra-ASInter-AS
ProtocolOSPF, IS-IS, RIPBGP
GoalLowest-cost pathPolicy + reachability
AdministrationA single organizationMultiple organizations

OSPF (Open Shortest Path First)

OSPF is a link-state protocol. Each router spreads the state of its links to everyone in the AS by flooding (link-state advertisement, LSA). It does so when something changes, and also periodically even if nothing changes (at least every 30 minutes). Each router runs Dijkstra on the same map and builds its own shortest-path tree.

Features:

  • Messages go directly inside IP, with protocol 89. No TCP/UDP; OSPF provides reliable delivery itself.
  • Authentication: messages can be authenticated against the injection of forged LSAs. This matters for the security part of the course.
  • If there are several equal-cost paths, traffic can be split (ECMP).
  • Hierarchy: large ASes are divided into areas. LSAs spread within an area. All areas connect to the backbone, which is area 0. Routers on an area boundary are ABRs (area border routers), and those connecting outside the AS are ASBRs.

OSPF cost calculation

The administrator determines the link cost. A common default (Cisco style): reference bandwidth / interface bandwidth, rounded down to an integer, at least 1.

reference = 100 Mbps
10 Mbps     → 100/10    = 10
100 Mbps    → 100/100   = 1
1 Gbps      → 100/1000  = 0.1 → at least 1
45 Mbps     → 100/45    = 2.22 → 2
1.544 Mbps  → 100/1.544 = 64.77 → 64      (T1)

path: T1 + 100 Mbps + 10 Mbps = 64 + 1 + 10 = 75
path: 45 Mbps + 100 Mbps + 100 Mbps = 2 + 1 + 1 = 4

PITFALL · fast links become equal. With a reference of 100, 100 Mbps, 1 Gbps and 10 Gbps all come out as 1. OSPF sees them all as the same. With a reference of 10000, 100 Mbps → 100, 1 Gbps → 10, 10 Gbps → 1.

BGP (Border Gateway Protocol)

BGP is the protocol that holds the Internet together. It gives each AS two things: learning which prefixes are reachable through neighbouring ASes, and spreading this information to all the routers inside its own AS. And most importantly: deciding by policy which route to use and to whom to advertise.

Sessions. Two BGP routers open a session over TCP port 179.

  • eBGP: between two border routers (gateways) in different ASes.
  • iBGP: between routers inside the same AS; it distributes the route learned by eBGP inward.

Route = prefix + attributes. BGP is a path-vector protocol: for each destination it advertises not just a cost but the whole AS path.

AttributeMeaning
AS-PATHThe list of ASes the advertisement has passed through, e.g. AS3 AS7. Used for loop checking and length comparison.
NEXT-HOPThe IP address of the router interface that started the AS-PATH; the exit point.
LOCAL_PREFA preference value given by the administrator inside the AS. A policy tool.

If a router sees its own AS number in the AS-PATH of an advertisement, it rejects the advertisement. This is how loops are prevented.

Route selection

If there are several routes for the same prefix, the rules are applied in order; when a rule leaves a single candidate, you stop:

  1. Highest LOCAL_PREF.
  2. Shortest AS-PATH.
  3. Closest NEXT-HOP (the exit with the lowest intra-AS cost): hot potato routing.
  4. For remaining ties, binding rules such as the BGP router ID.

Example. R1 learned three routes for prefix 198.18.0.0/16:

route  LOCAL_PREF  AS-PATH       intra-AS cost to NEXT-HOP
K      150         AS2 AS9       7
L      150         AS4 AS9       3
M      100         AS9           1

1) Highest LOCAL_PREF: K and L (150). M is eliminated (even though its AS-PATH is the shortest)
2) AS-PATH: both are 2 ASes → equal
3) hot potato: L's NEXT-HOP is closer (3 < 7) → L is selected

PITFALL · mixing up the order. Choosing M because it has the shortest AS-PATH is wrong. The LOCAL_PREF rule comes earlier and expresses the administrator’s policy.

Policy

An AS also chooses which routes to advertise. A typical rule: traffic going to customer networks is carried, but free transit is not given between two providers. A stub network does not advertise itself as transit, even if it is connected to several providers (multi-homed). Security note: BGP advertisements are not verified by default. If an AS advertises a prefix that does not belong to it, traffic flows to it (prefix hijacking). Mechanisms such as RPKI try to prevent this.

Broadcast and multicast

Broadcast sends a packet to everyone in the network, multicast only to those who are members of a group. Sending N separate copies for N receivers (N-way unicast) uses up the source’s link. Copying inside the network is more efficient.

Broadcast methods. Uncontrolled flooding produces endless copies in loops (broadcast storm). Solutions:

  • Sequence-number-controlled flooding: each node does not forward a (source, sequence number) pair it has seen before.
  • Reverse path forwarding (RPF): if the packet arrived on the interface of the router’s own shortest path to the source, it is forwarded on all other interfaces; if it came from another interface, it is dropped.
  • Spanning tree: a spanning tree is built first, and the packet moves only along the edges of the tree.

Multicast addresses. In IPv4, class D: 224.0.0.0/4, that is 224.0.0.0 to 239.255.255.255. 224.0.0.x is reserved for the local link (e.g. 224.0.0.5 for OSPF routers).

IGMP runs between a host and the router directly attached to it: the router asks “is there a member of this group?” (membership query), and the host answers (membership report). Multicast trees between routers are built by PIM (Protocol Independent Multicast) or DVMRP.

TreeIdeaWhenProtocol
Source-basedA separate tree per source, RPF + pruningMembers are denseDVMRP, PIM-DM
SharedA single tree, central router (rendezvous point)Members are sparsePIM-SM

From multicast IP to Ethernet MAC

The Ethernet multicast MAC starts with 01:00:5e, followed by one 0 bit and the low 23 bits of the IP address.

239.200.15.7
2nd octet 200 = 11001000 → top bit dropped → 1001000 = 0x48
3rd octet 15 = 0x0f, 4th octet 7 = 0x07
MAC = 01:00:5e:48:0f:07

224.10.20.30   → 01:00:5e:0a:14:1e
224.138.20.30  → 01:00:5e:0a:14:1e   (138 & 0x7f = 10)
225.10.20.30   → 01:00:5e:0a:14:1e   (the first octet does not enter at all)

There are 28 bits for the group (the first 4 bits 1110 are fixed), and 23 of them enter the MAC. Because of the 5 lost bits, 25=322^5 = 32 groups share the same MAC. The card receives them, and the IP layer drops the unwanted ones.

TIP · quick calculation. If the second octet is less than 128, write it as is; if it is 128 or more, subtract 128. Then append the hexadecimal values of the three octets after 01:00:5e.

Common mistakes

Wrong ideaCorrect
OSPF uses TCP or UDPDirectly over IP, protocol 89
BGP uses UDPTCP port 179
BGP always picks the shortest AS-PATHLOCAL_PREF is checked first
Hot potato = shortest total pathThe closest exit inside the AS; the outside is ignored
iBGP runs between ASesiBGP is inside an AS, eBGP is between ASes
OSPF cost is rounded (64.77 → 65)It is truncated: 64
The OSPF cost of 1 Gbps is 0.1At least 1
The whole IP enters the multicast MACOnly the low 23 bits, so 32 groups collide
IGMP is a protocol between routersIt is between a host and its first router; between routers it is PIM

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

Which transport does BGP use to exchange routing information between peers?

  1. UDP port 520
  2. TCP port 179
  3. IP protocol 89 directly
  4. ICMP
Show answer
B) TCP port 179

A BGP session is a semi-permanent TCP connection between two routers, on port 179. RIP uses UDP 520, and OSPF runs directly over IP with protocol 89.

Question 2easy

OSPF messages are carried how?

  1. Over TCP
  2. Over UDP
  3. Directly in IP datagrams (protocol number 89)
  4. In Ethernet frames without IP
Show answer
C) Directly in IP datagrams (protocol number 89)

OSPF does not use a transport layer; it carries its messages directly in IP (protocol = 89). It provides reliability (ACKs, retransmission) by itself.

Question 3easy

With a reference bandwidth of 100 Mbps, what is the OSPF cost of a 10 Mbps interface?

Show answer
10

OSPF cost = reference bandwidth / interface bandwidth = 100 / 10 = 10. The cost of a 100 Mbps interface is 1.

Question 4medium

Reference bandwidth is 100 Mbps. A path crosses a T1 link (1.544 Mbps), a 100 Mbps link and a 10 Mbps link. What is the total OSPF cost of the path?

Show answer
75

The cost of each link is rounded down to an integer. T1: 100 / 1.544 = 64.77 → 64. 100 Mbps: 1. 10 Mbps: 10. Total 64 + 1 + 10 = 75.

Question 5medium

With the default reference of 100 Mbps, a 1 Gbps link and a 100 Mbps link both get cost 1. What is the usual fix?

  1. Disable OSPF on the slower link
  2. Increase the reference bandwidth (e.g. to 10000 Mbps)
  3. Switch to RIP
  4. Use a smaller MTU
Show answer
B) Increase the reference bandwidth (e.g. to 10000 Mbps)

Since the cost can be at least 1, 100 Mbps and above always come out as 1, and OSPF cannot tell them apart. With a reference of 10000, 100 Mbps → 100, 1 Gbps → 10, 10 Gbps → 1.

Question 6hard

Router R1 in AS1 learns three routes to prefix 203.0.113.0/24. Assuming all routes are valid, which one does BGP select?

Route  LOCAL_PREF  AS-PATH         NEXT-HOP IGP cost
X      100         AS2 AS5         4
Y      200         AS3 AS4 AS5     9
Z      200         AS6 AS5         12
  1. X
  2. Y
  3. Z
  4. BGP load-balances across all three
Show answer
C) Z

BGP rules are applied in order. 1) Highest LOCAL_PREF: Y and Z (200) remain, X is eliminated. 2) Shortest AS-PATH: 3 ASes in Y, 2 in Z. Z is selected. The NEXT-HOP cost (hot potato) would be consulted only if the first two rules left a tie; here it was not needed.

Question 7medium

Two BGP routes to the same prefix have equal LOCAL_PREF and equal AS-PATH length. Router R picks the one whose NEXT-HOP has the lowest intra-AS cost. What is this called?

  1. Cold potato routing
  2. Hot potato routing
  3. Poisoned reverse
  4. Reverse path forwarding
Show answer
B) Hot potato routing

Hot potato: get the packet out of your own AS as quickly as possible, choosing the cheapest exit point (gateway) inside the AS. It doesn't care about the total cost of the path outside the AS; it is selfish but protects the AS's internal resources.

Question 8medium

A BGP router receives an advertisement whose AS-PATH already contains its own AS number. What does it do?

  1. Accepts it and prepends its AS again
  2. Rejects it to prevent a loop
  3. Forwards it unchanged to all peers
  4. Converts it into an OSPF LSA
Show answer
B) Rejects it to prevent a loop

The AS-PATH is the list of ASes the advertisement has passed through. Seeing its own AS number in it means the advertisement has come back to it. It is rejected to prevent a loop.

Question 9medium

What is the Ethernet multicast MAC address for the IPv4 group 224.10.20.30?

Show answer
01:00:5e:0a:14:1e

Rule: the prefix 01:00:5e + the low 23 bits of the IP address. The top bit of the second octet is dropped: 10 & 0x7F=1010 \,\&\, 0x7F = 10 = 0x0a. The third and fourth octets are copied as is: 20 = 0x14, 30 = 0x1e. The result is 01:00:5e:0a:14:1e.

Question 10hard

Because only 23 bits of a multicast IPv4 address are copied into the MAC address, how many IPv4 multicast groups map to the same Ethernet MAC address?

Show answer
32

The first 4 bits of a class D address are fixed at 1110, leaving 28 bits of group information. 23 of them go into the MAC, so 28−23=528 - 23 = 5 bits are lost. 25=322^5 = 32 groups share the same MAC. For example, 224.10.20.30, 224.138.20.30 and 225.10.20.30 fall on the same MAC; the host's IP layer filters out the extras.

Question 11easy

Which protocol does a host use to tell its local router that it wants to join a multicast group?

  1. IGMP
  2. ICMP
  3. ARP
  4. BGP
Show answer
A) IGMP

IGMP (Internet Group Management Protocol) runs between a host and the router directly attached to it: membership query, membership report, leave. Multicast routing between routers is done by PIM or DVMRP.

Question 12medium

Why do intra-AS and inter-AS routing protocols optimize different things?

  1. Inter-AS routing is dominated by policy between organizations, while intra-AS routing can focus on performance
  2. Intra-AS routing must hide topology, inter-AS must flood it
  3. Inter-AS routing only uses link costs
  4. There is no difference; both use Dijkstra
Show answer
A) Inter-AS routing is dominated by policy between organizations, while intra-AS routing can focus on performance

Inside a single organization everyone is under the same administration, so choosing the shortest path is enough. Between ASes, commercial relationships decide: whose traffic you carry and which route you advertise to whom is a policy decision. The scale is different too: BGP carries aggregated prefixes.

Verification: OSPF interface and path costs (floor(ref/bandwidth)) and the multicast IP-to-MAC mapping (low 23 bits) were computed with node (verify/SEN2008/06.mjs). BGP selection questions were traced by hand following the rule order.

Review card

AS = network under a single administration. OSPF/RIP inside, BGP between OSPF: link-state + Dijkstra, proto 89 over IP, flooding OSPF cost = floor(ref / bandwidth), at least 1. ref 100: 10M→10, T1→64 OSPF areas: area 0 = backbone, ABR connects areas; authentication BGP: path-vector, TCP 179. eBGP between ASes, iBGP spreads inside the AS route = prefix + attributes: AS-PATH, NEXT-HOP, LOCAL_PREF selection order: higher LOCAL_PREF → shorter AS-PATH → closest NEXT-HOP (hot potato) → BGP ID if you see your own AS in the AS-PATH, REJECT (loop) policy: customer traffic is carried, no transit between two providers multicast: 224.0.0.0/4 (224-239), IGMP host-router, PIM router-router MAC = 01:00:5e + low 23 bits → 32 groups share a MAC RPF: forward if the packet came in on the interface of the shortest path to the source trees: source-based (dense, DVMRP/PIM-DM) / shared (sparse, PIM-SM, RP)