飞羽

初体验:OVS的openflow协议
本章讲解了使用OpenVSwitch的openflow协议的一些记录。
扫描右侧二维码阅读全文
18
2019/06

初体验:OVS的openflow协议

本章讲解了使用OpenVSwitch的openflow协议的一些记录。

初体验:OVS的openflow协议

初体验:OVS的openflow协议.jpg

全文概括

本章讲解了使用OpenVSwitch的openflow协议的一些命令,以后可能会用到,因此,在博客里做个记录。

openflow介绍

OpenVSwitch介绍

  • 软件定义网络(Software Defined Network,SDN)是由美国斯坦福大学CLean State课题研究组提出的一种新型网络创新架构,是网络虚拟化的一种实现方式。其核心技术OpenFlow通过将网络设备的控制面与数据面分离开来,从而实现了网络流量的灵活控制,使网络作为管道变得更加智能,为核心网络及应用的创新提供了良好的平台。
  • OpenFlow,一种网络通信协议,属于数据链路层,能够控制网上交换器或路由器的转发平面(forwarding plane),借此改变网络数据包所走的网络路径。


如果想要看openvswitch的介绍或者ovs的编译步骤,请看以下文章:

命令汇总

  1. 列出br1网桥的接口
[root@localhost ~]# ovs-ofctl -O OpenFlow13 show br1
#列出br4网桥的接口
OFPT_FEATURES_REPLY (OF1.3) (xid=0x2): dpid:0000227f47f14b45
n_tables:254, n_buffers:256
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
OFPST_PORT_DESC reply (OF1.3) (xid=0x3):
 1(ca5ab26545b04_l): addr:da:ed:cd:c6:bf:0a
     config:     0
     state:      0
     current:    10GB-FD COPPER
     speed: 10000 Mbps now, 0 Mbps max
 2(619496038daf4_l): addr:3a:0b:d6:59:99:4f
     config:     0
     state:      0
     current:    10GB-FD COPPER
     speed: 10000 Mbps now, 0 Mbps max
 LOCAL(br1): addr:22:7f:47:f1:4b:45
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (OF1.3) (xid=0x5): frags=normal miss_send_len=0
  1. 列出br1网桥的接口
[root@localhost ~]# ovs-ofctl dump-ports -O OpenFlow13 br1
#列出br1网桥的接口
OFPST_PORT reply (OF1.3) (xid=0x2): 3 ports
  port LOCAL: rx pkts=0, bytes=0, drop=1, errs=0, frame=0, over=0, crc=0
           tx pkts=0, bytes=0, drop=0, errs=0, coll=0
           duration=6401.851s
  port  1: rx pkts=551, bytes=1043382, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=391, bytes=29298, drop=0, errs=0, coll=0
           duration=6392.311s
  port  2: rx pkts=383, bytes=28650, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=394, bytes=702996, drop=0, errs=0, coll=0
           duration=6390.151s
  1. 列出br1网桥的某个接口的详细信息
[root@localhost ~]# ovs-ofctl dump-ports -O OpenFlow13 br1
OFPST_PORT reply (OF1.3) (xid=0x2): 3 ports
  port LOCAL: rx pkts=0, bytes=0, drop=1, errs=0, frame=0, over=0, crc=0
           tx pkts=0, bytes=0, drop=0, errs=0, coll=0
           duration=6401.851s
  port  1: rx pkts=551, bytes=1043382, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=391, bytes=29298, drop=0, errs=0, coll=0
           duration=6392.311s
  port  2: rx pkts=383, bytes=28650, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=394, bytes=702996, drop=0, errs=0, coll=0
           duration=6390.151s
[root@localhost ~]# ovs-ofctl dump-ports -O OpenFlow13 br1
OFPST_PORT reply (OF1.3) (xid=0x2): 3 ports
  port LOCAL: rx pkts=0, bytes=0, drop=1, errs=0, frame=0, over=0, crc=0
           tx pkts=0, bytes=0, drop=0, errs=0, coll=0
           duration=6434.883s
  port  1: rx pkts=551, bytes=1043382, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=391, bytes=29298, drop=0, errs=0, coll=0
           duration=6425.343s
  port  2: rx pkts=383, bytes=28650, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=394, bytes=702996, drop=0, errs=0, coll=0
           duration=6423.183s
  1. 查看 Open vSwitch 中的端口信息
[root@localhost ~]# ovs-ofctl show -O OpenFlow13 br1
OFPT_FEATURES_REPLY (OF1.3) (xid=0x2): dpid:0000227f47f14b45
n_tables:254, n_buffers:256
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
OFPST_PORT_DESC reply (OF1.3) (xid=0x3):
 1(ca5ab26545b04_l): addr:da:ed:cd:c6:bf:0a
     config:     0
     state:      0
     current:    10GB-FD COPPER
     speed: 10000 Mbps now, 0 Mbps max
 2(619496038daf4_l): addr:3a:0b:d6:59:99:4f
     config:     0
     state:      0
     current:    10GB-FD COPPER
     speed: 10000 Mbps now, 0 Mbps max
 LOCAL(br1): addr:22:7f:47:f1:4b:45
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (OF1.3) (xid=0x5): frags=normal miss_send_len=0
  1. 获得网络接口的 OpenFlow 编号
[root@localhost ~]# ovs-vsctl get Interface 619496038daf4_l ofport
#获得网络接口的 OpenFlow 编号
2
  1. 查看网桥下的流表
[root@localhost ~]# ovs-ofctl dump-flows -O OpenFlow13 br1
#查看网桥下的流表
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x0, duration=6575.901s, table=0, n_packets=769, n_bytes=730998, priority=0 actions=NORMAL
  1. 添加流表
ovs-ofctl add-flow br1 in_port=1,actions=output:2
  1. 删除网桥中所有的流表
ovs-ofctl del-flows br1
  1. 删除根据匹配项删除网桥中的流表
ovs-ofctl del-flows br0 "in_port=1"
  1. 让端口发来的数据包全部丢弃
ovs-ofctl add-flow br1 priority=12,in_port=2,actions=drop
文章名: 《初体验:OVS的openflow协议》

文章链接:https://blog.8086k.cn/archives/47/

联系方式:1412981048@qq.com

除特别注明外,文章均为飞羽小随笔原创,转载时请注明本文出处及文章链接
Last modification:June 18th, 2019 at 05:13 pm
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment