深入理解 OSPF 协议:从基础概念到 LSA 类型

注:机翻,未校。


OSPF - Part 1: Introduction, OSPF Packet Structure, OSPF Messages and Characteristics OSPF - 第 1 部分:简介、OSPF 数据包结构、OSPF 消息和特性

Open Shortest Path First (OSPF) is a popular routing protocol developed for Internet Protocol (IP) networks by the Interior Gateway Protocol (IGP) working group of the Internet Engineering Task Force (IETF). The working group was formed in 1988 to design an IGP based on the shortest path first (SPF) algorithm for use in the Internet. Similar to the Interior Gateway Routing Protocol (IGRP), OSPF was created because in the mid-1980s, the Routing Information Protocol (RIP) was increasingly unable to serve large, heterogeneous internetworks.
开放最短路径优先 (OSPF) 是由互联网工程任务组 (IETF) 的内部网关协议 (IGP) 工作组为 Internet 协议 (IP) 网络开发的一种常用路由协议。该工作组成立于 1988 年,旨在设计一种基于最短路径优先 (SPF) 算法的 IGP,用于互联网。与内部网关路由协议 (IGRP) 类似,OSPF 的创建是因为在 1980 年代中期,路由信息协议 (RIP) 越来越无法为大型异构网际网络提供服务。

OSPF Packet Structure & Analysis OSPF数据包结构与分析

OSPF is a classless routing protocol, which means that in its updates, it includes the subnet of each route it knows about, thus, enabling variable-length subnet masks. With variable-length subnet masks, an IP network can be broken into many subnets of various sizes. This provides network administrators with extra network-configuration flexibility.These updates are multicasts at specific addresses (224.0.0.5 and 224.0.0.6).
OSPF 是一种无类别路由协议,这意味着在其更新中,它包含它知道的每个路由的子网,从而启用可变长度的子网掩码。使用可变长度的子网掩码,可以将 IP 网络分成许多不同大小的子网。这为网络管理员提供了额外的网络配置灵活性。这些更新是特定地址(224.0.0.5 和 224.0.0.6)的多播。

The diagram below shows us the information that each field of an OSPF packet contains:
下图显示了 OSPF 数据包的每个字段包含的信息:

ospf-1

The numbers shown inside the coloured blocks represent the field length in bytes.
彩色块内显示的数字表示字段长度(以字节为单位)。

ospf-2

All OSPF packets begin with a 24-byte header, which is shown right above.
所有 OSPF 数据包都以 24 字节的标头开头,如上图所示。

OSPF ‘Type’ Field OSPF “类型”字段

The ‘Type’ field (1-byte long) is a critical component of an OSPF (Open Shortest Path First) package. It indicates the type of OSPF message contained within the package, such as a Hello message, Link State Request message, Link State Update message, or Link State Acknowledgment message. The type field plays a crucial role in the OSPF protocol by helping to ensure that routers exchange the correct types of messages with each other, enabling them to learn about the network topology and establish the shortest path to the destination network.
“Type”字段(1 个字节长)是 OSPF(Open Shortest Path First)包的关键组件。它指示包中包含的 OSPF 消息的类型,例如 Hello 消息、链接状态请求消息、链接状态更新消息或链接状态确认消息。类型字段在 OSPF 协议中起着至关重要的作用,它有助于确保路由器相互交换正确类型的消息,使它们能够了解网络拓扑并建立到目标网络的最短路径。

Understanding the significance of the “Type” field is essential for network administrators to troubleshoot OSPF network issues and optimize the performance of their networks. Below are the Type field messages contained with a bit more information about their purpose and role:
了解“类型”字段的重要性对于网络管理员解决 OSPF 网络问题并优化其网络性能至关重要。以下是包含的 Type 字段消息,其中包含有关其用途和角色的更多信息:

  • Hello: Establishes and maintains neighbor relationships.
    您好:建立并维护邻居关系。
  • Database Description: Describes the contents of the topological database. These messages are exchanged when an adjacency is initialized.
    数据库说明:描述拓扑数据库的内容。这些消息在初始化邻接关系时交换。
  • Link-state Request: Requests pieces of the topological database from neighbor routers. These messages are exchanged after a router discovers (by examining database-description packets) that parts of its topological database are out of date.
    链路状态请求:从邻居路由器请求拓扑数据库的各个部分。在路由器发现(通过检查数据库描述数据包)其拓扑数据库的某些部分已过期后,将交换这些消息。
  • Link-state Update: Responds to a link-state request packet. These messages also are used for the regular dispersal of Link-State Acknowledgments (LSA). Several LSAs can be included within a single link-state update packet.
    链路状态更新:响应链路状态请求数据包。这些消息还用于定期传播链路状态确认 (LSA)。多个 LSA 可以包含在单个链路状态更新数据包中。
  • Link-state Acknowledgment: Acknowledges link-state update packets.
    链路状态确认:确认链路状态更新数据包。

OSPF’s Primary Characteristics OSPF的主要特点

OSPF - The Open Routing Protocol OSPF - 开放式路由协议

The protocol is open (non proprietary), which means that its specification is in the public domain. The OSPF specification is published as Request For Comments (RFC) 1247. This has allowed vendors around the world to produce products and devices that fully support OSPF, without the need of paying any royalty licenses. This also played a major role in making OSPF as a widely acceptable routing protocol for small, medium and large networks.
该协议是开放的(非专有的),这意味着其规范属于公共领域。OSPF 规范以征求意见 (RFC) 1247 的形式发布。这使得世界各地的供应商能够生产完全支持 OSPF 的产品和设备,而无需支付任何版税许可。这也在使 OSPF 成为小型、中型和大型网络广泛接受的路由协议方面发挥了重要作用。

OSPF - Dijkstra SPF Algorithm OSPF - DIJKSTRA SPF 算法

The second principal characteristic is that OSPF is based on the SPF algorithm, which sometimes is referred to as the Dijkstra algorithm, named for the person credited with its creation.
第二个主要特征是 OSPF 基于 SPF 算法,该算法有时被称为 Dijkstra 算法,以创建该算法的人命名。

The SPF algorithm calculates the shortest path by constructing a graph of the network, assigning costs to the links based on their bandwidth and determining the shortest path from each router to every other router in the network. The algorithm ensures that the path chosen has the lowest cost and that the route is loop-free, providing fast and efficient communication across the network.
SPF 算法通过构建网络图来计算最短路径,根据链路的带宽为链路分配成本,并确定从每个路由器到网络中每个其他路由器的最短路径。该算法确保所选路径的成本最低,并且路由是无环路的,从而在网络上提供快速高效的通信。

The SPF algorithm also helps to ensure network stability and performance by quickly detecting changes in the network topology and recalculating the shortest path. When a change occurs, such as a link failure or a new link being added to the network, OSPF sends out Link State Advertisement (LSA) messages to inform all routers in the network of the change. The routers then use the SPF algorithm to recalculate the shortest path to the destination network based on the updated network topology. This ensures that the network continues to operate efficiently and that data is routed along the most optimal path.
SPF 算法还可以快速检测网络拓扑的变化并重新计算最短路径,从而帮助确保网络的稳定性和性能。当发生更改时,例如链路故障或向网络添加新链路,OSPF 会发送链路状态通告 (LSA) 消息,以将更改通知网络中的所有路由器。然后,路由器使用 SPF 算法根据更新的网络拓扑重新计算到目标网络的最短路径。这确保了网络继续高效运行,并且数据沿着最优的路径进行路由。

OSPF - A Link State Routing Protocol OSPF - 链路状态路由协议

OSPF is a Link State routing protocol that calls for the sending of link-state advertisements (LSAs) to all other routers within the same hierarchical area. Information on attached interfaces, metrics used, and other variables is included in OSPF LSAs. As OSPF routers accumulate link-state information, they use the SPF algorithm to calculate the shortest path to each node.
OSPF 是一种链路状态路由协议,它要求将链路状态通告 (LSA) 发送到同一层次结构区域内的所有其他路由器。有关附加接口、使用的指标和其他变量的信息包含在 OSPF LSA 中。当 OSPF 路由器积累链路状态信息时,它们使用 SPF 算法来计算到每个节点的最短路径。

As a Link State routing protocol, OSPF contrasts with RIP and IGRP, which are Distance Vector routing protocols. Routers running the Distance Vector algorithm send all or a portion of their routing tables in routing-update messages to their neighbors.
作为链路状态路由协议,OSPF 与 RIP 和 IGRP 形成鲜明对比,后者是距离矢量路由协议。运行距离矢量算法的路由器以路由更新消息的形式将其全部或部分路由表发送到其邻居。

Additional OSPF features include equal-cost, multipath routing, and routing based on upper-layer type-of-service (TOS) requests. TOS-based routing supports those upper-layer protocols that can specify particular types of service. An application, for example, might specify that certain data is urgent. If OSPF has high-priority links at its disposal, these can be used to transport the urgent datagram.
其他 OSPF 功能包括等价、多路径路由和基于上层服务类型 (TOS) 请求的路由。基于 TOS 的路由支持那些可以指定特定类型服务的上层协议。例如,应用程序可能会指定某些数据是紧急的。如果 OSPF 可以使用高优先级链路,则这些链路可用于传输紧急数据报。

OSPF supports one or more metrics. If only one metric is used, it is considered to be arbitrary, and TOS is not supported. If more than one metric is used, TOS is optionally supported through the use of a separate metric (and, therefore, a separate routing table) for each of the eight combinations created by the three IP TOS bits (the delay, throughput, and reliability bits). If, for example, the IP TOS bits specify low delay, low throughput, and high reliability, OSPF calculates routes to all destinations based on this TOS designation.
OSPF 支持一个或多个指标。如果仅使用一个指标,则将其视为任意指标,并且不支持 TOS。如果使用多个度量,则可以选择性地通过使用单独的度量(因此,对于三个 IP TOS 位(延迟、吞吐量和可靠性位)创建的八个组合中的每个组合,都可以选择性地支持 TOS。例如,如果 IP TOS 位指定了低延迟、低吞吐量和高可靠性,则 OSPF 将根据此 TOS 指定计算到所有目的地的路由。

Summary 总结

This article introduced the OSPF routing protocol. It provided an overview of the routing protocol, its purpose, capabilities, and analyzed its structure within an Ethernet II frame. The ‘Type’ field within the OSPF header was examined and we also saw the different type of messages supported (Hello, Database description, Link-state Request, Link-state Update and Acknowledgment).
本文介绍了 OSPF 路由协议。它概述了路由协议、其用途和功能,并分析了其在以太网 II 帧中的结构。检查了 OSPF 标头中的“类型”字段,我们还看到了支持的不同类型的消息(Hello、数据库描述、链路状态请求、链路状态更新和确认)。


OSPF - Part 2: How OSPF Protocol Works & Basic Concepts: OSPF Neighbor, Topology & Routing Table, OSPF Areas & Router Roles, Theory & Overview OSPF - 第 2 部分:OSPF 协议的工作原理和基本概念:OSPF 邻居、拓扑和路由表、OSPF 区域和路由器角色、理论和概述

Article Reads:242970

ospf-operation-basic-advanced-concepts-ospf-areas-roles-theory-overview
This article covers basic OSPF concepts and operation. We explain how OSPF works, how OSPF tables are built on an OSPF-enabled router and their purpose (Neighbour Table, Topology Table, Routing Table), OSPF areas and their importance. Next we cover OSPF Link State Packet types used to exchange data between OSPF routers: Link State Advertisement (LSA), Link State Database (LSDB), Link State Request (LSR), Link State Update (LSU) and Link State Acknowledgment (LSAcK).
本文介绍 OSPF 的基本概念和操作。我们将解释 OSPF 的工作原理、如何在启用了 OSPF 的路由器上构建 OSPF 表及其用途(邻居表、拓扑表、路由表)、OSPF 区域及其重要性。接下来,我们将介绍用于在 OSPF 路由器之间交换数据的 OSPF 链路状态数据包类型:链路状态通告 (LSA)、链路状态数据库 (LSDB)、链路状态请求 (LSR)、链路状态更新 (LSU) 和链路状态确认 (LSAcK)。

Finally, we take a look at the OSPF roles: Area Boarder Router (ABR), Autonomous System Boundary Router (ASBR), Designated Router (DR), Backup DR and more.
最后,我们看一下 OSPF 角色:区域边界路由器 (ABR)、自治系统边界路由器 (ASBR)、指定路由器 (DR)、备份 DR 等。

What Is OSPF & How Does It Work? 什么是OSPF,它是如何工作的?

OSPF is a Link State protocol that’s considered may be the most famous protocol among the Interior Gateway Protocol (IGP) family, developed in the mid 1980’s by the OSPF working group of the IETF.
OSPF 是一种链路状态协议,被认为是内部网关协议 (IGP) 系列中最著名的协议,由 IETF 的 OSPF 工作组在 1980 年代中期开发。

When configured, OSPF will listen to neighbors and gather all link state data available to build a topology map of all available paths in its network and then save the information in its topology database, also known as its Link-State Database (LSDB). Using the information from its topology database. From the information gathered, it will calculate the best shortest path to each reachable subnet/network using an algorithm called Shortest Path First (SFP) that was developed by the computer scientist Edsger W. Dijkstra in 1956. OSPF will then construct three tables to store the following information:
配置后,OSPF 将侦听邻居并收集所有可用的链路状态数据,以构建其网络中所有可用路径的拓扑图,然后将信息保存在其拓扑数据库(也称为链路状态数据库 (LSDB))中。使用其拓扑数据库中的信息。根据收集到的信息,它将使用计算机科学家 Edsger W. Dijkstra 于 1956 年开发的称为最短路径优先 (SFP) 的算法计算到每个可访问子网/网络的最佳最短路径。然后,OSPF 将构造三个表来存储以下信息:

  • Neighbor Table: Contains all discovered OSPF neighbors with whom routing information will be interchanged
    邻居表:包含所有已发现的 OSPF 邻居,路由信息将与之交换
  • Topology Table: Contains the entire road map of the network with all available OSPF routers and calculated best and alternative paths.
    拓扑表:包含网络的完整路线图,包括所有可用的 OSPF 路由器以及计算出的最佳和替代路径。
  • Routing Table: Contain the current working best paths that will be used to forward data traffic between neighbors.
    路由表:包含将用于在邻居之间转发数据流量的当前工作最佳路径。

Understanding OSPF Areas 了解 OSPF 区域

OSPF offers a very distinguishable feature named: Routing Areas. It means dividing routers inside a single autonomous system running OSPF, into areas where each area consists of a group of connected routers.
OSPF 提供了一个非常明显的功能,称为:路由区域。这意味着在运行 OSPF 的单个自治系统内将路由器划分为多个区域,每个区域由一组连接的路由器组成。

The idea of dividing the OSPF network into areas is to simplify administration and optimize available resources. Resource optimization is especially important for large enterprise networks with a plethora of network and links. Having many routers exchange the link state database could flood the network and reduce its efficiency – this was the need that led to the creation of concept Areas.
将 OSPF 网络划分为多个区域的想法是为了简化管理并优化可用资源。对于拥有大量网络和链接的大型企业网络来说,资源优化尤为重要。 让许多路由器交换链路状态数据库可能会泛洪网络并降低其效率 - 这就是导致创建概念区域的需求。

Areas are a logical collection of routers that carry the same Area ID or number inside of an OSPF network, the OSPF network itself can contain multiple areas, the first and main Area is called the backbone area “Area 0”, all other areas must connect to Area 0 as shown in the diagram below:
区域是 OSPF 网络内部携带相同区域 ID 或编号的路由器的逻辑集合,OSPF 网络本身可以包含多个区域,第一个和主要区域称为主干区域“区域 0”,所有其他区域必须连接到区域 0,如下图所示:

ospf-operation-basic-advanced-concepts-ospf-areas-roles-theory-overview1
Figure 1. OSPF Areas, Area 0 (Backbone Area), ABR and ASBR OSPF routers
图 1.OSPF 区域、区域 0(骨干区域)、ABR 和 ASBR OSPF 路由器

All routers within the same Area have the same topology table -Link State Database- but different routing table as OSPF calculates different best paths for each router depending on its location within the network topology while they will all share the same Link State topology.
同一区域内的所有路由器具有相同的拓扑表(链路状态数据库),但路由表不同,因为 OSPF 根据每个路由器在网络拓扑中的位置为每个路由器计算不同的最佳路径,同时它们都将共享相同的链路状态拓扑。

The goal of having an Area is to localize the network as follow:
拥有 Area 的目标是按以下方式对网络进行本地化:

  • The Area boundaries will give the opportunity of using summarization, as it’s not possible to summarize network prefixes in normal link state protocols because routers are supposed to have the same map topology of the entire network coincide in all neighbors.
    区域边界将提供使用汇总的机会,因为不可能在正常的链路状态协议中汇总网络前缀,因为路由器应该具有相同的映射拓扑,即整个网络在所有邻居中重合。
  • Area boundaries will also help preventing fault containment by suppressing updates that take place when a change occurs in the network causing a flood of updates between routers. This also happens to be a weakness of link state protocols: When connecting large sized networks it is very difficult to avoid link state database floods.
    区域边界还有助于防止故障控制,因为它会抑制在网络发生更改时发生的更新,从而导致路由器之间的更新泛洪。这也恰好是链路状态协议的一个弱点:当连接大型网络时,很难避免链路状态数据库泛洪。

With Area boundaries, updates are kept only inside the same area, while other areas remain completely unaware of the update.
对于区域边界,更新仅保留在同一区域内,而其他区域则完全不知道更新。

OSPF Link State Packet Types OSPF 链路状态数据包类型

OSPF routers generate packets of information that are exchaged with neighboring routers. These packets are designed for several purposes such as forming neighbor relations between routers, calculating cost and best path for a specific route and more.
OSPF路由器生成信息包,这些信息包与相邻路由器交换。这些数据包设计用于多种目的,例如在路由器之间形成邻居关系、计算特定路由的成本和最佳路径等。

The following is a list of the most frequently used OSPF packets:
以下是最常用的 OSPF 数据包列表:

Link State Advertisement (LSA): The primary mean of communication between OSPF routers, it’s the packet that carries all fundamental information about the topology and is flooded between areas to perform different functions, there are 11 types of LSA packets that will be covred in great depth in future OSPF articles here on Firewall.cx
链路状态通告 (LSA):OSPF 路由器之间通信的主要方式,它是携带有关拓扑的所有基本信息的数据包,并在区域之间泛洪以执行不同的功能,有 11 种类型的 LSA 数据包将在未来的 OSPF 文章中深入介绍 Firewall.cx

Link State DataBase (LSDB): LSDB packet contains all updated link-state information exchanged among the network, and all routers within the same area have identical LSDB, and when two routers form new neighbor adjacency, they sync their LSDB to be fully adjacent.
链路状态数据库 (LSDB):LSDB 数据包包含在网络之间交换的所有更新的链路状态信息,并且同一区域内的所有路由器都具有相同的 LSDB,当两个路由器形成新的邻居邻接关系时,它们会同步其 LSDB 以完全相邻。

Link State Request (LSR): Once neighbor adjacency is formed and LSDB is exchanged, neighbor routers may locate a missing LSDB information, they then send a request packet to claim the missing piece, neighbors receive this packet and respond with LSU.
链路状态请求 (LSR):一旦形成邻居邻接并交换 LSDB,邻居路由器可能会找到丢失的 LSDB 信息,然后它们发送请求数据包以认领丢失的部分,邻居收到此数据包并使用 LSU 进行响应。

Link State Update (LSU): A response packet sends a specific piece of LSDB information requested by an OSPF neighbor via LSR packet.
链路状态更新 (LSU):响应数据包通过 LSR 数据包发送 OSPF 邻居请求的特定 LSDB 信息。

Link State Acknowledgment (LSAcK): The router that sends the LSR packet confirms receiving the LSU from neighbor by sending a confirmation packet acknowledging receiving the requested LSUs.
链路状态确认 (LSAcK):发送 LSR 数据包的路由器通过发送确认数据包确认接收请求的 LSU 来确认从邻居接收 LSU。

Working Inside Of A Single Area 在单个区域内工作

Working inside of an Area is hierarchically organized among routers that share this area and are categorized as:
在区域内工作在共享此区域的路由器之间按层次结构组织,并分类为:

Area Boarder Routers (ABR):
Routers located on the borders of each Area connect to more than one OSPF area, are called ABR Routers. ABR Routers are responsible for summarizing IP addresses of each area and suppressing updates among areas to prevent fault containment.
区域边界路由器 (ABR): 位于每个区域边界的路由器连接到多个 OSPF 区域,称为 ABR 路由器。ABR路由器负责汇总每个区域的IP地址,并抑制区域之间的更新,以防止故障控制。

Autonomous System Boundary Router (ASBR):
An ASBR is a router that has interfaces connected to one or more OSPF areas, similarly as the ABR, however the difference with an ASBR is that it also connects to other routing systems such as BGP, EIGRP, Internet and others. An ASBR router normally advertises routes from other routing systems into the OSPF area to which it belongs.
自治系统边界路由器 (ASBR): ASBR 是一种路由器,其接口连接到一个或多个 OSPF 区域,类似于 ABR,但与 ASBR 的区别在于它还连接到其他路由系统,例如 BGP、EIGRP、Internet 等。ASBR 路由器通常将来自其他路由系统的路由通告到其所属的 OSPF 区域。

Designated Router (DR):
A Designated Router is elected by the routers on multi-access segments (e.g Local Area Network), based on its priority (Router ID, priority). The DR router performs special functions such as generating Link State Advertisements (LSAs) and exchanging information with all other routers in the same Area. Every router in the same Area will create an adjacency with the DR and BDR (analysed below).
指定路由器 (DR): 指定路由器由多接入网段(例如局域网)上的路由器根据其优先级(路由器 ID、优先级)选择。DR 路由器执行特殊功能,例如生成链路状态通告 (LSA) 以及与同一区域中的所有其他路由器交换信息。 同一区域中的每个路由器都将与 DR 和 BDR 创建邻接关系(如下所述)。

The DR sends updates to all Area routers using the Multicast address 224.0.0.5. All OSPF routers except the DR use Multicast address 224.0.0.6 to send Link State Update (LSU) and Link State Advertisements (LSAs) packets to the DR.
DR 使用组播地址 224.0.0.5 向所有区域路由器发送更新。除 DR 之外的所有 OSPF 路由器都使用组播地址 224.0.0.6 向 DR 发送链路状态更新 (LSU) 和链路状态通告 (LSA) 数据包。

Backup Designated Router (BDR):
The BDR is a router that becomes the DR should the existing DR fail. The BDR has the second highest priority (the DR having the highest priority) in the OSPF network. When the BDR becomes a DR, a new election is made to find a new BDR.
备份指定路由器 (BDR): BDR 是一个路由器,如果现有 DR 发生故障,它将成为 DR。BDR 在 OSPF 网络中具有第二高优先级(具有最高优先级的 DR)。当 BDR 成为 DR 时,将进行新的选择以查找新的 BDR。

This article introduced the OSPF protocol and examined how OSPF works. We covered important OSPF concepts such as OSPF areas, OSPF Neighbour Table, Topology Table and Routing Table, plus OSPF Link State packet types (LSA, LSDB, LSR, LSU & LSAcK). To complete our introduction, we analysed the OSPF roles Area Boarder Router (ABR), Autonomous System Boundary Router (ASBR), Designated Router (DR), Backup DR.
本文介绍了 OSPF 协议,并研究了 OSPF 的工作原理。我们涵盖了重要的 OSPF 概念,例如 OSPF 区域、OSPF 邻居表、拓扑表和路由表,以及 OSPF 链路状态数据包类型(LSA、LSDB、LSR、LSU 和 LSAcK)。为了完成我们的介绍,我们分析了 OSPF 的角色:区域边界路由器 (ABR)、自治系统边界路由器 (ASBR)、指定路由器 (DR)、备份 DR。


OSPF - Part 3: OSPF Adjacency & Neighbor Forming Process. OSPF Hello Messages, OSPF Database Updates via Link State Requests (LSR & LSU) OSPF - 第 3 部分:OSPF 邻接和邻居形成过程。OSPF Hello 消息,通过链路状态请求 (LSR 和 LSU) 更新 OSPF 数据库

Article Reads:76936

ospf-adjacency-neighbor-forming-process-hello-packets-lsr-lsu-1aThis is the thrid article of our 6-part OSPF series (see below) that describes how OSPF routers perform neighbor relationship and adjacency. We’ll examine how OSPF discovers neighbors by sending Hello packets through the router interfaces and how it shares Link State Advertisements (LSAs) to form adjacencies and build its topology table. We’ll also examine the contents of OSPF Hello packets (Router ID, Hello/Dead Intervals, Subnet Mask, Router Priority, Area ID, DB & BDR IP Address, Authentication information) and more.
这是我们的 6 部分 OSPF 系列(见下文)的第三篇文章,介绍了 OSPF 路由器如何执行邻居关系和邻接关系。我们将研究 OSPF 如何通过路由器接口发送 Hello 数据包来发现邻居,以及它如何共享链路状态通告 (LSA) 以形成邻接关系并构建其拓扑表。我们还将检查 OSPF Hello 数据包的内容(路由器 ID、Hello/Dead 间隔、子网掩码、路由器优先级、区域 ID、DB 和 BDR IP 地址、身份验证信息)等。

How OSPF Forms Neighbor Relations OSPF如何形成邻里关系

Once OSPF is enabled on a router interface, a Link State Database (LSD) is established and all interfaces running OSPF are added to this table to be used in Link State Advertisements (LSAs), OSPF then the begins neighbor discovery and forming adjacency process.
在路由器接口上启用 OSPF 后,将建立链路状态数据库 (LSD),并将运行 OSPF 的所有接口添加到此表中,以用于链路状态通告 (LSA),OSPF 然后开始发现邻居并形成邻接过程。

We’ll now take a closer look at both, neighbor discover and adjacency forming process:
现在,我们将仔细研究邻域发现和邻接形成过程:

R1 sends an initial OSPF Hello packet. R2 responds with an OSPF Reply Hello packet.

Figure 1. R1 sends an initial OSPF Hello packet. R2 responds with an OSPF Reply Hello packet.
图 1.R1 发送初始 OSPF Hello 数据包。R2 使用 OSPF Reply Hello 数据包进行响应。

Sending & Receiving OSPF Hello Messages 发送和接收 OSPF Hello 消息

An OSPF router generates a Hello packet every poll interval -10 seconds for Peer-to-Peer (P2P) networks and 30 seconds for Non-Broadcast-Multiple-Access (NBMA) networks by default- and advertises it through multicast address 224.0.0.5 to all routers connected to its interfaces while it searches for potential OSPF neighbors. The Hello message contains a list of information needed to form an OSPF neighbor relation between two neighboring routers, the following a list of information contained the Hello messages:
OSPF 路由器每隔轮询间隔生成一个 Hello 数据包,默认情况下,点对点 (P2P) 网络为 10 秒,非广播多址 (NBMA) 网络为 30 秒),并通过组播地址 224.0.0.5 将其通告到连接到其接口的所有路由器,同时搜索潜在的 OSPF 邻居。Hello 消息包含在两个相邻路由器之间形成 OSPF 邻居关系所需的信息列表,以下信息列表包含 Hello 消息:

  • OSPF Router ID. The router’s ID which is configured or automatically selected by OSPF (analyzed below)
    OSPF 路由器 ID。由 OSPF 配置或自动选择的路由器 ID(如下所述)
  • Hello Interval Timer. Frequency upon which Hello packets are sent.
    你好间隔计时器。发送 Hello 数据包的频率。
  • Dead Interval Timer. Defines how long we should wait for hello packets before we declare the neighbor dead.
    死区间隔计时器。定义在宣布邻居死亡之前,我们应该等待你好数据包的时间。
  • Subnet Mask 子网掩码
  • Router Priority. Used to help determine the Designated Router (DR). Higher priority takes precedence. A configured Priority of 0 means the router will not become a DR or BDR.
    路由器优先级。用于帮助确定指定路由器 (DR)。优先级越高。配置的优先级为 0 表示路由器不会成为 DR 或 BDR。
  • List of reachable OSPF neighbors in the network.
    网络中可访问的 OSPF 邻居列表。
  • Area ID 区域 ID
  • DR & BDR’s IP addresses (if exists)
    DR 和 BDR 的 IP 地址(如果存在)
  • Authentication Password (if configured)
    身份验证密码(如果已配置)

