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 ...
随机推荐
- python学习-day 2
1.执行Python脚本的两种方式1)调用解释器 Python +绝对路径+文件名称2)调用解释器 Python +相对路径+文件名称 2.简述位.字节的关系8位为1个字节 3.简述ASCII.uni ...
- leetcode58
public class Solution { public int LengthOfLastWord(string s) { s = s.Trim(); || s.Trim().Length == ...
- 【317】python 指定浏览器打开网页 / 文件
一.python 打开浏览器的方法: 1. startfile方法(打开指定浏览器) import os os.startfile("C:\Program Files\internet ex ...
- maven 统一管理依赖的版本号
- AUC,KS,ROC
要弄明白ks值和auc值的关系首先要弄懂roc曲线和ks曲线是怎么画出来的.其实从某个角度上来讲ROC曲线和KS曲线是一回事,只是横纵坐标的取法不同而已.拿逻辑回归举例,模型训练完成之后每个样本都会得 ...
- SQL Server判断数据库、表、存储过程、函数是否存在
--判断数据库是否存在 if exists (select * from sys.databases where name = '数据库名') drop database [数据库名] --判断表是否 ...
- leetcode 13 Roman to Integer 罗马数组转整型
描述: 将一个字符串表示的罗马数字转为整数,范围0~3999 解决: 如果后一个比前一个大,则表示减,没什么技巧. map<}, {}, {}, {}, {}, {}, {}}; int rom ...
- sqlserver2008事物处理---待续
声明事物:begin tran 回滚事物:ROLLBACK TRAN 提交事物:commit tran(不写会隐式提交) 判断是否发生异常: 结束前: IF @@ERROR <> 0 BE ...
- wcf将一个服务同时绑定到http和tcp的写法
服务器端:<?xml version="1.0" encoding="utf-8" ?><configuration> <con ...
- shiro 和spring集合 实现登录时输入验证码并校验(七)
编写实现验证码的主体实现类:CaptchaCode import java.util.UUID; import javax.servlet.http.HttpServletRequest; impor ...