Open vSwitch系列之一 Open vSwitch诞生

Open vSwitch系列之二 安装指定版本ovs

Open vSwitch系列之三 ovs-vsctl命令使用

Open vSwitch系列之四 ovs-ofctl命令使用

Open vSwitch系列之五 网桥特性功能配置

Open vSwitch系列之六 vlan隔离

Open vSwitch系列之七 meter表限速

Open vSwitch系列之八 vxlan隧道

Open vSwitch系列之九 Group表

Open vSwitch系列之十 调用北向接口下发流表

OpenvSwitch系列之十一 ovs-dpdk

postman介绍

在开发中,前端和后端是分开开发的,当后端开发完成之后会测试接口。Postman就是一个后端接口的测试工具,通过postman可以发送GET、POST、DELETE等请求。通过Postman可以调用控制器的北向接口,下发流表到交换机

GET请求

Get请求需要注意两点,第一请求方法是get,第二是URL

POST请求

POST请求需要注意三点:第一 请求方式是POST,第二URL,第三请求的body体。

Postman下发流表的标准格式

postman下发一条流表需要准备4个部分,分别是:

  1. 动作
  2. URL
  3. 身份认证
  4. body体

动作:PUT

URL:替换自己控制器的ip和交换机switch_id,还要注意flow_id即url最后一个参数,该参数要和body体中一致。

控制器ip:8181/restconf/config/opendaylight-inventory:nodes/node/你的交换机switch_id/flow-node-inventory:table/0/flow/flow6

认证信息:Basic Auth, username: admin password:admin



body体:格式为 raw --> Json。body体里的内容就是流表的信息。

body体具体内容:

body体就是一个流表的具体内容,分为三大块:流表元数据、匹配、动作。

元数据:流表名字,id,优先级等

匹配:流表匹配规则,如经典匹配十二元组

动作:标准动作转发和丢弃

物理端口匹配

匹配进端口为1,动作是转发到222端口

ovs-ofctl add-flow br0 in_port=1,action=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_14
{
"flow": [
{
"id": "demo_14",
"flow-name": "demo_14",
"table_id": 0,
"match": {
"in-port": "1",
"ethernet-match": { }
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}

mac地址匹配

匹配源mac地址:78:45:c4:1c:ba:b9,目的mac地址:00:50:56:c0:00:08,动作是丢弃

ovs-ofctl add-flow br0 dl_src=78:45:c4:1c:ba:b9,dl_dst=00:50:56:c0:00:08,aciton=drop
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_four
{
"flow": [
{
"id": "demo_four",
"flow-name": "demo_four",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-source": {
"mask": "ff:ff:ff:ff:ff:ff",
"address": "78:45:c4:1c:ba:b9"
},
"ethernet-destination": {
"mask": "ff:ff:ff:ff:ff:ff",
"address": "00:50:56:c0:00:08"
}
}
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"drop-action": { }
}
]
}
}
]
}
}
]
}

ip地址匹配

匹配源ip地址为30.0.0.1/32,目的ip为30.0.0.2/32的流表,动作是转发到222端口

ovs-ofctl add-flow br0 ip,nw_src=30.0.0.1/32,nw_dst=30.0.0.2/32,aciton=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_14
{
"flow": [
{
"id": "demo_14",
"flow-name": "demo_14",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
}
},
"ipv4-source": "30.0.0.1/32",
"ipv4-destination": "30.0.0.2/32"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}

udp端口匹配

匹配 源端口为112,目的端口为2321的UDP数据包,动作是转发到222端口。

ovs-ofctl add-flow br0 udp,udp_src=112,udp_dst=2321,action=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_13
{
"flow": [
{
"id": "demo_13",
"flow-name": "demo_13",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
}
},
"ip-match": {
"ip-protocol": 17
},
"udp-destination-port": "2321",
"udp-source-port": "112"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}

tcp端口匹配

匹配源端口是888,目的端口是999的TCP流量,动作是转发到222端口

ovs-ofctl add-flow br0 tcp,tcp_src=888,tcp_dst=999,action=output:222
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/demo_14
{
"flow": [
{
"id": "demo_14",
"flow-name": "demo_14",
"table_id": 0,
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
}
},
"ip-match": {
"ip-protocol": 6
},
"tcp-destination-port": "999",
"tcp-source-port": "888"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"output-action": {
"output-node-connector": "222"
}
}
]
}
}
]
}
}
]
}

meter表

meter表,限速为10k,超过限制的流量丢弃。

ovs-ofctl add-meter s1 meter=1,kbps,band=type=drop,rate=10 -O OpenFlow13
控制器ip:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/meter/1
{
"meter": { "meter-id": "1",
"meter-name": "guestMeter",
"flags": "meter-kbps", "meter-band-headers": {
"meter-band-header": {
"band-id": "0",
"meter-band-types": { "flags": "ofpmbt-drop" },
"drop-burst-size": "0",
"drop-rate": "10"
}
}
}
}

匹配进端口为1的流量,经过meter表限速,然后转发到2端口