Once a neighbor router (R2) running OSPF receives the Hello message, it runs a check on the above list.
运行 OSPF 的邻居路由器 (R2) 收到 Hello 消息后,它会对上述列表运行检查。

The following conditions must be met for two routers to become neighbors:
两个路由器必须满足以下条件才能成为邻居:

  1. They must have the same IP network/subnet
    它们必须具有相同的 IP 网络/子网
  2. The Hello and Dead Interval timers must be identical
    Hello 和 Dead Interval 计时器必须相同
  3. Router interfaces connecting two routers must have the same Area ID
    连接两个路由器的路由器接口必须具有相同的区域 ID
  4. Type of area must be identical (normal or stub area)
    区域类型必须相同(正常区域或存根区域)
  5. Authentication password (if used) must be identical
    身份验证密码(如果使用)必须相同

Hello Parameters Mismatch Hello 参数不匹配

If there’s a mismatch between some of the items (Hello/Dead interval, Subnetmask, Area ID etc), a Bouncing Relation case occurs as this potential neighbor (R2) keeps flapping on the router’s OSPF topology, indicating a mismatch with the Hello message information.
如果某些项目(Hello/Dead 间隔、子网掩码、区域 ID 等)不匹配,则会发生跳跳关系情况,因为此潜在邻居 (R2) 在路由器的 OSPF 拓扑上不断抖动,表明与 Hello 消息信息不匹配。

