2019 SDN上機第3次做業

1. 利用Mininet仿真平臺構建以下圖所示的網絡拓撲,配置主機h1和h2的IP地址(h1:10.0.0.1,h2:10.0.0.2),測試兩臺主機之間的網絡連通性

  • 網絡拓撲以下:
  • 主機連通性測試:

2. 利用Wireshark工具,捕獲拓撲中交換機與控制器之間的通訊數據,對OpenFlow協議類型的各種報文(hello, features_request, features_reply, set_config, packet_in, packet_out等)進行分析,對照wireshark截圖寫出你的分析內容。

  • HELLO報文
    從控制器發往交換機的HELLO報文,說明控制器使用的協議版本爲1.0

    從交換機發往控制器的HELLO報文,說明交換機使用的協議版本爲1.3

    至此雙方採用openflow1.0版本創建鏈接
    Q1:Hello 消息是使用什麼協議傳輸?TCP?UDP?
    TCP,從上面的報文截圖能夠觀察到傳輸層使用TCP協議
    Q2:全部的網絡協議在升級的時候都必須向前兼容更低版本的協議?why?
    是。由於網絡是一個龐大的系統,裏面有不少機器是很早就部署好的,當協議升級後那些機器由於開銷或各類緣由沒有辦法當即更換。若是協議不能向下兼容,那這臺機器就會失去做用,那它負責的網絡就會沒法訪問,這是不能容忍的。
  • Features Request報文
    控制器向交換機請求特徵信息
  • Set Config報文

    控制器配置交換機的屬性
    • 第一個屬性爲 flags,用來指示交換機如何處理 IP 分片數據包。
    • 第二個屬性爲 miss_send_len,用來指示當一個交換機沒法處理的數據包到達時,將數據包發給控制器的最大字節數。
  • Features Reply報文

    報文詳細內容以下:
No.     Time           Source                Destination           Protocol Length Info
     20 0.136426006    127.0.0.1             127.0.0.1             OpenFlow 244    Type: OFPT_FEATURES_REPLY

