《虚拟化和云计算》实验报告——MININET实践SDN
生活随笔
收集整理的這篇文章主要介紹了
《虚拟化和云计算》实验报告——MININET实践SDN
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
MiniNet
由一些虛擬的終端節(jié)點(end-hosts)、交換機、路由器連接而成的一個網(wǎng)絡(luò)仿真器,支持0penflow協(xié)議,可以用它來實踐SDN。
MiniNet安裝
源碼安裝
git clone git://github.com/mininet/mininet cd mininet/util ./install.sh -a直接安裝
apt install mininet安裝測試
sudo mn # 會顯示mn的默認網(wǎng)絡(luò)拓撲 pingall # 使用pingall測試,會顯示主機h1和h2可以ping通 nodes #其他命令測試 net
singe,3
sudo mn --topo singe,3 pingall nodes net
linear,3
sudo mn --topo linear,3 pingall nodes net
tree,2
sudo mn --topo tree,2 pingall nodes net
cutsom
cd mininet/custom ll mn --custom topo-2sw-2host.py --topo mytopo pingall nodes net
custom修改
vim topo-2sw-2host.py mn --custom topo-2sw-2host.py --topo mytopo pingall nodes net from mininet.topo import Topoclass MyTopo( Topo ):"Simple topology example."def build( self ):"Create custom topo."# Add hosts and switchesleftHost = self.addHost( 'h1' )midHost = self.addHost( 'h3' )rightHost = self.addHost( 'h2' )leftSwitch = self.addSwitch( 's1' )midSwitch = self.addSwitch( 's3' )rightSwitch = self.addSwitch( 's2' )# Add linksself.addLink( leftHost, leftSwitch )self.addLink( leftSwitch, midSwitch)self.addLink( midHost, midSwitch )self.addLink( midSwitch, rightSwitch )self.addLink( rightSwitch, rightHost )topos = { 'mytopo': ( lambda: MyTopo() ) }
Ryu
RYU是一款基于python的控制器,你可用Ryu實現(xiàn)各種想要實現(xiàn)的網(wǎng)絡(luò)功能,它可以下發(fā)或接收流表進行各種路由運算。
Ryu 安裝
apt-get update apt install python3-pip pip3 install ryuRyu 測試
ryu-managerRyu 簡單使用
Test 1
Terminal 1
ryu-manager
Terminal 2
無法ping通
Test2
Terminal 1
ryu-manager ryu.app.simple_switchTerminal 2
mn --controller=remote,ip=127.0.0.1,port=6653 pingall h1 ping h2Ryu Restful 控制
官方文檔:https://ryu.readthedocs.io/en/latest/app/ofctl_rest.html
構(gòu)建
ryu-manager ryu.app.ofctl_rest
Terminal 2
無法ping通
獲取信息
GET 192.168.30.134:8080/stats/desc/1
獲取交換機流表
獲取dpid為1的交換機流表
GET 192.168.30.134:8080/stats/flow/1
增加流表表項
POST 192.168.30.134:8080/stats/flowentry/add
{"dpid": 1,"match": {"in_port": 1},"actions": [{"type": "OUTPUT","port": 2}] } {"dpid": 1,"match": {"in_port": 2},"actions": [{"type": "OUTPUT","port": 1}] }ping通
刪除流表表項
POST 192.168.30.134:8080/stats/flowentry/clear/1
無法ping通
參考文章
總結(jié)
以上是生活随笔為你收集整理的《虚拟化和云计算》实验报告——MININET实践SDN的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: uni-app——一种通过Nginx反向
- 下一篇: uni-app——map组件路线[pol