Note: Router ID can be a name, a number or an IP address. By default, OSPF will choose the highest active interface’s IP address as the Router ID. In case the interface does down (e.g Ethernet interface begin disconnected), it can create problems with the OSPF process. For this reason, it is always recommended to either configure a suitable IP address on a Loopback interface (virtual interface that is always ‘Up’) or manually configure the Router ID to something suitable for the OSPF network.
注意:路由器ID可以是名称、数字或IP地址。默认情况下,OSPF 会选择最高活动接口的 IP 地址作为路由器 ID。如果接口出现故障(例如,以太网接口开始断开连接),则可能会对 OSPF 进程产生问题。因此,始终建议在环回接口(始终处于“Up”状态的虚拟接口)上配置合适的 IP 地址,或手动将路由器 ID 配置为适合 OSPF 网络的 IP 地址。

Hello Parameters Match - Replying Hello messages Hello 参数匹配 - 回复 Hello 消息

When R2 receives the OSPF Hello message from R1 and all necessary Hello parameters match, R2 will send a Reply Hello packet back to R1.
当 R2 收到来自 R1 的 OSPF Hello 消息并且所有必要的 Hello 参数匹配时,R2 将向 R1 发送回 Reply Hello 数据包。

The Reply Hello allows the R1 (who sent the original Hello message) to investigate if the neighboring router R2 is listed in its neighbor list or not.
Reply Hello 允许 R1(发送原始 Hello 消息)调查相邻路由器 R2 是否列在其邻居列表中。

  • If the neighboring router R2 is listed as a neighbor already, then R1 resets its dead timer and the Reply Hello messages act as a Keep Alive mechanism.
    如果相邻路由器 R2 已作为邻居列出,则 R1 将重置其失效计时器,并且 Reply Hello 消息充当 Keep Alive 机制。

  • If the neighboring router R2 is not listed in R1’s neighbor database, it will add the newly discovered neighbor R2 router to its OSPF neighbor database. All further OSPF Hello and Hello Reply messages will act as a Keep Alive mechanism.
    如果相邻路由器 R2 未在 R1 的邻居数据库中列出,它会将新发现的邻居 R2 路由器添加到其 OSPF 邻居数据库中。所有其他 OSPF Hello 和 Hello Reply 消息将充当 Keep Alive 机制。

Establishing Master-Slave Relation 建立主从关系

When a neighbor relation is formed between two routers running OSPF, a hierarchy order of exchanging information must be established, which determines which router sends DataBase Descriptor (DBD) updates first (Master) while the other router (Slave) listens. Once the Master sends the DBD packets, the Slave follows by sending its DataBase Descriptor (DBD) packets next.
当两个运行 OSPF 的路由器之间形成邻居关系时,必须建立交换信息的层次结构顺序,该顺序决定了哪个路由器首先发送数据库描述符 (DBD) 更新(主路由器),而另一个路由器(从路由器)侦听。一旦主服务器发送 DBD 数据包,从服务器就会紧随其后发送其数据库描述符 (DBD) 数据包。

OSPF elects master router based on highest priority -which can be configured manually-, however if priority is not configured, OSPF will use the router ID as a reference.
OSPF 根据最高优先级选择主路由器(可以手动配置),但如果未配置优先级,OSPF 将使用路由器 ID 作为参考。

Note that the Designated Router (DR) is doesn’t have to be the master, it’s only a router priority based relation to arrange the exchanging data between neighbors but doesn’t affect the role of DR & BDR.
请注意,指定路由器(DR)不一定是主路由器,它只是基于路由器优先级的关系,用于安排邻居之间的交换数据,但不会影响DR和BDR的作用。

Exchanging DataBase Descriptor (DBD’s) - DBD Acknowledgement & Review 交换数据库描述符 (DBD) - DBD 确认和审查

OSPF neighbors follow a strict process of exchanging routing information and updates to prevent fault containment caused by updates flood, this process follows the order described below:
OSPF邻居遵循严格的路由信息和更新交换过程,以防止更新泛洪导致的故障控制,此过程遵循下述顺序:

ospf-adjacency-neighbor-forming-process-hello-packets-lsr-lsu-2

Figure 2. Steps 1 & 2: R1 sends a DBD Packet while R2 replies with a Link State Request (LSR)
图2.步骤 1 和 2:R1 发送 DBD 数据包,而 R2 回复链路状态请求 (LSR)

  1. Master sends DataBase Descriptor (DBD) update packet first.
  2. 主服务器首先发送数据库描述符 (DBD) 更新数据包。
  3. Slave checks DataBase Descriptor (DBD) and finds new routes information, it then requests updates by sending a Link State Request (LSR) packet.
  4. Slave 检查数据库描述符 (DBD) 并找到新的路由信息,然后通过发送链路状态请求 (LSR) 数据包来请求更新。

R1 replies with a Link State Update (LSU) and R2 Acknowledges with a LSAck

Figure 3. Steps 3 & 4. R1 replies with a Link State Update (LSU) and R2 Acknowledges with a LSAck
图3.步骤 3 和 4。R1 使用链路状态更新 (LSU) 进行回复,R2 使用 LSAck 进行确认

  1. Master sends back updates through Link State Updates (LSU) packets.
  2. 主服务器通过链路状态更新 (LSU) 数据包发回更新。
  3. Slave acknowledges the reception of updates by sending a Link State Acknowledge (LSAck) packet.
  4. Slave 通过发送链路状态确认 (LSAck) 数据包来确认接收更新。
  5. Slave sends DataBase Descriptor (DBD) update packet next.
  6. Slave 接下来发送数据库描述符 (DBD) 更新数据包。
  7. Master requests updates by sending a Link State Request (LSR) packet.
  8. 主服务器通过发送链路状态请求 (LSR) 数据包来请求更新。
  9. Slave sends updates through the Link State Update (LSU) packets.
  10. 从服务器通过链路状态更新 (LSU) 数据包发送更新。
  11. Master acknowledges receiving updates by sending a Link State Acknowledge (LSAck) packet.
  12. 主服务器通过发送链路状态确认 (LSAck) 数据包来确认接收更新。

