Floodlight Static Flow Pusher API
来源:互联网 发布:ubuntu redis 安装 编辑:程序博客网 时间:2024/06/05 18:07
什么是 Static Flow Pusher?
Static Flow Pusher 是一个 Floodlight 模块,使用的是REST API接口,允许用户在OpenFlow 网络中插入流表 。
主动式和反应式流插入
OpenFlow 支持两种流表插入: 主动式和反应式。当数据包抵达OpenFlow交换机,而交换机没有该包对应的匹配流表时,反应时流表插入起作用。该数据包被送到控制器,由控制器进行评估,并向交换机添加相应的流表,从而把该数据包正确的转发出去。主动式插入则是在数据包到达之前就插入相应的流表,这就是两种方式的区别。
Static Flow Pusher 对于主动式流表插入很有用。Floodlight 默认会加载 Forwarding模块, 该模块使用反应式流插入 ,如果你只想使用静态流,你可以在floodlight.properties配置文件中删除 Forwarding。
API 概要
添加静态流操作
静态流添加是通过REST API接口来进行的。例如,在交换机1上插入一条让数据包从端口1进端口2出的流表,则可以使用curl命令。 第二个命令可以显示插入的流表。
curl -d '{"switch": "00:00:00:00:00:00:00:01", "name":"flow-mod-1", "priority":"32768", "ingress-port":"1","active":"true", "actions":"output=2"}' http://<controller_ip>:8080/wm/staticflowentrypusher/jsoncurl http://<controller_ip>:8080/wm/core/switch/1/flow/json;
删除静态流操作
通过包含流表名字的 HTTP DELETE命令来删除指定流表。
curl -X DELETE -d '{"name":"flow-mod-1"}' http://<controller_ip>:8080/wm/staticflowentrypusher/json
flow entry的可能属性
xx:xx:xx:xx:xx:xx:xx:xxname<string>Name of the flow entry, this is the primary key, it MUST be uniqueactions<key>=<value>See table of actions below
Specify multiple actions using a comma-separated list
Specifying no actions will cause the packets to be droppedpriority<number>default is 32767
maximum value is 32767active<boolean> wildcards ingress-port<number>switch port on which the packet is received
Can be hexadecimal (with leading 0x) or decimalsrc-mac<mac address>xx:xx:xx:xx:xx:xxdst-mac<mac address>xx:xx:xx:xx:xx:xxvlan-id<number>Can be hexadecimal (with leading 0x) or decimalvlan-priority<number>Can be hexadecimal (with leading 0x) or decimalether-type<number>Can be hexadecimal (with leading 0x) or decimaltos-bits<number>Can be hexadecimal (with leading 0x) or decimalprotocol<number>Can be hexadecimal (with leading 0x) or decimalsrc-ip<ip address>xx.xx.xx.xxdst-ip<ip address>xx.xx.xx.xxsrc-port<number>Can be hexadecimal (with leading 0x) or decimaldst-port<number>Can be hexadecimal (with leading 0x) or decimal
Possible actions within the "action" field:
all
controller
local
ingress-port
normal
floodno "drop" option
(instead, specify no action to drop packets)
enqueue<number>:<number>First number is port number, second is queue ID
Can be hexadecimal (with leading 0x) or decimalstrip-vlan set-vlan-id<number>Can be hexadecimal (with leading 0x) or decimalset-vlan-priority<number>Can be hexadecimal (with leading 0x) or decimalset-src-mac<mac address>xx:xx:xx:xx:xx:xxset-dst-mac<mac address>xx:xx:xx:xx:xx:xxset-tos-bits<number> set-src-ip<ip address>xx.xx.xx.xxset-dst-ip<ip address>xx.xx.xx.xxset-src-port<number>Can be hexadecimal (with leading 0x) or decimalset-dst-port<number>Can be hexadecimal (with leading 0x) or decimal
静态流表插入的实际应用
我们可以使用Python脚本写流表操作, 例如, 使用mininet产生一个简单的拓扑,并连接上控制器,默认的拓扑是一个交换机(s1)和两个主机(h2和h3)。
sudo mn --controller=remote --ip=<controller ip> --port=6633
下面的代码插入从h2到h3的流和h3到h2的流。
import httplibimport jsonclass StaticFlowPusher(object): def __init__(self, server): self.server = server def get(self, data): ret = self.rest_call({}, 'GET') return json.loads(ret[2]) def set(self, data): ret = self.rest_call(data, 'POST') return ret[0] == 200 def remove(self, objtype, data): ret = self.rest_call(data, 'DELETE') return ret[0] == 200 def rest_call(self, data, action): path = '/wm/staticflowentrypusher/json' headers = { 'Content-type': 'application/json', 'Accept': 'application/json', } body = json.dumps(data) conn = httplib.HTTPConnection(self.server, 8080) conn.request(action, path, body, headers) response = conn.getresponse() ret = (response.status, response.reason, response.read()) print ret conn.close() return retpusher = StaticFlowPusher('<insert_controller_ip')flow1 = { 'switch':"00:00:00:00:00:00:00:01", "name":"flow-mod-1", "cookie":"0", "priority":"32768", "ingress-port":"1", "active":"true", "actions":"output=flood" }flow2 ={ 'switch':"00:00:00:00:00:00:00:01", "name":"flow-mod-2", "cookie":"0", "priority":"32768", "ingress-port":"2", "active":"true", "actions":"output=flood" }pusher.set(flow1)pusher.set(flow2)
通过ping命令进行测试
mininet> h2 ping h3
- 顶
- 0
- 踩
0 0
- Floodlight Static Flow Pusher API
- Floodlight Static Flow Pusher API
- Floodlight 用Static Flow Pusher 改变流表
- Floodlight 用Static Flow Pusher 改变流表规则
- 学习 The Floodlight REST API
- floodlight 控制器的 ACL REST API学习笔记
- hdu2821 Pusher
- Floodlight出现错误:Error! Check the fields specified for the flow.Make sure IPv4 fields are not mixed wi
- Google streetview static api
- Google Static Maps API
- flow
- flow
- flow
- flow
- flow
- flow
- floodlight控制器中通过REST API下发流表遇到的坑
- Floodlight 架构
- Centos 7 裸机编译安装python3 pip3
- QComboBox
- GPU版Tensorflow安装 centos7 64位
- 十分钟理解Scipy.csc_matrix和coo_matrix
- 算法时间复杂度和空间复杂度
- Floodlight Static Flow Pusher API
- Android Studio编译使用了Maven的工程卡住的解决方案
- dedecms 实现两个网站调用一个数据库
- Java实例1-素数的判断
- 快速掌握一个语言最常用的50%
- Go 语言常量
- 使用国内的镜像服务器更新android sdk
- 有一个字符数组的内容为:"student a am i",请你将数组的内容改为"i am a student". 要求: 不能使用库函数。只能开辟有限个空间(空间个数和字符串的长度无关)。
- ubuntu14-系统重装后-脚本命令