Sub topic 4
Hello Packets and Neighbor Discovery
This chapter assumes you know IPv4 addressing and subnet masks, basic router interface configuration, and the idea of a link-state protocol and a router ID. It covers how OSPF routers find each other, which Hello fields must match, and how a neighbor relationship starts.
What the Hello Protocol Does
An OSPF router does not know who is on its links until it asks. The Hello protocol does three jobs:
- It discovers neighbors, which are routers on the same link that run OSPF.
- It checks that two routers agree on the settings needed to work together.
- It acts as a keepalive. If Hellos stop arriving, the router declares the neighbor dead.
Hello is OSPF packet type 1. It runs directly over IP protocol number 89, not over TCP or UDP. On broadcast and point-to-point links, Hellos go to the multicast address 224.0.0.5 (AllSPFRouters). On a link where OSPF has to send unicast, such as a non-broadcast network, they go to a configured neighbor address.
What a Hello Contains
Each Hello carries the sender's view of the link. The fields that matter most are listed here.
| Field | Meaning | Must match? |
|---|---|---|
| Router ID | Unique 32-bit identity of the sender | No, must be different |
| Area ID | Area the interface belongs to | Yes |
| Network mask | Mask of the sending interface | Yes (broadcast and NBMA links) |
| Hello interval | Seconds between Hellos | Yes |
| Dead interval | Seconds of silence before the neighbor is declared down | Yes |
| Options | Capability flags, including the stub-area flag | Yes (the stub flag must agree) |
| Router priority | Used in DR/BDR election | No |
| Designated Router and Backup DR | Addresses of the current DR and BDR | No |
| Active neighbor list | Router IDs the sender has heard Hellos from | No |
| Authentication | Type and key data, when configured | Yes |
The last row of mismatches is a common source of trouble. Two routers that disagree on a required field will see each other's Hellos but will not become neighbors.
Default Timers
Default timers depend on the network type, which the next chapter covers.
| Network type | Hello interval | Dead interval |
|---|---|---|
| Broadcast | 10 s | 40 s |
| Point-to-point | 10 s | 40 s |
| Non-broadcast (NBMA) | 30 s | 120 s |
The dead interval defaults to four times the Hello interval. If you change only the Hello interval on an IOS-style router, the dead interval follows automatically. If you set the dead interval by hand, it stays where you put it.
interface GigabitEthernet0/0
ip ospf hello-interval 5
ip ospf dead-interval 20Both routers on the link need the same values. Setting only one side produces a mismatch, and the neighbors never form.
How Two Routers Discover Each Other
The exchange is a short conversation. The key detail is the active neighbor list: a router adds a neighbor's router ID to its own Hello only after it has received a Hello from that neighbor.
The steps in order:
- R1 enables OSPF on an interface and sends a Hello with an empty neighbor list. R1 has no neighbors yet, so its state for R2 is Down.
- R2 receives that Hello. It checks the parameters. If they match, R2 records R1 and moves R1 to the Init state.
- R2's next Hello lists 1.1.1.1 in its neighbor list.
- R1 sees its own router ID in R2's Hello. This proves R2 can hear R1, so the link works in both directions. R1 moves R2 to 2-Way.
- R1's next Hello lists 2.2.2.2, and R2 moves to 2-Way as well.
The 2-Way state is what proves bidirectional communication. A link where R1 hears R2 but R2 cannot hear R1 stays in Init on one side. This is a useful clue when troubleshooting.
Reaching 2-Way does not always lead to a full adjacency. On a broadcast segment, routers that are not the DR or BDR stay in 2-Way with each other. The DR/BDR election chapter explains why.
A Hello Checker in Python
The following script models the parameter check a router performs on an incoming Hello. It is a simplified model, not a real OSPF stack, but it shows which mismatches block a neighbor relationship.
from dataclasses import dataclass
@dataclass
class Hello:
router_id: str
area: int
mask: str
hello: int
dead: int
stub: bool = False
def check(local: Hello, remote: Hello, broadcast: bool = True):
problems = []
if remote.router_id == local.router_id:
problems.append("duplicate router ID")
if remote.area != local.area:
problems.append("area mismatch")
if broadcast and remote.mask != local.mask:
problems.append("subnet mask mismatch")
if remote.hello != local.hello:
problems.append("hello interval mismatch")
if remote.dead != local.dead:
problems.append("dead interval mismatch")
if remote.stub != local.stub:
problems.append("stub flag mismatch")
return problems or ["parameters match"]
r1 = Hello("1.1.1.1", 0, "255.255.255.252", 10, 40)
r2 = Hello("2.2.2.2", 0, "255.255.255.252", 10, 40)
r3 = Hello("3.3.3.3", 1, "255.255.255.252", 5, 20)
print(check(r1, r2)) # ['parameters match']
print(check(r1, r3)) # ['area mismatch', 'hello interval mismatch', 'dead interval mismatch']Edge Cases and Gotchas
- Subnet mask: On broadcast links the mask must match. On point-to-point links the mask check is skipped, so two routers can become neighbors with different masks. Routing can then behave oddly, so do not rely on this.
- Different subnets: Two interfaces in different subnets will not form a neighbor relationship on a broadcast link, because the Hello source address must fall in the receiving interface's subnet. Point-to-point links are looser here as well.
- Duplicate router IDs: Two routers with the same router ID fail to form a stable adjacency, and the link-state database becomes inconsistent. Set the router ID by hand so this cannot happen.
- Passive interfaces: A passive interface sends no Hellos, so no neighbor forms there. This is the intended behavior for LAN-facing interfaces that have no other routers.
- Hello timers and dead timers: A short Hello interval detects failures faster but adds control traffic and can cause flaps if the link drops a few packets.
- Access lists: A filter that blocks protocol 89 or the 224.0.0.5 multicast stops the Hellos silently.
- MTU: An MTU mismatch does not stop Hellos, and neighbors reach 2-Way. The problem appears later, during database exchange, as a stall in ExStart or Exchange.
Checking Hellos on a Router
Two commands show Hello behavior. The first lists neighbors and their states. The second shows the timers on each interface.
show ip ospf neighbor
show ip ospf interface GigabitEthernet0/0The interface output includes lines such as Timer intervals configured, Hello 10, Dead 40, the network type, and the time until the next Hello. If a neighbor is missing from the first command, compare the timer lines on both routers first. Mismatches show up there at once.
Exercise
R1 uses Hello 10 and Dead 40 on a broadcast link. R2 on the same link uses Hello 5 and Dead 20. Both are in area 0, have matching masks, and have unique router IDs. Will they become neighbors, and how would you fix it?
Show answer
No. The Hello and dead intervals must match on both routers, so each router discards the other's Hellos and no neighbor forms. Fix it by setting the same values on both interfaces, for example ip ospf hello-interval 10 and ip ospf dead-interval 40 on R2, or by removing the custom timers so both use the defaults.
Exercise
R1's neighbor table shows R2 in Init and stays there. What does this tell you about which router can hear the other?
Show answer
R1 has received Hellos from R2, but R2's Hellos do not list R1's router ID. So R2 is not hearing R1. The fault is in the direction from R1 to R2, such as an access list, a one-way link fault, or an authentication mismatch on R2.