There are no diagrams showing steps 5 to 8, however these are similar to the first 4 steps, but with the Master router requesting the Link State Request (LSR).
没有显示步骤 5 到 8 的图表,但这些步骤与前 4 个步骤类似,但主路由器请求链路状态请求 (LSR)。

This article explained how OSPF routers build neighbor relationships and adjacencies. We saw the OSPF neighbor discovering process via OSPF Hello packets and the role of Link State Requests (LSR) and Link State Updates (LSU). We also examined the contents of OSPF Hello packets and which fields are necessary to ensure an OSPF adjacency is formed. Finally, we saw how OSPF routers exchange information and update their database via DataBase Descriptor (DBD) packets.
本文介绍了 OSPF 路由器如何建立邻居关系和邻接关系。我们看到 OSPF 邻居通过 OSPF Hello 数据包发现进程,以及链路状态请求 (LSR) 和链路状态更新 (LSU) 的角色。我们还检查了 OSPF Hello 数据包的内容,以及哪些字段是确保形成 OSPF 邻接关系所必需的。最后,我们了解了 OSPF 路由器如何通过数据库描述符 (DBD) 数据包交换信息并更新其数据库。


OSPF - Part 4: OSPF Neighbor States – OSPF Neighbor Forming Process OSPF - 第 4 部分:OSPF 邻居状态 – OSPF 邻居形成过程

Article Reads:143387

This is the third article of our OSPF series which analyzes the different OSPF States routers go through during the OSPF discovery and neighbor forming process. We analyze OSPF states (Init state, 2-way state, Exstart state, Exchange state, Loading state Full state, Down state), LSA Hello messages and more.
这是我们 OSPF 系列的第三篇文章,该系列分析了路由器在 OSPF 发现和邻居形成过程中经历的不同 OSPF 状态。我们分析 OSPF 状态(Init 状态、2 路状态、Exstart 状态、Exchange 状态、加载状态、Full 状态、Down 状态)、LSA Hello 消息等。

OSPF Neighbor States OSPF 邻国

When OSPF forms adjacency with neighbors, the connection goes through several states before the routers are fully adjacent with each other, this section describes each state in detail. Following are the OSPF States we’ll be examining:
当OSPF与邻居形成邻接关系时,连接会经历多种状态,然后路由器才会完全相邻,本节将对每种状态进行详细介绍。以下是我们将要检查的 OSPF 状态:

  • Down state 关闭状态
  • Attempt state 尝试状态
  • Init state 初始化状态
  • 2-Way state 2 路状态
  • Exstart state Exstart 状态
  • Exchange state 交换状态
  • Loading state 加载状态
  • Full state 完整状态

The diagram below shows the different states OSPF routers will go through when discovering their OSPF neighbors:
下图显示了 OSPF 路由器在发现其 OSPF 邻居时将经历的不同状态:

ospf-adjacency-neighbor-states-forming-process-1

Figure 1. OSPF Neighbor States & OSPF Neighbor Forming Process
图 1.OSPF 邻域状态和 OSPF 邻域形成过程

Down State 关闭状态

The Down State is the first OSPF neighbor state and means no Hello packets have been received from a neighbor. In an already established OSPF adjacency, an OSPF state will transition from a FULL or 2-Way State to the Down State when the router Dead Interval Timer expires (4 x Hello Interval timer), which means OSPF has lost communication with its neighbor and is now considered non-reachable or dead.
Down State 是第一个 OSPF 邻居状态,表示未从邻居收到 Hello 数据包。在已建立的 OSPF 邻接关系中,当路由器 Dead Interval Timer 过期 (4 x Hello Interval Timer) 时,OSPF 状态将从 FULL 或 2 向状态转换为 Down 状态,这意味着 OSPF 已失去与其邻居的通信,现在被视为无法访问或死机。

This is a special state used only for manually configured neighbors in a Non-Broadcast MultiAccess (NBMA) network, it indicates that the router is sending Hello packets to its neighbor in a Non-Broadcast MultiAccess (NBMA) environment via unicast but no reply is received within the Dead Interval (4 x Hello Interval).
这是一种特殊状态,仅用于非广播多接入 (NBMA) 网络中手动配置的邻居,它表示路由器正在通过单播向非广播多接入 (NBMA) 环境中的邻居发送 Hello 数据包,但在死区间隔(4 x Hello 间隔)内未收到应答。

An example of an NBMA network is a Frame Relay network where there are no intrinsic broadcast and multicast capabilities.
NBMA 网络的一个示例是帧中继网络,其中没有固有的广播和组播功能。

2-Way State 2 路状态

This state indicates that a Hello packet was received from a neighbor router but the receiving Router’s ID wasn’t listed in the Hello packet. When a router receives a Hello packet from a neighbor, it should list the sender’s Router ID as an acknowledgment that it previously received a valid Hello packet.
此状态表示已从邻居路由器收到 Hello 数据包,但接收路由器的 ID 未在 Hello 数据包中列出。当路由器收到来自邻居的 Hello 数据包时,它应列出发送方的路由器 ID 作为确认它之前收到过有效的 Hello 数据包。

This state describes the Bi-Directional communication state, Bi- Directional means that each router has received the other’s Hello packet and that each router can see its own Router ID included within the Hello packet’s neighbor field.
此状态描述了双向通信状态,双向意味着每个路由器都收到了另一个路由器的 Hello 数据包,并且每个路由器都可以在 Hello 数据包的邻居字段中看到自己的路由器 ID。

On broadcast media (e.g LAN) and Non-Broadcast MultiAccess (NBMA) networks (e.g Frame Relay, ATM, X.25), a router becomes full state (analyzed below) only with the Designated Router (DR) and the Backup Designated Router (BDR). It will, however, stay in the 2-way state with all other neighbors.
在广播媒体(例如LAN)和非广播多址(NBMA)网络(例如帧中继,ATM,X.25)上,路由器仅在指定路由器(DR)和备份指定路由器(BDR)的情况下变为全状态(如下所述)。但是,它将与所有其他邻居保持 2 向状态。

When the 2-Way state is complete, the DR and DBR routers are elected, considering they are on a broadcast or NBMA network.
当 2-Way 状态完成时,考虑到 DR 和 DBR 路由器位于广播或 NBMA 网络上,则会选择它们。

Exstart State Exstart 状态

This state specifies that DR and BDR have been elected and master-slave relation is determined. An initial sequence number for adjacency formation is also selected. The router with the highest router ID becomes the master and begins to exchange Link State data. Only the Master router is able to increment the sequence number.
此状态指定已选择 DR 和 BDR,并确定了主从关系。此外,还选择了用于邻接关系形成的初始序列号。具有最高路由器 ID 的路由器成为主路由器,并开始交换链路状态数据。只有主路由器才能增加序列号。

Exchange State 交换状态

In this state, OSPF routers exchange DataBase Descriptor (DBD) packets. These contain Link State Advertisement (LSA) headers describing the content of the entire Link State Database (LSD). The contents of the DataBase Descriptor (DBD) received by the router are compared with its own Link State Database (LSD) to check if changes or additional link-state information is available from its neighbor.
在此状态下,OSPF 路由器交换数据库描述符 (DBD) 数据包。它们包含链接状态通告 (LSA) 标头,用于描述整个链接状态数据库 (LSD) 的内容。将路由器接收的数据库描述符 (DBD) 的内容与其自己的链路状态数据库 (LSD) 进行比较,以检查其邻居是否提供更改或其他链路状态信息。

Loading State 加载状态

In this state, routers exchange full Link State information based on DataBase Descriptor (DBD) provided by neighbors, the OSPF router sends Link State Request (LSR) and receives Link State Update (LSU) containing all Link State Advertisements (LSAs).
在此状态下,路由器根据邻居提供的数据库描述符 (DBD) 交换完整的链路状态信息,OSPF 路由器发送链路状态请求 (LSR) 并接收包含所有链路状态通告 (LSA) 的链路状态更新 (LSU)。

Link State Updates (LSU) actually act as an envelope that contains all the Link State Advertisements (LSAs) – that have been sent to neighbors with new changes or new networks learned.
链路状态更新 (LSU) 实际上充当一个信封,其中包含所有链路状态广告 (LSA) – 这些广告已发送给具有新更改或学习新网络的邻居。

Full State 完整状态

Full state is the normal operating state of OSPF that indicates everything is functioning normally. In this state, routers are fully adjacent with each other and all the router and network Link State Advertisements (LSAs) are exchanged and the routers’ databases are fully synchronized.
完全状态是 OSPF 的正常运行状态,表明一切正常。在这种状态下,路由器彼此完全相邻,并且所有路由器和网络链路状态通告 (LSA) 都会交换,并且路由器的数据库会完全同步。

