Structure of the OSPF packet

OSPF packet is solely encapsulated by IP and data-link headers. OSPF does not define a way to fragment its protocol headers, IP fragmentation is used when large DBD needs to be send over medium. OSPF can use multicast. OSPF is IP protocol number 89. Two distinct IP addresses are used:

ALLSPFRouters – 224.0.0.5, All OSPF routers should be prepared to receive packets sent to this address.

ALLDRouters – 224.0.0.6 – Both DR and BDR must be prepared to receive packets destined to this address.

ospf_packet

 

OSPF Common header format

Each type of OSPF message includes slightly different information, however they all share same header:

ospf-packet-header-2

Specific message formats

Following the header, the body of the message includes a variable number of fields that depends on message type.

The Hello Packet

Field Name

Size (bytes)

Description

Network Mask

4

Network Mask: The subnet mask associated with this interface

Hello Interval

2

Hello Interval: The number of seconds this router waits between sending Hello messages.

Options

1

Options: Indicates which optional OSPF capabilities the router supports.

Rtr Pri

1

Router Priority: Indicates the router’s priority, when electing a backup designated router.

Router Dead Interval

4

Router Dead Interval: The number of seconds a router can be “silent” before it is considered to have failed.

Designated Router

4

Designated Router: The address of a router designated for certain special functions on some networks. Set to zeroes if there is no designated router.

Backup Designated Router

4

Backup Designated Router: The address of a backup designated router. Set to all zeroes if there is no backup designated router.

Neighbors

Multiple
of 4

Neighbors: The addresses of each router from which this router has received Hello messages recently.

ospfhelloformat

 

The following hello packets must match on neighboring routers to establish adjacency:

  • Hello interval
  • Dead interval
  • Area ID
  • Authentication password
  • Stub Area Flag
  • Not in hello packet but also must match – MTU, ip addresses on interfaces must be on same subnet with same subnet mask

 Database description packet

DBD packet is OSPF packet type 2.These packets are exchanged when adjacency is being initialized. They describe the content of the LSDB. Multiple DBD packets may be exchanged to describe the database.

 

Field Name

Size (bytes)

Description

Interface MTU

2

Interface MTU: The size of the largest IP message that can be sent on this router’s interface without fragmentation.

Options

1

Options: Indicates which of several optional OSPF capabilities the router supports.

Flags

1

 

DD Sequence Number

4

DD Sequence Number: Used to number a sequence of Database Description messages so they are kept in order.

LSA Headers

Variable

LSA Headers: Contains link-state advertisement headers, which carry information about the LSDB. See near the end of the topic for more information on LSAs.

Important to note is that DBD packets contain LSA headers. Each LSA in database is described by its LSA header.

ospfdatabasedescriptionformat

 The link state request

Link State Request packets are OSPF packet type 3. After exchanging Database Description packets with a neighboring router, a router may find that parts of its link-state database are  out-of-date. The Link State Request packet is used to request the pieces of the neighbor’s database that are more up-to-date. Multiple Link State Request packets may need to be used.

Field Name

Size (bytes)

Description

LS Type

4

Link State Type: The type of link state advertisement (LSA) being sought. (router, network, summary…)

Link State ID

4

Link State ID: The identifier of the LSA, usually the IP address of either the router or network linked.

Advertising Router

4

Advertising Router: The ID of the router that created the LSA whose update is being sought.

ospflinkstaterequestformat

 

The link state update

Link State Update packets are OSPF packet type 4. These packets implement the flooding of LSAs. Each Link State Update packet carries a collection of LSAs one hop further from their origin. Several LSAs may be included in a single packet.

Field Name

Size (bytes)

Description

# LSAs

4

Number of LSAs: The number of link-state advertisements included in this message.

LSAs

Variable

LSAs: One or more link-state advertisements. See below for more details.

 

ospflinkstateupdateformat

The link state acknowledgement packet

