「OSPF」- 报文格式

IP.PROTOCOL=89

报文格式

OSPF Header

Version number:OSPF v2 for IPv4:2;OSPF v3 for IPv6;
Router ID:表示生成此报文的路由器的 Router ID;
Area ID:表示此报文需要被通告到的区域;
Type:类型字段。即 Data 部分的类型,即不同的 OSPF 报文类型;
Packet length:表示整个OSPF报文的长度,单位是字节;
Checksum:校验字段,其校验的范围是整个 OSPF 报文,包括 OSPF 报文头部;
Auth Type:0,表示不认证;1,表示简单的明文密码认证;2,表示加密(MD5)认证;
Authentication:认证所需的信息。该字段的内容随AuType的值不同而不同;

OSPF Payload

LSR, Link State Request

  • 解释:OSPF_Header.Type = 3,向对方请求所需要的 LSA 数据(只有当 DD 报文交换成功后,才会向双方发送 LSR 报文)

LSAck, Link State Acknowledgment

  • 解释:OSPF_Header.Type = 5,确认已经收到对方的 LSA 报文。

报文示例

IP.OSPFHeader.Type == 1 | Hello

Frame 125: 82 bytes on wire (656 bits), 82 bytes captured (656 bits) on interface -, id 0
Ethernet II, Src: 38:39:cc:02:01:00 (38:39:cc:02:01:00), Dst: IPv4mcast_05 (01:00:5e:00:00:05)
Internet Protocol Version 4, Src: 10.0.12.2, Dst: 224.0.0.5
Open Shortest Path First
    OSPF Header
        Version: 2
        Message Type: Hello Packet (1)
        Packet Length: 48
        Source OSPF Router: 2.2.2.2
        Area ID: 0.0.0.0 (Backbone)
        Checksum: 0xca91 [correct]
        Auth Type: Null (0)
        Auth Data (none): 0000000000000000
    OSPF Hello Packet
        Network Mask: 255.255.255.0
        Hello Interval [sec]: 10
        Options: 0x02, (E) External Routing
            0... .... = DN: Not set
            .0.. .... = (O) Opaque: 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
        Router Priority: 1
        Router Dead Interval [sec]: 40
        Designated Router: 10.0.12.1
        Backup Designated Router: 10.0.12.2
        Active Neighbor: 1.1.1.1

IP.OSPFHeader.Type == 2 | DD

Frame 163: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface -, id 0
Ethernet II, Src: 38:39:cc:02:01:00 (38:39:cc:02:01:00), Dst: 38:39:cc:01:01:00 (38:39:cc:01:01:00)
Internet Protocol Version 4, Src: 10.0.12.2, Dst: 10.0.12.1
Open Shortest Path First
    OSPF Header
        Version: 2
        Message Type: DB Description (2)
        Packet Length: 32
        Source OSPF Router: 2.2.2.2
        Area ID: 0.0.0.0 (Backbone)
        Checksum: 0xaf6e [correct]
        Auth Type: Null (0)
        Auth Data (none): 0000000000000000
    OSPF DB Description
        Interface MTU: 0
        Options: 0x42, (O) Opaque, (E) External Routing
            0... .... = DN: Not set
            .1.. .... = (O) Opaque: 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
        DB Description: 0x07, (I) Init, (M) More, (MS) Master
            .... 0... = (R) OOBResync: Not set
            .... .1.. = (I) Init: Set
            .... ..1. = (M) More: Set
            .... ...1 = (MS) Master: Yes
        DD Sequence: 2148

IP.OSPFHeader.Type == 4 | LSU

Internet Protocol Version 4, Src: 10.0.12.1, Dst: 224.0.0.6
Open Shortest Path First
    OSPF Header
    LS Update Packet
        Number of LSAs: 2
        LSA-type 1 (Router-LSA), len 36
        LSA-type 2 (Network-LSA), len 36
            .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: Network-LSA (2)
            Link State ID: 10.0.12.3
            Advertising Router: 3.3.3.3
            Sequence Number: 0x80000002
            Checksum: 0xa966
            Length: 36
            Netmask: 255.255.255.0
            Attached Router: 3.3.3.3
            Attached Router: 1.1.1.1
            Attached Router: 4.4.4.4