For Broadcast and NBMA media, routers will achieve the Full State with their DR and BDR router only, while for Point-to-point and Point-to-multipoint networks a router should be in the Full State with every neighboring router.
对于广播和 NBMA 媒体,路由器将仅通过其 DR 和 BDR 路由器实现完整状态,而对于点对点和点对多点网络,路由器应与每个相邻路由器一起处于完整状态。

This article analyzed the states OSPF routers go through during OSPF neighbor discovery and adjacency process. We examined in detail each OSPF State including: Down state, Attempt state, Init state, 2-way state, Exstart state, Exchange state, Loading state and Full state.
本文分析了OSPF路由器在OSPF邻居发现和邻接过程中所经历的状态。我们详细检查了每个 OSPF 状态,包括:关闭状态、尝试状态、初始化状态、2 向状态、Exstart 状态、Exchange 状态、加载状态和完全状态。


OSPF - Part 5: Analysis of OSPF Link State Update (LSU) - Link State Advertisement (LSA) Packet Structure. Common LSA Types OSPF - 第 5 部分:OSPF 链路状态更新 (LSU) 分析 - 链路状态通告 (LSA) 数据包结构。常见的 LSA 类型

Article Reads:67524

This article explains how OSPF uses Link State Advertisement (LSA) to exchange information about the network topology between routers. When a router receives an LSA, it is stored in the Link-State DataBase (LSDB). Once the LSDBs between routers are in sync, OSPF uses the Shortest Path First (SPF) algorithm to calculate the best routes for each network. It is important to understand that LSAs are information about a route that is transported inside Link State Update (LSU) packets.
本文介绍 OSPF 如何使用链路状态通告 (LSA) 在路由器之间交换有关网络拓扑的信息。当路由器收到 LSA 时,它将存储在链路状态数据库 (LSDB) 中。一旦路由器之间的LSDB同步,OSPF就会使用最短路径优先(SPF)算法来计算每个网络的最佳路由。请务必了解 LSA 是在链路状态更新 (LSU) 数据包内传输的路由的相关信息。

Each single Link State Update (LSU) packet can contain one or more LSAs inside it and when an LSU is sent between OSPF routers, it floods the LSA information through the network.
每个链路状态更新 (LSU) 数据包内部都可以包含一个或多个 LSA,当在 OSPF 路由器之间发送 LSU 时,它会通过网络泛洪 LSA 信息。

It is very important for any network engineer to understand how LSAs are contained within an LSU. We’ll use the example below, where an OSPF router sends an LSU to the OSPF Designated Router (DR) containing LSA information about a new network:
对于任何网络工程师来说,了解 LSA 如何包含在 LSU 中都非常重要。我们将使用以下示例,其中 OSPF 路由器将 LSU 发送到 OSPF 指定路由器 (DR),其中包含有关新网络的 LSA 信息:

OSPF Link State Update (LSU) packet containing a Link State Advertisement (LSA)

Figure 1. OSPF Link State Multicast Update (LSU) packet containing a Link State Advertisement (LSA)
图 1.包含链路状态通告 (LSA) 的 OSPF 链路状态组播更新 (LSU) 数据包

As shown above, LSAs are contained within LSUs, which are all part of an OSPF packet encapsulated within an Ethernet frame (assuming an Ethernet network).
如上所示,LSA 包含在 LSU 中,LSU 都是封装在以太网帧(假设是以太网网络)中的 OSPF 数据包的一部分。

Our diagram of the LSU/LSA packet structure is confirmed by capturing an OSPF Ethernet frame below. We’ve highlighted each section (LSA, LSU, OSPF Header) using the same colors:
我们的 LSU/LSA 数据包结构图通过捕获下面的 OSPF 以太网帧来确认。我们使用相同的颜色突出显示了每个部分(LSA、LSU、OSPF 标题):

OSPF Link State Update and List State Advertisement within an Ethernet frame

Figure 2. OSPF Link State Update and List State Advertisement within an Ethernet frame
图2.以太网帧内的 OSPF 链路状态更新和列表状态通告

Notice that the destination IP address is multicast address 224.0.0.6, as expected since routers send updates to the Designated Router (DR) using this multicast address. This is also analyzed under the Working Inside a Single Area section in our article How OSPF Protocol Works & Basic Concepts: OSPF Neighbor, Topology & Routing Table, OSPF Areas & Router Roles, Theory & Overview
请注意,目标 IP 地址是组播地址 224.0.0.6,正如预期的那样,因为路由器使用此组播地址向指定路由器 (DR) 发送更新。在我们的文章《OSPF协议的工作原理和基本概念:OSPF邻居、拓扑和路由表、OSPF区域和路由器角色、理论和概述》一文的“在单个区域内工作”部分也对此进行了分析

Most Popular OSPF LSA Types 最受欢迎的 OSPF LSA 类型

OSPF currently defines 11 different LSA types, however, despite the large variety of LSAs only around half of them are commonly found in OSPF networks. Table 1 below shows the most popular LSA types, the type of OSPF routers (DR, ABR, ASBR etc) that generate them along with their function and the OSPF areas they affect:
OSPF 目前定义了 11 种不同的 LSA 类型,然而,尽管 LSA 种类繁多,但只有大约一半的 LSA 在 OSPF 网络中常见。下表 1 显示了最受欢迎的 LSA 类型、生成它们的 OSPF 路由器类型(DR、ABR、ASBR 等)及其功能以及它们影响的 OSPF 区域:

LSAGenerated by 生成者Function 功能Flooding Map 洪水地图
Type 1 类型 1Normal Area Routers 普通区域路由器Advertising router’s interface and status to neighbors 广告路由器的接口 和邻居的地位Intra-Area (Area of origin) 区域内 (原产地)
Type 2 类型 2DRAdvertising DRs direct connected neighbors 广告 DR 直接 连接的邻居Intra-Area (Area of origin) 区域内 (原产地)
Type 3 类型 3ABRAdvertising ABRs areas summary ABRs 区域广告 总结Inter-Area (Multiple Areas) 区域间 (多个领域)
Type 4 类型 4ABRAdvertising the presence of ASBRs 广告存在 ASBRs的数量Inter-Area (Multiple Areas) 区域间 (多个领域)
Type 5 类型 5ASBRAdvertising external routes to internet 播发外部路由 到互联网Inter-Area (Multiple Areas) 区域间 (多个领域)
Type 7 类型 7ASBRAdvertising external routes to internet to NSSA areas 播发外部路由 到互联网到 NSSA 区域Inter-Area (Multiple Areas) 区域间 (多个领域)

Table 1. Most often used LSA Types, router origin type, their function and Areas affected
表 1.最常用的 LSA 类型、路由器源类型、其功能和受影响的区域

Looking at the OSPF packet captured with our network analyzer, we can now understand that the specific LSA was a Type-3 LSA (LS Type: Summary-LSA IP network 3) which means it was generated by an ABR OSPF router.
查看使用我们的网络分析器捕获的 OSPF 数据包,我们现在可以理解特定的 LSA 是 Type-3 LSA(LS Type:Summary-LSA IP network 3),这意味着它是由 ABR OSPF 路由器生成的。

Link State Advertisement (LSA) Packet Structure (Within a Link State Update - LSU) 链路状态通告 (LSA) 数据包结构(在链路状态更新 - LSU 中)

Each LSA packet consists of a header and a body that contains all the information needed to exchange network information within an OSPF network. The diagram below shows the structure of an OSPF LSA packet:
每个 LSA 数据包都由一个标头和一个正文组成,其中包含在 OSPF 网络内交换网络信息所需的所有信息。下图显示了 OSPF LSA 数据包的结构:

OSPF LSA Packet structure and fields

Figure 3. OSPF LSA Packet structure and fields
图3.OSPF LSA 数据包结构和字段

The LSA header is a 20 byte (32x5 = 160 bits) section that consists of the following fields:
LSA 标头是一个 20 字节 (32x5 = 160 位) 部分,由以下字段组成:

  • LS Age (2 Bytes): Time passed since the LSA was generated (in seconds).
    LS Age(2 字节):自 LSA 生成以来经过的时间(以秒为单位)。

  • Options (1 Byte): Indicates the OSPF features and options the origin can support.
    选项(1 字节):表示源可以支持的 OSPF 功能和选项。

  • LS Type (1 Byte): Defines the LSA type (all types will be explained later).
    LS 类型(1 字节):定义 LSA 类型(所有类型将在后面解释)。

  • Link State ID (4 Bytes): Identifies the network link between OSPF routers (usually IP address).
    链路状态 ID(4 字节):标识 OSPF 路由器之间的网络链路(通常是 IP 地址)。

  • Advertising Router (4 Bytes): Indicates the origin router’s ID.
    Advertising Router(4 字节):表示源路由器的 ID。

  • LS Sequence Number (4 Bytes): A specific digit on each LSA packet to filter old and repeated
    LS 序列号(4 字节):每个 LSA 数据包上的特定数字,用于过滤旧的和重复的

  • LS Checksum (2 Bytes): A certain digit given to LS to compare and detect errors.
    LS 校验和(2 个字节):提供给 LS 的某个数字,用于比较和检测错误。

  • Length (2 Bytes): Represents LSA packet length.
    长度(2 个字节):表示 LSA 数据包长度。

