01 - OSPF Protocol Basics
01 - OSPF Protocol Basics
Can RIP meet these requirements? What problems may RIP encounter?
Hop-by-hop convergence:
Routing-by-rumor mechanism:
RIP uses hop count to measure the distance to a destination. Therefore, when
data packets traverse networks from N1 to N2, the links RTA->RTB->RTD-
>RTE are chosen as the optimal route. Obviously, the Ethernet links RTB-
>RTC->RTD have much higher bandwidths than the serial link RTB->RTD.
Because a RIP router obtains routing information just from neighbors, it cannot
identify or eliminate non-optimal or incorrect routing information. The best
solution to this problem is that it collects networkwide information and
independently calculates routes on the basis of the information.
When using hop count to measure the distance to a destination, the propagation
delay is not taken into account. If the accumulated bandwidth is used as the
criterion for route decision, the risk of selecting a suboptimal route can be
eliminated.
By what means do link-state routing protocols solve all the problems mentioned
above?
The term link-state refers to the status of interfaces on an OSPF router, which
includes the following information:
…
OSPF transmits link state information to its neighbors instead of transmitting its
complete routing table.
Each router maintains its link state database (LSDB). Neighbors synchronize their
LSDBs and then use the SPF algorithm to calculate the optimal route. This speeds
up the network convergence speed.
OSPF uses the accumulated bandwidth of the links as the criterion for route
selection. This method is more accurate than using the accumulated hop count.
OSPF can solve RIP problems in large networks. The following describes how OSPF
works.
An enterprise network, often in analogy with a road map, usually consists of a
large number of devices, including routers and switches, of different models and
various kinds of links, which results in great computational complexity.
Each router generates link state information and floods it to all neighbors,
meanwhile collects link state information from its neighbors until the LSDBs
are synchronized among OSPF neighbors.
On the basis of its LSDB, each router uses the SPF algorithm to calculate a
Shortest Path Tree (SPT) with itself as the root. By building an SPT, each
router calculates the optimal routes to destination. The routes form a routing
table eventually.
Let's focus on the three steps mentioned to learn the principles and
implementation of OSPF.
There are several, dozens of, or even hundreds of devices on an enterprise network.
Each of these devices must be uniquely identified by a router ID.
It prefers the manually configured router ID. You are advised to manually
configure a router ID for an OSPF router.
When two OSPF routers sharing a common data link successfully negotiate
certain parameters, the neighbor relationship between them is established.
Down: This is the initial state of a neighbor relationship. It indicates that there
has been no information received from the neighbor.
Init: This state occurs when a router has received a Hello packet from its
neighbor but its router ID is not in the neighbor list contained in the received
Hello packet. This means that bidirectional communication with the neighbor
has not yet been established.
2-Way: In this state, a router finds that its router ID is in the Hello packet
from a neighbor. Bidirectional communication with the neighbor is then
established.
RTA has a router ID 1.1.1.1 and RTB has a router ID 2.2.2.2. When the OSPF
process starts on RTA, RTA sends the first Hello packet, in which the neighbor
list is empty. The neighbor state is Down. When RTB receives the Hello packet
from RTA, the neighbor state is set to Init.
Likewise, almost at the same time, RTB sends a Hello packet with an empty
list of active neighbor. As what RTB does, RTA sets the neighbor state to Init,
as soon as it receives this Hello packet from RTB.
RTB sends another Hello packet to RTA, saying that the router ID 1.1.1.1 is on its
list of active neighbor. Upon receiving this Hello packet, RTA finds its router ID
included in the neighbor list of the packet, and then sets the neighbor state to 2-
way.
(Similarly, RTA sends RTB the next Hello packet with RTB’s router ID 2.2.2.2 on
the list of active neighbor. RTB sees itself in the neighbor list of the packet, then
sets the neighbor state to 2-way.
Because the neighbors were unknown before an OSPF router starts its discovery of
neighbors, the destination IP address of a Hello packet is a multicast address
224.0.0.5 instead of a specific unicast address. How does an OSPF router discover
neighbors on a network that does not support multicast?
If the network does not have the multicast capability, neighbor relationships must
be manually established.
When the network scale increases or devices are frequently updated, static
configurations need to be modified on related OSPF routers. However, manually
modifying configurations is of heavy workload and error-prone.
Link state information includes the link type, interface IP address and subnet mask,
neighbors on the link, and link cost.
A router just needs to know the destination network ID/subnet mask, next hop,
and cost (interface IP address and subnet mask, neighbors on the link, and link
cost). But why is the link type included in the link state information?
The development of devices, communication media, and protocols are critical parts
of the evolution of networking technologies. Device performance increasingly
improves, and communication links have developed from serial link, ATM, and FR
into Ethernet, xPON, SDH, MSTP, and OTN. A new generation of technology never
comes into being at the snap of a finger. Instead, it is a progressive process.
Different kinds of physical links have their unique characteristics. Accordingly, a
mature routing protocol must fit the characteristics of a physical link where it is
applied.
Point-to-point and broadcast networks are the most common OSPF network types.
Besides, there are two more network types which are rarely found.
Unlike the broadcast network, a non-broadcast multiple access (NBMA) network
does not support broadcast and multicast by default. On an NBMA network, OSPF
emulates operations over a broadcast network. But the neighbor must be manually
specified.
So here comes the question: how is the cost in OSPF link state information
determined?
The formula for OSPF cost calculation is: Interface cost = Reference
bandwidth/Interface bandwidth, which defines the interface cost as the reference
bandwidth divided by the interface bandwidth. The default reference bandwidth is
100Mbps. If the result is not an integer, it is truncated to a whole number to be the
cost value. If the result is less than 1, the interface has the cost of 1.
Configure the cost under interface configuration mode. Note that the
configured cost is the final value for this interface , but is valid only on this
interface.
Change the default reference bandwidth for OSPF. This modification takes
effect only on all OSPF-enabled interfaces of the local router. It is suggested
that all routers in the Autonomous System should be configured with the
same reference bandwidth in order to ensure consistency in route selection.
When changing the default reference bandwidth, you should give overall
consideration on bandwidth distribution on the whole network before you
decide a new value.
OSPF metric is the cumulative cost, which is a total cost of all outbound interfaces
of the routers the packet passing through from the source to the destination. For
example, if a packet routed by OSPF from RTA destined for RTC’s interface
Loopback 1 attached to subnet 192.168.3.3/24, the cost is equal to the cost of G1
plus the cost of G3.
OSPF take both hop count and bandwidth into account in cost calculation. Hence,
it is a more reliable routing protocol than RIP.
How do OSPF routers exchange link state information and synchronize their LSDBs?
RIP operates on UDP port number 520, while OSPF is defined above IP rather than
TCP or UDP, which means OSPF packets are directly encapsulated in IP packets,
with protocol number 89.
Router ID: indicates the identity of the router that originates this packet.
Area ID: indicates the OSPF area into which the packet is being advertised.
Checksum: is used to verify data integrity of the entire OSPF packet, including
the OSPF packet header.
Auth Type: indicates the authentication mode being used. The value 0
indicates non-authentication. The value 1 indicates simple password. The
value 2 indicates cryptographic (MD5) authentication.
OSPF packet header defines the communication standards and rules between
OSPF routers. Based on these standards, what functions need to be developed for
OSPF packets?
Type 1 packets are Hello packets, which are used to establish and maintain
neighbor relationships. As discussed earlier, before establishing an OSPF neighbor
relationship, two routers must negotiate some parameters.
Type 2 packets are Database Description (DD) packets, which are used to describe
the content of local LSDB to neighbors so that the neighbors can determine
whether their LSDBs are complete.
Type 3 packets are Link State Request (LSR) packets. A router determines whether
its LSDB is complete compared with the information in DD packets from its
neighbors. If its LSDB is incomplete, it creates a list of LSAs that need to be
obtained from the sender of the DD packets and then sends.
Type 4 packets are Link State Update (LSU) packets, which are used to respond to
the LSR packets received from neighbors. According to the request list in the
received LSR packet, the router packs the required LSAs into LSU packets and
sends them to the neighbor. LSA flooding is performed by LSU packets, and as a
result, the LSDB synchronization among all routers in the area is implemented.
Type 5 packets are Link State Acknowledgment (LSAck) packets, which are used to
acknowledge received LSAs in order to ensure LSA synchronization reliability.
DD, LSR, LSU, and LSAck packets contain LSA information in varying degrees:
All these five types of OSPF packets ensure an efficient LSA synchronization
process. So how are these packets utilized to fulfill the task?
In previous parts of this series, the Hello mechanism used to dynamically discover
neighbors and maintain OSPF neighbor relationships has been explained and need
not be repeated here.
Compared with the Request and Response messages used for synchronization of
routing information bases (RIBs) in RIP, LSAs are employed to synchronize LSDBs
in OSPF. One possible way for an OSPF router is to send all its LSAs to neighbors;
however, this method is not a perfect one.
A faster and more efficient method should be like this: summary information
rather than all link-state information is sent to neighbors. On receiving it, the
neighbors examine which LSAs are new or more up-to-date to themselves, and
then request detailed LSAs from the sender. For OSPF protocol, there is necessity
to employ a more efficient and reliable method than RIP’s to synchronize link-
state database between routers.
State description:
Loading: This state occurs when two routers send LSR, LSU, and LSAck
packets to each other. This state occurs when a router finds entries in its Link
State Request list. In this state, the router sends LSR packets to its neighbor,
receives LSU packets from it and answers LSAck packets as acknowledgement.
Full: This state occurs when the neighboring router’s LSDB is synchronized.
In this state, the neighboring routers are fully adjacent.
RTA and RTB have router IDs 1.1.1.1 and 2.2.2.2 respectively, and a neighbor
relationship has been established between them. When the neighbor RTB’s
state becomes ExStart, RTA sends its first DD packet to RTB. The DD packet
sequence number is randomly set to X, the I-bit is set to 1, indicating that
this is its first DD packet; the M-bit is set to 1, indicating that subsequent DD
packets need to be sent, and the MS-bit is set to 1, indicating that RTA
asserts itself as the master.
Similarly, when the neighbor RTA’s state becomes ExStart, RTB sends its first DD
packet, with a DD sequence number of y and three flags I-bit, M-bit and MS-bit set
to 1, 1 and 1 respectively, as the same meaning as RTA’s. Because RTB has a
larger router ID, RTB will become the master. Upon receipt of the DD packet from
RTB, RTA generates a Negotiation-Done event agreeing that RTB is the master,
and transitions neighbor RTB’s state from ExStart to Exchange.
Then RTA sends a new DD packet containing summary information of its LSDB. In
this packet, the DD packet sequence number is overrode by RTB with Y in step 2,
the I-bit is set to 0, indicating that this packet is not its first DD packet, the M-bit is
set to 0, indicating that this packet is the last DD packet containing LSDB summary
information, and the MS-bit is set to 0, indicating that RTA asserts itself as the
slave. When receiving this DD packet, RTB generates a Negotiation-Done event
and transitions its neighbor RTA’s state from ExStart to Exchange.
Then RTB sends a new DD packet, which contains LSDB summary information
together with sequence number Y+1 and the M-bit set to 1, indicating that RTB
asserts itself as the master. Suppose all its LSDB summary information is included
in this DD packet, the M-bit is now set to 0, telling RTA, "this is the last DD packet
for you".
Although there is no need for RTA to sends its LSDB summary information to RTB,
as a slave, it still needs to acknowledge each DD packet from the master. Therefore,
RTA responds to RTB’s DD packet with an empty DD packet containing the
sequence number Y+1. Then RTA generates an Exchange-Done event and
transitions neighbor RTB’s state to Loading. When RTB receives this DD packet, it
transitions its neighbor state to Full. (Assume that RTB has the latest and complete
LSDB and does not need to request updates from RTA.)
RTA sends an LSR packet to RTB to request more recent LSAs that have been
discovered in the Exchange state but have not yet been received.
RTB then provides RTA with the requested LSAs in an LSU packet. On
receiving this LSU packet, RTA transitions neighbor RTB’s state from
Loading to Full.
Down: This is the initial state of a neighbor conversation. It indicates that the
router has not received any Hello packet from its neighbor in the last
RouterDeadInterval. On an NBMA network, a router can still send Hello
packets at every PollInterval to its manually configured neighbor which is in
Down state. The PollInterval is often as large as the RouterDeadInterval.
Attempt: This state only appears on NBMA networks. It indicates that the
router has not received any recent information from its manually configured
neighbor, but that it has been sending Hello packets to the neighbor at every
HelloInterval. If the router does not receive any Hello packet from its
neighbor within a RouterDeadInterval, the neighbor state transitions to Down.
Init: This state occurs when the router receives a Hello packet from a
neighbor but does not see its own Router ID in neighbor list of this Hello
packet, which means they have not established a two-way communication
with each other. In this state, the router IDs of all its known neighbors must
be included in the neighbor list of the Hello packet sent by the router.
2-way Received: This event occurs when the router sees its own Router ID in
neighbor list of the Hello packet received from the neighbor, or receives a DD
packet from the neighbor. If the router needs to establish an adjacency with a
neighbor, the neighbor state transitions to ExStart and LSDB synchronization
begins. Otherwise, the neighbor state transitions to 2-Way.
1-Way Received: This event occurs when the router finds that its router ID is not
contained in the neighbor list of the received Hello packet. This is often due to a
restart of the neighboring router.
ExStart: This state occurs when the router starts to send DD packets to its neighbor.
In this state, the master-slave relationship is established and the initial DD
sequence number is determined. Note that the DD packets do not include any LSA
summary information in this state. This is the first step towards forming an
adjacency.
Exchange: This state occurs when the router exchanges with its neighbor DD
packets containing LSA summary information to describe its entire LSDB.
Loading: This state occurs when the router sends LSR packets to its neighbor
requesting the more recent LSAs that have been discovered in the received DD
packets in the Exchange state. Subsequently, the router receives responding LSU
packets from the neighbor.
Full: This state occurs when its link state request list is empty, which means the
local LSDB is synchronized with its neighbor’s. It indicates that the neighbor is
fully adjacent.
A Link State Advertisement (LSA) is the carrier of OSPF link state information
between routers. The LSA is the basic structural unit of LSDB. In other words, an
LSDB is composed of an array of LSAs.
All LSAs have the same format of header, including the following fields:
LS type: indicates the LSA format and function. There are five types of
commonly used LSAs.
Link State ID: identifies the link described by an LSA, for example, router ID.
Advertising Router: indicates the router ID of the router that originates this
LSA.
LS type, Link State ID, and Advertising Router together identify an LSA.
Aside from locally originated LSAs, there are LSAs obtained from other neighbors
in LSDB. It’s necessary for LSAs to be advertised between neighboring routers
through a passageway.
OSPF-running MA networks include broadcast and NBMA networks, which are
facing the following problems:
The same copies of LSAs will be flooded repeatedly among neighbors. For
example, RTA sends its LSAs with the same content to neighbors RTB, RTC
and RTD separately. And what’s more, RTB forwarded these LSAs to
neighbors RTD and RTC, and even RTA where the LSAs are from. This process
is called flooding.
The DR establishes adjacencies and exchanges link state information with all the
other routers, while other routes do not directly exchange link state information
with each other. This greatly reduces the number of adjacencies in an MA network,
and as a result, saves resources used to exchange link state information.
Once the DR becomes invalid, its adjacencies with other routers all become invalid,
and LSDB synchronization fails. A new DR needs to be elected to establish new
adjacencies with non-DR routers for LSDB synchronization. To prevent the single
point of failure, OSPF puts forward the concept of Backup Designated Router
(BDR), which is a backup for DR and elected at the same time as when DR is
elected. When the current DR becomes invalid, the BDR instantly takes over the
role of DR.
A pseudo node is a virtual device node. The following describes DR and BDR
election.
The concepts neighbor relationship and adjacency are different from each other.
After two OSPF routers establish a neighbor relationship, they synchronize their
LSDBs and eventually establish an adjacency.