ryu 下发流表配置
资料链接:http://ryu.readthedocs.io/en/latest/app/ofctl_rest.html
运行ryu进程:
ryu-manager --ofp-tcp-listen-port 6655 --wsapi-port 8080 --verbose /usr/lib/python2.7/site-packages/ryu/app/ofctl_rest.py
#! /bin/python import re
import urllib
import urllib2
import json
import requests
import json
import time # get switch dpid
post_url = 'http://127.0.0.1:8080/stats/switches';
req = urllib2.Request(post_url)
response = urllib2.urlopen(req)
dpid_data = response.read().strip('[]') # show switch group
post_url = 'http://127.0.0.1:8080/stats/groupdesc/%s' % dpid_data;
req = urllib2.Request(post_url)
response = urllib2.urlopen(req)
print response.read() # add switch group
post_url = 'http://127.0.0.1:8080/stats/groupentry/add';
group_data = {
"dpid": dpid_data,
"type": "SELECT",
"fields": "ip_src",
"group_id": 1,
"buckets": [{
"weight": 1,
"actions": [{
"type": "OUTPUT",
"port": 1
}]
},
{
"weight": 1,
"actions": [{
"type": "OUTPUT",
"port": 2
}]
},
{
"weight": 1,
"actions": [{
"type": "OUTPUT",
"port": 3
}]
}]
}
data = json.dumps(group_data)
req = urllib2.Request(post_url)
response = urllib2.urlopen(req,data=data)
print response.read() # show flows
post_url = 'http://127.0.0.1:8080/stats/flow/%s' % dpid_data;
req = urllib2.Request(post_url)
response = urllib2.urlopen(req)
print response.read() # add flow
post_url = 'http://127.0.0.1:8080/stats/flowentry/add';
flows_data = {
"dpid": dpid_data,
"table_id": 0,
"cookie": 10000,
"priority": 1000,
"match":{
"dl_type": "0x8000",
"in_port": 5,
"dl_vlan": 100,
#"dl_vlan": "0x1005" # Describe sum of VLAN-ID(e.g. 5) | OFPVID_PRESENT(0x1000)
"eth_src": "aa:bb:cc:11:22:33",
"eth_dst": "aa:bb:cc:11:22:33",
"ipv4_dst": "192.168.10.10/255.255.255.0", "eth_type": 2048,
"ipv4_src": "192.168.0.1", "eth_type": 2048
},
"actions":[
{
"type": "PUSH_VLAN",
"ethertype": 33024 # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
},
{
"type": "SET_FIELD",
"field": "vlan_vid",
"value": 4102 # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
},
{
"type": "OUTPUT",
"port": 20
}
]
}
data = json.dumps(flows_data)
req = urllib2.Request(post_url)
response = urllib2.urlopen(req,data=data)
print response.read()
ryu 下发流表配置的更多相关文章
- SDNLAB技术分享(四):利用ODL下发流表创建VxLAN网络
邓晓涛,当前就职于江苏省未来网络创新研究院,是CDN团队的一名研发人员,主要从事SDN相关的研发相关工作.曾就职于三星电子于先行解决方案研发组任高级工程师.思科系统于云协作应用技术部(CCATG)任工 ...
- FAST:通过Floodlight控制器下发流表
参考: Floodlight+Mininet搭建OpenFlow(四):流表操作 通过Floodlight控制器下发流表 下发流表的方式有两种: 1.借助Floodlight的北向API,利用curl ...
- Floodlight下发流表过程分析
https://blog.csdn.net/vonzhoufz/article/details/32166445 当一个packet到达openflow交换机,会进行流表的匹配,如果没有找到相应的流表 ...
- OpenDayLight Beryllium版本 下发流表实现hardtimeout
1. 实验拓扑 2. 创建拓扑 from mininet.topo import Topo class MyTopo(Topo): def __init__(self): # initilaize t ...
- onos控制器通过REST API下发流表
onos控制器REST API地址:http://192.168.43.14:8181/onos/v1/docs/ stream书写格式: { "id": "675540 ...
- ryu的RESTAPI简介——我主要用于下发和查看流表
一.Rest API简介 REST即表述性状态传递(RepreSentational State Transfer),是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性. 表 ...
- openflow流表项中有关ip掩码的匹配的问题(控制器为ryu)
一.写在前面 唉,被分配到sdn安全方向,顶不住,顶不住,感觉搞不出来什么有搞头的东西.可若是让我水水的应付,我想我也是做不到的,世上无难事只怕有心人.好了,进入正题,本次要讨论的时一个比较细节的东西 ...
- 实验 6:OpenDaylight 实验——OpenDaylight 及 Postman 实现流表下发
一.实验目的 熟悉 Postman 的使用;熟悉如何使用 OpenDaylight 通过 Postman 下发流表. 二.实验任务 流表有软超时和硬超时的概念,分别对应流表中的 idle_timeou ...
- 实验 6:OpenDaylight 实验——OpenDaylight 及 Postman 实现流表下发
一.实验目的 熟悉 Postman 的使用:熟悉如何使用 OpenDaylight 通过 Postman 下发流表. 二.实验任务 流表有软超时和硬超时的概念,分别对应流表中的 idle_timeou ...
随机推荐
- 【316】python.requests 读取网页信息
参考:Python:在网页中查找字符串的一般方法--in 参考:python怎么安装requests 参考:Requests 快速上手 操作步骤如下: 添加环境变量,将 python 所在文件夹添加至 ...
- c语言实现常见字符串函数strchr strstr strcmp atoi itoi(字符串换成整数)
好久没有更新博客了,刚刚出炉练练手的程序如下,很简单,没有考虑过多复杂的东西,有好的想法,欢迎指教: 字符查找函数: char *my_strchr(const char *s,int c) { ch ...
- for 续3
--------siwuxie095 (三)delims=xxx (xxx 是被定义的符号,该符号在文本中存在,将作为分隔符) 定义分隔符(用于切分文本) ...
- vmware虚拟机开机报附件中的错误的解决办法
Virtualized Inter VT-x/EPT is incompatible with this virtual machine configuration 在没有虚拟化msg.inter.h ...
- PHP - MongoDB连接攻略
http://blog.163.com/lgh_2002/blog/static/44017526201261111044608/ 使用PHP的Mongo扩展连接MongoDB.通过new Mongo ...
- 系统批量运维管理器paramiko详解
一.paramiko介绍 paramiko是基于Python实现的SSH2远程安全连接,支持认证及密钥方式.可以实现远程命令执行.文件传输.中间SSH代理等功能,相对于Pexpect,封装的层次更高, ...
- Shiro和Spring 集合实现同一个账号只能一个人在线使用,其它人在使用进行剔除(八)
1.实现原理其实就是自定义过滤器,然后登录时,A登录系统后,B也登录了,这个时候获取此账号之前的session给删除,然后将新的session放入到缓存里面去,一个账户对应一个有序的集合 编写自定义过 ...
- 如何用Python实现常见机器学习算法-3
三.BP神经网络 1.神经网络模型 首先介绍三层神经网络,如下图 输入层(input layer)有三个units(为补上的bias,通常设为1) 表示第j层的第i个激励,也称为单元unit 为第j层 ...
- idea中代码补全
在IDEA中,默认的代码自动提示不够智能,现在配置成更加智能的方式. File-Settings-Editor-General-Code Completion中 把最上面的大小写敏感度改成none,下 ...
- java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector解决方法
java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector解决方法 错误描述:java.lang.NoClassDefFoundErro ...