前言
上一节中介绍了使用floodlight搭建环境的方法,后来在跟研三学长交流的过程中,发现一个比较成熟的东西:Ryu,控制器,其功能强大,支持python API.而floodlight坑比较多,支持的是java.故而趁早跳坑,改用Ryu.
搭建过程
安装Ryu控制器:
- 下载ryu源码并安装:
使用git
git clone git://github.com/osrg/ryu.git
cd ryu
sudo python ./setup.py install
下载源码
ryu v4.12.zip
解压到/home/
cd /home/ryu/
sudo python ./setup.py install
其间 需要安装setuptools
先修改一个有用的软件源,如阿里、163
sudo apt-get update
sudo apt-get install pip
sudo pip install -U setuptools
其间可能报错:
The ‘repoze.lru>=0.3’ distribution was not found and is required by routes
安装 repoze:
sudo pip install -U repoze.lru
还可能遇到:
The ‘debtcollector>=1.2.0’ distribution was not found and is required by oslo.config
安装 debtcollector
sudo pip install -U debtcollector
还可能遇到:
The ‘stevedore>=1.20.0’ distribution was not found and is required by oslo.config
安装:stevedore
sudo pip install -U stevedore
···少什么安装什么,555555
在安装greenlet出现:
greenlet.h:8:20: fatal error: Python.h: No such file or directory
解决:
sudo apt-get install python-dev python3-dev
少enum34 安装 enum34:
sudo pip install -U enum34
看一下有没有安装成功:
sudo ryu-manager --version
如果显示:ryu-manager 4.13 说明成功了
太烦了!最简单的安装方法:
安装依赖库:
sudo apt-get install python-dev python3-dev python-pip python-settools git -y
git clone git://github.com/osrg/ryu.git
cd ryu
sudo python install ./
使用控制器
-
开启控制器
sudo ryu-manager --verbose ./ryu/ryu/app/simple_switch_13.py
效果如下:
loading app simple_switch_13.py loading app ryu.controller.ofp_handler instantiating app simple_switch_13.py of SimpleSwitch13 instantiating app ryu.controller.ofp_handler of OFPHandler BRICK SimpleSwitch13 CONSUMES EventOFPSwitchFeatures CONSUMES EventOFPPacketIn BRICK ofp_event PROVIDES EventOFPSwitchFeatures TO {'SimpleSwitch13': set(['config'])} PROVIDES EventOFPPacketIn TO {'SimpleSwitch13': set(['main'])} CONSUMES EventOFPEchoReply CONSUMES EventOFPHello CONSUMES EventOFPSwitchFeatures CONSUMES EventOFPErrorMsg CONSUMES EventOFPEchoRequest CONSUMES EventOFPPortStatus CONSUMES EventOFPPortDescStatsReply
- 开启mininet虚拟网即可
sudo mn --controller=remote,ip=192.168.1.197,port=6653