• 2019 SDN上机第3次作业


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


    输入pingall

    2. 利用Wireshark工具,捕获拓扑中交换机与控制器之间的通信数据,对OpenFlow协议类型的各类报文进行分析,对照wireshark截图写出你的分析内容。

    只支持OpenFlow1.0版本

    Hello报文

    ​控制器6633端口,对应交换机51646端口

    交换机51646端口,对应6633端口控制器

    双方建立连接,并使用OpenFlow1.0

    Features_Request报文

    控制器6633端口,需要交换机51646端口的特征信息

    Set_Config报文

    控制器6633端口按照给定的flag和max bytes of packet进行配置交换机的51646端口

    Features_Reply报文

    交换机51646端口发出自身的特征信息,请控制器6633端口查收

    Features 消息包括 OpenFlow Header 和 Features Reply Message
    对照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*/
    };
    

    对应到抓取到的报文,逐项查看报文内容

    Packet_in报文

    交换机51646端口(有数据包进来,请指示)--- 控制器6633端口

    结合Packet_in的结构:

    struct ofp_packet_in {
        struct ofp_header header;
        uint32_t buffer_id; /*Packet-in消息所携带的数据包在交换机缓存区中的ID*/
        uint16_t total_len; /*data字段的长度*/
        uint16_t in_port; /*数据包进入交换机时的端口号*/
        uint8_t reason; /*发送Packet-in消息的原因,具体见 ofp_packet_in_reason*/
        uint8_t pad;
        uint8_t data[0]; /*携带的数据包*/
    };
    

    分析抓取的数据包,可以发现是因为交换机发现此时自己并没有匹配的流表(Reason: No matching flow (table-miss flow entry) (0)),所以要问控制器如何处理:

    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: 96:3f:21:4c:f5:0e (96:3f:21:4c:f5:0e), 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: 96:3f:21:4c:f5:0e (96:3f:21:4c:f5:0e)
                Address: 96:3f:21:4c:f5:0e (96:3f:21:4c:f5:0e)
                .... ..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: 0x7a2f [correct]
            [Checksum Status: Good]
            Reserved: 0000
            Number of Multicast Address Records: 1
            Multicast Address Record Changed to exclude: ff02::1:ff4c:f50e
                Record Type: Changed to exclude (4)
                Aux Data Len: 0
                Number of Sources: 0
                Multicast Address: ff02::1:ff4c:f50e
    

    Packet_out报文

    控制器6633端口(请按照我给你的action进行处理) ---> 交换机51646端口

    结合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]; /*数据缓存区,可以存储一个以太网帧,可选*/
    }
    

    告诉输出到交换机的51646端口:

    OpenFlow 1.0
        .000 0001 = Version: 1.0 (0x01)
        Type: OFPT_PACKET_OUT (13)
        Length: 24
        Transaction ID: 0
        Buffer Id: 0x00000100
        In port: 1
        Actions length: 8
        Actions type: Output to switch port (0)
        Action length: 8
        Output port: 65531
        Max length: 0
    

    h1 ping h2

    Packet_out

    flow_mod

    结合flow_mod结构:

    struct ofp_flow_mod {
        struct ofp_header header;
        struct ofp_match match; /*流表的匹配域*/ 
        uint64_t cookie; /*流表项标识符*/
        uint16_t command; /*可以是ADD,DELETE,DELETE-STRICT,MODIFY,MODIFY-STRICT*/
        uint16_t idle_timeout; /*空闲超时时间*/
        uint16_t hard_timeout; /*最大生存时间*/
        uint16_t priority; /*优先级,优先级高的流表项优先匹配*/
        uint32_t buffer_id; /*缓存区ID ,用于指定缓存区中的一个数据包按这个消息的action列表处理*/  
        uint16_t out_port; /*如果这条消息是用于删除流表则需要提供额外的匹配参数*/
        uint16_t flags; /*标志位,可以用来指示流表删除后是否发送flow‐removed消息,添加流表时是否检查流表重复项,添加的流表项是否为应急流表项。*/
        struct ofp_action_header actions[0]; /*action列表*/
    };
    

    分析抓取的flow_mod数据包,控制器通过6633端口向交换机55端口、交换机51646端口下发流表项,指导数据的转发处理:

  • 相关阅读:
    最近在学习vala,并打算用它写点东西, 先上个习作 -- popplersample
    GTK# 学习笔记
    monodevelop2.0在SmartQ5上成功运行
    c, cs, vala 性能简单测试
    在Q5上用vala写程序
    树结构型数据在基于关系型数据库的分布式应用的解决方案
    常用常忘的delegate,记一下。
    JSON
    HTML5脚本编程
    event事件对象
  • 原文地址:https://www.cnblogs.com/HuangYH723/p/11852045.html
Copyright © 2020-2023  润新知