OSPF Packet Formats

I briefly wrote about OSPF previously. As we saw OSPF packets are encapsulated in the IP Packets with protocol number 89. But how does OSPF establishes adjacency and how does it exchanges the Database? The process is part of another post. But before we go into those details, we must first know how the OSPF packets look like. This will give us an insight of what information they carry and later we can put all these pieces together and get to know when and why each of these packet contents are used?

So first what are the various types of packets:

  • Hello Packets
  • Database Description (DBD) Packets
  • Link State Request (LSR) Packets
  • Link State Update (LSU) Packets
  • Link State Acknowledgement (LSAck) Packets

Each OSPF packets have a common OSPF Header. Other than Hello Packets, all other packets are LSA related. Each such LSA packet typehas a common LSA header. The DBD, LSR and LSA packets carry only this header, while the LSU packets carry the entire LSA. There are various types of LSAs which will be covered in a later post in detail.

OSPF Packet Header

The OSPF Packet Header is of 24 bytes length. Each OSPF packet carries this. The header gives all information necessary that enables routers to know whether the packet should be processed further or not.

OSPF Packet Header

Version No – This field specifies the version number of OSPF. Currently what we are discussing here and is used everywhere is OSPFv2. For IPv6, it is OSPFv3.

Type – This states the type of OSPF Packet. We have 1 (Hello), 2 (DBD), 3 (LSR), 4 (LSU) and 5 (LSAck).

Packet Length - This is the length of the complete OSPF Packet including the header.

Router ID - The Router ID of the source. Each router in an OSPF Domain must have a unique Router ID as described here. It is denoted as a 4 byte IP Address format.

Area ID - The area to which the packet belongs too. Each OSPF packet belongs to 1 area. This is denoted as a 4 byte IP Address format. For backbone area packet, the area ID is 0.0.0.0 For other areas like area 1 it contains the value as 0.0.0.1 etc.

Checksum - This is the standard IP checksum of the entire OSPF packet excluding the Authentication field. It is calculated as 16-bit one’s complement of one’s complement of all 16 bit words present. The packet needs to be padded with extra 0s at the end if the packet is not a multiple of 16 bit words.

Auth Type – The type of authentication done between the neighbors. Current values are 0 (null or no authentication), 1 (Plain text password) and 2 (cryptographic or MD5 hashing based password). All other values are reserved by IANA.

Authentication – This is a 64 bit (8 bytes) field. This contains the actual authentication information if enabled.

For all the OSPF Packets described below, the above OSPF Header is always present. Only the extra distinct fields of the specific packet types are being mentioned below.

Hello Packets

Hello Packets are notified in the header by type 1. They are sent at periodic intervals (default 30 secs) over all the OSPF enabled interfaces. The purpose of these packets are for dynamic discovery of neighbors, establishing and maintaining neighbor ship. Routers in a common network negotiate few common parameters. These parameter values are carried in the Hello Packets. The parameters are Network Mask, Hello interval and Dead Interval.

Hello Packet FormatNetwork Mask - The network mask that is associated with the interface. This should match on both sides of a link in order for adjacency to come up.

Hello Interval – The time interval between successive hello packets sent by a router.

Options – The optional capabilities supported by the router. These are described at the end of this post.

Rtr Priority - This is the priority value of the router. This is used in case of DR-BDR election. If priority value is 0, then the router doesn’t take part in DR-BDR election.

Dead Interval - The number of seconds to wait before declaring a router as down. This starts when a router misses a Hello Message from its neighbor. By default it is 3 times the Hello Interval.

Designated Router - The router ID of the DR as seen by the router. Initially this is set to 0.0.0.0 and once it is elected it changes this value.

Backup Designated Router - Same as above, this field specifies the router ID of the BDR.

Neighbor (s) – The router IDs of all the neighbors from whom a Hello Message has been received within the last Dead Interval seconds. This is a variable field and initially it contains no router IDs.

Database Description (DBD) Packets

The DBD packets are exchanged during the initialization of the adjacency. They are OSPF Packet Type 2. The master/slave mechanism is used for exchanging the DBD Packets. During the Exstart state of OSPF, an empty DBD packet is exchanged where the Master/Slave is elected per link and the initial sequence number to be used by the master is decided. During the Exchange state, the DBD packets contain the LSA headers and using these the routers make a list of LSAs that they are going to request from their neighbors.

Database Description Packet

Interface MTU - The maximum size of IP packets that can be sent over the link. This value should match on both the routers in order for the adjacency to come up.

Options - The optional capabilities that are explained below.

I Bit – The init bit which states that this is the first of the DBD packets.

M Bit - The more bit which states that there are more DBD packets after the current packet.

MS Bit – The Master/Slave Bit. If it is set to 1, it implies that the router is a Master else the router is a slave.

DD Sequence Number - This is the sequence number for the DBD packets. This can only be incremented by the Master and the initial value is set when the I bit is set.

LSA Headers - The remaining field contains the list of LSA headers. This can be a partial list too and hence multiple DBD packets are needed.

Link State Request (LSR) Packets

The LSR Packets are of OSPF Packet Type 3. Once the DBD packets are exchanged, each router checks the LSA Headers against its own database and if it finds it doesn’t have up to date information for any LSA, it creates the LSR packets and sends it to its neighbor asking for the updated LSAs. The LSA instance is defined by the LS sequence number, Checksum and LS Age. But the response to the LSR can be a more updated instance of the LSA.

LSR Packet Format

The LSR packets however do not contain the LSA instance related fields but the LSA identification fields.

LS Type - The type of Link State being asked for.

Link State ID - Each LSA has a ID. This is mentioned in this field.

Advertising Router - The router that has originated the LSA.

There can be 1 or more LSA request fields in each LSR packet.

Link State Update (LSU) Packets

Link State Update (LSU) packets contain the actual complete LSAs. The various types of LSAs and their formats will be described in a later post. Each LSU packet contains a field that mentions the total number of LSAs contained in that packet. The LSU packets are OSPF Packet Type 4.

Link State Acknowledgement (LSAck) Packets

The LSAck packets help in reliable transmission of the LSAs. Each LSAs are explicitly acknowledged. The LSAck packets are OSPF Type 5 and they can contain acknowledgements for multiple LSAs. The LSA header is contained in the LSAck packet and this suffices for the acknowledgement for the corresponding LSA.

The Options Field

The Options field is present in the Hello Packets, Database Description Packets and in each individual LSAs. Each router uses the options field to advertise the capabilities it supports to all its neighbors. The options field in Hello Packets enables each router to reject adjacency request due to the capabilities mismatch. When used in the DBD packets, the Options field lets a router decide whether it has to forward an LSA or not due to its reduced capability. In LSAs, the Options helps routers by enabling it to take proper forwarding decisions by bypassing the LSAs with reduced capabilities.

Out of the 8 bits in the options field, the first, second and eight bits are reserved and not used. The other bits from 3rd to 7th bit in sequence are:

  1. DC Bit - This specifies the handling mechanisms for Demand Circuits.
  2. EA Bit - This specifies that the routers can handle External Attributes LSAs.
  3. N/P Bit - This is used for handling Type-7 LSAs which are used in case of NSSA areas.
  4. MC Bit - This bit is used for handling Multicast Packets.
  5. E Bit - This bit specifies how the AS External LSAs are flooded in the OSPF domain.

In later posts, we will see how some of the options are implemented and used. As I have mentioned before, a major part of the packet formats are the LSA types. I will discuss these in detail in a later post. Also the way these OSPF packets are used will also be discussed by me in a later post. Hope you had a nice refresh of the various packet types.

Be Sociable, Share!

Speak Your Mind

*