Frame 20: 244 bytes on wire (1952 bits), 244 bytes captured (1952 bits) on interface 0
Linux cooked capture
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 57198, Dst Port: 6633, Seq: 9, Ack: 29, Len: 176
OpenFlow 1.0
    .000 0001 = Version: 1.0 (0x01)
    Type: OFPT_FEATURES_REPLY (6)
    Length: 176
    Transaction ID: 1882383166
    Datapath unique ID: 0x0000000000000002
    n_buffers: 0
    n_tables: 254
    Pad: 000000
    capabilities: 0x000000c7
        .... .... .... .... .... .... .... ...1 = Flow statistics: True
        .... .... .... .... .... .... .... ..1. = Table statistics: True
        .... .... .... .... .... .... .... .1.. = Port statistics: True
        .... .... .... .... .... .... .... 0... = Group statistics: False
        .... .... .... .... .... .... ..0. .... = Can reassemble IP fragments: False
        .... .... .... .... .... .... .1.. .... = Queue statistics: True
        .... .... .... .... .... ...0 .... .... = Switch will block looping ports: False
    actions: 0x00000fff
        .... .... .... .... .... .... .... ...1 = Output to switch port: True
        .... .... .... .... .... .... .... ..1. = Set the 802.1q VLAN id: True
        .... .... .... .... .... .... .... .1.. = Set the 802.1q priority: True
        .... .... .... .... .... .... .... 1... = Strip the 802.1q header: True
        .... .... .... .... .... .... ...1 .... = Ethernet source address: True
        .... .... .... .... .... .... ..1. .... = Ethernet destination address: True
        .... .... .... .... .... .... .1.. .... = IP source address: True
        .... .... .... .... .... .... 1... .... = IP destination address: True
        .... .... .... .... .... ...1 .... .... = IP ToS (DSCP field, 6 bits): True
        .... .... .... .... .... ..1. .... .... = TCP/UDP source port: True
        .... .... .... .... .... .1.. .... .... = TCP/UDP destination port: True
        .... .... .... .... .... 1... .... .... = Output to queue: True
    Port data 1
        Port number: 65534
        HW Address: f2:7d:e8:d6:b0:93 (f2:7d:e8:d6:b0:93)
        Port Name: s2
        Config flags: 0x00000001
            .... .... .... .... .... .... .... ...1 = Port is administratively down: True
            .... .... .... .... .... .... .... ..0. = Disable 802.1D spanning tree on port: False
            .... .... .... .... .... .... .... .0.. = Drop all packets except 802.1D spanning tree packets: False
            .... .... .... .... .... .... .... 0... = Drop received 802.1D STP packets: False
            .... .... .... .... .... .... ...0 .... = Do not include this port when flooding: False
            .... .... .... .... .... .... ..0. .... = Drop packets forwarded to port: False
            .... .... .... .... .... .... .0.. .... = Do not send packet-in msgs for port: False
        State flags: 0x00000001
            .... .... .... .... .... .... .... ...1 = No physical link present: True
        Current features: 0x00000000
            .... .... .... .... .... .... .... ...0 = 10 Mb half-duplex rate support: False
            .... .... .... .... .... .... .... ..0. = 10 Mb full-duplex rate support: False
            .... .... .... .... .... .... .... .0.. = 100 Mb half-duplex rate support: False
            .... .... .... .... .... .... .... 0... = 100 Mb full-duplex rate support: False
            .... .... .... .... .... .... ...0 .... = 1 Gb half-duplex rate support: False
            .... .... .... .... .... .... ..0. .... = 1 Gb full-duplex rate support: False
            .... .... .... .... .... .... .0.. .... = 10 Gb full-duplex rate support: False
            .... .... .... .... .... .... 0... .... = Copper medium: False
            .... .... .... .... .... ...0 .... .... = Fiber medium: False
            .... .... .... .... .... ..0. .... .... = Auto-negotiation: False
            .... .... .... .... .... .0.. .... .... = Pause: False
            .... .... .... .... .... 0... .... .... = Asymmetric pause: False
        Advertised features: 0x00000000
        Features supported: 0x00000000
        Features advertised by peer: 0x00000000
    Port data 2
        Port number: 1
        HW Address: 36:47:33:19:cf:87 (36:47:33:19:cf:87)
        Port Name: s2-eth1
        Config flags: 0x00000000
            .... .... .... .... .... .... .... ...0 = Port is administratively down: False
            .... .... .... .... .... .... .... ..0. = Disable 802.1D spanning tree on port: False
            .... .... .... .... .... .... .... .0.. = Drop all packets except 802.1D spanning tree packets: False
            .... .... .... .... .... .... .... 0... = Drop received 802.1D STP packets: False
            .... .... .... .... .... .... ...0 .... = Do not include this port when flooding: False
            .... .... .... .... .... .... ..0. .... = Drop packets forwarded to port: False
            .... .... .... .... .... .... .0.. .... = Do not send packet-in msgs for port: False
        State flags: 0x00000000
            .... .... .... .... .... .... .... ...0 = No physical link present: False
        Current features: 0x000000c0
            .... .... .... .... .... .... .... ...0 = 10 Mb half-duplex rate support: False
            .... .... .... .... .... .... .... ..0. = 10 Mb full-duplex rate support: False
            .... .... .... .... .... .... .... .0.. = 100 Mb half-duplex rate support: False
            .... .... .... .... .... .... .... 0... = 100 Mb full-duplex rate support: False
            .... .... .... .... .... .... ...0 .... = 1 Gb half-duplex rate support: False
            .... .... .... .... .... .... ..0. .... = 1 Gb full-duplex rate support: False
            .... .... .... .... .... .... .1.. .... = 10 Gb full-duplex rate support: True
            .... .... .... .... .... .... 1... .... = Copper medium: True
            .... .... .... .... .... ...0 .... .... = Fiber medium: False
            .... .... .... .... .... ..0. .... .... = Auto-negotiation: False
            .... .... .... .... .... .0.. .... .... = Pause: False
            .... .... .... .... .... 0... .... .... = Asymmetric pause: False
        Advertised features: 0x00000000
        Features supported: 0x00000000
        Features advertised by peer: 0x00000000
    Port data 3
        Port number: 2
        HW Address: 5e:78:e3:b1:ca:a6 (5e:78:e3:b1:ca:a6)
        Port Name: s2-eth2
        Config flags: 0x00000000
            .... .... .... .... .... .... .... ...0 = Port is administratively down: False
            .... .... .... .... .... .... .... ..0. = Disable 802.1D spanning tree on port: False
            .... .... .... .... .... .... .... .0.. = Drop all packets except 802.1D spanning tree packets: False
            .... .... .... .... .... .... .... 0... = Drop received 802.1D STP packets: False
            .... .... .... .... .... .... ...0 .... = Do not include this port when flooding: False
            .... .... .... .... .... .... ..0. .... = Drop packets forwarded to port: False
            .... .... .... .... .... .... .0.. .... = Do not send packet-in msgs for port: False
        State flags: 0x00000000
            .... .... .... .... .... .... .... ...0 = No physical link present: False
        Current features: 0x000000c0
            .... .... .... .... .... .... .... ...0 = 10 Mb half-duplex rate support: False
            .... .... .... .... .... .... .... ..0. = 10 Mb full-duplex rate support: False
            .... .... .... .... .... .... .... .0.. = 100 Mb half-duplex rate support: False
            .... .... .... .... .... .... .... 0... = 100 Mb full-duplex rate support: False
            .... .... .... .... .... .... ...0 .... = 1 Gb half-duplex rate support: False
            .... .... .... .... .... .... ..0. .... = 1 Gb full-duplex rate support: False
            .... .... .... .... .... .... .1.. .... = 10 Gb full-duplex rate support: True
            .... .... .... .... .... .... 1... .... = Copper medium: True
            .... .... .... .... .... ...0 .... .... = Fiber medium: False
            .... .... .... .... .... ..0. .... .... = Auto-negotiation: False
            .... .... .... .... .... .0.. .... .... = Pause: False
            .... .... .... .... .... 0... .... .... = Asymmetric pause: False
        Advertised features: 0x00000000
        Features supported: 0x00000000
        Features advertised by peer: 0x00000000
