OSPF packet formats
OSPF packets are directly encapsulated into IP packets. OSPF uses the IP protocol number 89. The format of an OSPF LSU packet is shown in Figure 24.
Figure 24: OSPF packet format
OSPF packet header
OSPF packets are classified into five types that have the same packet header.
Figure 25: OSPF packet header
Major fields of the OSPF packet header are as follows:
Version—OSPF version number, which is 2 for OSPFv2.
Type—OSPF packet type from 1 to 5, corresponding to hello, DD, LSR, LSU, and LSAck, respectively.
Packet length—Total length of the OSPF packet in bytes, including the header.
Router ID—ID of the advertising router.
Area ID—ID of the area where the advertising router resides.
Checksum—Checksum of the message.
AuType—Authentication type, ranging from 0 to 2, corresponding to non-authentication, simple (plaintext) authentication, and MD5 authentication, respectively.
Authentication—Information determined by authentication type. It is not defined for authentication type 0. It is defined as password information for authentication type 1, and defined as Key ID, MD5 authentication data length, and sequence number for authentication type 2.
NOTE: MD5 authentication data is added following an OSPF packet rather than contained in the Authentication field. | ||
Hello packet
A router sends hello packets periodically to find and maintain neighbor relationships, and to elect the DR or BDR, including information about values of timers, DR, BDR, and neighbors that are already known.
Figure 26: Hello packet format
Major fields of the hello packet are as follows:
Network mask—Network mask associated with the router’s sending interface. If two routers have different network masks, they cannot become neighbors.
HelloInterval—Interval for sending hello packets. If two routers have different intervals, they cannot become neighbors.
Rtr Pri—Router priority. A value of 0 means the router cannot become the DR or BDR.
RouterDeadInterval—Time before declaring a silent router down. If two routers have different dead intervals, they cannot become neighbors.
Designated router—IP address of the DR.
Backup designated router—IP address of the BDR.
Neighbor—Router ID of the neighbor router.
DD packet
Two routers exchange database description (DD) packets, describing their LSDBs for database synchronization. A DD packet contains only the headers of LSAs to reduce traffic.
Figure 27: DD packet format
Major fields of the DD packets are as follows:
Interface MTU—Specifies the largest IP datagram in bytes that the interface can send without fragmentation.
I (Initial)—The Init bit, which is set to 1 if the packet is the first DD packet. It is set to 0 if not.
M (More)—The More bit, which is set to 0 if the packet is the last DD packet. It is set to 1 if more DD packets are to follow.
MS (Master/Slave)—The Master/Slave bit. When set to 1, it indicates that the router is the master during the database exchange process; otherwise, the router is the slave router.
DD sequence number—Used to sequence the collection of DD packets. The initial value is set by the master. The DD sequence number then increments until the complete database description has been sent.
LSR packet
After exchanging DD packets, two routers know which LSAs of the peer are missing from the local LSDB. Then, they send (link state request) LSR packets to request the missing LSAs. An LSR packet contains the brief of the missing LSAs.
Figure 28: LSR packet format
Major fields of the LSR packets are as follows:
LS type—Type of the LSA to be requested. Type 1 for example indicates the Router LSA.
Link state ID—Determined by LSA type.
Advertising router—ID of the router that sent the LSA.
LSU packet
LSU (Link State Update) packets are used to send the requested LSAs to the peer. Each packet carries a collection of LSAs.
Figure 29: LSU packet format
LSAck packet
Link State Acknowledgment (LSAck) packets are used to acknowledge received LSU packets. An LSAack packet carries the headers of LSAs to be acknowledged.
Figure 30: LSAck packet format
LSA header format
All LSAs have the same header.
Figure 31: LSA header format
Major fields of the LSA header are as follows:
LS age—Time, in seconds, elapsed since the LSA was originated. An LSA ages in the LSDB (added by 1 per second), but does not age during transmission.
LS type—Type of the LSA.
Link state ID—The contents of this field depend on the LSA's type.
LS sequence number—Used by other routers to judge new and old LSAs.
LS checksum—Checksum of the LSA except the LS age field.
Length—Length in bytes of the LSA, including the LSA header.
LSAs formats
Router LSA
Figure 32: Router LSA format
Major fields of the Router LSA are as follows:
Link state ID—ID of the router that originated the LSA.
V (Virtual Link)—Set to 1 if the router that originated the LSA is a virtual link endpoint.
E (External)—Set to 1 if the router that originated the LSA is an ASBR.
B (Border)—Set to 1 if the router that originated the LSA is an ABR.
# Links—Number of router links (interfaces) to the area, as described in the LSA.
Link ID—Determined by link type.
Link data—Determined by link type.
Type—Link type. A value of 1 indicates a point-to-point link to a remote router; a value of 2 indicates a link to a transit network; a value of 3 indicates a link to a stub network; and a value of 4 indicates a virtual link.
#TOS—Number of different TOS metrics given for this link. If no TOS metric is given for the link, this field is set to 0. TOS is not supported in RFC 2328. The #TOS field is reserved for early versions of OSPF.
Metric—Cost of using this router link.
TOS—IP Type of Service that this metric refers to.
TOS metric—TOS-specific metric information.
Network LSA
A Network LSA is originated by the DR on a broadcast or NBMA network. The LSA describes all routers attached to the network.
Figure 33: Network LSA format
Major fields of the Network LSA are as follows:
Link state ID—The interface address of the DR.
Network mask—The mask of the network (a broadcast or NBMA network).
Attached router—The IDs of the routers, which are adjacent to the DR, including the DR itself.
Summary LSA
Network summary LSAs (Type-3 LSAs) and ASBR summary LSAs (Type-4 LSAs) are originated by ABRs. Except for the Link state ID field, the formats of Type 3 and 4 summary-LSAs are identical.
Figure 34: Summary LSA format
Major fields of the Summary LSA are as follows:
Link state ID—For a Type-3 LSA, it is an IP address outside the area. For a type 4 LSA, it is the router ID of an ASBR outside the area.
Network mask—The network mask for the type 3 LSA. It is set to 0.0.0.0 for the Type-4 LSA.
Metric—The metric to the destination.
NOTE: A Type-3 LSA can be used to advertise a default route if the link state ID and network mask are set to 0.0.0.0. | ||
AS external LSA
An AS external LSA is originated by an ASBR, and describes routing information to a destination outside the AS.
Figure 35: AS external LSA format
Major fields of the AS external LSA are as follows:
Link state ID—The IP address of another AS to be advertised. When describing a default route, the Link state ID is always set to default destination (0.0.0.0) and the network mask is set to 0.0.0.0
Network mask—The IP address mask for the advertised destination
E (External Metric)—The type of the external metric value, which is set to 1 for type 2 external routes, and set to 0 for type 1 external routes. See "Route types" for a description of external route types.
Metric—The metric to the destination.
Forwarding address—Data traffic for the advertised destination is forwarded to this address.
External route tag—A tag attached to each external route. This is not used by the OSPF protocol. It may be used to manage external routes.
NSSA external LSA
An NSSA external LSA originates from the ASBR in an NSSA, and is flooded in the NSSA area only. It has the same format as the AS external LSA.
Figure 36: NSSA external LSA format