ospf报文

ospf头部

Open Shortest Path First
    OSPF Header
        Version: 2
        Message Type: Hello Packet (1)
        Packet Length: 48
        Source OSPF Router: 3.3.3.3
        Area ID: 0.0.0.0 (Backbone)
        Checksum: 0xf290 [correct]
        Auth Type: Null (0)
        Auth Data (none): 0000000000000000
字段 长度 字段说明
Version 8bit IPv4使用ospfv2,IPv6使用ospfv3
Message Type 8bit Hello packet为1,DD报文为2,LSR报文为3,LSU报文为4,LSack报文为5
Packet Length 16bit ospf报文长度
Source OSPF Router 32bit 路由器的router-id
Area ID 32bit 区域ID
Checksum 16bit 校验和
Auth Type 16bit 认证类型,Null表示无认证,支持md5等认证方式
Auth Data 64bit 加密后的认证密钥

LSA头部

    .000 0000 0000 0001 = LS Age (seconds): 1
    0... .... .... .... = Do Not Age Flag: 0
    Options: 0x02, (E) External Routing
        0... .... = DN: Not set
        .0.. .... = O: Not set
        ..0. .... = (DC) Demand Circuits: Not supported
        ...0 .... = (L) LLS Data block: Not Present
        .... 0... = (N) NSSA: Not supported
        .... .0.. = (MC) Multicast: Not capable
        .... ..1. = (E) External Routing: Capable
        .... ...0 = (MT) Multi-Topology Routing: No
    LS Type: Router-LSA (1)
    Link State ID: 2.2.2.2
    Advertising Router: 2.2.2.2
    Sequence Number: 0x8000000c
    Checksum: 0x37b1
    Length: 48
字段 字段说明
LS Age 16bit,LSA产生后所经过的时间,以s为单位。(最大3600s,超过3600秒后LSA老化)
Do Not Age Flag LSA不老化标志位,该置于1,则表示该LSA不老化,此情况只在DC(虚电路)中应用。
Options 8bit,每位表示不同的意思。DN位,为MPLS/VPN所用,DC-虚电路,E-外部路由,路由器告诉其它路由器自己的支持哪些哪些能力。
LS Type LSA的类型
Link State ID LS ID,在不同的LSA type中表示不同的意思。
Advertising Router LSA的通告路由器
Sequence Number 32bit,LSA的序列号,数值越大,表示LSA越新,若seq相同,checksum越大,表示LSA越新。
Checksum LSA的校验和
Length LSA的总长度,包括LSA头部
  • Normal/Backbone区域 options字段E位 置1,stub、NSSA区域 options字段E位 置0。

  • LSA type、adv router、LS id 三个字段可以用来标识唯一的LSA。

hello报文

    OSPF Hello Packet
        Network Mask: 255.255.255.0
        Hello Interval [sec]: 10
        Options: 0x02, (E) External Routing
        Router Priority: 1
        Router Dead Interval [sec]: 40
        Designated Router: 23.1.1.3
        Backup Designated Router: 23.1.1.2
        Active Neighbor: 3.3.3.3
字段 字段说明
Network Mask 发送hello报文的接口掩码
Hello Interval 发送hello报文时间间隔,在BMA网络和P2P网络中默认10s发送一次hello报文,在NBMA和P2MP网络中每30s发送一次hello报文。
Options 同LSA头部中option字段一致
Router Priority DR优先级,默认为1,如果为0则表示不参与DR的选举。
Dead Interval ospf邻居超时的时间,BMA网络、P2P网络默认40s,hello时间的4倍,修改hello时间,dead时间默认自动更新成hello*4,而修改dead时间,hello时间不会改变。
Designated Router 本链路上(网段)上DR路由器的接口IP地址
Backup Designated Router 本链路上(网段)上BDR路由器的接口IP地址
Active Neighbor 邻居列表,表示该接口所连接的链路上建立的所有的邻居 router-id。

[扩展]:帧中继、x.25、ATM网络等可以配置成P2MP、NBMA网络类型。

