環境:vmware中安裝的ubuntu-16.04.2,在ubuntu16.04.2中安裝mininet+opendaylight/floodlight+wireshark。
安裝floodlight說明:ubuntu中java環境要求jdk1.8,在ubuntu-16.04.2中默認的java環境爲jdk1.8,所以下述過程中直接通過git獲取的安裝包都是最新版本的。若ubuntu版本低,則會出現jdk版本達不到要求,即使在低版本ubuntu中手動安裝jdk1.8,在安裝floodlight過程中還是會出現各種問題,比如web界面訪問不了;ant floodlight過程中出現問題;啓動floodlight時報錯,sudo module init命令執行不了等各種奇葩問題。
說明:Opendaylight和floodlight只需要安裝一個就行,他們都是控制器。
1、 安裝mininet
參考:http://mininet.org/download/
三種方式:
(1)虛擬機映像文件下載
在windows 7 操作系統中,從mininet官網http://mininet.org下載最新的虛擬機文件,解壓、並導入到vmware workstation,啓動虛擬機。關於虛擬機的配置不再贅述,請自行解決。(這種方式安裝的mininet是server版的,沒有桌面圖形化界面,不好操作。)
(2)基於源碼安裝Mininet
最簡單的方式是使用Mininet官網上的最新虛擬機大家Mininet環境。下面則基於源代碼安裝。
首先要安裝git,代碼如下:
sudo apt-get update
sudo apt-get install git
測試是否安裝成功:git
1)獲取最新的源碼樹:
輸入命令:git clone git://github.com/mininet/mininet
上述命令會在當前目錄下創建mininet文件夾。
選擇安裝版本:
進入mininet目錄
git tag (可以查看版本)
git checkout -b 2.2.0 2.2.0
2)安裝:
進入mininet//util下輸入下述命令:
1. 在當前目錄下安裝所有Toinstall everything (using your home directory):
./install.sh -a
2. 在mydir下安裝所有To installeverything (using another directory):
./install.sh -s mydir -a
3. 在當前目錄下安裝Mininet+ user switch + OVS To install Mininet + user switch + OVS (using your homedir):
./install.sh -nfv
4. 在當前mydir下安裝Mininet +user switch + OVS To install Mininet + user switch + OVS (using another dir):
./install.sh -s mydir –nfv
這裏我選擇的第二個:
install.sh -s /usr/local –a
3)打開mininet
sudo mn
4)使用miniedit自定義拓撲/python腳本自定義拓撲
http://blog.sina.com.cn/s/blog_88125af10102wrdk.html
運行自定義拓撲命令:
sudo mn --custom XXX.py --topo classname --mac --controller=remote, ip=yourcontrollerIp,port=6633/6653
(pingall之後可以在opendaylight上看見host圖形,否則只能看見交換機圖形)
5)mininet常見命令
https://segmentfault.com/a/1190000000669218
http://www.sdnlab.com/11495.html
2、 安裝opendaylight
(1)下載地址:http://www.opendaylight.org/software/downloads
(2)解壓並進入
unzip distribution-karaf-0.2.0-Helium.zip
cd distribution-karaf-0.2.0-Helium
./bin/karaf
即可見到以下畫面:
(3)安裝組件
要讓其顯示webUI必須安裝相關的DLUX 安裝DLUX步驟:
1)Install L2switch and openflow plugin
feature:install odl-restconf-all
feature:install odl-l2switch-switch
feature:install odl-openflowplugin-all
2)Installbasic md-sal controller features on the Karaf console
feature:install odl-mdsal-all
3)Then,install dlux feature
feature:install odl-dlux-all
4)Installad-sal features on the Karaf console.
feature:install odl-adsal-northbound
一定要按照上述步驟安裝,否則會出錯。
如果安裝出現問題和衝突,退出karaf console,執行./karaf clean
(4)web顯示
安裝完後等一段時間既可以訪問你的OpenDaylight的webUI頁面了,輸入:http://<IP of your machine>:8181 /index.html
默認用戶名和密碼都爲:admin
3、 安裝floodlight
Ctrl+Alt+T打開控制檯輸入:
sudo apt-get update
sudo apt-get install build-essential default-jdk ant python-dev eclipse
git clone git://github.com/floodlight/floodlight.git
(如果要選擇安裝的版本的話,可做如下修改)
git clone -b v1.2.0 git://github.com/floodlight/floodlight.git
cd floodlight
git submodule init(首次執行該命令會有輸出,之後執行結果見下圖)
git submodule update(首次執行該命令會有輸出,之後執行結果見下圖)
ant
首次運行floodlight需要執行下述兩個命令,以後不需要。
sudo mkdir /var/lib/floodlight
sudo chmod 777 /var/lib/floodlight
打開瀏覽器輸入:localhost:8080/ui/index.html進入如下界面則說明安裝成功:
4、 安裝wireshark
新建終端控制檯,輸入:
sudo apt-get install wireshark
這樣全部的準備工作已經做完了
(注意打開wireshark要用root權限打開,輸入命令:su root)
5、 聯機調試
在進行抓包之前將之前運行的floodlight和mininet全部關閉
(1)運行floodlight
java -jar floodlight/target/floodlight.jar
(2)運行wireshark
sudo wireshark (一定要用root權限打開,否則無法檢測網卡端口)
點擊監測的端口,如果在同一臺機器上測試,就選擇lo環回端口,如果mininet鏈接練成控制器則監測eth0端口。
在開始對網卡端口監測之後在啓動mininet,確保能抓到Hello包
(3)啓動mininet
sudo mn --custom XXX.py --topo classname --mac --controller=remote,ip=yourcontrollerIp,port=6653(注意端口號不是6633,而是6653)
pingall
這時你就能從wireshark中看到各種OFP的數據包了!
That’sall