ovs-ofctl add-flow s1 priority=200,in_port=1,action=meter:1,output:2 -O OpenFlow13
控制器ip地址:8181/restconf/config/opendaylight-inventory:nodes/node/交换机switch_id/flow-node-inventory:table/0/flow/flow1
{
"flow": {
"id": "flow1",
"table_id": "0",
"priority": "120",
"name":"flow_name" "match": {
"in-port":"1"
}, "instructions": {
"instruction": [
{
"order": "0",
"meter": { "meter-id": "1" }
},
{
"order": "1",
"apply-actions": {
"action": {
"order": "1",
"output-action": {
"output-node-connector": "2"
}
}
}
}
]
}
}
}

Open vSwitch系列之十 调用北向接口下发流表的更多相关文章

  1. Liferay 6.2 改造系列之十九:修改站点设置的表单内容

    在/portal-master/portal-impl/src/portal.properties文件中,有如下配置: # # Input a list of sections that will b ...

  2. Redis系列(十二):数据结构SortedSet跳跃表中基本操作命令和源码解析

    1.SkipList Redis的sortedSet数据结构是有序不重复的(索引为唯一的,数据(score)却可以重复), 跳表是redis的一个核心组件,也同时被广泛地运用到了各种缓存地实现当中,它 ...

  3. Open vSwitch系列之一 Open vSwitch诞生

    Open vSwitch系列之一 Open vSwitch诞生 Open vSwitch系列之二 安装指定版本ovs 2006年,SDN诞生于美国GENI项目资助的斯坦福大学Clean Slate课题 ...

  4. Open vSwitch系列实验(一):Open vSwitch使用案例扩展实验

    一.实验目的 通过python脚本调用OpenvSwitch命令: 学习Mininet基于python脚本创建拓扑的实现: 进一步深度使用“ovs-vsctl”命令直接控制Open vSwitch. ...

  5. Open vSwitch流表应用实战

    本文参考:Open vSwitch流表应用实战 一个通过改变流表下发而实现的互相通信实验. 实验目的: 掌握Open vSwitch下发流表操作: 掌握添加.删除流表命令以及设备通信的原理. 原理:. ...

  6. CRL快速开发框架系列教程十二(MongoDB支持)

    本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...

  7. CRL快速开发框架系列教程十(导出对象结构)

    本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...

  8. Chrome浏览器扩展开发系列之十四

    Chrome浏览器扩展开发系列之十四:本地消息机制Native messaging 时间:2015-10-08 16:17:59      阅读:1361      评论:0      收藏:0    ...

  9. Unity3D脚本中文系列教程(十六)

    Unity3D脚本中文系列教程(十五) ◆ function OnPostprocessAudio (clip:AudioClip):void 描述:◆  function OnPostprocess ...

  10. Unity3D脚本中文系列教程(十五)

    http://dong2008hong.blog.163.com/blog/static/4696882720140322449780/ Unity3D脚本中文系列教程(十四) ◆ LightRend ...

随机推荐

  1. centos7安装glibc_2.28和gcc 8.2

    centos7默认的gcc版本是4.8.5,无法编译高版本的glibc 2.28,需要升级到gcc 8.2版本 注:gcc高版本和glibc 2.28不兼容 ## 查看自带默认的glibc strin ...

  2. 关于一类最优解存在长度为 $k$ 的循环节的问题

    灵感来源 问题形式:给定长度为 \(n\) 的序列,要求选出一些位置,使这些位置满足限制条件 \(T\),其中 \(T\) 可以表述为一个长度为 \(k\) 的环满足条件 \(T'\),选出第 \(i ...

  3. C语言二进制转换成八,十,十六进制

    代码目前只支持整数转换,小数转换后续更新呀 #include <stdio.h> #include <math.h> void B_O(int n); void B_H(int ...

  4. Jenkins从Ubuntu迁移至AlmaLinux问题及相关解决记录

    相关背景 之前在Ubuntu平台上搭建了Jenkins(在Ubuntu机器上使用war包安装Jenkins),现在由于一些需求,需要将系统迁移到AlmaLinux平台.由于AlmaLinux属于Cen ...

  5. RabbitMQ高可用集群的搭建部署(Centos7)

    高可用集群架构 节点域名 操作系统 RabbitMQ版本 Erlang版本 iamdemo.tp-link.com Centos7.9 3.8.28 23.3-2 iamdemo2.tp-link.c ...

  6. [NOI online2022提高C] 如何正确地排序

    题目描述 有一个 \(m\times n\) 的数组 \(a_{i,j}\). 定义: \(f(i,j)=\min\limits_{k=1}^m(a_{k,i}+a_{k,j})+\max\limit ...

  7. Redis 学习笔记2:持久化

    目录 1 什么是持久化 1.1 aof 1.2 rdb 2 RDB持久化 2.1 RDB 是什么 2.2 手动触发 3 AOF持久化 3.1 aof 是什么 3.2 appendfile 文件说明: ...

  8. Codeforces Round #426 (Div. 2) A. The Useless Toy

    A. The Useless Toy time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. pinia状态管理初识

    一款官方推荐的,代替vuex的,新的状态管理工具. 官方网: https://pinia.vuejs.org/zh/introduction.html 主要区别: 去除了modules的概念,每个st ...

  10. Reformer 模型 - 突破语言建模的极限

    Reformer 如何在不到 8GB 的内存上训练 50 万个词元 Kitaev.Kaiser 等人于 20202 年引入的 Reformer 模型 是迄今为止长序列建模领域内存效率最高的 trans ...