IP Technology Basics · Topic 4 of 5

OSPF

Learn OSPF areas, router ID, packet types, neighbor states, DR and BDR election, timers, cost and single-area OSPF configuration on Huawei VRP for HCIA.

  • 6 min
In a nutshell
  • OSPF is link state, uses IP protocol 89, cost metric and preference 10 (external routes 150).
  • Five packet types: Hello, DD, LSR, LSU, LSAck. Multicasts 224.0.0.5 and 224.0.0.6.
  • State order: Down, Init, 2-Way, ExStart, Exchange, Loading, Full.

What it is

OSPF (Open Shortest Path First) is a link state interior routing protocol. Each router floods descriptions of its links (LSAs), every router in an area builds the same link state database (LSDB), and each runs the SPF algorithm to compute loop free shortest paths.

OSPFv2 is for IPv4. It runs over IP with protocol number 89 and uses cost as its metric.

Hellofind neighborsExchange LSAsbuild LSDBSPFshortest path treeRouting tableOSPF routes

How it works

Router ID and areas

Every OSPF router needs a 32 bit router ID, written like an IPv4 address and unique in the domain. Configure it by hand with ospf 1 router-id 1.1.1.1. A changed router ID takes effect only after reset ospf process.

An area groups routers that share one LSDB. Area 0 is the backbone, and every other area must connect to it.

An ABR (area border router) has interfaces in area 0 and another area. An ASBR imports external routes into OSPF.

Packet types

TypePacketJob
1HelloDiscover and keep neighbors, elect DR and BDR
2Database Description (DD)Summarize the LSDB
3Link State Request (LSR)Ask for missing LSAs
4Link State Update (LSU)Carry the LSAs
5Link State Acknowledgment (LSAck)Confirm received LSAs

All OSPF routers listen on 224.0.0.5. DR and BDR also listen on 224.0.0.6.

Neighbor states

DownInitHello receivedTwo Wayown ID seen in HelloExStartmaster and slaveExchangeDD packetsLoadingLSR and LSUFull
StateWhat happened
DownNo Hello received yet
InitA Hello arrived, but it does not list this router's ID
2-WayEach router sees its own ID in the other's Hello
ExStartMaster and slave chosen for the DD exchange
ExchangeDD packets describe the LSDB
LoadingLSR asks for missing LSAs, LSU delivers them
FullLSDBs are synchronized, an adjacency exists

Routers are neighbors at 2-Way and adjacent at Full. Two DROther routers on a LAN correctly stay in 2-Way.

To become neighbors, the Hello packets must agree on area ID, Hello and dead intervals, authentication, area type and, on broadcast networks, the network mask. Router IDs must be different.

Network types and timers

Network typeTypical linkHelloDeadDR and BDR
BroadcastEthernet10 s40 sYes
P2PPPP, HDLC10 s40 sNo
NBMAFrame Relay30 s120 sYes
P2MPConfigured manually30 s120 sNo

DR and BDR election

On broadcast and NBMA networks, a DR (designated router) and BDR reduce adjacencies. Every router forms Full adjacencies only with the DR and BDR.

The router with the highest interface DR priority wins (default 1, range 0 to 255). On a tie, the highest router ID wins. Priority 0 means the router never becomes DR or BDR.

The election is not preemptive. A router with higher priority that joins later does not take over until the DR and BDR fail or the OSPF process is reset.

Cost

Cost = reference bandwidth / interface bandwidth, with a minimum of 1. The Huawei default reference bandwidth is 100 Mbit/s, so FE and GE links both cost 1 and a 10 Mbit/s link costs 10. Change the reference with bandwidth-reference or set a cost per interface with ospf cost. The route cost is the sum of outbound interface costs along the path.

Typical configuration

[R1] ospf 1 router-id 1.1.1.1
[R1-ospf-1] area 0
[R1-ospf-1-area-0.0.0.0] network 10.0.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0] network 1.1.1.1 0.0.0.0

The network command uses a wildcard mask (0 bits must match). Any interface whose address falls in the range runs OSPF in that area.

CommandPurpose
ospf cost 10 (interface view)Set the interface cost
ospf dr-priority 100 (interface view)Influence DR election
ospf timer hello 5 (interface view)Change the Hello interval
silent-interface GigabitEthernet0/0/2 (OSPF view)Stop sending Hellos out of a user facing port
default-route-advertise (OSPF view)Advertise a default route into OSPF

Verify with display ospf peer brief and display ip routing-table protocol ospf.

<R1> display ospf peer brief
         OSPF Process 1 with Router ID 1.1.1.1
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full
 ----------------------------------------------------------------------------

A worked example

R1 and R2 share an Ethernet link but never become neighbors. R1 has ospf timer hello 5 on its interface and R2 uses the default 10 seconds.

Hello intervals must match, so each router ignores the other's Hellos. After undo ospf timer hello on R1, the neighbor reaches Full.

How the exam asks about this

  • "What is the default OSPF Hello interval on an Ethernet interface?" → 10 seconds, with a dead interval of 40 seconds.
  • "Two routers have DR priority 1. Which becomes DR?" → The one with the higher router ID.
  • "In which state do two DROther routers on the same LAN remain?" → 2-Way.

What to remember for the exam

  • OSPF is link state, uses IP protocol 89, cost metric and preference 10 (external routes 150).
  • Five packet types: Hello, DD, LSR, LSU, LSAck. Multicasts 224.0.0.5 and 224.0.0.6.
  • State order: Down, Init, 2-Way, ExStart, Exchange, Loading, Full.
  • DR election: highest priority (default 1), then highest router ID, priority 0 never elected, no preemption.
  • Huawei reference bandwidth is 100 Mbit/s, and network uses a wildcard mask.
Watch out

Full is the state of an adjacency, but 2-Way between DROther routers is correct and is not a fault.

Common mistakes

Using a subnet mask in the network command. network 10.0.12.0 255.255.255.0 is wrong. The wildcard form is network 10.0.12.0 0.0.0.255.

Expecting a new router to become DR. A higher priority router added later waits. The current DR keeps the role until it fails.

Forgetting the router ID change needs a reset. A new router-id does not take effect until reset ospf process is run.

Check yourself

  • Which OSPF packet asks a neighbor for specific missing LSAs?

    The Link State Request (LSR). The neighbor answers with an LSU carrying those LSAs.

  • What OSPF cost does a GE interface get with the Huawei defaults?

    Cost 1, because 100 Mbit/s divided by 1000 Mbit/s is below 1 and the minimum is 1.

  • What does silent-interface do?

    It stops the interface from sending and receiving Hello packets, while its network is still advertised.

Topic 4 of 5 in IP Technology Basics

Test yourself on IP Technology Basics

The full Huawei HCIA-Datacom H12-811 question bank has 600 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Huawei. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.