Mininet 2.2.0之后的版本內置了一個mininet可視化工具miniedit,使用Mininet可視化界面方便了用戶自定義拓撲創建,為不熟悉python腳本的使用者創造了更簡單的環境,界面直觀,可操作性強。
總之就是比寫Python腳本簡單,降低了SDN入門的門檻,尷尬,我也是最近才知道有這個功能的,一起來學習一波。
Mininet都是用root權限啟動的,所以miniedit也不例外。
首先獲得mininet目錄的權限,這點就不細說了,chmod blablabla就可以了。
然后就能愉快的啟動miniedit了
xxt@xxt-VirtualBox:~$ sudo ~/mininet/examples/miniedit.py [sudo] password for xxt:
然后就彈出miniedit的界面了

左邊類似工具欄的東西依次是select、Host、Switch、legancy switch、legancy router、netlink、controller。
接下來可以像操作C#里控件一樣把需要的設備托到右邊的面板上,例如:先擺4個host

miniedit會依次默認的給host命名h1,h2,···,hn。我們也可以通過右鍵點擊某個host來指定該host的名字

可以看到除了名字還有許多其他參數可以設置,新型switch相比傳統switch還是nb不少,這里我也不太清楚大部分參數的設置,略過
添加四個switch

添加一個controller

右鍵點擊controller,可以設置ip,端口,類型等信息,這里我把控制器設為remote controller,ip設置為控制器所在主機ip,
連接各個主機和交換機與controller,需要注意,連接順序和端口號一致,如果第一次連h1和s1,第二次連接h2和s1,那么s1的eth1就和h1連接,s1的eth2和h2連接,以此類推
拓撲基本已經OK,眼熟的同學會發現2016SDN大賽提高題第二道就是這么個拓撲,接着點擊 Edit->Preferences,勾上start CLI ,選擇你需要版本的OF協議
點擊run,就可以和平時使用sudo mn blablabla好多參數 一樣的效果
可以看到終端的顯示
MiniEdit running against Mininet 2.2.1 topo=none New controller details for c0 = {'remotePort': 6633, 'controllerProtocol': 'tcp', 'hostname': 'c0', 'remoteIP': '10.201.121.155', 'controllerType': 'remote'} New Prefs = None New Prefs = {'ipBase': '10.0.0.0/8', 'sflow': {'sflowPolling': '30', 'sflowSampling': '400', 'sflowHeader': '128', 'sflowTarget': ''}, 'terminalType': 'xterm', 'startCLI': '1', 'switchType': 'ovs', 'netflow': {'nflowAddId': '0', 'nflowTarget': '', 'nflowTimeout': '600'}, 'dpctl': '', 'openFlowVersions': {'ovsOf11': '0', 'ovsOf10': '1', 'ovsOf13': '0', 'ovsOf12': '0'}} Build network based on our topology. Getting Hosts and Switches. <class 'mininet.node.Host'> <class 'mininet.node.Host'> Getting controller selection:remote Unable to contact the remote controller at 10.201.121.155:6633 <class 'mininet.node.Host'> <class 'mininet.node.Host'> Getting Links. *** Configuring hosts h2 h3 h1 h4 **** Starting 1 controllers c0 **** Starting 4 switches s1 s3 s2 s4 No NetFlow targets specified. No sFlow targets specified. NOTE: PLEASE REMEMBER TO EXIT THE CLI BEFORE YOU PRESS THE STOP BUTTON. Not exiting will prevent MiniEdit from quitting and will prevent you from starting the network again during this sessoin. *** Starting CLI: mininet>
啟動控制器(floodlight)

在mininet端查看連接情況
mininet> pingall *** Ping: testing ping reachability h2 -> h3 h1 h4 h3 -> h2 h1 h4 h1 -> h2 h3 h4 h4 -> h2 h3 h1 *** Results: 0% dropped (12/12 received) mininet>
查看拓撲結構
mininet> net h2 h2-eth0:s1-eth2 h3 h3-eth0:s4-eth1 h1 h1-eth0:s1-eth1 h4 h4-eth0:s4-eth2 s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0 s1-eth3:s2-eth1 s1-eth4:s3-eth1 s3 lo: s3-eth1:s1-eth4 s3-eth2:s4-eth4 s2 lo: s2-eth1:s1-eth3 s2-eth2:s4-eth3 s4 lo: s4-eth1:h3-eth0 s4-eth2:h4-eth0 s4-eth3:s2-eth2 s4-eth4:s3-eth2 c0 mininet>
會發現和之前的連接順序一致。除了這些功能外,還可以通過菜單欄file->save/save level 2 script直接將拓撲保存為.mn腳本或.py腳本方便建立相同topo時
使用。

最后退出時需要注意
NOTE: PLEASE REMEMBER TO EXIT THE CLI BEFORE YOU PRESS THE STOP BUTTON. Not exiting will prevent MiniEdit from quitting and will prevent you from starting the network again during this sessoin.
先推出CLI再STOP,就可以安全滴退出了。
