首页 > 其他分享 >实验3:OpenFlow协议分析实践

实验3:OpenFlow协议分析实践

时间:2022-10-06 13:13:07浏览次数:53  
标签:struct OpenFlow 端口 实践 header ofp uint16 实验 port

(一)基础要求
1)/home/用户名/学号/lab3/目录下的拓扑文件

2)wireshark抓包的结果截图和对应的文字说明

  • Hello
    控制器6633端口(我最高能支持OpenFlow 1.0) ---> 交换机52084端口

    交换机52084端口(我最高能支持OpenFlow 1.5) ---> 控制器6633端口
  • Features Request
    控制器6633端口(我需要你的特征信息) ---> 交换机52084端口
  • Set Conig
    控制器6633端口(请按照我给你的flag和max bytes of packet进行配置) ---> 交换机52084端口
  • Port Status
    从交换机52084端口到控制器6633端口当交换机端口发生变化时,告知控制器相应的端口状态。
  • Features Reply
    交换机52084端口(这是我的特征信息,请查收) ---> 控制器6633端口
  • Packet_in
    交换机52084端口(有数据包进来,请指示)--- 控制器6633端口
  • Flow_mod
    控制器通过6633端口向交换机52084端口下发流表项,指导数据的转发处理

  • Packet_out
    控制器6633端口向交换机52084端口发送数据,并告知交换机输出到端口

    3)OpenFlow协议中交换机与控制器的消息交互过程,画出相关交互图或流程图

    4)交换机与控制器建立通信时是使用TCP协议还是UDP协议?
    使用的是TCP协议,如下图

    (二)进阶要求
  • hello
/* Header on all OpenFlow packets. */
struct ofp_header {
    uint8_t version;    /* OFP_VERSION. */
    uint8_t type;       /* One of the OFPT_ constants. */
    uint16_t length;    /* Length including this ofp_header. */
    uint32_t xid;       /* Transaction id associated with this packet.
                           Replies use the same id as was in the request
                           to facilitate pairing. */
};
OFP_ASSERT(sizeof(struct ofp_header) == 8);

/* OFPT_HELLO.  This message has an empty body, but implementations must
 * ignore any data included in the body, to allow for future extensions. */
struct ofp_hello {
    struct ofp_header header;
};
  • Features Request
/* Header on all OpenFlow packets. */
struct ofp_header {
    uint8_t version;       /* OFP_VERSION. */
    uint8_t type;          /* One of the OFPT_ constants. */
    uint16_t length;       /* Length including this ofp_header. */
    uint32_t xid;          /* Transaction id associated with this packet.
                           Replies use the same id as was in the request
                           to facilitate pairing. */
};
OFP_ASSERT(sizeof(struct ofp_header) == 8);

/* OFPT_HELLO.  This message has an empty body, but implementations must
 * ignore any data included in the body, to allow for future extensions. */
struct ofp_hello {
    struct ofp_header header;
};
  • Set Config
enum ofp_config_flags {
    /* Handling of IP fragments. */
    OFPC_FRAG_NORMAL   = 0,  /* No special handling for fragments. */
    OFPC_FRAG_DROP     = 1,  /* Drop fragments. */
    OFPC_FRAG_REASM    = 2,  /* Reassemble (only if OFPC_IP_REASM set). */
    OFPC_FRAG_MASK     = 3
};                              

/* Switch configuration. */
struct ofp_switch_config {
    struct ofp_header header;
    uint16_t flags;             /* OFPC_* flags. */                      //flag不同的值代表不同的处理方式
    uint16_t miss_send_len;     /* Max bytes of new flow that datapath should
                                   send to the controller. */
};
OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
  • Port_Status
/* A physical port has changed in the datapath */
struct ofp_port_status {
    struct ofp_header header;
    uint8_t reason;          /* One of OFPPR_*. */
    uint8_t pad[7];          /* Align to 64-bits. */
    struct ofp_phy_port desc;
};
OFP_ASSERT(sizeof(struct ofp_port_status) == 64);     //发生变化,则需发送port status来告知
  • Features Reply
/* Switch features. */
struct ofp_switch_features {
    struct ofp_header header;
    uint64_t datapath_id;   /* Datapath unique ID.  The lower 48-bits are for
                               a MAC address, while the upper 16-bits are
                               implementer-defined. */

    uint32_t n_buffers;     /* Max packets buffered at once. */

    uint8_t n_tables;       /* Number of tables supported by datapath. */
    uint8_t pad[3];         /* Align to 64-bits. */

    /* Features. */
    uint32_t capabilities;  /* Bitmap of support "ofp_capabilities". */
    uint32_t actions;       /* Bitmap of supported "ofp_action_type"s. */

    /* Port info.*/
    struct ofp_phy_port ports[0];  /* Port definitions.  The number of ports
                                      is inferred from the length field in
                                      the header. */
};
OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
  • Packet_in
