Analyze the hello packets, database description packets and link state requests, updates and acknowledgments which occur when you start the OSPF processes.
Current version of OSPF is version 2 RFC 2328 for IPv4 and version 3 for IPv6. There are 5 types of the packets according to the aforementioned RFC
Type Packet name Protocol function __________________________________________________________ 1 Hello Discover/maintain neighbors 2 Database Description Summarize database contents 3 Link State Request Database download 4 Link State Update Database update 5 Link State Ack Flooding acknowledgment
Common header
We will walk through each of them. But first let's look at the common header format. As we learned in class, OSPF is directly running on IP and has it's own packet type. So it is actually using the IP packet format.
- version number (version 1 is also for IPv4, but not compatible with version 2, mostly obsolete):
- 2 for version 2 (IPv4)
- 3 for version 3 (IPv6)
- Type, corresponding to the packet type mentioned above.
- Packet length: total length of the OSPF packet including header.
- Router ID: It is a 4 byte IPv4 address, which makes OSPF heavily coupled with the specific type of IP. It can be statically configured or take the lowest from the interface connected to the network. In case a static IP is given as router id, it will not change even when the router is restarted or certain interface went up or down.
- Area ID: area in which the packet belong to.
- Checksum: error detection
- AuType: is mandatory, but…
- 0: null type authentication. There should be authentication, but not authentication is set to null.
- 1: plain text. clear text authentication
- 2: MD5 used.
- Authentication: authentication key
See example in a captured LSA packet, between router 1 and router 4 on switch14
54 66.123172 192.168.30.2 224.0.0.5 OSPF LS Acknowledge OSPF Header OSPF Version: 2 Message Type: LS Acknowledge (5) Packet Length: 44 Source OSPF Router: 192.168.30.4 (192.168.30.4) Area ID: 0.0.0.0 (Backbone) Packet Checksum: 0xfa53 [correct] Auth Type: Null Auth Data (none)
Type 1 Hello
4 10.007945 192.168.30.1 224.0.0.5 OSPF Hello Packet OSPF Hello Packet Network Mask: 255.255.255.252 Hello Interval: 10 seconds Options: 0x02 (E) 0... .... = DN: DN-bit is NOT set .0.. .... = O: O-bit is NOT set ..0. .... = DC: Demand circuits are NOT supported ...0 .... = L: The packet does NOT contain LLS data block .... 0... = NP: Nssa is NOT supported .... .0.. = MC: NOT multicast capable .... ..1. = E: ExternalRoutingCapability Router Priority: 1 Router Dead Interval: 40 seconds Designated Router: 0.0.0.0 Backup Designated Router: 0.0.0.0
- network mask: network mask of the network in which the interface is operating by using OSPF.
- Hello interval: time to fire the hello packet. It must be the same on two routers to form adjacency.
- Option: optional router capability
- O bit is used for opaque LSAs, mentioned in RFC 2370
- DC is used for demand circuit capabilities, mentioned in RFC 1793
- EA is the external attribute
- N/P is used for not-so-stubby area (NSSA) option, mentioned in RFC 1587
- MC designates multicast OSPF
- E, when set, means that external LSA are allowed in this area
- T bit is used for ToS capability (normally set to 0)
- Router priority: the administrative priority assigned to the router in election of DR/BDR.
- Dead interval: timer to mark a neighbor as dead. It is usually 4 times the hello.
- DR: DR address. In case no DR, it is set to 0.0.0.0
- BDR: BDR address. in case no BDR, it is set to 0.0.0.0
- neighbour: contains the addresses of neighbours which can be seen by using Hello packet.
The DR/BDR are elected by using the Hello packet. The router with the highest priority wins. If the priorities are equal, the router with the highest router ID becomes the DR.
The purpose of the DR is to reduce the amount of flooding on multiaccess media. The DR uses multicasting to reduce the amount of flooding. All routers flood their link-state database to the DR, and the DR then floods that information back to other routers on that segment. No DRs/BDRs exist on point-to-point or point-to-multipoint segments.
In the above mentioned packet (packet 4), there is no DR/BDR, nor neighbour. That is because it is one of the very first packets sent on the wire. The election of DR/BDR had not been completed yet. And no neighbor adjacency is formed yet. In the later packet (packet 10) we can see that the election of DR is done, but not the BDR and there is one neighbor in the packet.
10 40.017620 192.168.30.1 224.0.0.5 OSPF Hello Packet OSPF Hello Packet Network Mask: 255.255.255.252 Hello Interval: 10 seconds Options: 0x02 (E) Router Priority: 1 Router Dead Interval: 40 seconds Designated Router: 192.168.30.1 Backup Designated Router: 0.0.0.0 Active Neighbor: 192.168.30.4
Type 2 DD (Database description)
- MTU: define the largest data size can be send on over the link. It has to be set to 0 in case of virtual link.
- option: as previously discussed.
- 5 bits of data padding: all padded with 0 to fill up the gap. This is due to uniform of the packets.
- I bit: when set to 1, this means this is the first packet DD exchange
- M bit: indicate there are more DD packets following this packet
- MS bit: master/slave bit. In every DD exchange there is a master/slave relationship defined. When set to one, the router is a master in DD exchange. In case of slave it is set to 0.
- Sequence number: Unique value set by master. It is used during the DD exchange. and can only be increased by master.
- LSA headers: Contains a list of link state database header.
Illustrated in the following packets
14 40.030508 192.168.30.2 192.168.30.1 OSPF DB Descr. OSPF DB Description Interface MTU: 1500 Options: 0x02 (E) DB Description: 0x07 (I, M, MS) .... 0... = R: OOBResync bit is NOT set .... .1.. = I: Init bit is SET .... ..1. = M: More bit is SET .... ...1 = MS: Master/Slave bit is SET DD Sequence: 1299749504
192.168.30.2 would like to initiate the DD exchange with 192.168.30.1. The I, M and MS are all set. This means this is the first packet in the DD exchange, there will be more packets follow and itself is the master in the change.
However we can see from the packet below which directly follow packet 14
15 40.031592 192.168.30.1 192.168.30.2 OSPF DB Descr. DB Description: 0x07 (I, M, MS) .... 0... = R: OOBResync bit is NOT set .... .1.. = I: Init bit is SET .... ..1. = M: More bit is SET .... ...1 = MS: Master/Slave bit is SET DD Sequence: 1299749504
We can see that a conflict occurs. Both of them want to start the exchange, but only one can win
16 40.031940 192.168.30.1 192.168.30.2 OSPF DB Descr. DB Description: 0x00 () .... 0... = R: OOBResync bit is NOT set .... .0.. = I: Init bit is NOT set .... ..0. = M: More bit is NOT set .... ...0 = MS: Master/Slave bit is NOT set DD Sequence: 1299749504 LSA Header LS Age: 0 seconds Do Not Age: False Options: 0x02 (E) Link-State Advertisement Type: Router-LSA (1) Link State ID: 192.168.30.1 Advertising Router: 192.168.30.1 (192.168.30.1) LS Sequence Number: 0x80000002
We can see that 192.168.30.1 become slave and started the exchange.
Then 192.168.30.2 start also exchange, but as master. And we can see indeed that the DD sequence is only increased here by “master”.
17 40.032278 192.168.30.2 192.168.30.1 OSPF DB Descr. OSPF DB Description Interface MTU: 1500 Options: 0x02 (E) DB Description: 0x01 (MS) DD Sequence: 1299749505 LSA Header LS Age: 0 seconds Do Not Age: False Options: 0x02 (E) Link-State Advertisement Type: Router-LSA (1) Link State ID: 192.168.30.4 Advertising Router: 192.168.30.4 (192.168.30.4) LS Sequence Number: 0x80000002 LS Checksum: 0xf9e3 Length: 60
And in the next “empty” DD packet (without LSA header), 192.168.30.1 indicate the end of the exchange process.
18 40.032742 192.168.30.1 192.168.30.2 OSPF DB Descr. OSPF DB Description Interface MTU: 1500 Options: 0x02 (E) DB Description: 0x00 () DD Sequence: 1299749505
Packet 3 LSR (link state request)
After the DD exchange, the two parties notice that they are some interesting information they want to from each other. But as in the DD, only the description is exchange, they now have to send LSR to particularly request the content of the information. One LSR can contain more LSA requests.
With the combination of three of the fields we can uniquely identify an individual
- LS type: as discussed below
- Link-state ID:
- Advertising router
Type LSA Functionality 1 Router Defines the state and cost of the link to the neighbor and IP prefix associated with the point-to-point link. 2 Network Defines the number of routers attached to the segment. It gives information about the subnet mask on that segment. 3 Summary network Describes the destination outside an area but within the OSPF domain. The summary for one area is flooded into other areas, and vice versa. 4 Summary ASBR Describes the information about the ASBR. In a single area, there will be no summary Type 4 LSA. 5 External Defines routes to destination external to OSPF domain. Every subnet is represented by a single external LSA. 6 Group membership 7 NSSA Defines routes to an external destination, but in a separate LSA format known as Type 7. 8 Unused 9–11 Opaque
- Type 6 is used for group membership in Multicast OSPF (MOSPF)
- Type 8 is unused
- Types 9–11 are used for Opaque LSA, which is not used for route calculation but is used for MPLS traffic engineering
A packet for example
This is the LSR sent by 192.168.30.2 unicast to 192.168.30.1 to request its router-LSA, link state ID 192.168.30.1.
19 40.033192 192.168.30.2 192.168.30.1 OSPF LS Request Link State Request Link-State Advertisement Type: Router-LSA (1) Link State ID: 192.168.30.1 Advertising Router: 192.168.30.1 (192.168.30.1)
Type 4 LSU (link state update)
LSU format is the same as LSR, but has LSA (link state advertisement) integrated. The LSU is multicasted to the all ospf group (224.0.0.5). In case of non acknowledged LSA, it has to be retransmitted by using unicast. As the same with LSR, the LSU can also contain more LSA.
22 40.034613 192.168.30.1 224.0.0.5 OSPF LS Update LS Update Packet Number of LSAs: 1 Link-State Advertisement Type: Router-LSA (1) Link State ID: 192.168.30.1 Advertising Router: 192.168.30.1 (192.168.30.1) LS Sequence Number: 0x80000002 Flags: 0x02 (E) .... .0.. = V: NO Virtual link endpoint .... ..1. = E: AS boundary router .... ...0 = B: NO Area border router Number of Links: 3 Type: Stub ID: 10.1.0.0 Data: 255.255.0.0 Metric: 10 Type: Stub ID: 10.0.0.0 Data: 255.255.240.0 Metric: 10 Type: Stub ID: 192.168.30.0 Data: 255.255.255.252 Metric: 10
This is the update for the request described previously.
192.168.30.1 as request, it give away information about itself (router LSA). We can see the unique identity (LS ID, LS type, and advertising router), and the router type (ASBR, since it is connected to a external and none OSPF area 10.1.0.0) and it has three connections.
It is multicasted to 224.0.0.5. Hence it should be acknowledged by all the recipients with LSA, explained in the next section.
Type 5 LSA (link state advertisement acknowledgment)
Each update has to be acknowledged by LSA. Each LSA can contain more acknowledgments. The only thing has to be in the acknowledgment is the LSA header.
LSA are sent by multicasts. If the the router is DR/BDR, the acknowledgment is sent to the OSPF router multicast address of 224.0.0.5. If the router is not DR/BDR, the acknowledgment is sent to the all DR router multicast address of 224.0.0.6.
We can see in the below packet, which is the acknowledgment for packet 22 mentioned in the last section. But it contains second LSA to acknowledge another update.
27 41.020307 192.168.30.2 224.0.0.5 OSPF LS Acknowledge LSA Header Link-State Advertisement Type: Router-LSA (1) Link State ID: 192.168.30.1 Advertising Router: 192.168.30.1 (192.168.30.1) LS Sequence Number: 0x80000002 LS Checksum: 0xdd98 Length: 60 LSA Header LS Age: 1 seconds Do Not Age: False Link-State Advertisement Type: Network-LSA (2) Link State ID: 192.168.30.1 Advertising Router: 192.168.30.1 (192.168.30.1) LS Sequence Number: 0x80000001 LS Checksum: 0x1721 Length: 32
How does the election process for the DR and BDR work? Explain using a thorough walkthrough of a packet trace on the network.
At the starting point, no DR/BDR, router joins 224.0.0.5 as of all OSPF router should.
2 0.001025 192.168.30.1 224.0.0.5 OSPF Hello Packet OSPF Hello Packet Hello Interval: 10 seconds Router Priority: 1 Router Dead Interval: 40 seconds Designated Router: 0.0.0.0 Backup Designated Router: 0.0.0.0
Only after 40 seconds,wait time to ensure every router sends out hello packet and received by every other neighbors, the election starts. When there is no objection, say higher preference or higher router ID, the router with highest preference or router ID will be put into BR and join group 224.0.0.6 (all DR/BDR)
10 40.017620 192.168.30.1 224.0.0.5 OSPF Hello Packet OSPF Hello Packet Designated Router: 192.168.30.1 Backup Designated Router: 0.0.0.0
Then router with a bit lower preference will be elected as the BDR and also enter the 224.0.0.6 group
25 40.056353 192.168.30.2 224.0.0.5 OSPF Hello Packet OSPF Hello Packet Designated Router: 192.168.30.1 Backup Designated Router: 192.168.30.2
Now the election is done.
When there is a tie, we have tie breakers as
- preference (high)
- router id (high)
By chance, DR and BDR can be the same router. In this case BDR will be re elected with the DR removed from the pool.
OSPF is also capable of running on links with a /31 netmask or even on unnumbered links. Implement this between routers 4 and 5.
Please see the work log.
However, unnumber is not doable here. Due to
- no corresponding command (ip un)
- ppp encapsulation is needed but not present here.
In the case of /31, there is no DR/BDR election. The line is just point to point connected, hence no election is needed.
2167 10806.010310 192.168.30.4 224.0.0.5 OSPF Hello Packet OSPF Hello Packet Network Mask: 0.0.0.0 Designated Router: 0.0.0.0 Backup Designated Router: 0.0.0.0 Active Neighbor: 192.168.30.5
We can see from the packet above that there is no DR/BDR. And netowrk mask is set to 0.0.0.0. And the neighbor is directly put into the hello packet.
Below is the interface on router 4 connected to router 5
#ospf interface ospfd4# sh ip o i . eth2 is up ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST> Internet Address 192.168.30.4/31, Broadcast 192.168.30.255, Area 0.0.0.0 MTU mismatch detection:enabled Router ID 192.168.30.5, Network Type POINTOPOINT, Cost: 10 Transmit Delay is 1 sec, State Point-To-Point, Priority 1 No designated router on this network No backup designated router on this network Multicast group memberships: OSPFAllRouters Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5 Hello due in 7.300s Neighbor Count is 1, Adjacent neighbor count is 1