解壓opendayligh軟體包,運作啟動
unzip -o distribution-karaf-0.6.0-Carbon.zip -d /root
配置java環境變量
apt install openjdk-8-jdk -y
檢視java環境變量的安裝包
cd /usr/lib/jvm ls -l 檢視
寫入到開機加載檔案
echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64' >> /etc/profile
檢查一下寫入情況:
tail -f /etc/profile
加載環境變量:
source /etc/profile
執行啟動:
cd /root/distribution-karaf-0.6.0-Carbon/bin./karaf
安裝元件:
feature:install odl-restconf
feature:install odl-l2switch-switch-ui
feature:install odl-mdsal-apidocs
feature:install odl-dluxapps-applications
然後就可以進行浏覽器通路:
例如:http://192.168.10.3:8181/index.html
()擴充開啟遠端連接配接:
進入:vim /etc/ssh/sshd_config
修改32行注釋取消然後修改yes
重新開機:systemctl restart ssh
開啟開機自啟:systemctl ssh
安裝mininet軟體包
apt --fix-broken install -y 安裝包
dpkg -i mininet_2.2.2-4_amd64.deb
安裝ovs軟體平台
apt install openvswitch-switch -y
建構拓撲:
mn --controller=remote,ip=192.168.10.3,port=6653 --topo=single,3 --switch=ovs,protocols=OpenFlow10
--controller=CONTROLLER:指定遠端控制器
remote:遠端主機
ip:遠端位址
port:表示端口
--topo=TOPO:指定拓撲類型
single,m:建立拓撲為星型拓撲,m表示m個主機
--switch=SWITCH:指定交換機類型
ovs:使用交換機的類型
mininet>
#測試網絡是否互通
pingall
#執行結果
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3
h2 -> h1 h3
h3 -> h1 h2
*** Results: 0% dropped (6/6 received)
#進行手動下發流表
mininet> sh ovs-ofctl add-flow s1 in_port=2,actions=drop
mininet> pingall
*** Ping: testing ping reachability
h1 -> X h3
h2 -> X X
h3 -> h1 X
*** Results: 66% dropped (2/6 received)
####出現66%才表示成功####
#檢視端口(若出現三個表示成功)
mininet> sh netstat -an | grep 6653
tcp 0 0 192.168.76.131:43654 192.168.76.131:6653 ESTABLISHED
tcp6 0 0 :::6653 :::* LISTEN
tcp6 0 0 192.168.76.131:6653 192.168.76.131:43654 ESTABLISHED
#檢視交換機的流表(5條)
mininet> sh ovs-ofctl dump-flows s1
登入到ODL管理界面,檢視topology界面,出現下圖表示正确
cookie=0x2b00000000000000, duration=3019.974s, table=0, n_packets=54,
n_bytes=3865, priority=2,in_port="s1-eth3" actions=output:"s1-eth1",output:"s1-
eth2",CONTROLLER:65535
cookie=0x2b00000000000001, duration=3019.970s, table=0, n_packets=54,
n_bytes=5545, priority=2,in_port="s1-eth1" actions=output:"s1-eth3",output:"s1-
eth2",CONTROLLER:65535
cookie=0x2b00000000000002, duration=3019.970s, table=0, n_packets=10,
n_bytes=728, priority=2,in_port="s1-eth2" actions=output:"s1-eth3",output:"s1-
eth1",CONTROLLER:65535
cookie=0x0, duration=2979.411s, table=0, n_packets=26, n_bytes=1372,
in_port="s1-eth2" actions=drop
cookie=0x2b00000000000000, duration=3021.885s, table=0, n_packets=0, n_bytes=0,
priority=100,dl_type=0x88cc actions=CONTROLLER:65535
cookie=0x2a00000000000032, duration=19.747s, table=0, n_packets=0, n_bytes=0,
idle_timeout=600, hard_timeout=300,
priority=10,dl_src=0e:ba:81:cb:fa:27,dl_dst=1a:ec:b0:fc:fd:b4
actions=output:"s1-eth1"
cookie=0x2a00000000000033, duration=19.746s, table=0, n_packets=0, n_bytes=0,
idle_timeout=600, hard_timeout=300,
priority=10,dl_src=1a:ec:b0:fc:fd:b4,dl_dst=0e:ba:81:cb:fa:27
actions=output:"s1-eth3"
cookie=0x2b00000000000000, duration=3021.885s, table=0, n_packets=9,
n_bytes=750, priority=0 actions=drop
mininet>
#檢視交換機的流表(有dorp)
mininet> sh ovs-ofctl dump-flows s1 | grep "in_port=2"
cookie=0x2b00000000000002, duration=3046.231s, table=0, n_packets=10,
n_bytes=728, idle_age=3018, priority=2,in_port=2
actions=output:3,output:1,CONTROLLER:65535
cookie=0x0, duration=3005.672s, table=0, n_packets=26, n_bytes=1372,
idle_age=935, in_port=2 actions=drop
mininet>
#使用iperf工具測試h1和h3的帶寬
mininet> iperf h1 h3
*** Iperf: testing TCP bandwidth between h1 and h3
*** Results: ['2.11 Gbits/sec', '2.12 Gbits/sec']
#h1啟動HTTP—Server功能
mininet> h1 python -m SimpleHTTPServer 8080 &
#檢視h1的位址
mininet> h1 ip add
#檢視端口
mininet> sh ss -lntp | grep 8080
LISTEN 0 50 *:8080 *:*
users:(("java",pid=11357,fd=413))
安裝wget
apt install wget -y
#擷取h1的html網頁配置
mininet> h3 wget -O h1 http://10.0.0.1:8080
--2022-05-12 14:21:08-- http://10.0.0.1:8080/
正在連接配接 10.0.0.1:8080... 已連接配接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:844 [text/html]
正在儲存至: “10.0.0.1”
10.0.0.1 100%[===================>] 844 --.-KB/s 用時 0s
2022-05-12 14:21:08 (82.3 MB/s) - 已儲存 “10.0.0.1” [844/844])
安裝curl
apt insatll curl -y
#使用h3通路h1的網頁
mininet> h3 curl 10.0.0.1:8080
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>
<title>Directory listing for /</title>
<body>
<h2>Directory listing for /</h2>
<hr>
<ul>
<li><a href=".bash_history">.bash_history</a>
<li><a href=".bashrc">.bashrc</a>
<li><a href=".cache/">.cache/</a>
<li><a href=".gnupg/">.gnupg/</a>
<li><a href=".karaf/">.karaf/</a>
<li><a href=".mininet_history">.mininet_history</a>
<li><a href=".profile">.profile</a>
<li><a href=".viminfo">.viminfo</a>
<li><a href=".Xauthority">.Xauthority</a>
<li><a href="10.0.0.1">10.0.0.1</a>
<li><a href="distribution-karaf-0.6.0-Carbon/">distribution-karaf-0.6.0-
Carbon/</a>
<li><a href="distribution-karaf-0.6.0-Carbon.zip">distribution-karaf-0.6.0-
Carbon.zip</a>
<li><a href="mininet_2.2.2-4_amd64.deb">mininet_2.2.2-4_amd64.deb</a>
<li><a href="nohup.out">nohup.out</a>
</ul>
<hr>
</body>
</html>
#測試通路
mininet> h3 curl -I 10.0.0.1:8080
HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/2.7.16
Date: Thu, 12 May 2022 06:22:28 GMT
Content-type: text/html; charset=UTF-8
Content-Length: 844
#殺死h1的網頁python程式
mininet> h1 kill %python
Serving HTTP on 0.0.0.0 port 80 ...
10.0.0.3 - - [12/May/2022 14:15:46] "GET / HTTP/1.1" 200 -
10.0.0.3 - - [12/May/2022 14:17:26] "GET / HTTP/1.1" 200 -