The LSA body varies in size according to the LS type and the details it identifies, LSA types are explained in great detail in our upcoming article.
LSA 主体的大小根据 LS 类型及其识别的详细信息而变化,我们即将发表的文章中将详细解释 LSA 类型。

This article explained OSPF Link State Update (LSA) packets and showed how they contain Link State Advertisements (LSAs). We also analyzed OSPF LSU & LSAs packet structure and explained each field in an OSPF LSA packet. Finally, we spoke about the most common LSA Types, router origin type (ABR, ASBR, DR etc), their function and Areas affected.
本文介绍了 OSPF 链路状态更新 (LSA) 数据包,并展示了它们如何包含链路状态播发 (LSA)。我们还分析了OSPF LSU和LSAs数据包结构,并解释了OSPF LSA数据包中的每个字段。最后,我们谈到了最常见的LSA类型,路由器原始类型(ABR,ASBR,DR等),它们的功能和受影响的区域。


OSPF - Part 6: OSPF LSA Types - Purpose and Function of Every OSPF LSA OSPF - 第 6 部分:OSPF LSA 类型 - 每个 OSPF LSA 的用途和功能

Our previous article explained the purpose of Link State Update (LSU) packets and examined the Link State Advertisement (LSA) information contained within LSU packets. We also saw the most common LSA packets found in OSPF networks. In this article we’ll be diving deeper to analyse all eleven OSPF LSA Types using network network diagrams and examples to help understand when each LSA type is used and how they keep the OSPF network updated.
我们之前的文章介绍了链路状态更新 (LSU) 数据包的用途,并检查了 LSU 数据包中包含的链路状态通告 (LSA) 信息。我们还看到了在 OSPF 网络中发现的最常见的 LSA 数据包。在本文中,我们将使用网络图和示例更深入地分析所有 11 种 OSPF LSA 类型,以帮助理解何时使用每种 LSA 类型以及它们如何保持 OSPF 网络更新。

LSA Types - Quick Overview LSA 类型 - 快速概述

Before we begin, let’s take a quick look at the different type of OSPF LSA packets we’ll cover:
在开始之前,让我们快速了解一下我们将介绍的不同类型的 OSPF LSA 数据包:

  • LSA Type 1: OSPF Router LSA
    LSA 类型 1:OSPF 路由器 LSA
  • LSA Type 2: OSPF Network LSA
    LSA 类型 2:OSPF 网络 LSA
  • LSA Type 3: OSPF Summary LSA
    LSA 类型 3:OSPF 摘要 LSA
  • LSA Type 4: OSPF ASBR Summary LSA
    LSA 类型 4:OSPF ASBR 摘要 LSA
  • LSA Type 5: OSPF ASBR External LSA
    LSA 类型 5:OSPF ASBR 外部 LSA
  • LSA Type 6: OSPF Group Membership LSA
    LSA 类型 6:OSPF 组成员资格 LSA
  • LSA Type 7: OSPF Not So Stubby Area (NSSA) External LSA
    LSA 类型 7:OSPF 不那么短的区域 (NSSA) 外部 LSA
  • LSA Type 8: OSPF External Attributes LSA (OSPFv2) / Link Local LSA (OSPFv3)
    LSA 类型 8:OSPF 外部属性 LSA (OSPFv2) / 链路本地 LSA (OSPFv3)
  • LSA Type 9: OSPF Link Scope Opaque (OSPFv2) / Intra Area Prefix LSA (OSPFv3)
    LSA 类型 9:OSPF 链路范围不透明 (OSPFv2) / 区域内前缀 LSA (OSPFv3)
  • LSA Type 10: OSPF Area Scope Opaque LSA
    LSA 类型 10:OSPF 区域范围不透明 LSA
  • LSA Type 11:OSPF AS (Autonomous System) Scope Opaque LSA
    LSA 类型 11:OSPF AS(自治系统)范围不透明 LSA

The LSA payload varies in size according to the LSA type and the information it includes. The diagram below clearly shows how LSAs are contained within LSUs:
LSA 有效负载的大小根据 LSA 类型及其包含的信息而变化。下图清楚地显示了 LSA 是如何包含在 LSU 中的:

OSPF LSA Types

Figure 1. LSA Types contained within an OSPF LSU packet
图 1.OSPF LSU 数据包中包含的 LSA 类型

As mentioned, OSPF currently supports 11 types of LSAs. Each LSA is used within specific boundaries of an OSPF network.
如前所述,OSPF 目前支持 11 种类型的 LSA。每个 LSA 都在 OSPF 网络的特定边界内使用。

OSPF concepts, including router roles such as Designated Router (DR), Area Border Router (ABR), Autonomous System Border Router (ASBR), OSPF Areas and more, are analyzed in great depth in our article OSPF Basic Concepts – OSPF Areas – Router Roles. This article assumes the reader has a good understanding of basic OSPF theory and is comfortable with OSPF concepts.
OSPF 概念,包括指定路由器 (DR)、区域边界路由器 (ABR)、自治系统边界路由器 (ASBR)、OSPF 区域等路由器角色,在我们的文章 OSPF 基本概念 – OSPF 区域 – 路由器角色中进行了深入分析。本文假设读者对基本的 OSPF 理论有很好的理解,并且对 OSPF 概念熟悉。

LSA Type 1 – OSPF Router LSA LSA 类型 1 – OSPF 路由器 LSA

LSA Type 1 (Router LSA) packets are sent between routers within the same area of origin and do not leave the area. An OSPF router uses LSA Type 1 packets to describe its own interfaces but also carries information about its neighbors to adjacent routers in the same area.
LSA 类型 1(路由器 LSA)数据包在同一源区域内的路由器之间发送,不会离开该区域。OSPF 路由器使用 LSA Type 1 数据包来描述其自己的接口,但也将其邻居的信息传送到同一区域中的相邻路由器。

LSA Type 1 Packets exchanged between OSPF routers within the same area

Figure 2. LSA Type 1 Packets exchanged between OSPF routers within the same area
图2.在同一区域内的 OSPF 路由器之间交换的 LSA Type 1 数据包

LSA Type 2 – OSPF Network LSA LSA 类型 2 – OSPF 网络 LSA

LSA Type 2 (Network LSA) packets are generated by the Designated Router (DR) to describe all routers connected to its segment directly. LSA Type 2 packets are flooded between neighbors in the same area of origin and remain within that area.
LSA 类型 2(网络 LSA)数据包由指定路由器 (DR) 生成,用于描述直接连接到其分段的所有路由器。LSA Type 2 数据包在同一源区域的邻居之间泛洪,并保持在该区域内。

LSA Type 2 Packets exchanged between OSPF DR and neighbor routers

Figure 3. LSA Type 2 Packets exchanged between OSPF DR and neighbor routers
图3.OSPF DR 和邻居路由器之间交换的 LSA Type 2 数据包

LSA Type 3 – OSPF Summary LSA LSA 类型 3 – OSPF 摘要 LSA

LSA Type 3 (Summary LSA) packets are generated by Area Border Routers (ABR) to summarize its directly connected area, and advertise inter-area router information to other areas the ABR is connected to, with the use of a summary prefix (e.g 192.168.0.0/22). LSA Type 3 packets are flooded to multiple areas throughout the network and help with OSPF’s scalability with the use of summary prefixes.
LSA Type 3 (Summary LSA) 数据包由区域边界路由器 (ABR) 生成,用于汇总其直接连接的区域,并使用摘要前缀(例如 192.168.0.0/22)将区域间路由器信息通告到 ABR 连接到的其他区域。LSA Type 3 数据包被泛洪到整个网络的多个区域,并通过使用摘要前缀来帮助实现 OSPF 的可扩展性。

LSA Type 3 - An OSPF ABR router advertises the summarized route 192.168.2.0/24 to Area 0

Figure 4. LSA Type 3 - An OSPF ABR router advertises the summarized route 192.168.2.0/24 to Area 0
图4.LSA 类型 3 — OSPF ABR 路由器将汇总路由 192.168.2.0/24 通告到区域 0

Looking at the diagram above, ABR router R2 creates a Type 3 Summary LSA and floods it into Area 0. In a similar way, ABR router R3 creates a Type 3 Summary LSA and floods it into Area 2. Type 3 Summary LSAs appear as O IA entries in the router routing table.
如上图所示,ABR 路由器 R2 创建一个 Type 3 Summary LSA 并将其泛洪到区域 0。以类似的方式,ABR 路由器 R3 创建 Type 3 Summary LSA 并将其泛洪到区域 2。类型 3 摘要 LSA 在路由器路由表中显示为 O IA 条目。

