ICMP, ARP, RIP and OSPF
Concise study notes explaining ICMP (error/reporting messages), ARP (IP-to-MAC mapping), RIP (distance-vector routing) and OSPF (link-state routing) with definitions, algorithms, examples and exam focus.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
ICMP, ARP, RIP and OSPF are fundamental control protocols used by network devices. Engineers use ICMP for error reporting and reachability tests, ARP to discover link-layer addresses for IPv4, RIP and OSPF to compute routes inside an autonomous system (intradomain routing). Understanding them is essential for debugging networks, configuring routers, and answering routing behaviour questions in exams.
Key ideas
Start from first principles: a network forwards packets (layer 3) over a link layer (layer 2). Control protocols support addressing, error signalling and route computation.
Definition: ICMP (Internet Control Message Protocol) — a network-layer control protocol used by IP to report error conditions and perform simple diagnostics. ICMP messages are carried in IP datagrams. ICMP is IP protocol number 1 and does not use TCP/UDP ports. When an IP datagram cannot be delivered or processed, or when a diagnostic (like ping) is requested, ICMP creates a control message and sends it back to the originator.
- Key message types to know: Echo Request, Echo Reply, Destination Unreachable, Time Exceeded, Redirect. For exam diagrams: draw an IP datagram arriving at a router with TTL=1 -> router decrements TTL to 0 and generates an ICMP Time Exceeded sent to source.
Definition: ARP (Address Resolution Protocol) — a protocol used to map an IPv4 address to a link-layer (MAC) address on the same broadcast domain. ARP runs on hosts and routers in the same layer-2 network. When the destination IP is off-link, the host ARPs for the default gateway’s MAC (next hop) rather than the remote host.
- Typical ARP operation: a host needing to send an IP packet to an IPv4 address on the same LAN broadcasts an ARP Request (Who has X.X.X.X? Tell A.A.A.A). The owner replies with an ARP Reply (X.X.X.X is at M:M:M:M:M:M). Hosts cache mappings in an ARP cache for a limited time.
- Draw for exams: an Ethernet segment with Host A (IP A.A.A.A, MAC A:1), Host B (IP B.B.B.B, MAC B:2). Show ARP Request broadcast frame (source MAC A:1, dest ff:ff:ff:ff:ff:ff) and ARP Reply unicast (dest MAC A:1).
Definition: RIP (Routing Information Protocol) — a simple distance-vector routing protocol that uses hop count as metric and periodic full updates. Each router maintains a routing table with destination, next hop, and metric (hop count). Routers exchange their entire routing table every update interval.
- Key properties: maximum hop count = 15 (16 == unreachable); split horizon, poisoned reverse, and triggered updates mitigate count-to-infinity; timers (typical): update 30 s, invalid 180 s, holddown 180 s, flush 240 s (RFC also defines a 120 s garbage-collection after invalidation; vendor defaults may vary). RIPv1 is classful (no CIDR) and uses broadcast; RIPv2 is classless (supports CIDR/VLSM and authentication), uses UDP port 520 with multicast 224.0.0.9.
- Underlying algorithm: iterative relaxation using the Bellman-Ford idea: each router updates cost to destination D as min over neighbours (cost_to_neighbour + neighbour_cost_to_D).
- Diagram to draw: three routers A-B-C with link failures; show update messages and how counts increase each periodic update until convergence (or infinity). Label hop counts in each table entry.
Definition: OSPF (Open Shortest Path First) — a link-state routing protocol. Each router discovers its neighbours and link costs, floods link-state advertisements (LSAs) so all routers in the area build the same link-state database (graph), and each router independently runs Dijkstra’s shortest-path algorithm on that graph to build its routing table.
- Key concepts: LSA, area, DR/BDR (on multi-access networks), adjacency, sequence numbers, SPF tree (shortest-path tree). OSPF uses cost (administrative weight) per interface; path cost = sum of link costs along path. OSPF runs directly over IP as protocol number 89; on multi-access networks it uses multicast 224.0.0.5 (AllSPFRouters) and 224.0.0.6 (AllDRouters).
- Exam diagram: small graph of four routers (nodes with link costs) and show the SPF tree rooted at a chosen router; step through Dijkstra selecting the next closest node each iteration.
Assumptions typically stated in answers: RIP assumes small networks (hop-count metric, limited scalability); OSPF assumes database convergence via reliable flooding and that all routers have identical link-state databases within an area.
Formulas
R = min_{n in neighbours} (cost(root->n) + cost_n(dest)) — In distance-vector (RIP) updates: R is new cost from root to destination, cost(root->n) is cost to neighbour n, cost_n(dest) is neighbour’s advertised cost to destination. Units: hop count (dimensionless). Applies to RIP and other distance-vector algorithms.
path_cost = sum_{links in path} link_cost — In OSPF, total path cost is the sum of interface/link costs along that path. Units: administrative cost (dimensionless). Applies when computing shortest path via Dijkstra.
OSPF_cost(interface) = reference_bandwidth / interface_bandwidth — Common vendor formula for interface cost where reference_bandwidth is a configured constant (typical default used by some vendors). Units: dimensionless. OSPF cost is an integer with minimum 1; adjust the reference bandwidth so high-speed links do not all collapse to cost 1 under older defaults. Verify vendor-specific default before using in configuration.
ICMP payload: IP_header_of_original + 8_bytes_of_original_payload — When creating an ICMP error message, the ICMP message includes the IP header and first 8 bytes of the original datagram’s payload (so the sender can match to a socket). Do not send ICMP error messages in response to other ICMP error messages, to broadcast/multicast IP packets, or for fragments other than the first. Applies to ICMP error messages like Destination Unreachable.
Dijkstra complexity ≈ O(E + V log V) with a Fibonacci heap (or O((V+E) log V) with binary heap) — where V = number of vertices (routers), E = number of edges (links). Applies to SPF calculation in link-state protocols.
Worked examples
ARP sequence (numeric-like trace):
- Given: Host A IP 192.168.1.10 MAC 00:AA:00:00:00:01 wants to send IPv4 packet to 192.168.1.20; Host B has IP 192.168.1.20 MAC 00:BB:00:00:00:02. ARP cache at A has no entry for 192.168.1.20.
- Steps:
- A broadcasts ARP Request: Ethernet src=00:AA:..., dst=ff:ff:ff:ff:ff:ff; ARP payload: Who has 192.168.1.20? Tell 192.168.1.10.
- All hosts receive; only B recognizes target IP and sends ARP Reply unicast to A: Ethernet src=00:BB:..., dst=00:AA:...; ARP payload: 192.168.1.20 is at 00:BB:...
- A receives reply and updates ARP cache: 192.168.1.20 -> 00:BB:00:00:00:02 (cached). A sends the original IP packet in Ethernet frame with dst MAC 00:BB:...
- Final: ARP resolved; original IP packet delivered. (Bold final: mapping learned: 192.168.1.20 = 00:BB:00:00:00:02)
RIP count-to-infinity small trace (conceptual):
- Topology: Router A -- Router B -- Router C. Initially A-B-C all working. Each link cost = 1 hop.
- Initial tables: A: to C via B cost 2; B: to C cost 1; C: to C 0.
- Suppose link B–C fails. C becomes unreachable. B sets route to C as infinity? Immediately B notices directly connected loss and sets route to C = ∞ and sends update (depending on timers) but if a delay happens, legacy behaviour: A might advertise route to C via B with cost 2; B receives advertisement from A saying cost to C = 2, so B computes new cost = cost(B->A) + 2 = 3 and updates. Next update A sees B reports cost 3 and increments to 4, and so on — this is count-to-infinity. With poisoned reverse, A would advertise route to C to B as ∞, preventing the loop. Final answer should describe iterations until convergence or infinity.
OSPF Dijkstra example (step-by-step):
- Given graph (draw this): Nodes R1, R2, R3, R4. Links: R1–R2 cost 2, R1–R3 cost 5, R2–R3 cost 1, R2–R4 cost 4, R3–R4 cost 2. Root = R1.
- Step 0: distances: d(R1)=0 (permanent), d(R2)=2 via R1, d(R3)=5 via R1, d(R4)=∞.
- Pick smallest tentative (R2:2) -> mark permanent. Relax neighbours of R2: R3 via R2 = 2+1=3 <5, update d(R3)=3 via R2; R4 via R2 = 2+4=6 so d(R4)=6 via R2.
- Next pick smallest tentative (R3:3) -> mark permanent. Relax R4 via R3 = 3+2=5 <6, update d(R4)=5 via R3.
- Next pick R4:5 -> mark permanent. All nodes permanent. Resulting shortest paths from R1: R2 via R1 cost2; R3 via R2 cost3; R4 via R3 cost5. (Bold final routing: R1->R4 path R1-R2-R3-R4 cost 5.)
Common mistakes
- Saying ICMP is a transport protocol — it is a network-layer control protocol carried inside IP.
- In RIP questions: using unlimited hop count or forgetting the max hop count = 15 rule when computing reachability.
- In RIP count-to-infinity traces: forgetting to apply split-horizon or poisoned-reverse when the question explicitly asks their effect.
- In OSPF Dijkstra: failing to update tentative distances correctly after each node selection, or not drawing/labeling the SPF tree when asked for a diagram.
- Mixing link-state flooding details: forgetting that LSAs are flooded reliably and that DR/BDR election occurs only on multi-access networks; adjacencies form on all OSPF link types.
For your exam
- Short notes: Explain ICMP message types with examples (ping, traceroute), explain ARP request/reply flow and ARP cache purpose, compare RIP vs OSPF in scalability and convergence.
- Derivations/algorithms: Show Bellman-Ford update formula for RIP and step through a small iteration. For OSPF, derive SPF tree using Dijkstra step-by-step on a small graph; explicitly show tentative lists and picks.
- Numericals: RIP hop-count calculations, count-to-infinity traces, OSPF path-cost sums and Dijkstra iterations. Show units (hop count or dimensionless cost) and final routing table entries.
- Diagrams: Always draw the network, label node names, IPs and MACs for ARP; label link costs for OSPF; draw routing table snapshots for RIP. A full-marks answer includes labels, step-by-step state evolution, and final tables with next hop and metric.
Quick check
- What ICMP message does traceroute rely on from intermediate routers when TTL expires?
- What is the metric used by RIP and what is the maximum reachable hop count?
- In OSPF, after flooding LSAs, which algorithm does each router run to compute paths? Answers: 1) ICMP Time Exceeded. 2) Hop count; maximum reachable = 15 (16 means unreachable). 3) Dijkstra’s shortest-path algorithm (SPF).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?