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.
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:
- Inside an AS = performance, between ASes = policy.
- OSPF is link-state and runs directly over IP (protocol 89).
- BGP is path-vector and runs over TCP 179.
- BGP selection is ordered: LOCAL_PREF, then AS-PATH length, then hot potato.
- 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-AS | Inter-AS | |
|---|---|---|
| Protocol | OSPF, IS-IS, RIP | BGP |
| Goal | Lowest-cost path | Policy + reachability |
| Administration | A single organization | Multiple 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.
| Attribute | Meaning |
|---|---|
| AS-PATH | The list of ASes the advertisement has passed through, e.g. AS3 AS7. Used for loop checking and length comparison. |
| NEXT-HOP | The IP address of the router interface that started the AS-PATH; the exit point. |
| LOCAL_PREF | A 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:
- Highest LOCAL_PREF.
- Shortest AS-PATH.
- Closest NEXT-HOP (the exit with the lowest intra-AS cost): hot potato routing.
- 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.
| Tree | Idea | When | Protocol |
|---|---|---|---|
| Source-based | A separate tree per source, RPF + pruning | Members are dense | DVMRP, PIM-DM |
| Shared | A single tree, central router (rendezvous point) | Members are sparse | PIM-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, 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 idea | Correct |
|---|---|
| OSPF uses TCP or UDP | Directly over IP, protocol 89 |
| BGP uses UDP | TCP port 179 |
| BGP always picks the shortest AS-PATH | LOCAL_PREF is checked first |
| Hot potato = shortest total path | The closest exit inside the AS; the outside is ignored |
| iBGP runs between ASes | iBGP 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.1 | At least 1 |
| The whole IP enters the multicast MAC | Only the low 23 bits, so 32 groups collide |
| IGMP is a protocol between routers | It 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.
Which transport does BGP use to exchange routing information between peers?
- UDP port 520
- TCP port 179
- IP protocol 89 directly
- ICMP
Show answer
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.
OSPF messages are carried how?
- Over TCP
- Over UDP
- Directly in IP datagrams (protocol number 89)
- In Ethernet frames without IP
Show answer
OSPF does not use a transport layer; it carries its messages directly in IP (protocol = 89). It provides reliability (ACKs, retransmission) by itself.
With a reference bandwidth of 100 Mbps, what is the OSPF cost of a 10 Mbps interface?
Show answer
OSPF cost = reference bandwidth / interface bandwidth = 100 / 10 = 10. The cost of a 100 Mbps interface is 1.
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
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.
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?
- Disable OSPF on the slower link
- Increase the reference bandwidth (e.g. to 10000 Mbps)
- Switch to RIP
- Use a smaller MTU
Show answer
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.
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- X
- Y
- Z
- BGP load-balances across all three
Show answer
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.
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?
- Cold potato routing
- Hot potato routing
- Poisoned reverse
- Reverse path forwarding
Show answer
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.
A BGP router receives an advertisement whose AS-PATH already contains its own AS number. What does it do?
- Accepts it and prepends its AS again
- Rejects it to prevent a loop
- Forwards it unchanged to all peers
- Converts it into an OSPF LSA
Show answer
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.
What is the Ethernet multicast MAC address for the IPv4 group 224.10.20.30?
Show answer
Rule: the prefix 01:00:5e + the low 23 bits of the IP address. The top bit of the second octet is dropped: = 0x0a. The third and fourth octets are copied as is: 20 = 0x14, 30 = 0x1e. The result is 01:00:5e:0a:14:1e.
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
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 bits are lost. 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.
Which protocol does a host use to tell its local router that it wants to join a multicast group?
- IGMP
- ICMP
- ARP
- BGP
Show answer
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.
Why do intra-AS and inter-AS routing protocols optimize different things?
- Inter-AS routing is dominated by policy between organizations, while intra-AS routing can focus on performance
- Intra-AS routing must hide topology, inter-AS must flood it
- Inter-AS routing only uses link costs
- There is no difference; both use Dijkstra
Show answer
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.