Sub topic 2
What OSPF Is and the Five Packet Types
Prerequisites
This chapter assumes you know IPv4 addressing and subnet masks, basic router interface configuration, the difference between static and dynamic routing, and how a routing table uses longest-prefix match. You should also be comfortable with Ethernet and point-to-point links. The previous chapter covered link-state routing in general. This one covers the protocol that implements it.
What OSPF Is
Open Shortest Path First (OSPF) is a link-state interior gateway protocol (IGP). An IGP exchanges routes between routers inside one organization, called an autonomous system (AS). OSPF is "open" because it is an open standard. RFC 2328 defines version 2, which carries IPv4 routes. OSPFv3 (RFC 5340) carries IPv6 routes and gets its own chapter later.
Each OSPF router describes its own links and their costs. It floods that description to the other routers in its area. Every router stores the descriptions in a link-state database (LSDB). Each one then runs the shortest path first (SPF) algorithm on that database to build a loop-free tree of best paths. A distance-vector protocol such as RIP shares computed routes. OSPF shares the raw topology and lets each router compute its own routes.
Key properties:
- Classless. Updates carry a prefix and a mask, so VLSM and CIDR work.
- Fast convergence. A topology change is flooded at once. Routers do not wait for a periodic update timer.
- Metric is cost. The default cost is based on interface bandwidth.
- Hierarchical. Areas limit how far detailed topology information spreads.
- Own transport. OSPF does not use TCP or UDP. It runs directly over IP as protocol number 89.
OSPF sends to two multicast addresses: 224.0.0.5 (AllSPFRouters, every OSPF router) and 224.0.0.6 (AllDRouters, the designated router and backup designated router). Multicast OSPF packets use an IP TTL of 1, so they never leave the local link. On a link where multicast is not suitable, OSPF can send unicast packets to configured neighbors.
The OSPF Packet Header
All five packet types begin with the same 24-byte header. These fields matter most when you read a packet capture or debug an adjacency.
| Field | Purpose |
|---|---|
| Version | 2 for OSPFv2 |
| Type | 1 to 5, identifies the packet type |
| Router ID | The 32-bit ID of the sender |
| Area ID | The area the packet belongs to |
| Checksum | Detects corruption |
| Authentication type and data | Used when authentication is enabled |
A receiving router drops a packet if the Area ID does not match the area configured on the receiving interface. It also drops the packet if authentication fails. These checks explain several adjacency failures that later chapters cover.
The Five Packet Types
| Type | Name | Job |
|---|---|---|
| 1 | Hello | Discover neighbors, keep them alive, elect the DR and BDR |
| 2 | Database Description (DBD) | Summarize the LSDB by listing LSA headers |
| 3 | Link-State Request (LSR) | Ask for full copies of specific LSAs |
| 4 | Link-State Update (LSU) | Carry full LSAs |
| 5 | Link-State Acknowledgment (LSAck) | Confirm that LSAs were received |
A link-state advertisement (LSA) is one unit of topology information. The LSDB is a collection of LSAs.
Hello (type 1)
Hello packets are sent periodically on every OSPF-enabled interface. They find neighbors and then act as a keepalive. A Hello carries the parameters both routers must agree on, such as the Hello interval, the dead interval, the area ID, and the subnet mask on broadcast networks. It also lists the router IDs the sender has heard from, and the current DR and BDR. The next chapters cover these fields.
Database Description (type 2)
Two routers that become neighbors must synchronize their databases. They do not send everything at once. In the DBD exchange, each router sends a list of LSA headers, which are short summaries of what it has. One router acts as master and the other as slave to control sequencing. Flags in the DBD mark the initial packet, whether more packets follow, and which router is master.
Link-State Request (type 3)
After comparing DBD headers, a router knows which LSAs it lacks or holds only in an older version. It lists them in an LSR and asks the neighbor for the full LSAs.
Link-State Update (type 4)
An LSU carries one or more full LSAs. It answers an LSR. A router also sends one when it originates a new LSA or refreshes an existing one, and when it floods a changed LSA onward. LSUs are the packets that carry topology changes through the network.
Link-State Acknowledgment (type 5)
OSPF has its own reliability mechanism because it does not use TCP. Each LSA must be acknowledged. A router that sends an LSU and gets no LSAck retransmits the LSU after a timer expires. An LSAck can acknowledge several LSAs and can also be implied by a matching LSA arriving in the reverse direction.
How the Packets Work Together
The sequence below shows two routers that have just discovered each other.
After this initial synchronization, only Hellos flow regularly. LSUs and LSAcks appear again when the topology changes.
Reading the Traffic on a Live Router
You can see the packet types as they arrive. This command is for lab use. Debugging on a busy production router can overload the CPU.
debug ip ospf packetEach line shows the version, type, length, router ID, and area ID. Seeing type 1 packets only means the routers are exchanging Hellos. If type 2 packets appear and then stop, the adjacency has stalled during database exchange. A later chapter on the neighbor state machine explains where and why.
Common Errors at This Stage
- Expecting OSPF to use TCP. If a firewall allows TCP and UDP but blocks IP protocol 89, OSPF fails even though other traffic works.
- Mixing up Hello and LSU roles. Hellos do not carry routing information. They only build and maintain neighbor relationships.
- Believing a full database is sent immediately. Neighbors first exchange headers in DBDs. Only missing or newer LSAs are requested and sent.
- Forgetting the TTL of 1. Multicast OSPF packets do not cross a router. Neighbors must share a link, or you must use a virtual link or tunnel.
- Mismatched area IDs. The receiver silently discards the packet because the header carries the area.
Exercise
Two routers are connected, and a firewall between them permits all TCP and UDP traffic but blocks every other IP protocol. They never become OSPF neighbors. Why, and which packet type is affected first?
Show answer
OSPF runs directly over IP as protocol 89, not over TCP or UDP, so the firewall drops it. The Hello packets (type 1) are blocked first, so the routers never discover each other and no DBD, LSR, LSU, or LSAck packets are ever sent.
Exercise
A router has received a DBD from a neighbor and found three LSAs it does not have. Which packet type does it send next, and which type brings the answer back?
Show answer
It sends a Link-State Request (type 3) listing the three LSAs. The neighbor answers with a Link-State Update (type 4) containing the full LSAs, and the requester then sends a Link-State Acknowledgment (type 5).