Frame 416: 254 bytes on wire (2032 bits), 254 bytes captured (2032 bits) on interface -, id 0
Ethernet II, Src: 38:39:cc:02:01:00 (38:39:cc:02:01:00), Dst: IPv4mcast_05 (01:00:5e:00:00:05)
Internet Protocol Version 4, Src: 10.0.12.2, Dst: 224.0.0.5
Open Shortest Path First
    OSPF Header
        Version: 2
        Message Type: LS Update (4)
        Packet Length: 220
        Source OSPF Router: 2.2.2.2
        Area ID: 0.0.0.0 (Backbone)
        Checksum: 0x30d8 [correct]
        Auth Type: Null (0)
        Auth Data (none): 0000000000000000
    LS Update Packet
        Number of LSAs: 4
        LSA-type 10 (Opaque LSA, Area-local scope), len 52
            .000 0000 0000 0010 = LS Age (seconds): 2
            0... .... .... .... = Do Not Age Flag: 0
            Options: 0x02, (E) External Routing
                0... .... = DN: Not set
                .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
            Link State ID Opaque Type: OSPFv2 Extended Link Opaque LSA (8)
            Link State ID Opaque ID: 1
            Advertising Router: 3.3.3.3
            Sequence Number: 0x80000001
            Checksum: 0xb1ed
            Length: 52
            OSPFv2 Extended Link Opaque LSA
                OSPFv2 Extended Link TLV  (Type: Transit  ID: 10.0.34.3       Data: 10.0.34.3)
                    TLV Type: OSPFv2 Extended Link (1)
                    TLV Length: 28
                    Link Type: 2 - Connection to a transit network
                    Reserved: 000000
                    Link ID: 10.0.34.3
                    Link Data: 10.0.34.3
                    LAN Adj-SID Sub-TLV  (SID/Label: 48081, Neighbor: 4.4.4.4)
                        TLV Type: LAN Adj-SID (3)
                        TLV Length: 11
                        Flags: 0x60, (V) Value/Index Flag, (L) Local/Global Flag
                            0... .... = (B) Backup Flag: Not set
                            .1.. .... = (V) Value/Index Flag: Set
                            ..1. .... = (L) Local/Global Flag: Set
                            ...0 .... = (G) Group Flag: Not set
                            .... 0... = (P) Persistent Flag: Not set
                        Reserved: 00
                        Multi-Topology ID: 0
                        Weight: 0
                        Neighbor ID: 4.4.4.4
                        SID/Label: 48081
        LSA-type 10 (Opaque LSA, Area-local scope), len 52
            .000 0000 0000 0010 = LS Age (seconds): 2
            0... .... .... .... = Do Not Age Flag: 0
            Options: 0x02, (E) External Routing
                0... .... = DN: Not set
                .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
            Link State ID Opaque Type: OSPFv2 Extended Link Opaque LSA (8)
            Link State ID Opaque ID: 0
            Advertising Router: 3.3.3.3
            Sequence Number: 0x80000001
            Checksum: 0x6a55
            Length: 52
            OSPFv2 Extended Link Opaque LSA
                OSPFv2 Extended Link TLV  (Type: Transit  ID: 10.0.23.3       Data: 10.0.23.3)
                    TLV Type: OSPFv2 Extended Link (1)
                    TLV Length: 28
                    Link Type: 2 - Connection to a transit network
                    Reserved: 000000
                    Link ID: 10.0.23.3
                    Link Data: 10.0.23.3
                    LAN Adj-SID Sub-TLV  (SID/Label: 48080, Neighbor: 2.2.2.2)
                        TLV Type: LAN Adj-SID (3)
                        TLV Length: 11
                        Flags: 0x60, (V) Value/Index Flag, (L) Local/Global Flag
                            0... .... = (B) Backup Flag: Not set
                            .1.. .... = (V) Value/Index Flag: Set
                            ..1. .... = (L) Local/Global Flag: Set
                            ...0 .... = (G) Group Flag: Not set
                            .... 0... = (P) Persistent Flag: Not set
                        Reserved: 00
                        Multi-Topology ID: 0
                        Weight: 0
                        Neighbor ID: 2.2.2.2
                        SID/Label: 48080
        LSA-type 10 (Opaque LSA, Area-local scope), len 44
            .000 0000 0000 0010 = LS Age (seconds): 2
            0... .... .... .... = Do Not Age Flag: 0
            Options: 0x02, (E) External Routing
                0... .... = DN: Not set
                .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
            Link State ID Opaque Type: OSPFv2 Extended Prefix Opaque LSA (7)
            Link State ID Opaque ID: 0
            Advertising Router: 3.3.3.3
            Sequence Number: 0x80000001
            Checksum: 0x1093
            Length: 44
            OSPFv2 Extended Prefix Opaque LSA
                OSPFv2 Extended Prefix TLV  (Type: Intra-Area    Prefix: 3.3.3.3/32)
                    TLV Type: OSPFv2 Extended Prefix (1)
                    TLV Length: 20
                    Route Type: Intra-Area (1)
                    PrefixLength: 32
                    Address Family: IPv4 Unicast (0)
                    Flags: 0x40, (N) Node Flag
                        0... .... = (A) Attach Flag: Not set
                        .1.. .... = (N) Node Flag: Set
                    Address Prefix: 3.3.3.3
                    Prefix SID Sub-TLV  (SID/Label: 3)
                        TLV Type: Prefix SID (2)
                        TLV Length: 8
                        Flags: 0x00
                            .0.. .... = (NP) No-PHP Flag: Not set
                            ..0. .... = (M) Mapping Server Flag: Not set
                            ...0 .... = (E) Explicit-Null Flag: Not set
                            .... 0... = (V) Value/Index Flag: Not set
                            .... .0.. = (L) Local/Global Flag: Not set
                        Reserved: 00
                        Multi-Topology ID: 0
                        SR-Algorithm: Shortest Path First (0)
                        SID/Label: 3
        LSA-type 10 (Opaque LSA, Area-local scope), len 44
            .000 0000 0000 0010 = LS Age (seconds): 2
            0... .... .... .... = Do Not Age Flag: 0
            Options: 0x02, (E) External Routing
                0... .... = DN: Not set
                .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
            Link State ID Opaque Type: Router Information (RI) (4)
            Link State ID Opaque ID: 0
            Advertising Router: 3.3.3.3
            Sequence Number: 0x80000001
            Checksum: 0xc138
            Length: 44
            Opaque Router Information LSA
                SR-Algorithm 
                    TLV Type: SR-Algorithm  (8)
                    TLV Length: 1
                    SR-Algorithm: Shortest Path First (0)
                SID/Label Range  (Range Size: 1001)
                    TLV Type: SID/Label Range (9)
                    TLV Length: 12
                    Range Size: 1001
                    Reserved: 00
                    SID/Label Sub-TLV  (SID/Label: 36000)
                        TLV Type: SID/Label (1)
                        TLV Length: 3
                        SID/Label: 36000