Link State Acknowledgment Packets are OSPF packet type 5. To make the flooding of LSAs reliable, flooded LSAs are explicitly acknowledged. This acknowledgment is accomplished through the sending and receiving of Link State Acknowledgment packets. Multiple LSAs can be acknowledged in a single Link State Acknowledgment packet.

Field Name

Size (bytes)

Description

LSA Headers

Variable

LSA Headers: Contains link-state advertisement headers, to identify the LSAs acknowledged.

ospflinkstateackformat

LSA formats

Each LSA describes a piece of the OSPF routing domain. Every router originates a router-LSA. In addition, whenever the router is elected Designated Router, it originates a network-LSA. Other types of LSAs may also be originated. All LSAs are then flooded throughout the OSPF routing domain. The flooding algorithm is reliable, ensuring that all routers have the same collection of LSAs.This collection of LSAs is called the link-state database. From the link state database, each router constructs a shortest path tree with itself as root. This yields a routing table.

The LSA header

All LSAs begin with a common 20 byte header. This header contains enough information to uniquely identify the LSA (LS type, Link State ID, and Advertising Router). Multiple instances of the LSA may exist in the routing domain at the same time. It is then necessary to determine which instance is more recent. This is accomplished by examining the LS age, LS sequence number and LS checksum fields that are also contained in the LSA header.

Subfield Name

Size (bytes)

Description

LS Age

2

LS Age: The number of seconds elapsed since the LSA was created.

Options

1

Options: Indicates which of several optional OSPF capabilities the router supports.

LS Type

1

 

Link State ID

4

Link State ID: explained below

Advertising Router

4

Advertising Router: The ID of the router originating the LSA.

LS Sequence Number

4

LS Sequence Number: A sequence number used to detect old or duplicate LSAs.

LS Checksum

2

LS Checksum: A checksum of the LSA, for data corruption protection.

Length

2

Length: The length of the LSA, including the 20 bytes of the header.

ospflsaheaderformat

Some of these field needs further explanation:

  • LS type – The LS type field dictates the format and function of the LSA. LSAs of different types have different names (e.g., router-LSAs or network-LSAs). All LSA types defined by this memo, except the AS-external-LSAs (LS type = 5), are flooded throughout a single area only. AS-external-LSAs are flooded throughout the entire Autonomous System, excepting stub areas
  • Links State ID – This field identifies the piece of the routing domain that is being described by the LSA. Depending on the LSA’s LS type, the Link State ID takes different values. Link state ID is presented under the name „Link ID“ when you execute show ip ospf database command. Because when you execute this command you see LSAs headers only.
  • Advertising router – This field specifies the OSPF Router ID of the LSA’s originator. For router-LSAs, this field is identical to the Link State ID field. Network-LSAs are originated by the network’s Designated Router. Summary-LSAs originated by area border routers. AS-external-LSAs are originated by AS boundary routers.
            LS Type   LSA description
            ________________________________________________
            1         These are the router-LSAs.
                      They describe the collected
                       states of the router's
                      interfaces.
            ________________________________________________
            2         These are the network-LSAs.
                      They describe the set of routers
                      attached to the network.
            ________________________________________________
            3 or 4    These are the summary-LSAs.
                      They describe inter-area routes,
                      and enable the condensation of
                      routing information at area
                      borders. Originated by area border
                      routers, the Type 3 summary-LSAs
                      describe routes to networks while the
                      Type 4 summary-LSAs describe routes to
                      AS boundary routers.
            ________________________________________________
            5         These are the AS-external-LSAs.
                      Originated by AS boundary routers,
                      they describe routes
                      to destinations external to the
                      Autonomous System. A default route for
                      the Autonomous System can also be
                      described by an AS-external-LSA.
            LS Type   Link State ID
            _______________________________________________
            1         The originating router's Router ID.
            2         The IP interface address of the
                      network's Designated Router.
            3         The destination network's IP address.
            4         The Router ID of the described AS
                      boundary router.
            5         The destination network's IP address.