/* Packet received on port (datapath -> controller). */
struct ofp_packet_in {
    struct ofp_header header;
    uint32_t buffer_id;     /* ID assigned by datapath. */
    uint16_t total_len;     /* Full length of frame. */
    uint16_t in_port;       /* Port on which frame was received. */
    uint8_t reason;         /* Reason packet is being sent (one of OFPR_*) */
    uint8_t pad;
    uint8_t data[0];        /* Ethernet frame, halfway through 32-bit word,
                               so the IP header is 32-bit aligned.  The
                               amount of data is inferred from the length
                               field in the header.  Because of padding,
                               offsetof(struct ofp_packet_in, data) ==
                               sizeof(struct ofp_packet_in) - 2. */
};
OFP_ASSERT(sizeof(struct ofp_packet_in) == 20);
  • Flow_mod
/* Flow setup and teardown (controller -> datapath). */
struct ofp_flow_mod {
    struct ofp_header header;
    struct ofp_match match;      /* Fields to match */
    uint64_t cookie;             /* Opaque controller-issued identifier. */

    /* Flow actions. */
    uint16_t command;             /* One of OFPFC_*. */
    uint16_t idle_timeout;        /* Idle time before discarding (seconds). */    //空闲超时时间
    uint16_t hard_timeout;        /* Max time before discarding (seconds). */   //最大生存时间
    uint16_t priority;            /* Priority level of flow entry. */
    uint32_t buffer_id;           /* Buffered packet to apply to (or -1).
                                     Not meaningful for OFPFC_DELETE*. */
    uint16_t out_port;            /* For OFPFC_DELETE* commands, require
                                     matching entries to include this as an
                                     output port.  A value of OFPP_NONE
                                     indicates no restriction. */
    uint16_t flags;               /* One of OFPFF_*. */
//标志位,可以用来指示流表删除后是否发送flow‐removed消息,添加流表时是否检查流表重复项,添加的流表项是否为应急流表项
    struct ofp_action_header actions[0]; /* The action length is inferred
                                            from the length field in the
                                            header. */
};
OFP_ASSERT(sizeof(struct ofp_flow_mod) == 72);
  • Packet_out
/* Send packet (controller -> datapath). */
struct ofp_packet_out {
    struct ofp_header header;
    uint32_t buffer_id;          //交换机缓存区id,如果为-1则指定的为packet-out消息携带的data字段 /* ID assigned by datapath (-1 if none). */
    uint16_t in_port;            //如果buffer_id为‐1,并且action列表中指定了Output=TABLE的动作,in_port将作为data段数据包的额外匹配信息进行流表查询  
 /* Packet's input port (OFPP_NONE if none). */
    uint16_t actions_len;        //用来区分actions和data段 /* Size of action array in bytes. */
    struct ofp_action_header actions[0]; /* Actions. */
    /* uint8_t data[0]; */        /* Packet data.  The length is inferred
                                     from the length field in the header.
                                     (Only meaningful if buffer_id == -1.) */
};
OFP_ASSERT(sizeof(struct ofp_packet_out) == 16);

(三)个人总结
在做的过程中由于不大熟悉命令有所卡顿,这个实验主要是抓包分析OpenFlow通讯过程数据包。对wireshark工具使用更加熟练,通过抓包的结果进行观察与学习,了解OpenFlow主要消息类型对应的数据结构定义。在最开始的时候找hello包时,老是找不到(太费眼睛了),后面同学帮忙才找到,其它包就比较容易找到,然后是在进阶部分对源代码进行分析比较难,看不懂英文,就得去网上查阅。一定要做一题存稿!!!以免发生意外,就白做了,或者看看有没有自动备份。

标签:struct,OpenFlow,端口,实践,header,ofp,uint16,实验,port
From: https://www.cnblogs.com/fei-fei-f/p/16757428.html

相关文章

  • TCP与UDP的联系与区别,网络字节序与主机字节序的转换函数实践
     (1)TCP与UDP的联系与区别:TCP是基于连接的协议,也就是说,在正式收发数据前,必须和对方建立可靠的连接,一个TCP连接必须要经过三次“对话”才能建立起来。UDP是与TCP相对应的协......
  • 实验3:OpenFlow协议分析实践&&实验2:Open vSwitch虚拟交换机实践
    实验3:OpenFlow协议分析实践一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制......
  • 实验四
    (一)基本要求利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight控制器;......
  • 实验3:OpenFlow协议分析实践
    一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制。二、实验环境Ubuntu20.0......
  • 实验3:OpenFlow协议分析实践
    一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制。二、实验环境Ubuntu20.0......
  • 实验3:OpenFlow协议分析实践
    实验3:OpenFlow协议分析实践一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制......
  • SDN第三次实验
    实验3:OpenFlow协议分析实践一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制......
  • 实验三
    实验3:OpenFlow协议分析实践 一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程......
  • 实验3:OpenFlow协议分析实践
    1.基础要求a)/home/用户名/学号/lab3/目录下的拓扑文件b)wireshark抓包的结果截图和对应的文字说明Hello控制器6633端口(我最高能支持OpenFlow1.0)--->交换机36994......
  • 实验三
    实验3:OpenFlow协议分析实践 一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程......