**Q3:uint8_t pad[3] 這一字段的做用是什麼?爲了保證整個結構體長度是 64bits 的整數倍?**
是
  • Packet_in報文
    交換機收到報文時根據下發的流表進行轉發行爲。
    在報文與流表項目匹配時,action指示發往控制器,則交換機會向控制器發送packet_in報文。
    在沒有控制器且在沒有流表項目與報文匹配的狀況下,交換機的默認行爲是丟棄該報文。
    在有控制器的狀況下,交換機就會向控制器發送packet_in報文。
    報文內容中值得注意的點是:
    reason:no matching flow
    以及一個封裝在openflow協議中具備層次結構的ICMPv6報文

    報文詳細內容以下:
No.     Time           Source                Destination           Protocol Length Info
     56 0.351175209    ::                    ff02::16              OpenFlow 176    Type: OFPT_PACKET_IN

Frame 56: 176 bytes on wire (1408 bits), 176 bytes captured (1408 bits) on interface 0
Linux cooked capture
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 57198, Dst Port: 6633, Seq: 249, Ack: 29, Len: 108
OpenFlow 1.0
    .000 0001 = Version: 1.0 (0x01)
    Type: OFPT_PACKET_IN (10)
    Length: 108
    Transaction ID: 0
    Buffer Id: 0xffffffff
    Total length: 90
    In port: 2
    Reason: No matching flow (table-miss flow entry) (0)
    Pad: 00
    Ethernet II, Src: 0e:cd:34:08:88:9d (0e:cd:34:08:88:9d), Dst: IPv6mcast_16 (33:33:00:00:00:16)
        Destination: IPv6mcast_16 (33:33:00:00:00:16)
            Address: IPv6mcast_16 (33:33:00:00:00:16)
            .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
            .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
        Source: 0e:cd:34:08:88:9d (0e:cd:34:08:88:9d)
            Address: 0e:cd:34:08:88:9d (0e:cd:34:08:88:9d)
            .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv6 (0x86dd)
    Internet Protocol Version 6, Src: ::, Dst: ff02::16
        0110 .... = Version: 6
        .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
            .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
            .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        .... .... .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
        Payload Length: 36
        Next Header: IPv6 Hop-by-Hop Option (0)
        Hop Limit: 1
        Source: ::
        Destination: ff02::16
        IPv6 Hop-by-Hop Option
            Next Header: ICMPv6 (58)
            Length: 0
            [Length: 8 bytes]
            Router Alert
                Type: Router Alert (0x05)
                    00.. .... = Action: Skip and continue (0)
                    ..0. .... = May Change: No
                    ...0 0101 = Low-Order Bits: 0x05
                Length: 2
                Router Alert: MLD (0)
            PadN
                Type: PadN (0x01)
                    00.. .... = Action: Skip and continue (0)
                    ..0. .... = May Change: No
                    ...0 0001 = Low-Order Bits: 0x01
                Length: 0
                PadN: <none>
    Internet Control Message Protocol v6
        Type: Multicast Listener Report Message v2 (143)
        Code: 0
        Checksum: 0xe6e4 [correct]
        [Checksum Status: Good]
        Reserved: 0000
        Number of Multicast Address Records: 1
        Multicast Address Record Changed to exclude: ff02::1:ff08:889d
            Record Type: Changed to exclude (4)
            Aux Data Len: 0
            Number of Sources: 0
            Multicast Address: ff02::1:ff08:889d
  • Packet_out報文
    控制器回覆報文給交換機作出指示,應當注意的字段爲:
    actions type:output to switch port
    output port:65531

    報文詳細內容以下:
