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

实验3:OpenFlow协议分析实践

时间:2022-09-26 21:35:43浏览次数:58  
标签:struct OpenFlow 实践 uint32 header ofp uint16 实验 port

1.基本要求

(1)拓扑文件

(2)抓包结果截图

hello

Features Request / Set Config

Port_Status

Features Reply

Packet_in

Flow_mod

Packet_out

(3)交互图

(4)回答问题:交换机与控制器建立通信时是使用TCP协议还是UDP协议?

Transmission Control Protocol:TCP

2.进阶要求

(1)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. */
};

(2)Features Request

同上

(3)Set Config

/* Switch configuration. */
struct ofp_switch_config {
    struct ofp_header header;
    uint16_t flags;             /* OFPC_* flags. */
    uint16_t miss_send_len;     /* Max bytes of new flow that datapath should
                                   send to the controller. */
};

(4)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;
};

(5)Features Reply

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. */
};
/* Description of a physical port */
struct ofp_phy_port {
    uint16_t port_no;
    uint8_t hw_addr[OFP_ETH_ALEN];
    char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */

    uint32_t config;        /* Bitmap of OFPPC_* flags. */
    uint32_t state;         /* Bitmap of OFPPS_* flags. */

    /* Bitmaps of OFPPF_* that describe features.  All bits zeroed if
     * unsupported or unavailable. */
    uint32_t curr;          /* Current features. */
    uint32_t advertised;    /* Features being advertised by the port. */
    uint32_t supported;     /* Features supported by the port. */
    uint32_t peer;          /* Features advertised by peer. */
};

(6)Packet_in

/* Why is this packet being sent to the controller? */
enum ofp_packet_in_reason {
    OFPR_NO_MATCH,          /* No matching flow. */
    OFPR_ACTION             /* Action explicitly output to controller. */
};

(7)Flow_mod

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_*. */
    struct ofp_action_header actions[0]; /* The action length is inferred
                                            from the length field in the
                                            header. */
};
struct ofp_action_header {
    uint16_t type;                  /* One of OFPAT_*. */
    uint16_t len;                   /* Length of action, including this
                                       header.  This is the length of action,
                                       including any padding to make it
                                       64-bit aligned. */
    uint8_t pad[4];
};

(7)Packet_out

struct ofp_packet_out {
    struct ofp_header header;
    uint32_t buffer_id;           /* ID assigned by datapath (-1 if none). */
    uint16_t in_port;             /* Packet's input port (OFPP_NONE if none). */
    uint16_t actions_len;         /* 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.) */
};

3.个人总结

(1)遇到的问题和解决

在第一次实验时,用wireshark没有抓到hello的包,通过仔细阅读pdf文档和思考,确定是开启wireshark和构建拓扑结构的顺序错误导致的,先抓包后构建拓扑,就能抓到hello包了。

(2)经验总结

本次实验的难度并不大,主要是查看和分析抓包信息和对照源码。经过实验,我更加了解了OpenFlow协议数据的交互过程,提升了运用wireshark抓取数据包的能力。在将数据包信息与源码进行对比后,对OpenFlow消息类型的数据结构有了更深入的了解。

标签:struct,OpenFlow,实践,uint32,header,ofp,uint16,实验,port
From: https://www.cnblogs.com/itlcn/p/16732290.html

相关文章

  • 实验3:OpenFlow协议分析实践
    实验3:OpenFlow协议分析实践一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制......
  • 实验3:OpenFlow协议分析实践
    一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制。二、实验环境Ubuntu2......
  • 实验3:OpenFlow协议分析实践
    (一)基本要求拓扑文件wireshark抓包的结果OFPT_HELLO控制器6633端口(我最高能支持OpenFlow1.0)--->交换机55692端口交换机55692端口(我最高能支持OpenFlow1.5)-......
  • 实验3:OpenFlow协议分析实践
    (一)基本要求搭建下图所示拓扑,完成相关IP配置,并实现主机与主机之间的IP通信。用抓包软件获取控制器与交换机之间的通信数据。            ......
  • 实验3:OpenFlow协议分析实践
    实验3:OpenFlow协议分析实践一、实验目的1.能够运用wireshark对OpenFlow协议数据交互过程进行抓包;2.能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与......
  • 实验3:OpenFlow协议分析实践
    一、基本要求1.搭建拓扑2.抓包结果HELLO控制器6633端口(我最高能支持OpenFlow1.0)--->交换机41986端口交换机41986端口(我最高能支持OpenFlow1.3)--->控制器6633......
  • 实验3:OpenFlow协议分析实践
    一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制。二、实验环境Ubuntu20......
  • 实验3:OpenFlow协议分析实践
    (一)基本要求拓扑文件wireshark抓包的结果OFPT_HELLO控制器6633端口(我最高能支持OpenFlow1.0)--->交换机46192端口交换机46192端口(我最高能支持OpenFlow1.5)--->......
  • 阿里云 ACK 容器服务生产级可观测体系建设实践
    简介: 随着容器被越来越对企业接纳与落地,可观测成为重点。那么,让我们深入了解阿里云ACK容器服务生产级可观测体系建设实践,为自身业务可观测提供参考~作者:冯诗淳......
  • ARMS实践|日志在可观测场景下的应用
    简介: 在实际生产中,通过灵活组合文内几种使用方式,运维团队可以很好地排除日常观测、故障定位过程中的干扰因素,更快的定界甚至定位问题根因。作者:陈陈 日志在......