https://yeasy.gitbooks.io/mininet_book/index.html
1.在VirtualBox安裝ubuntu 14.04.5 server x64,Package select openssh
2.讓root可以用putty login
vi /etc/ssh/sshd_config
修改
PermitRootLogin Yes
重新開機,讓root可以用putty login
3.OS更新
#apt-get update
#apt-get upgrade
4.安裝git
root@mininet:/etc/init.d# apt-get install git
5.安裝mininet
root@mininet:~# git clone git://github.com/mininet/mininet
root@mininet:~# mininet/util/install.sh -a
(會跑很久)
6.登入mininet
root@mininet:~# mn
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 1 switches
s1 ...
*** Starting CLI:
mininet>
預設會建立2台主機h1、h2
1台交換器 s1
1台控制器 c1
7.查看節點數
mininet> nodes
available nodes are:
c0 h1 h2 s1
8.查看連結訊息
mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0
c0
8.查看各節點訊息
mininet> dump
9.h1 ping h2
mininet> h1 ping -c 1 h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=1.96 ms
--- 10.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.969/1.969/1.969/0.000 ms
10.開啟h1終端機
mininet> xterm h1
Error: Cannot connect to display
出現錯誤,必須在GUI模式才能開啟
11.在h1建一個web Server,再從h2 get h1 資料
mininet> h1 python -m SimpleHTTPServer 80 &
mininet> h2 wget -O - h1
刪除web服務
mininet> h1 kill %python
12.cmd line自訂拓樸
http://sdnhub.org/resources/useful-mininet-setups/
1個控制器、1個交換器、3個主機
root@mininet:~# sudo mn --arp --topo single,3 --mac --switch ovsk --controller remote
In the above command, there are some important keywords worth paying attention to:
- –mac: Auto set MAC addresses
- –arp: Populate static ARP entries of each host in each other
- –switch: ovsk refers to kernel mode OVS
- –controller: remote controller can take IP address and port number as options
root@mininet:~# sudo mn --topo linear --switch ovsk --controller remote
mininet> nodes
available nodes are:
c0 h1 h2 s1 s2
1個控制器、1個交換器、3個主機、1個Client
root@mininet:~# sudo mn --arp --topo single,4 --mac --switch ovsk --controller remote
mininet> nodes
available nodes are:
c0 h1 h2 h3 h4 s1
mininet> nodes
available nodes are:
c0 h1 h2 s1 s2
1個控制器、1個交換器、3個主機、1個Client
root@mininet:~# sudo mn --arp --topo single,4 --mac --switch ovsk --controller remote
mininet> nodes
available nodes are:
c0 h1 h2 h3 h4 s1
- Virtual IP/MAC: Pick a virtual IP (VIP) and MAC for the load-balancer. This is the IP address to which the clients will make a HTTP request. The controller will push rules to rewrite the VIP with the selected HTTP server. To make this work, you need to static set an ARP entry for the VIP in the client. If ‘h1′ is the client and 10.0.0.5 is the VIP, the following command will add the static ARP entry:
mininet> h1 arp -s 10.0.0.5 00:00:00:00:00:05
- Server setup: The –arp keyword is very important to populate MAC addresses in each host. Besides that we need to run the following commands within mininet:
mininet> h2 python -m CGIHTTPServer & mininet> h3 python -m CGIHTTPServer & mininet> h4 python -m CGIHTTPServer &
- Warm-up controller learning: After the hosts are up, it is important to make the controller learn the location of each host. You can do this through a pingall command in mininet:
mininet> pingall
- Client request: In our custom VM, we have CGI script configured to report back which server is handling a particular client request. Thus, when a client performs the following command, you will receive the IP address of the handling server.
mininet> h1 curl http://10.0.0.5:8000/cgi-bin/serverip.cgi
13.Python API 腳本自訂拓樸
在 mininet\custom目錄下有一個範例 topo-2sw-2host.py
文件中定义了一个 mytopo,则可以通过
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s3 s4
*** Adding links:
(h1, s3) (s3, s4) (s4, h2)
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 2 switches
s3 s4 ...
*** Waiting for switches to connect
s3 s4
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)
*** Stopping 1 controllers
c0
*** Stopping 3 links
...
*** Stopping 2 switches
s3 s4
*** Stopping 2 hosts
h1 h2
*** Done
completed in 5.341 seconds
14.Mininet 範例程式介紹
http://yhhuanglab.blogspot.tw/2015/09/mininet.html
文件中定义了一个 mytopo,则可以通过
--topo
选项来指定使用这一拓扑,命令为 sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --test pingall
root@mininet:~# sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --test pingall
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s3 s4
*** Adding links:
(h1, s3) (s3, s4) (s4, h2)
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 2 switches
s3 s4 ...
*** Waiting for switches to connect
s3 s4
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)
*** Stopping 1 controllers
c0
*** Stopping 3 links
...
*** Stopping 2 switches
s3 s4
*** Stopping 2 hosts
h1 h2
*** Done
completed in 5.341 seconds
14.Mininet 範例程式介紹
http://yhhuanglab.blogspot.tw/2015/09/mininet.html
沒有留言:
張貼留言