How OSPF Neighbors Form and Elect a DR, Packet by Packet
This walkthrough uses captures from the late Nick Russo's free packet-capture library. They are in the OSPF archive, ospf_pcap.zip, under ospf_pcap/ospfv2/: ospfv2_dr_election.pcapng, ospfv2_mtu_mismatch.pcapng, ospfv2_lsa1_lsa2.pcapng, ospfv2_auth_md5.pcapng, and ospfv2_auth_sha256.pcapng. The archive is preserved by the Internet Archive, with the rest of the library listed on his job aid page. We decoded the captures with VisualEther, which turns a Wireshark PCAP into a sequence diagram with a plain-English caption on every message.
OSPF (Open Shortest Path First) is the routing protocol most enterprise networks run inside their own walls. Each router tells its neighbors which links it has, every router collects the same map, and each one computes its own shortest paths from it. Before any of that, routers have to find each other, agree on who coordinates a shared segment, and copy each other's maps. Most OSPF problems show up in those first seconds, and these captures record them packet by packet.
Two captures are drawn as annotated sequence diagrams:
- Three routers on one Ethernet segment elect a designated router (DR), synchronize their databases, and settle into steady state (60 frames, all OSPF).
- Two routers with different interface MTUs go from Down to 2-Way in two Hellos, then never get past ExStart (16 frames).
Three shorter captures fill in the rest: a pair of Router and Network LSAs being withdrawn, and the same Hello signed with MD5 and with SHA-256.
Each participant gets a lane, and each OSPF packet is an arrow, numbered as in Wireshark and captioned with what it does. Every diagram comes in three forms: an interactive viewer, an HTML page, and a printable PDF. In the viewer and the HTML page, clicking any message opens its full Wireshark field tree.
💡 Read the walkthrough and a diagram side by side: open the interactive diagram in a split-screen window, or open the HTML version in a new tab and snap the two windows side by side. Each capture section below links its own diagram.
OSPF in one minute
OSPF runs directly over IP as protocol 89, with no TCP or UDP, and its packets are never forwarded past the local link. Every router keeps a link-state database: a set of link-state advertisements (LSAs), each describing one router or one network. Routers that share an area must hold identical databases, so most of OSPF's packets exist to keep those databases in step. Version 2, for IPv4, is defined in RFC 2328; section numbers below refer to it.
There are five packet types (A.3):
| Type | Packet | Job |
|---|---|---|
| 1 | Hello | Find neighbors, check that they agree on parameters, and elect the DR |
| 2 | Database Description (DBD) | Summarize a database as a list of LSA headers |
| 3 | Link State Request (LSR) | Ask for LSAs the router is missing or holds an older copy of |
| 4 | Link State Update (LSU) | Carry full LSAs, in reply to a request or when flooding a change |
| 5 | Link State Acknowledgment (LSAck) | Confirm that LSAs arrived |
Two multicast addresses carry most of the traffic: 224.0.0.5 (AllSPFRouters), which every OSPF router listens to, and 224.0.0.6 (AllDRouters), which only the DR and backup DR (BDR) listen to.
On a segment with many routers, such as an Ethernet LAN, every pair of routers swapping databases would scale badly. So OSPF elects a DR. Every router synchronizes with the DR, and the BDR stands by to take over. Two routers that are neither DR nor BDR, called DROthers, stop at 2-Way with each other and never exchange databases directly (10.4).
Each neighbor relationship moves through these states (10.1):
Capture 1: three routers elect a DR
R1, R2, and R3 share the Ethernet segment 10.0.123.0/24 in area 0, the backbone. Their router IDs are 10.0.0.1, 10.0.0.2, and 10.0.0.3. The diagram has a lane for each router and one for each multicast group, so you can see which packets go to everyone, which go only to the DR, and which go to a single neighbor.
How do two routers move from Down to Full?
They step through the states above, and each step is driven by a packet you can find in the capture. Capture 1 starts after the routers have found each other: in frame 1, R3's Hello already lists R1 and R2 as neighbors, so every pair is at 2-Way. (Capture 2 below shows the Down and Init steps.)
| State | What it means | Where it shows in capture 1 |
|---|---|---|
| 2-Way | Each router sees its own ID in the other's Hello | Frames 1–6: every Hello lists the other two routers |
| ExStart | The pair decides who is master | Frames 7–11: opening DBDs with I, M, and MS set |
| Exchange | They swap LSA headers | Frames 12, 13, 15 (R2) and 20, 21, 23 (R1) |
| Loading | They request and receive missing LSAs | Frames 14, 16–18 (R2) and 22, 24–26 (R1) |
| Full | The databases match | After frame 18 for R2 and frame 26 for R1 |
R1 and R2 are both DROthers, so they stay at 2-Way with each other for the whole capture. Only the DR forms adjacencies.
What does an OSPF Hello carry?
A Hello is a router's introduction and its heartbeat. It carries the parameters that neighbors must agree on, the router's vote for DR and BDR, and the list of neighbors it hears. Here is R3's Hello from frame 38, the first one it sends as DR:
frame : Frame 38: Packet, 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface -, id 0
Interface id : 0 (-)
eth : Ethernet II, Src: aa:bb:cc:00:03:00, Dst: 01:00:5e:00:00:05
Destination : 01:00:5e:00:00:05
Source : aa:bb:cc:00:03:00
ip : Internet Protocol Version 4, Src: 10.0.123.3, Dst: 224.0.0.5
Differentiated Services Field : 0xc0 (DSCP: CS6, ECN: Not-ECT)
000. .... = Flags : 0x0
ospf : Open Shortest Path First
OSPF Header
OSPF Hello Packet
Options : 0x12, (L) LLS Data block, (E) External Routing
OSPF LLS Data Block
Extended options TLV
Options : 0x00000001, (LR) LSDB Resynchronization
Frame 38, R3's Hello after the election. Under OSPF Hello Packet: Router Priority 33, Designated Router 10.0.123.3, Backup Designated Router 0.0.0.0, and Active Neighbor entries for R1 and R2.
Hello Interval(10 s) andRouter Dead Interval(40 s). A router discards a Hello whose intervals don't match its own, or, on a broadcast segment, whoseNetwork Maskdoesn't match, and the neighbor never appears (10.5). 10 and 40 seconds are the usual values on Ethernet; RFC 2328 suggests the dead interval be four Hello intervals (C.3).Router Priority. Zero means the router can never be DR or BDR. R3 sends 33; R1 and R2 send 0.Designated RouterandBackup Designated Router. These carry the DR's and BDR's interface addresses, not router IDs, and0.0.0.0means none.Active Neighbor. The router IDs of every router this one has heard from within the dead interval. Seeing yourself in this list is what moves a neighbor to 2-Way.
The packet's destination is 224.0.0.5, and its IP time to live is 1, so it never leaves the segment.
How does OSPF elect the DR and BDR?
The router with the highest priority wins, and the highest router ID breaks a tie (9.4). A priority of 0 takes a router out of the running. R3 has priority 33 and the other two have 0, so R3 is the only candidate and wins without a contest.
The election picks the BDR first and then the DR. A router that already declares itself DR in its Hellos can't be BDR. If no router declares itself DR, the newly chosen BDR is promoted to DR. Here, R3 is the only eligible router, so once it is DR there is nobody left to be BDR. Frame 38 confirms it: DR 10.0.123.3, BDR 0.0.0.0. With no BDR, and with R1 and R2 unable to stand, losing R3 would leave the segment with no DR and no adjacencies at all.
Frame 37 shows a detail of the algorithm. R1's Hello, sent just before frame 38, lists R3 as both DR and BDR. R1 ran the election using R3's last Hello, frame 4, in which R3 claimed no role. As the only eligible router, R3 became BDR, then was promoted to DR because nobody claimed that role. The algorithm reruns its two steps only when the calculating router's own role changes (9.4, step 4), and R1's didn't. Once frame 38 arrives with R3 claiming DR, R3 drops out of the BDR choice, and R1's next Hello, frame 49, shows BDR 0.0.0.0.
An election is also not preemptive. A router with a higher priority that joins later doesn't take over; it waits until the current DR fails.
Why does the router wait 40 seconds before electing a DR?
So it doesn't take over a segment that already has a DR. An eligible router that comes up listens for RouterDeadInterval, 40 seconds here, before electing anyone (9.3). That is long enough to hear a Hello from every live router. If a neighbor announces itself as BDR, or as DR with no BDR, the router stops waiting and runs the election at once.
The capture catches only the end of R3's wait. R3's Hellos in frames 1 and 4 still show DR 0.0.0.0; then, 10.9 seconds into the capture, R3 sends its first Database Description as DR in frame 7. The LSA ages give a hint of when the wait began: R1's Summary LSAs are 40 seconds old by frame 26, so OSPF had been running for at least 25 seconds before the capture started. A wait that ends 11 seconds in fits a 40-second timer.
How are master and slave chosen in ExStart?
In ExStart, both routers claim master, and the higher router ID wins (10.6). The master sets the DBD sequence numbers, and the slave echoes them to acknowledge each packet. The negotiation runs on three flags in the DBD header (A.3.3):
| Flag | Name | Meaning when set |
|---|---|---|
I | Init | This is the first DBD of the exchange |
M | More | More DBDs follow |
MS | Master/Slave | The sender is (or claims to be) master |
In frame 8, R3 opens with all three set and sequence 2569. R2 answers in frame 10 with its own opening DBD and sequence 3291 instead of agreeing. R3's packet reached R2 before R2 had moved R3 out of 2-Way, and a router ignores DBDs from a neighbor in that state, so R2 started ExStart on its own. R3 ignores R2's claim, because 10.0.0.3 is higher than 10.0.0.2, and waits.
About five seconds later, in frame 11, R3 resends its opening DBD. That five seconds is RxmtInterval, the retransmission timer (C.3). This time R2 is in ExStart and answers as slave: MS clear, sequence 2569 echoed, and its LSA headers attached. R1 goes through the same stall: frames 7, 9, and then the resend in frame 19.
The DBD also carries the sender's Interface MTU. Here every router reports 1500, so the check passes. Capture 2 shows what happens when it doesn't.
What happens in Exchange and Loading?
In Exchange, each router sends its database as LSA headers only: the LSA's type, ID, advertising router, and sequence number. Frame 12 lists R2's Router LSA and a Summary LSA for 10.2.7.0; frame 13 lists R3's. That is enough for each side to spot what it is missing or holds an older copy of. Exchange ends when both sides have sent a DBD with M clear (frames 13 and 15).
In Loading, each router requests what it lacks (an LSR, frame 14) and receives the full LSAs in an LSU (frame 16). Once nothing is outstanding, the pair is Full. For R2 and R3, the whole sequence from the resend in frame 11 to Full took 9 milliseconds.
Why do DROthers send updates to 224.0.0.6?
So that only the DR and BDR process them. A DROther sends its LSUs and acknowledgments to 224.0.0.6; the DR then refloods each new LSA to 224.0.0.5 for everyone (13.3). The capture shows the pattern repeatedly: R1's new Router LSA goes to AllDRouters in frame 31, and R3 refloods it to AllSPFRouters in frame 32.
Acknowledgments show the protocol's economy (13.5):
- The reflood is the DR's acknowledgment. R3 sends no LS Acknowledge anywhere in the capture. When it floods an LSA back out the interface it came from, as in frame 27, the sender takes that as the acknowledgment.
- DROthers batch their acknowledgments. R2's single acknowledgment in frame 35 covers seven LSAs received over the previous two seconds.
- Unacknowledged LSAs are resent by unicast. R2 never acknowledges the multicast copies of R1's Router LSA (frames 32 and 43). Each time, about five seconds later, R3 resends it directly to R2 (frames 40 and 48), and R2 acknowledges that copy (13.6). The capture doesn't show why R2 skips the multicast copy.
What do Router and Network LSAs contain?
A Router LSA (type 1) describes one router and its links; a Network LSA (type 2) describes one multi-access segment and the routers attached to it. Together, they form the core of the map on which each router runs its shortest-path calculation. Capture 1 shows both being created as the DR takes over.
Router LSA: from stub network to transit network
Each router's Router LSA lists its links in the area, and each link has a type (A.4.2). Before the election, R3's Router LSA (sequence 0x80000003, frame 16) lists the segment 10.0.123.0/24 as a stub network (type 3), the same way it would list a LAN with no other routers. In frame 30, R3 reissues it as 0x80000004, and the segment is now a transit network (type 2):
frame : Frame 30: Packet, 122 bytes on wire (976 bits), 122 bytes captured (976 bits) on interface -, id 0
Interface id : 0 (-)
eth : Ethernet II, Src: aa:bb:cc:00:03:00, Dst: 01:00:5e:00:00:05
Destination : 01:00:5e:00:00:05
Source : aa:bb:cc:00:03:00
ip : Internet Protocol Version 4, Src: 10.0.123.3, Dst: 224.0.0.5
Differentiated Services Field : 0xc0 (DSCP: CS6, ECN: Not-ECT)
000. .... = Flags : 0x0
ospf : Open Shortest Path First
OSPF Header
LS Update Packet
LSA-type 1 (Router-LSA), len 60
Options : 0x22, (DC) Demand Circuits, (E) External Routing
Flags : 0x01, (B) Area border router
Type : Stub ID: 10.0.0.3 Data: 255.255.255.255 Metric: 1
Type : Stub ID: 10.3.4.0 Data: 255.255.255.0 Metric: 10
Type : Transit ID: 10.0.123.3 Data: 10.0.123.3 Metric: 10
Frame 30, R3's Router LSA 0x80000004. Under the LSA: a stub link for the loopback 10.0.0.3/32, a stub link for 10.3.4.0/24, and a transit link with Link ID 10.0.123.3 (the DR's address) and Link Data 10.0.123.3 (R3's own address), metric 10.
For a transit link, Link ID is the DR's interface address and Link Data is the router's own address on the segment. A router may list a segment as transit only once it is Full with the DR, or is the DR and Full with at least one neighbor (12.4.1.2). R1 and R2 make the same change in frames 31 and 33, each pointing at 10.0.123.3.
The flags also identify each router's role: R3 and R1 set B (area border router), and R2 sets both B and E (AS boundary router).
After that, all three routers reissue their Router LSAs twice more with the same links (sequence 0x80000005 and 0x80000006). The first reissues come exactly 5.0 seconds after the 0x80000004 copies. RFC 2328 allows a router to originate a given LSA at most once every MinLSInterval, 5 seconds (12.4), so each reissue waited for that limit.
Network LSA: the DR speaks for the segment
Only the DR originates a Network LSA, on behalf of the whole segment (12.4.2). R3 floods its first one in frame 29:
frame : Frame 29: Packet, 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface -, id 0
Interface id : 0 (-)
eth : Ethernet II, Src: aa:bb:cc:00:03:00, Dst: 01:00:5e:00:00:05
Destination : 01:00:5e:00:00:05
Source : aa:bb:cc:00:03:00
ip : Internet Protocol Version 4, Src: 10.0.123.3, Dst: 224.0.0.5
Differentiated Services Field : 0xc0 (DSCP: CS6, ECN: Not-ECT)
000. .... = Flags : 0x0
ospf : Open Shortest Path First
OSPF Header
LS Update Packet
LSA-type 2 (Network-LSA), len 36
Options : 0x22, (DC) Demand Circuits, (E) External Routing
Frame 29, the Network LSA. Link State ID 10.0.123.3 (the DR's interface address), Advertising Router 10.0.0.3, Netmask 255.255.255.0, and Attached Router entries for 10.0.0.3, 10.0.0.1, and 10.0.0.2.
The Link State ID is the DR's interface address, and the list of attached routers names every router that is Full with the DR, plus the DR itself (A.4.3). The shortest-path calculation treats the segment as a node of its own, joined to each attached router, and the transit links in the Router LSAs point at that node.
Withdrawing LSAs: the lsa1_lsa2 capture
The two-frame ospfv2_lsa1_lsa2 capture holds one LSU with a Router LSA and a Network LSA, sent by R10 (router ID 172.16.0.10) to R1 in area 6. Both describe the usual layout: R10's Router LSA has a stub link for its loopback 10.0.0.10/32 and a transit link to the segment's DR, which is R10 itself at 10.1.10.10. The Network LSA lists R10 and R1 as attached routers.
Both LSAs carry LS Age 3600, though, which is MaxAge. An LSA at MaxAge is being withdrawn: every router that receives it floods it on and deletes its copy once its neighbors have acknowledged the withdrawal (14, 14.1). R10 is removing both its own Router LSA and the Network LSA it originated as DR. In frame 2, 2.5 seconds later, R1 acknowledges both. To see live Router and Network LSAs, use frames 29 and 30 of capture 1, above.
Capture 2: why is my OSPF neighbor stuck in ExStart?
Most often because the two interfaces have different MTUs. R6 and R5 share the link 10.5.6.0/24 in area 2. R6's interface MTU is 1496 bytes and R5's is 1500. The link is configured as point-to-point, so there is no DR: the routers go straight from 2-Way to ExStart.
Down, Init, and 2-Way in two Hellos
This capture shows the first neighbor states that capture 1 misses. In frame 1, R6's Hello lists no neighbors: R6 hasn't heard R5 yet, so for R6, R5 is Down. When R5 receives that Hello, it moves R6 to Init, meaning "I hear you, but you haven't said you hear me." R5's Hello in frame 2 lists R6, and when R6 sees its own router ID there, it moves R5 to 2-Way (10.5). A quarter of a millisecond later, R6 sends its opening DBD.
Why the MTU check stops the exchange
The DBD's Interface MTU field tells the neighbor the largest IP packet the sender can receive without fragmenting it. RFC 2328 says to reject a DBD whose MTU is larger than the receiving interface can accept (10.6), because the LSUs that follow could be that large and would be lost.
R6 has the higher router ID (10.0.0.6 beats 10.0.0.5), so it is master. R5 accepts R6's opening DBD, since 1496 fits in 1500, and in frame 6 replies as slave with its LSA headers and Interface MTU 1500. That is larger than R6's 1496, so R6 drops it. From then on:
- R6 never sees an acceptable reply, so it stays in ExStart and resends its opening DBD every 4.5 to 5 seconds (frames 8, 11, and 14).
- R5 thinks the exchange has started. It treats each resend as a duplicate and answers with its last DBD (10.6), still announcing 1500 (frames 9, 12, and 15).
- Hellos carry no MTU field, so they keep flowing (frames 7, 10, 13, and 16), and neither router declares the other dead.
The result is a neighbor that looks up but never carries routes: R6 lists R5 in ExStart, and R5 lists R6 in Exchange. The usual fix is to set the same MTU on both interfaces. Cisco IOS also offers ip ospf mtu-ignore, which skips the check, but that only hides the mismatch: R5's packets larger than 1496 bytes could still be lost.
OSPF authentication: MD5 vs SHA-256
The two authentication captures each hold one Hello from R5 and one from R6, on the same link in area 2, once signed with MD5 and once with HMAC-SHA-256. Both use authentication type 2, cryptographic authentication (D.3). The algorithm comes from the key configured on each router; on the wire, only the digest length tells them apart.
frame : Frame 1: Packet, 166 bytes on wire (1328 bits), 166 bytes captured (1328 bits) on interface -, id 0
Interface id : 0 (-)
eth : Ethernet II, Src: aa:bb:cc:00:05:00, Dst: 01:00:5e:00:00:05
Destination : 01:00:5e:00:00:05
Source : aa:bb:cc:00:05:00
ip : Internet Protocol Version 4, Src: 10.5.6.5, Dst: 224.0.0.5
Differentiated Services Field : 0xc0 (DSCP: CS6, ECN: Not-ECT)
000. .... = Flags : 0x0
ospf : Open Shortest Path First
OSPF Header
OSPF Hello Packet
Options : 0x12, (L) LLS Data block, (E) External Routing
OSPF LLS Data Block
Extended options TLV
Options : 0x00000001, (LR) LSDB Resynchronization
Crypto Authentication TLV
R5's Hello signed with HMAC-SHA-256. In the OSPF Header: Checksum 0x0000, Auth Type Cryptographic (2), Auth Crypt Key id 1, Auth Crypt Data Length 32, Auth Crypt Sequence Number, and the 32-byte Auth Crypt Data. The OSPF LLS Data Block at the end carries its own Crypto Authentication TLV.
| Field | MD5 capture | SHA-256 capture |
|---|---|---|
Auth Type | 2 (cryptographic) | 2 (cryptographic) |
Key ID | 1 | 1 |
Auth Data Length | 16 bytes | 32 bytes |
| Sequence number (R5's Hello) | 1596628689 | 1596628846 |
| OSPF checksum | 0x0000 | 0x0000 |
Packet Length | 48 | 48 |
| IP total length | 120 bytes | 152 bytes |
A few things the table shows:
- The key never appears. For MD5, the sender appends the shared secret to the packet, computes the digest, and sends the digest in place of the key (D.4.3). SHA-256 uses HMAC instead (RFC 5709). Either way, a capture reveals only the key ID and the digest.
- The digest sits after the OSPF packet.
Packet Lengthstays 48 in both captures because it doesn't count the digest. - The checksum is left at zero. With cryptographic authentication, the digest already detects corruption, so the standard OSPF checksum isn't computed (D.4.3).
- The sequence number stops replays. It must never decrease (D.3), so a recorded packet can't be replayed later. These values look like Unix timestamps: 1596628689 is 5 August 2020, 11:58 UTC.
There is one more digest at the end of each packet. These routers append a link-local signaling (LLS) data block to their Hellos, flagged by the L bit in Options. With authentication on, that block carries its own Crypto Authentication TLV, with a matching sequence number and digest (RFC 5613). With two digests per packet, SHA-256's packets are 32 bytes longer than MD5's, not 16.
Frequently asked questions
What are the OSPF neighbor states? Down, Attempt (used only on non-broadcast networks), Init, 2-Way, ExStart, Exchange, Loading, and Full (10.1). Capture 2 shows Down to 2-Way; capture 1 shows 2-Way to Full.
How is the OSPF DR elected? By the highest router priority in the Hellos, with the highest router ID as the tie-breaker. Priority 0 means the router can't be elected. The BDR is picked first, then the DR, and an existing DR isn't replaced when a higher-priority router joins.
What are 224.0.0.5 and 224.0.0.6? AllSPFRouters and AllDRouters. Every OSPF router listens to 224.0.0.5; only the DR and BDR listen to 224.0.0.6, which DROthers use to send updates and acknowledgments to them.
What are the default OSPF Hello and Dead intervals? 10 and 40 seconds on broadcast and point-to-point links, as in both captures. Both must match between neighbors, or the Hellos are discarded and the neighbor never forms.
Why is my OSPF neighbor stuck in 2-Way? On a broadcast segment, that is normal between two DROthers: only the DR and BDR form full adjacencies. R1 and R2 in capture 1 stay at 2-Way with each other for that reason.
Why is my OSPF neighbor stuck in ExStart or Exchange? Usually an interface MTU mismatch. The router with the smaller MTU rejects every DBD from the other, as capture 2 shows.
Takeaways
- 2-Way means "we hear each other." A router reaches it when it finds its own router ID in a neighbor's Hello. On a shared segment, DROthers stop there.
- The DR is chosen by priority, then router ID, after an eligible router waits up to the dead interval to see whether a DR already exists. Priority 0 opts out, so the segment in capture 1 ends up with a DR and no BDR.
- Master and slave are chosen by router ID, too. The master sets the DBD sequence numbers, and a lost opening DBD costs one
RxmtInterval, about five seconds. - The DR is the hub of flooding. DROthers send to
224.0.0.6, the DR refloods to224.0.0.5, and its reflood doubles as the acknowledgment. - The DR election changes the map. Each Router LSA turns the segment from a stub into a transit link pointing at the DR, and the DR adds a Network LSA listing everyone attached.
- A neighbor stuck in ExStart usually means mismatched MTUs. Hellos keep the neighbor alive while every DBD is rejected.