2019 SDN上机第3次作业

1.利用Mininet仿真平台构建如下图所示的网络拓扑,配置主机h1和h2的IP地址(h1:10.0.0.1,h2:10.0.0.2),测试两台主机之间的网络连通性

使用miniedit工具建立拓扑:

image
查看
image.png
image.png

在RUN之前,需要开启start cli 和 勾选OpenFlow1.3

2. 利用Wireshark工具,捕获拓扑中交换机与控制器之间的通信数据,对OpenFlow协议类型的各类报文(hello, features_request, features_reply, set_config, packet_in, packet_out等)进行分析,对照wireshark截图分析。

在拓扑建立后之后,先打开wireshark捕捉报文,再启动拓扑。

2.1 Hello报文:

控制器端口发往交换机的报文,最高支持OpenFlow1.0协议
image.png

二者最低版本协议为OpenFlow1.0,所以选取1.0作为通信协议。

Q1:Hello 消息是使用什么协议传输?TCP?UDP?
A1:使用TCP协议传输。

Q2:所有的网络协议在升级的时候都必须向前兼容更低版本的协议?why?
A2:所有网络协议在升级时都必须向前兼容更低版本的协议,因为网络上存在大量未升级的旧设备,这些设备因为成本等各种问题没有及时更新,他们支持的协议是相对低版本的,如果网络协议升级不支持低版本,那么就会造成旧设备所在的网络出现故障。

2.2 Features Request报文:

控制器向交换机发送 Features Request 消息查询交换机特性。
image
image.png

2.3 Set Config报文:

控制器对交换机flags和miss_send_len属性进行配置
flags:用来指示交换机如何才处理 IP 分片数据包。
miss_send_len:用来指示当一个交换机无法处理的数据包到达时,将数据包发给控制器的最大字节数。
image.png

2.4 Features Reply报文:

交换机在收到控制器发出的 Features Request 消息后返回 Features Request 消息。
image.png

Features Reply Message结构

 struct ofp_switch_features{
    struct ofp_header header;
    uint64_t datapath_id; /*唯一标识 id 号*/
    uint32_t n_buffers; /*交缓冲区可以缓存的最大数据包个数*/
    uint8_t n_tables; /*流表数量*/
    uint8_t pad[3]; /*align to 64 bits*/
    uint32_t capabilities; /*支持的特殊功能,具体见 ofp_capabilities*/
    uint32_t actions; /*支持的动作,具体见 ofp_actions_type*/
    struct ofp_phy_port ports[0]; /*物理端口描述列表,具体见 ofp_phy_port*/
};

Feature Reply报文:

Frame 562: 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: 51210, Dst Port: 6633, Seq: 73, Ack: 29, Len: 176
OpenFlow 1.0
    .000 0001 = Version: 1.0 (0x01)
    Type: OFPT_FEATURES_REPLY (6)
    Length: 176
    Transaction ID: 3788843471
    Datapath unique ID: 0x0000000000000002
        MAC addr: 00:00:00_00:00:00 (00:00:00:00:00:00)
        Implementers part: 0x0002
    n_buffers: 256
    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: 7e:b7:55:ce:21:4c (7e:b7:55:ce:21:4c)
        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: 3a:a8:73:f3:c9:64 (3a:a8:73:f3:c9:64)
        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: 7e:7b:12:2c:0f:65 (7e:7b:12:2c:0f:65)
        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



### 2.5 Packet_in报文:

当交换机收到一个数据包后,查找流表。如果流表中有匹配条目,则交换机按照流表所指示的 action 列表处理数据包。如果没有,则交换机将数据包封装在 Packet-in 消息中发送给控制器处理.
![image](https://upload-images.jianshu.io/upload_images/19518479-bb2d318778cc74df.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

`In port:1 Reason:No matching flow(tables-miss flow entry)(0)`
交换机发现此时自己并没有匹配的流表(Reason: No matching flow (table-miss flow entry) (0)),所以要发送Packet_in报文询问控制器如何处理

#### Packet_in报文:

> Frame 313: 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: 46522, 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: 0x00000100
> Total length: 90
> In port: 1
> Reason: No matching flow (table-miss flow entry) (0)
> Pad: 00
> Ethernet II, Src: 42:2d:75:d9:0f:5d (42:2d:75:d9:0f:5d), 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: 42:2d:75:d9:0f:5d (42:2d:75:d9:0f:5d)
> Address: 42:2d:75:d9:0f:5d (42:2d:75:d9:0f:5d)
> .... ..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: 0x5f54 [correct]
> [Checksum Status: Good]
> Reserved: 0000
> Number of Multicast Address Records: 1
> Multicast Address Record Changed to exclude: ff02::1:ffd9:f5d
> Record Type: Changed to exclude (4)
> Aux Data Len: 0
> Number of Sources: 0
> Multicast Address: ff02::1:ffd9:f5d</none>

2.6 Packet_out报文:

Packet_out的结构:

struct ofp_packet_out {
    struct ofp_header header;
    uint32_t buffer_id; /*交换机缓存区id,如果为-1则指定的为packet-out消息携带的data字段*/
    uint16_t in_port; /*如果buffer_id为‐1,并且action列表中指定了Output=TABLE的动作,in_port将作为data段数据包的额外匹配信息进行流表查询*/
    uint16_t actions_len; /*action列表的长度,可以用来区分actions和data段*/
    struct ofp_action_header actions[0]; /*动作列表*/
    uint8_t data[0]; /*数据缓存区,可以存储一个以太网帧,可选*/
}

image.png

告知端口1的报文可以输出到交换机的51210端口

2.7 Packet_in报文:

image.png

2.8 把控制器从openflow reference 改成ovs controller后:

控制器支持的OpenFlow版本从1.0变成了1.3
image

flow_mod:
image

image

posted @ 2019-11-18 22:54  左登峰  阅读(170)  评论(0编辑  收藏  举报