DD报文

    OSPF DB Description
        Interface MTU: 0
        Options: 0x02, (E) External Routing
        DB Description: 0x01, (MS) Master
        DD Sequence: 1066
      LSA-type 1 (Router-LSA), len 48
       	.000 0000 0000 0100 = LS Age (seconds): 4
        0... .... .... .... = Do Not Age Flag: 0
        Options: 0x02, (E) External Routing
        LS Type: Router-LSA (1)
        Link State ID: 3.3.3.3
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000008
        Checksum: 0x03fa
        Length: 48
      LSA-type 1 (Router-LSA), len 48
      LSA-type 2 (Network-LSA), len 32
  • DD报文是LSA的头部包,没有包含具体LSA内容

  • 上面的DD报文中有3个LSA(2个1类LSA,1个2类LSA)

  • Interface MTU:DD报文中存在MTU字段(如果两端MTU不一致,无法建立邻居(前提是路由器开启MTU检测功能),华为设备默认不检查MTU值。

LSR报文

Link State Request
    LS Type: Router-LSA (1)
    Link State ID: 3.3.3.3
    Advertising Router: 3.3.3.3
Link State Request
    LS Type: Network-LSA (2)
    Link State ID: 23.1.1.2
    Advertising Router: 2.2.2.2
  • 使用LSA 标识唯一性的三个字段向ospf邻居请求LSA

LSU报文

LS Update Packet
    Number of LSAs: 2
    > LSA-type 2 (Network-LSA), len 32
    > LSA-type 1 (Router-LSA), len 48
  • Number of LSAs标识LSU数据包中 LSA的数量
  • LSU报文中包含一个或多个完整的LSA。

type 1 LSA

    LSA-type 1 (Router-LSA), len 48
        .000 0000 0000 0001 = LS Age (seconds): 1
        0... .... .... .... = Do Not Age Flag: 0
        Options: 0x02, (E) External Routing
        LS Type: Router-LSA (1)
        Link State ID: 3.3.3.3
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000009
        Checksum: 0x518d
        Length: 48
        Flags: 0x00
        Number of Links: 2
        Type: Transit  ID: 23.1.1.3        Data: 23.1.1.3        Metric: 1
        Type: Stub     ID: 3.3.3.3         Data: 255.255.255.255 Metric: 0
        
另一个数据包
        Type: PTP      ID: 12.1.1.2        Data: 23.1.1.2        Metric: 1
  • 在type 1 LSA中 LS id表示路由器的router id。

  • 每台路由器都会产生(通告) type 1 LSA(router lsa),用于描述路由器自己的链路信息(接口信息、邻居信息等)

type description Link ID link Data
Point to Point 点到点类型链路 邻居路由器的 router id 自己接口的IP地址
TransitNet MA类型链路 DR接口IP地址 自己接口的IP地址
StubNet 末节类型链路 网络号 网络掩码

type 2 LSA

LSA-type 2 (Network-LSA), len 32
    .000 0011 1000 1011 = LS Age (seconds): 907
    0... .... .... .... = Do Not Age Flag: 0
    Options: 0x02, (E) External Routing
    LS Type: Network-LSA (2)
    Link State ID: 23.1.1.2
    Advertising Router: 2.2.2.2
    Sequence Number: 0x80000002
    Checksum: 0xc65b
    Length: 32
    Netmask: 255.255.255.0
    Attached Router: 2.2.2.2
    Attached Router: 3.3.3.3
  • 在type 2 LSA中 LS id表示路由器的DR接口的IP地址。

  • DR产生(通告) type 2 LSA(network lsa),用于描述多点网络上的拓扑关系。

type 3 LSA

image-20230409103914320
  • 在type 3 LSA中 LS id表示 网络号 。

  • Network 表示 掩码。

  • Metric 表示 cost。

  • ABR产生(通告) type 3 LSA(summary lsa),用于描述区域链路信息。

  • LSA 3进入其它区域 Adv router变为ABR的router-id。

type 4 LSA

1681008267776
  • type 4 LSA和type 3 LSA使用相同的报文格式,只是type字段为4。
  • 在type 4 LSA中 LS id表示 ASBR的router id
  • ABR 产生(通告) type 4 LSA(asbr lsa),用于描述区域到外部网络的距离。

type 5 LSA

1681008678794
  • 在type 5 LSA中 LS id表示 网络号 。

  • Network 表示 掩码。

  • Metric 表示 cost。

  • type 5 LSA 新增加了tag和FA(forwarding address)字段(FA字段若不为0 则路由器到外部网络必须要经过FA地址路由器 再转发到外部网络)

  • ASBR产生(通告) type 5 LSA(summary lsa),用于描述外部网络信息。

  • LSA 5进入其它区域 Adv router始终为ASBR的router-id。

type 7 LSA

1681008983739
  • type 7 LSA仅在NSSA区域里泛洪,ABR可以将7类LSA翻译成type 5 LSA 在其它区域泛洪。

  • 和type 5 LSA一样,中LS id表示 网络号 。

  • ASBR产生(通告) type 7 LSA(nssa lsa),用于描述外部网络信息。

  • LSA 7进入其它区域(非NSSA) Adv router变为ABR 的router id。

  • type 7 LSA FA地址一定要非 0,用于在区域间选路。

LSAck报文

    LSA-type 1 (Router-LSA), len 48
        .000 0000 0000 0010 = LS Age (seconds): 2
        0... .... .... .... = Do Not Age Flag: 0
        Options: 0x02, (E) External Routing
        LS Type: Router-LSA (1)
        Link State ID: 3.3.3.3
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000009
        Checksum: 0x518d
        Length: 48
    LSA-type 2 (Network-LSA), len 32

  • LSA 头列表,ospf通过LSA头对收到的完整的LSA做确认。一份LSAack可以对多个LSU中的LSA做确认。
posted @ 2022-03-09 18:21  wefjack  阅读(192)  评论(0)    收藏  举报