The OSPF protocol number is 89. OSPF packets are encapsulated into IP packets. OSPF packets are classified into Hello, DD, LSR, LSU, and LSAck packets.
The five types of OSPF packets have the same packet header format. The length of an OSPF packet header is 24 bytes. Figure 1 shows an OSPF packet header.
Field |
Length |
Description |
---|---|---|
Version |
8 bits |
OSPF version number. For OSPFv2, the value is 2. |
Type |
8 bits |
OSPF packet type. The values are as follows:
|
Packet length |
16 bits |
Length of the OSPF packet with the packet header, in bytes. |
Router ID |
32 bits |
ID of the router that sends the OSPF packet. |
Area ID |
32 bits |
ID of the area to which the router that sends the OSPF packet belongs. |
Checksum |
16 bits |
Checksum of the OSPF packet that does not carry the Authentication field. |
AuType |
16 bits |
Authentication type. The values are as follows:
|
Authentication |
64 bits |
This field has different meanings for different AuType values:
|
MD5 authentication data is added to an OSPF packet and is not included in the Authentication field.
Hello packets are commonly used packets, which are periodically sent by OSPF interfaces to establish and maintain neighbor relationships. A Hello packet includes information about the designated router (DR), backup designated router (BDR), timers, and known neighbors. Figure 2 shows the format of a Hello packet.
Field |
Length |
Description |
---|---|---|
Network Mask |
32 bits |
Mask of the network on which the interface that sends the Hello packet resides. |
HelloInterval |
16 bits |
Interval at which Hello packets are sent. |
Options |
8 bits |
The values are as follows:
|
Rtr Pri |
8 bits |
DR priority. The default value is 1. NOTE:
If the DR priority of a router interface is set to 0, the interface cannot participate in a DR or BDR election. |
RouterDeadInterval |
32 bits |
Dead interval. If a device does not receive any Hello packets from its neighbors within a specified dead interval, the neighbors are considered Down. |
Designated Router |
32 bits |
Interface address of the DR. |
Backup Designated Router |
32 bits |
Interface address of the BDR. |
Neighbor |
32 bits |
Router ID of the neighbor. |
Table 3 lists the address types, interval types, and default intervals used when Hello packets are transmitted on different networks.
Network Type |
Address Type |
Interval Type |
Default Interval |
---|---|---|---|
Broadcast |
Multicast address |
HelloInterval |
10 seconds for HelloInterval |
NBMA |
Unicast address |
|
30 seconds for HelloInterval 120 seconds for PollInterval |
P2P |
Multicast address |
HelloInterval |
10 seconds for HelloInterval |
P2MP |
Multicast address |
HelloInterval |
30 seconds for HelloInterval |
Routers on the same network segment must have the same HelloInterval and RouterDeadInterval values. Otherwise, they cannot establish neighbor relationships. In addition, on an NBMA network, the PollInterval values must be the same at both ends.
During an adjacency initialization, two routers use DD packets to describe their own link state databases (LSDBs) for LSDB synchronization. A DD packet contains the header of each LSA in an LSDB. An LSA header uniquely identifies an LSA. The LSA header occupies only a small portion of the LSA, which reduces the amount of traffic transmitted between routers. A neighbor can use the LSA header to check whether it already has the LSA. When two routers exchange DD packets, one functions as the master, and the other functions as the slave. The master defines a start sequence number and increases the sequence number by one each time it sends a DD packet. After the slave receives a DD packet, it uses the sequence number carried in the DD packet for acknowledgment.
Figure 3 shows the format of a DD packet.
Field |
Length |
Description |
---|---|---|
Interface MTU |
16 bits |
Maximum size of an IP packet that an interface can send without fragmenting the packet. |
Options |
8 bits |
The values are as follows:
|
I |
1 bit |
If the DD packet is the first packet among multiple consecutive DD packets sent by a device, this field is set to 1. In other cases, this field is set to 0. |
M (More) |
1 bit |
If the DD packet is the last packet among multiple consecutive DD packets sent by a device, this field is set to 0. In other cases, this field is set to 1. |
M/S (Master/Slave) |
1 bit |
When two OSPF devices exchange DD packets, they negotiate a master/slave relationship. The device with a larger router ID becomes the master. If this field is set to 1, the DD packet is sent by the master. |
DD sequence number |
32 bits |
Sequence number of the DD packet. The master and slave use the sequence number to ensure that DD packets are correctly transmitted. |
LSA Headers |
- |
LSA header information included in the DD packet. |
After two routers exchange DD packets, they send LSR packets to request each other's LSAs. The LSR packets contain the summaries of the requested LSAs. Figure 4 shows the format of an LSR packet.
Field |
Length |
Description |
---|---|---|
LS type |
32 bits |
Type of the LSA. |
Link State ID |
32 bits |
This field together with the LS type field describes an LSA in an AS. |
Advertising Router |
32 bits |
Router ID of the router that generates the LSA. |
The LS type, Link State ID, and Advertising Router fields can uniquely identify an LSA. If two LSAs have the same LS type, Link State ID, and Advertising Router fields, a device uses the LS sequence number, LS checksum, and LS age fields to obtain a required LSA.
A router uses an LSU packet to transmit LSAs requested by its neighbors or to flood its own updated LSAs. The LSU packet contains a set of LSAs. For multicast and broadcast networks, LSU packets are multicast to flood LSAs. To ensure reliable LSA flooding, a device uses an LSAck packet to acknowledge the LSAs contained in an LSU packet that is received from a neighbor. If an LSA fails to be acknowledged, the device retransmits the LSA to the neighbor. Figure 5 shows the format of an LSU packet.
Field |
Length |
Description |
---|---|---|
Number of LSAs |
32 bits |
Number of LSAs contained in the LSU packet |
A device uses an LSAck packet to acknowledge the LSAs contained in a received LSU packet. The LSAs can be acknowledged using LSA headers. LSAck packets can be transmitted in unicast or multicast mode, and the transmission mode is determined by the link type. Figure 6 shows the format of an LSAck packet.
Field |
Length |
Description |
---|---|---|
LSAs Headers |
Determined by the header length of the LSA to be acknowledged. |
This field is used to acknowledge an LSA. |