资料链接: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 下发流表配置的更多相关文章

  1. SDNLAB技术分享(四):利用ODL下发流表创建VxLAN网络

    邓晓涛,当前就职于江苏省未来网络创新研究院,是CDN团队的一名研发人员,主要从事SDN相关的研发相关工作.曾就职于三星电子于先行解决方案研发组任高级工程师.思科系统于云协作应用技术部(CCATG)任工 ...

  2. FAST:通过Floodlight控制器下发流表

    参考: Floodlight+Mininet搭建OpenFlow(四):流表操作 通过Floodlight控制器下发流表 下发流表的方式有两种: 1.借助Floodlight的北向API,利用curl ...

  3. Floodlight下发流表过程分析

    https://blog.csdn.net/vonzhoufz/article/details/32166445 当一个packet到达openflow交换机,会进行流表的匹配,如果没有找到相应的流表 ...

  4. OpenDayLight Beryllium版本 下发流表实现hardtimeout

    1. 实验拓扑 2. 创建拓扑 from mininet.topo import Topo class MyTopo(Topo): def __init__(self): # initilaize t ...

  5. onos控制器通过REST API下发流表

    onos控制器REST API地址:http://192.168.43.14:8181/onos/v1/docs/ stream书写格式: { "id": "675540 ...

  6. ryu的RESTAPI简介——我主要用于下发和查看流表

    一.Rest API简介 REST即表述性状态传递(RepreSentational State Transfer),是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性. 表 ...

  7. openflow流表项中有关ip掩码的匹配的问题(控制器为ryu)

    一.写在前面 唉,被分配到sdn安全方向,顶不住,顶不住,感觉搞不出来什么有搞头的东西.可若是让我水水的应付,我想我也是做不到的,世上无难事只怕有心人.好了,进入正题,本次要讨论的时一个比较细节的东西 ...

  8. 实验 6:OpenDaylight 实验——OpenDaylight 及 Postman 实现流表下发

    一.实验目的 熟悉 Postman 的使用;熟悉如何使用 OpenDaylight 通过 Postman 下发流表. 二.实验任务 流表有软超时和硬超时的概念,分别对应流表中的 idle_timeou ...

  9. 实验 6:OpenDaylight 实验——OpenDaylight 及 Postman 实现流表下发

    一.实验目的 熟悉 Postman 的使用:熟悉如何使用 OpenDaylight 通过 Postman 下发流表. 二.实验任务 流表有软超时和硬超时的概念,分别对应流表中的 idle_timeou ...

随机推荐

  1. 【CentOS 6.5】安装gcc-4.8.2和Qt5.2

    因为CentOS6.5中gcc版本比较低.安装Qt5.2前先升级gcc. 首先下载gcc,附上百度盘地址:http://pan.baidu.com/s/1jGibvqY 解压安装包,并进入到解压文件夹 ...

  2. 搜索框请输入关键字 onfocus 和 onblur

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. Nginx 前后端分离配置 分发

    前端项目VUE  端口8081 , 后端项目JAVA 端口8080 # For more information on configuration, see: # * Official English ...

  4. 73. Set Matrix Zeroes (Array)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow ...

  5. 15.3Sum (Two-Pointers)

    Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...

  6. vs与qt

    http://blog.csdn.net/woniuye/article/details/54928477 1. #include "qmessagebox.h" QMessage ...

  7. Linux之chmod使用

    Linux文件分三种身份和四中权限. u:文件的拥有者 g:文件所属的群组 o:其他用户 对于每个身份,又有四种权限,分别为: r:读取文件的权限(read) w:写入文件的权限(write) x:执 ...

  8. 关于简单的三层的简化(bll,dal,model)的封装这里全部都在一个文件主要在于明白意思

    using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace 封装泛型CRU ...

  9. spark yarn 集群提交kafka代码

    配置好hadoop的环境,具体根据http://blog.csdn.net/u010638969/article/details/51283216博客所写的进行配置. 运行start-dfs.sh启动 ...

  10. thinkphp ajax分页加载更多最简单的实现方法

    <div class="li_list"> <volist name="list" id="vo"> <div ...