Default VM image user/passwd : mininet/mininet
啟動 mininet 模擬網路環境
sudo mn
mn環境下指令
nodes目前fork出之節點( sN:switch hN:host )
net 目前模擬連線狀態
dump 虛擬節點詳細狀態
$host_name$ $bash_command 以節點下指令(EX: “s1 ifconfig”、”h1 ping h2″ 、”h1 ps aux” … )
pingall 各節點互ping
iperf 節點傳輸頻寬測試
xterm $host $host2 … Xmode下開啟host terminel
mn參數
環境模擬完成後測試$mn_command並結束模擬
sudo mn – -test $mn_command
以$topo_name拓樸建立$number_nodes節點數量之模擬環境
sudo mn – – topo={$topo_name},$number_nodes
$topo_name={ single、linear、tree }
MAC_address=ID模式
sudo mn – -mac
GUI X Mode
sudo mn -x
指定Controller (default port:6633)
sudo mn – -controller=remote,ip=$controller_ip,port=$controller_port
訊息控制
debug模式
sudo mn -v debug
output模式
sudo mn -v output
資料量
output > debug > general
自訂拓樸(畫圖:switch、host、link)
拓樸範例
custom/topo-2sw-2host.py
執行
sudo mn – -custom custom/topo-2sw-2host.py – – topo=mytopo
10/26更新 : mininet進階用法簡易環境版 ( 撰寫成 .py 後以python執行 )
#環境載入
#!/usr/bin/env python2
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.log import setLogLevel, info
from mininet.cli import CLI
from mininet.link import Intf
from mininet.util import dumpNodeConnections
REMOTE_CONTROLLER_IP=”192.168.18.151″
def MininetTopo():
net = Mininet (topo=None, build=False)
#設定Controller
controller =net.addController(name=’controller0′,
controller=RemoteController,
ip=REMOTE_CONTROLLER_IP,
port=6633)
#產生Switchs
info(“Create Switch node\n”)
switch = net.addSwitch(‘s1’)
#產生Hosts
info(“Create Host node\n”)
host1 = net.addHost(‘h1′, ip=’10.0.0.1’)
host2 = net.addHost(‘h2′, ip=’10.0.0.2’)
#產生LINKs
info(“Link switch to host\n”)
net.addLink(switch, host1)
net.addLink(switch, host2)
#啟動
info(“Start network\n”)
net.start()
#增加Flow
info(“Adding Flow\n”)
switch.cmdPrint(‘ovs-ofctl add-flow s1 in_port=1,actions=output:2’)
switch.cmdPrint(‘ovs-ofctl add-flow s1 in_port=2,actions=output:1’)
#Mininet CLI啟動
CLI(net)
#MininetCLI結束
net.stop()
if __name__ == ‘__main__’:
setLogLevel(‘info’)
MininetTopo()
搶先發佈留言