《openflow数据结构.ppt》由会员分享,可在线阅读,更多相关《openflow数据结构.ppt(38页珍藏版)》请在三一办公上搜索。
1、openflow,数据结构,header,struct ofp_header uint8_t version;uint8_t type;uint16_t length;uint32_t xid;/*Transaction id associated with this packet.Replies use the same id as was in the requestto facilitate pairing.*/;,hello,OFPT_HELLO 消息没有消息体,仅有of 消息头,struct ofp_error_msg struct ofp_header header;uint16_
2、t type;高层的错误类型uint16_t code;错误代码uint8_t data0;变长 至少包括64 字节的失败请求 代码中将整个错误报文全部发回去;,echo,echo请求消息由一个of 消息头加上任意的消息体组成,用来协助测量延迟、带宽、控制器跟交换机之间是否保持连接等信息。echo回复消息由一个of 消息头加上对应请求的无修改消息体组成,用来协助测量延迟、带宽、控制器跟交换机之间是否保持连接等信息。,代码中没有附加任何信息,只有协议头。没有处理,OFPT_FEATURES_REQUEST,发送一个仅有消息头的OFPT_FEATURES_REQUEST消息,OFPT_FEATUR
3、ES_REPLY,struct ofp_switch_features struct ofp_header header;uint64_t datapath_id;dp标示符uint32_t n_buffers;最多缓存多少数据报文uint8_t n_tables;交换机支持的流表个数uint8_t pad3;64位对齐uint32_t capabilities;功能uint32_t actions;标志支持行动的bit 串struct ofp_phy_port ports0;描绘所有支持of 的交换机端口;,enum ofp_capabilities OFPC_FLOW_STATS=1 0,
4、流统计OFPC_TABLE_STATS=1 1,表统计OFPC_PORT_STATS=1 2,端口统计OFPC_STP=1 3,802.1d生成树OFPC_RESERVED=1 4,保留项,必须为0OFPC_IP_REASM=1 5,可以重组IP分段OFPC_QUEUE_STATS=1 6,队列统计OFPC_ARP_MATCH_IP=1 7 匹配IP地址 in arp pkts;,enum ofp_action_type OFPAT_OUTPUT,输出到sw端口OFPAT_SET_VLAN_VID,设定802.1q虚拟网IDOFPAT_SET_VLAN_PCP,设定虚拟网优先级OFPAT_ST
5、RIP_VLAN,剥去虚拟网头部OFPAT_SET_DL_SRC,设定以太网源地址OFPAT_SET_DL_DST,设定以太网目的地址OFPAT_SET_NW_SRC,设定IP源地址OFPAT_SET_NW_DST,设定IP目的地址OFPAT_SET_NW_TOS,设定IPTOSOFPAT_SET_TP_SRC,设定TCP/UDP source portOFPAT_SET_TP_DST,设定TCP/UDP destinationportOFPAT_ENQUEUE,输出到队列中区OFPAT_VENDOR=0 xffff;,struct ofp_phy_port uint16_t port_no;
6、标明绑定到物理接口的datapath 值uint8_t hw_addrOFP_ETH_ALEN;是该物理接口的mac 地址char nameOFP_MAX_PORT_NAME_LEN;是该接口的名称字符串,以null 结尾uint32_t config;描述了生成树和管理设置uint32_t state;生成树状态和某个物理接口是否存在uint32_t curr;uint32_t advertised;uint32_t supported;uint32_t peer;,enum ofp_port_config OFPPC_PORT_DOWN=1 0,端口被手工downOFPPC_NO_STP=
7、1 1,无法802.1d生成树OFPPC_NO_RECV=1 2,drop所有的报文,除了802.1d生成树的报文OFPPC_NO_RECV_STP=1 3,drop已经收到的802.1d的生成树的报文OFPPC_NO_FLOOD=1 4,不计入该端口,当它洪泛的时候OFPPC_NO_FWD=1 5,drop被转发到端口的报文OFPPC_NO_PACKET_IN=1 6 不要为该端口发送packet-in报文;,enum ofp_port_state OFPPS_LINK_DOWN=1 0,现在没有物理链接OFPPS_STP_LISTEN=0 8,没有learning和relaying的帧OF
8、PPS_STP_LEARN=1 8,Learning but not relaying framesOFPPS_STP_FORWARD=2 8,Learning and relaying framesOFPPS_STP_BLOCK=3 8,不是生成树的一部分OFPPS_STP_MASK=3 8/*Bit mask for OFPPS_STP_*values.*/;,curr,advertised,supported 和peer 域标明 链路模式(10M 到10G,全双工、半双工),链路类型(铜线/光线)和链路特性(自动协商和暂停),OFPT_GET_CONFIG_REQUESTOFPT_GET
9、_CONFIG_REPLYOFPT_SET_CONFIG,struct ofp_switch_config struct ofp_header header;uint16_t flags;分片怎么处理uint16_t miss_send_len;不匹配 发给交换机 发的数据长度;,enum ofp_config_flags OFPC_FRAG_NORMAL=0,/*No special handling for fragments.*/OFPC_FRAG_DROP=1,/*Drop fragments.*/OFPC_FRAG_REASM=2,/*Reassemble(only if OFPC_
10、IP_REASM set).*/OFPC_FRAG_MASK=3,OFPT_PACKET_IN,struct ofp_packet_in struct ofp_header header;uint32_t buffer_id;dp标示缓存中的网包uint16_t total_len;帧的长度uint16_t in_port;帧被交换机接受的入口uint8_t reason;发给ctl的原因uint8_t pad;uint8_t data0;,enum ofp_packet_in_reason OFPR_NO_MATCH,/*No matching flow.*/OFPR_ACTION/*Act
11、ion explicitly output to controller.*/,OFPT_FLOW_REMOVED,struct ofp_flow_removed struct ofp_header header;struct ofp_match match;uint64_t cookie;/*Opaque controllerissued identifier.*/uint16_t priority;优先级uint8_t reason;删除原因uint8_t pad1;uint32_t duration_sec;生存时间uint32_t duration_nsec;/*Time flow wa
12、s alive in nanoseconds beyondduration_sec.*/uint16_t idle_timeout;/*Idle timeout from original flow mod.*/uint8_t pad22;uint64_t packet_count;包信息计数 uint64_t byte_count;流量信息计数;,enum ofp_flow_removed_reason OFPRR_IDLE_TIMEOUT,/*Flow idle time exceeded idle_timeout.*/OFPRR_HARD_TIMEOUT,/*Time exceeded
13、hard_timeout.*/OFPRR_DELETE/*Evicted by a DELETE flow mod.*/;,ofp_match,struct ofp_match uint32_t wildcards;uint16_t in_port;输入的交换机端口uint8_t dl_srcOFP_ETH_ALEN;uint8_t dl_dstOFP_ETH_ALEN;uint16_t dl_vlan;uint8_t dl_vlan_pcp;uint8_t pad11;uint16_t dl_type;uint8_t nw_tos;uint8_t nw_proto;uint8_t pad22
14、;uint32_t nw_src;uint32_t nw_dst;uint16_t tp_src;uint16_t tp_dst;,OFPT_PORT_STATUS,struct ofp_port_status struct ofp_header header;uint8_t reason;uint8_t pad7;struct ofp_phy_port desc;,enum ofp_port_reason OFPPR_ADD,OFPPR_DELETE,OFPPR_MODIFY;,OFPT_PACKET_OUT,struct ofp_packet_out struct ofp_header h
15、eader;uint32_t buffer_id;跟ofp_packet_in 中给出的一致。如果buffer_id 是-1,则网包内容被包括在data 域中,dp分配uint16_t in_port;报文的输入端口uint16_t actions_len 行为数组的长度struct ofp_action_header actions0;/*uint8_t data0;*/;,struct ofp_action_header uint16_t type;uint16_t len;uint8_t pad4;,OFPT_FLOW_MOD,struct ofp_flow_mod struct ofp
16、_header header;struct ofp_match match;uint64_t cookie;uint16_t command;如何处理uint16_t idle_timeout;uint16_t hard_timeout;uint16_t priority;优先级uint32_t buffer_id;标志被OFPT_PACKET_IN 消息发出的网包在buffer 中的iduint16_t out_port;out_port 可选的用于进行删除操作时的匹配uint16_t flags;struct ofp_action_header actions0;,enum ofp_flo
17、w_mod_flags OFPFF_SEND_FLOW_REM=1 0,/*Send flow removed message when flow expires or is deleted.*/OFPFF_CHECK_OVERLAP=1 1,/*Check for overlapping entries first.*/OFPFF_EMERG=1 2/*Remark this is for emergency.*/;,enum ofp_flow_mod_command OFPFC_ADD,/*New flow.*/OFPFC_MODIFY,/*Modify all matching flow
18、s.*/OFPFC_MODIFY_STRICT,/*Modify entry strictly matching wildcards*/OFPFC_DELETE,/*Delete all matching flows.*/OFPFC_DELETE_STRICT/*Strictly match wildcards and priority.*/;,OFPT_PORT_MOD,struct ofp_port_mod struct ofp_header header;uint16_t port_no;uint8_t hw_addrOFP_ETH_ALEN;uint32_t config;uint32
19、_t mask;用来选择config 中被修改的域uint32_t advertise;advertise 域没有掩码,所有的特性一起修改uint8_t pad4;,OFPT_STATS_REQUEST,struct ofp_stats_request struct ofp_header header;uint16_t type;type 则定义信息的类型,以决定body 中信息该如何解析(32页开始)uint16_t flags;uint8_t body0;,OFPT_STATS_REPLY,struct ofp_stats_reply struct ofp_header header;ui
20、nt16_t type;uint16_t flags;flags 用来标明是否有多条附加的回复uint8_t body0;,OFPT_BARRIER_REQUEST,没有消息体交换机一旦收到该消息,则需要先执行完该消息前到达的所有指令,然后再执行其后的。之前指令处理完成后,交换机要回复OFPT_BARRIER_REPLY 消息,且携带有原请求信息的xid 信息。,OFPT_QUEUE_GET_CONFIG_REQUEST,struct ofp_queue_get_config_request struct ofp_header header;uint16_t port;被询问的端口uint8_
21、t pad2;,OFPT_QUEUE_GET_CONFIG_REPLY,struct ofp_queue_get_config_reply struct ofp_header header;uint16_t port;uint8_t pad6;struct ofp_packet_queue queues0;,struct ofp_packet_queue uint32_t queue_id;/*id for the specific queue.*/uint16_t len;/*Length in bytes of this queue desc.*/uint8_t pad2;/*64bit
22、alignment.*/struct ofp_queue_prop_header properties0;/*List of properties.*/;,struct ofp_queue_prop_header uint16_t property;/*One of OFPQT_.*/uint16_t len;/*Length of property,including this header.*/uint8_t pad4;/*64bit alignemnt.*/;,enum ofp_queue_properties OFPQT_NONE=0,/*No property defined for
23、 queue(default).*/OFPQT_MIN_RATE,/*Minimum datarate guaranteed.*/*Other types should be added here*(i.e.max rate,precedence,etc).*/;,struct vconn struct vconn_class*class;int state;int error;int min_version;int version;uint32_t ip;char*name;bool reconnectable;struct ofpstat ofps_rcvd;struct ofpstat ofps_sent;,