接口开启 MPLS TE 特性,设备主动发送的报文:

Frame 470: 194 bytes on wire (1552 bits), 194 bytes captured (1552 bits) on interface -, id 0
Ethernet II, Src: 38:39:cc:01:01:00 (38:39:cc:01:01:00), Dst: IPv4mcast_05 (01:00:5e:00:00:05)
Internet Protocol Version 4, Src: 10.0.12.1, Dst: 224.0.0.5
Open Shortest Path First
    OSPF Header
        Version: 2
        Message Type: LS Update (4)
        Packet Length: 160
        Source OSPF Router: 1.1.1.1
        Area ID: 0.0.0.0 (Backbone)
        Checksum: 0x2b28 [correct]
        Auth Type: Null (0)
        Auth Data (none): 0000000000000000
    LS Update Packet
        Number of LSAs: 1
        LSA-type 10 (Opaque LSA, Area-local scope), len 132
            .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) Opaque: 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: Opaque LSA, Area-local scope (10)
            Link State ID Opaque Type: Traffic Engineering LSA (1)
            Link State ID TE-LSA Reserved: 0
            Link State ID TE-LSA Instance: 1
            Advertising Router: 1.1.1.1
            Sequence Number: 0x80000001
            Checksum: 0x945a
            Length: 132
            MPLS Traffic Engineering LSA
                Link Information
                    TLV Type: 2 - Link Information
                    TLV Length: 108
                    Link Type: 2 - Multi-access
                        TLV Type: 1: Link Type
                        TLV Length: 1
                        MPLS/TE Link Type: Multi-access (2)
                    Link ID: 10.0.12.2
                        TLV Type: 2: Link ID
                        TLV Length: 4
                        MPLS/TE Link ID: 10.0.12.2
                    Local Interface IP Address: 10.0.12.1
                        TLV Type: 3: Local Interface IP Address
                        TLV Length: 4
                        MPLS/TE Local Interface Address: 10.0.12.1
                    Remote Interface IP Address: 0.0.0.0
                        TLV Type: 4: Remote Interface IP Address
                        TLV Length: 4
                        MPLS/TE Remote Interface Address: 0.0.0.0
                    Traffic Engineering Metric: 1
                        TLV Type: 5: Traffic Engineering Metric
                        TLV Length: 4
                        Traffic Engineering Metric: 1
                    Maximum Bandwidth: 12500000 bytes/s (100000000 bits/s)
                        TLV Type: 6: Maximum Bandwidth
                        TLV Length: 4
                        Maximum Bandwidth: 12500000 bytes/s (100000000 bits/s)
                    Maximum Reservable Bandwidth: 0 bytes/s (0 bits/s)
                        TLV Type: 7: Maximum Reservable Bandwidth
                        TLV Length: 4
                        Maximum Reservable Bandwidth: 0 bytes/s (0 bits/s)
                    Unreserved Bandwidth
                        TLV Type: 8: Unreserved Bandwidth
                        TLV Length: 32
                        Pri (or TE-Class) 0: 0 bytes/s (0 bits/s)
                        Pri (or TE-Class) 1: 0 bytes/s (0 bits/s)
                        Pri (or TE-Class) 2: 0 bytes/s (0 bits/s)
                        Pri (or TE-Class) 3: 0 bytes/s (0 bits/s)
                        Pri (or TE-Class) 4: 0 bytes/s (0 bits/s)
                        Pri (or TE-Class) 5: 0 bytes/s (0 bits/s)
                        Pri (or TE-Class) 6: 0 bytes/s (0 bits/s)
                        Pri (or TE-Class) 7: 0 bytes/s (0 bits/s)
                    Resource Class/Color: 0x00000000
                        TLV Type: 9: Resource Class/Color
                        TLV Length: 4
                        MPLS/TE Link Resource Class/Color: 0x00000000
                    Unknown Link sub-TLV: 32770 (For Experimental Use)
                        TLV Type: 32770: Unknown sub-TLV (For Experimental Use)
                        TLV Length: 4
                        TLV Value: 00000001