No.     Time           Source                Destination           Protocol Length Info
     57 0.366529628    ::                    ff02::16              OpenFlow 182    Type: OFPT_PACKET_OUT

Frame 57: 182 bytes on wire (1456 bits), 182 bytes captured (1456 bits) on interface 0
Linux cooked capture
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 6633, Dst Port: 57198, Seq: 29, Ack: 357, Len: 114
OpenFlow 1.0
    .000 0001 = Version: 1.0 (0x01)
    Type: OFPT_PACKET_OUT (13)
    Length: 114
    Transaction ID: 0
    Buffer Id: 0xffffffff
    In port: 2
    Actions length: 8
    Actions type: Output to switch port (0)
    Action length: 8
    Output port: 65531
    Max length: 0
    Ethernet II, Src: 0e:cd:34:08:88:9d (0e:cd:34:08:88:9d), Dst: IPv6mcast_16 (33:33:00:00:00:16)
        Destination: IPv6mcast_16 (33:33:00:00:00:16)
            Address: IPv6mcast_16 (33:33:00:00:00:16)
            .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
            .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
        Source: 0e:cd:34:08:88:9d (0e:cd:34:08:88:9d)
            Address: 0e:cd:34:08:88:9d (0e:cd:34:08:88:9d)
            .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv6 (0x86dd)
    Internet Protocol Version 6, Src: ::, Dst: ff02::16
        0110 .... = Version: 6
        .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
            .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
            .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        .... .... .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
        Payload Length: 36
        Next Header: IPv6 Hop-by-Hop Option (0)
        Hop Limit: 1
        Source: ::
        Destination: ff02::16
        IPv6 Hop-by-Hop Option
            Next Header: ICMPv6 (58)
            Length: 0
            [Length: 8 bytes]
            Router Alert
                Type: Router Alert (0x05)
                    00.. .... = Action: Skip and continue (0)
                    ..0. .... = May Change: No
                    ...0 0101 = Low-Order Bits: 0x05
                Length: 2
                Router Alert: MLD (0)
            PadN
                Type: PadN (0x01)
                    00.. .... = Action: Skip and continue (0)
                    ..0. .... = May Change: No
                    ...0 0001 = Low-Order Bits: 0x01
                Length: 0
                PadN: <none>
    Internet Control Message Protocol v6
        Type: Multicast Listener Report Message v2 (143)
        Code: 0
        Checksum: 0xe6e4 [correct]
        [Checksum Status: Good]
        Reserved: 0000
        Number of Multicast Address Records: 1
        Multicast Address Record Changed to exclude: ff02::1:ff08:889d
            Record Type: Changed to exclude (4)
            Aux Data Len: 0
            Number of Sources: 0
            Multicast Address: ff02::1:ff08:889d

3.總結

以上就是OPENFLOW報文交互時的6種常見報文,常見的交互流程如圖所示:

而交換機的轉發行爲以下所示:

flow_mod報文以下:
flow_mod報文由控制器下發流表指導轉發行爲

h1 ping h2的交互過程:
能夠看出是由控制器指導ICMP報文的轉發,在這裏面有一些提示no response found,這個是wireshark抓包後本身添加的分析內容,其實觀察的話會發現request報文和response報文一直是一對一的。

把控制器的controller type從openflow reference改成OVS controller則openflow協議版本由1.0變爲1.3網絡

相關文章
相關標籤/搜索