LSA Type 4 – OSPF ASBR Summary LSA LSA 类型 4 – OSPF ASBR 摘要 LSA

LSA Type 4 (ASBR Summary LSA) packets are the LSAs that advertise the presence of an Autonomous System Border Router (ASBR) to other areas. In the example below when R2 (ABR) receives the LSA Type 1 packet from R1 it will create a LSA Type 4 (Summary ASBR LSA) packet, which advertises the ASBR route received from Area 1, and inject it into Area 0.
LSA 类型 4(ASBR 摘要 LSA)数据包是向其他区域通告自治系统边界路由器 (ASBR) 存在的 LSA。在下面的示例中,当 R2 (ABR) 从 R1 接收到 LSA Type 1 数据包时,它将创建一个 LSA Type 4 (Summary ASBR LSA) 数据包,该数据包通告从区域 1 接收的 ASBR 路由,并将其注入区域 0。

LSA Type 4 packets injected into Area 0 & 2 by the R2 ABR and R3 ABR

Figure 5. LSA Type 4 packets injected into Area 0 & 2 by the R2 ABR and R3 ABR
图5.LSA Type 4 数据包由 R2 ABR 和 R3 ABR 注入区域 0 和 2

While LSA Type 4 packets are used by ABRs to advertise the ASBR route through their areas, it will not be used by the ASBR itself within its local area (Area 1); ASBR uses LSA Type 1 to inform its neighbors (R2 in this case) within its networks.
虽然 ABR 使用 LSA Type 4 数据包在其区域内通告 ASBR 路由,但 ASBR 本身不会在其本地区域(区域 1)内使用它;ASBR 使用 LSA Type 1 通知其网络内的邻居(在本例中为 R2)。

LSA Type 5 – OSPF ASBR External LSA LSA 类型 5 – OSPF ASBR 外部 LSA

LSA Type 5 (ASBR External LSA) packets are generated by the ASBR to advertise external redistributed routes into the OSPF’s AS. A typical example of an LSA Type 5 would be an external prefix e.g 192.168.10.0/24 or default route (internet) as shown below:
LSA 类型 5(ASBR 外部 LSA)数据包由 ASBR 生成,用于将外部重新分发的路由通告到 OSPF 的 AS 中。LSA 类型 5 的典型示例是外部前缀,例如 192.168.10.0/24 或默认路由 (internet),如下所示:

LSA Type 5 packets advertise the default route to all OSPF routersFigure 6. LSA Type 5 packets advertise the default route to all OSPF routers
图6.LSA Type 5 数据包将默认路由通告到所有 OSPF 路由器

This external route/prefix is redistributed in to the OSPF network by the ASBR (R1) and seen as O E1 or E2 entries in other OSPF routers routing tables.
此外部路由/前缀由 ASBR (R1) 重新分发到 OSPF 网络中,并在其他 OSPF 路由器路由表中被视为 O E1 或 E2 条目。

LSA Type 6 – OSPF Group Membership LSA LSA 类型 6 – OSPF 组成员资格 LSA

LSA Type 6 (Group Membership LSA) packets were designed for Multicast OSPF (MOSPF), a protocol that supports multicast routing through OSPF. MOSPF is not supported by Cisco and is not widely used and is expected to be retired soon.
LSA 类型 6(组成员身份 LSA)数据包专为组播 OSPF (MOSPF) 而设计,MOSPF 是一种支持通过 OSPF 进行组播路由的协议。MOSPF 不受 Cisco 支持,未被广泛使用,预计很快就会退役。

LSA Type 7 – OSPF Not So Stubby Area (NSSA) External LSA LSA 类型 7 – OSPF 不那么短的区域 (NSSA) 外部 LSA

LSA Type 7 (NSSA External LSA) packets are used for some special area types that do not allow external distributed routes to go through and thus block LSA Type 5 packets from flooding through them, LSA Type 7 packets act as a mask for LSA Type 5 packets to allow them to move through these special areas and reach the ABR that is able to translate LSA Type 7 packets back to LSA Type 5 packets.
LSA Type 7 (NSSA External LSA) 数据包用于一些特殊区域类型,这些类型不允许外部分布式路由通过,从而阻止 LSA Type 5 数据包通过它们泛洪,LSA Type 7 数据包充当 LSA Type 5 数据包的掩码,允许它们穿过这些特殊区域并到达能够将 LSA Type 7 数据包转换回 LSA Type 5 的 ABR包。

LSA Type 7 packets passing through an NSSA and being transformed into LSA Type 5 by the ABR

Figure 7. LSA Type 7 packets passing through an NSSA and being transformed into LSA Type 5 by the ABR
图7.LSA Type 7 数据包通过 NSSA 并由 ABR 转换为 LSA Type 5

In the above example, ABR R2 translates *LSA* Type 7 into a LSA Type 5 and floods it into the OSPF network.
在上面的示例中,ABR R2 将 LSA Type 7 转换为 LSA Type 5,并将其泛洪到 OSPF 网络中。

LSA Type 8 - OSPF External Attributes LSA (OSPFv2) / Link Local LSA (OSPFv3) LSA 类型 8 - OSPF 外部属性 LSA (OSPFv2) / 链路本地 LSA (OSPFv3)

LSA Type 8 packets (External Attributes LSA -OSPFv2-/ Link Local LSA -OSPFv3-) in OSPFv2 (IPv4) are called External Attribute LSAs, and are used to transit BGP attributes through an OSPF network while BGP destinations are conveyed via LSA Type 5 packets, however, this feature isn’t supported by most routers. With OSPFv3 IPv6), LSA Type 8 is redefined to carry IPv6 information through OSPF network.
OSPFv2 (IPv4) 中的 LSA Type 8 数据包(外部属性 LSA -OSPFv2-/ Link Local LSA -OSPFv3-)称为外部属性 LSA,用于通过 OSPF 网络传输 BGP 属性,而 BGP 目标通过 LSA Type 5 数据包传输,但是,大多数路由器不支持此功能。在OSPFv3 IPv6中),LSA Type 8被重新定义为通过OSPF网络传输IPv6信息。

LSA Type 9, 10 & 11 LSA 类型 9、10 和 11

Generally Opaque LSAs (LSA Type 9, 10 & 11) are used to extend the capabilities of OSPF allowing the protocol to carry information OSPF doesn’t necessarily care about. Practical application of Opaque LSAs is in MPLS traffic engineering where they are used to communicate interface parameters such as maximum bandwidth, unreserved bandwidth, etc. Following is a short analysis of each of the three Opaque LSAs.
通常,不透明的LSA(LSA Type 9、10和11)用于扩展OSPF的功能,允许协议携带OSPF不一定关心的信息。不透明 LSA 的实际应用是在 MPLS 流量工程中,它们用于通信接口参数,例如最大带宽、未预留带宽等。以下是对三个不透明 LSA 中的每一个的简短分析。

LSA Type 9 – OSPF Link Scope Opaque (OSPFv2) / Intra Area Prefix LSA (OSPFv3) LSA 类型 9 – OSPF 链路范围不透明 (OSPFv2) / 区域内前缀 LSA (OSPFv3)

LSA Type 9 in OSPFv2 (IPv4) is defined as a Link Scope Opaque LSA for carrying OSPF information. For OSPFv3 it’s redefined to handle a communication prefix for a special area type called Stub Area.
OSPFv2 (IPv4) 中的 LSA 类型 9 被定义为用于传输 OSPF 信息的链路范围不透明 LSA。对于 OSPFv3,它被重新定义以处理称为存根区域的特殊区域类型的通信前缀。

LSA Type 10 – OSPF Area Scope Opaque LSA LSA 类型 10 – OSPF 区域范围不透明 LSA

LSA Type 10 packets are used to flood OSPF information through other area routers even if these routers do not process this information in order to extend OSPF functionality, this LSA is used for traffic engineering to advertise MPLS and other protocols.
LSA Type 10 数据包用于通过其他区域路由器泛洪 OSPF 信息,即使这些路由器不处理此信息以扩展 OSPF 功能,此 LSA 也用于流量工程以通告 MPLS 和其他协议。

LSA Type 11 – OSPF AS Scope Opaque LSA LSA 类型 11 – OSPF AS 示波器不透明 LSA

LSA Type 11 packets serve the same purpose as LSA Type 10 packets but are not flooded into special area types (Stub areas).
LSA Type 11 数据包与 LSA Type 10 数据包具有相同的用途,但不会泛洪到特殊区域类型(存根区域)中。

Summary 总结

In this article we examined all 11 OSPF LSA packet types and explained their purposes. We also examined the structure of an LSA packet and used network diagrams to help illustrate how LSA packets flow between routers & OSPF Areas. (https://www.firewall.cx/networking/routing-protocols/routing-protocol-ospf.html).
在本文中,我们检查了所有 11 种 OSPF LSA 数据包类型,并解释了它们的用途。我们还检查了LSA数据包的结构,并使用网络图来帮助说明LSA数据包如何在路由器和OSPF区域之间流动。


via:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值