一、Ryu的安裝
網上有很多關於Ryu的安裝教程,也可以按照官網的教程進行安裝。
第一步:獲取Ryu
git clone git://github.com/osrg/ryu.git
第二步:進入Ryu的文件目錄
cd ryu
第三步:利用pip安裝Ryu的依賴包
sudo pip install -r tools/pip-requires
第四步:安裝Ryu
sudo python setup.py install
二、下載並安裝補丁
根據李呈等人的教程下載並移GUI的位置;
第一步:安裝補丁運行所需要的依賴庫
sudo apt-get install python-flask
sudo apt-get install python-greentlet
sudo apt-get install python-route
sudo apt-get install python-paramiko
sudo apt-get install python-webob
第二步:下載GUI的補丁
https://github.com/yamada-h/ryu/tree/gui-patch-v3-rebase
第三步:解壓可視化的補丁,並將gui文件移動ryu/ryu的目錄下面。
三、修改補丁
由於在原來的版本中,gui/templates/base.html文件中,用到了幾個在線的庫。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript" ></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jsplumb.googlecode.com/files/jquery.jsPlumb-1.3.16-all-min.js" type="text/javascript"></script>
<link href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
通過調試發現,jsplumb這個庫在網上無法獲取到,因此我們換用國內提供的在線庫。
https://www.bootcdn.cn/jsPlumb/
比如我要用的版本是1.3.16,在庫裏找到對應的鏈接:
<script src="https://cdn.bootcss.com/jsPlumb/1.3.16/jquery.jsPlumb.min.js"></script>
替換掉base.html中的鏈接:
<script src="http://jsplumb.googlecode.com/files/jquery.jsPlumb-1.3.16-all-min.js" type="text/javascript"></script>
替換成:
<script src="https://cdn.bootcss.com/jsPlumb/1.3.16/jquery.jsPlumb.min.js" type="text/javascript"></script>
四、測試
(1)在mininet中啓動一個拓撲
sudo mn --controller remote --mac --topo tree,2,2
(2)啓動Ryu的控制器
ryu-manager --observ-links ryu/app/rest_topology.py ryu/app/ofctl_rest.py ryu/app/simple_switch_13.py
注:無須註釋掉switch.py中的命令行,我在這裏沒有遇到他們說的那種情況。
(3)啓動可視化的服務控制器
python ryu/gui/controller.py
(4)測試結果
參考文獻:
https://www.sdnlab.com/11010.html
http://linton.tw/2014/02/11/note-how-to-set-up-ryu-controller-with-gui-component/