IP.OSPFHeader.Type == 5 | LSACK

Frame 417: 138 bytes on wire (1104 bits), 138 bytes captured (1104 bits) on interface -, id 0
Ethernet II, Src: 38:39:cc:01:01:00 (38:39:cc:01:01:00), Dst: IPv4mcast_05 (01:00:5e:00:00:05)
Internet Protocol Version 4, Src: 10.0.12.1, Dst: 224.0.0.5
Open Shortest Path First
    OSPF Header
        Version: 2
        Message Type: LS Acknowledge (5)
        Packet Length: 104
        Source OSPF Router: 1.1.1.1
        Area ID: 0.0.0.0 (Backbone)
        Checksum: 0xd16e [correct]
        Auth Type: Null (0)
        Auth Data (none): 0000000000000000
    LSA-type 10 (Opaque LSA, Area-local scope), len 44
        .000 0000 0000 0011 = LS Age (seconds): 3
        0... .... .... .... = Do Not Age Flag: 0
        Options: 0x02, (E) External Routing
            0... .... = DN: Not set
            .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
        Link State ID Opaque Type: Router Information (RI) (4)
        Link State ID Opaque ID: 0
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000001
        Checksum: 0xc138
        Length: 44
    LSA-type 10 (Opaque LSA, Area-local scope), len 44
        .000 0000 0000 0011 = LS Age (seconds): 3
        0... .... .... .... = Do Not Age Flag: 0
        Options: 0x02, (E) External Routing
            0... .... = DN: Not set
            .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
        Link State ID Opaque Type: OSPFv2 Extended Prefix Opaque LSA (7)
        Link State ID Opaque ID: 0
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000001
        Checksum: 0x1093
        Length: 44
    LSA-type 10 (Opaque LSA, Area-local scope), len 52
        .000 0000 0000 0011 = LS Age (seconds): 3
        0... .... .... .... = Do Not Age Flag: 0
        Options: 0x02, (E) External Routing
            0... .... = DN: Not set
            .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
        Link State ID Opaque Type: OSPFv2 Extended Link Opaque LSA (8)
        Link State ID Opaque ID: 0
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000001
        Checksum: 0x6a55
        Length: 52
    LSA-type 10 (Opaque LSA, Area-local scope), len 52
        .000 0000 0000 0011 = LS Age (seconds): 3
        0... .... .... .... = Do Not Age Flag: 0
        Options: 0x02, (E) External Routing
            0... .... = DN: Not set
            .0.. .... = (O) Opaque: 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: Opaque LSA, Area-local scope (10)
        Link State ID Opaque Type: OSPFv2 Extended Link Opaque LSA (8)
        Link State ID Opaque ID: 1
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000001
        Checksum: 0xb1ed
        Length: 52

接口开启 MPLS TE 特性,针对 LSU 的 LSACK 报文:

Frame 471: 78 bytes on wire (624 bits), 78 bytes captured (624 bits) on interface -, id 0
Ethernet II, Src: 38:39:cc:03:01:00 (38:39:cc:03:01:00), Dst: IPv4mcast_05 (01:00:5e:00:00:05)
Internet Protocol Version 4, Src: 10.0.12.2, Dst: 224.0.0.5
Open Shortest Path First
    OSPF Header
        Version: 2
        Message Type: LS Acknowledge (5)
        Packet Length: 44
        Source OSPF Router: 2.2.2.2
        Area ID: 0.0.0.0 (Backbone)
        Checksum: 0xdfdc [correct]
        Auth Type: Null (0)
        Auth Data (none): 0000000000000000
    LSA-type 10 (Opaque LSA, Area-local scope), len 132
        .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) Opaque: 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: Opaque LSA, Area-local scope (10)
        Link State ID Opaque Type: Traffic Engineering LSA (1)
        Link State ID TE-LSA Reserved: 0
        Link State ID TE-LSA Instance: 1
        Advertising Router: 1.1.1.1
        Sequence Number: 0x80000001
        Checksum: 0x945a
        Length: 132