Professional Documents
Culture Documents
Kch bn gi lp :
1
2|Page
http://mirror-fpt-telecom.fpt.net/ubuntu-releases/16.04.2/ubuntu-16.04.2-desktop-
amd64.iso
Bc 2 : Download v ci t Mininet.
git clone git://github.com/mininet/mininet
mininet/util/install.sh a
// Sau khi ci t xong, thc hin test th
sudo mn --test pingall
2
3|Page
// Qu trnh ci t hon tt !
3
4|Page
Test kt ni :
mininet> pingall
*** Ping: testing ping reachability
h1 -> X X
h2 -> X X
h3 -> X X
*** Results: 100% dropped (0/6 received)
mininet>
mininet>
mininet>
mininet> links
h1-eth0<->s1-eth1 (OK OK)
h2-eth0<->s1-eth2 (OK OK)
h3-eth0<->s1-eth3 (OK OK)
mininet> dump
<Host h1: h1-eth0:10.0.0.1 pid=5337>
<Host h2: h2-eth0:10.0.0.2 pid=5340>
<Host h3: h3-eth0:10.0.0.3 pid=5342>
<OVSSwitch{'protocols': 'OpenFlow13'} s1: lo:127.0.0.1,s1-eth1:None,s1-
eth2:None,s1-eth3:None pid=5347>
<RemoteController c0: 127.0.0.1:6653 pid=5330>
mininet> nodes
available nodes are:
c0 h1 h2 h3 s1
mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
h3 h3-eth0:s1-eth3
s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0 s1-eth3:h3-eth0
c0
mininet> h1 ifconfig -a
h1-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:01
inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::200:ff:fe00:1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:56 errors:0 dropped:32 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6506 (6.5 KB) TX bytes:990 (990.0 B)
4
5|Page
collisions:0 txqueuelen:1
RX bytes:224 (224.0 B) TX bytes:224 (224.0 B)
mininet> h2 ifconfig -a
h2-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:02
inet addr:10.0.0.2 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::200:ff:fe00:2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:56 errors:0 dropped:32 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6506 (6.5 KB) TX bytes:990 (990.0 B)
mininet> h3 ifconfig -a
h3-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:03
inet addr:10.0.0.3 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::200:ff:fe00:3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:56 errors:0 dropped:32 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6506 (6.5 KB) TX bytes:990 (990.0 B)
mininet> s1 ifconfig -a
enp0s3 Link encap:Ethernet HWaddr 08:00:27:6f:c0:96
inet addr:192.168.5.104 Bcast:192.168.5.255 Mask:255.255.255.0
inet6 addr: fe80::2911:4fe7:890c:8688/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14996 errors:0 dropped:0 overruns:0 frame:0
TX packets:3055 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21203633 (21.2 MB) TX bytes:265240 (265.2 KB)
5
6|Page
Mask:255.255.255.0
inet6 addr: fe80::175c:1aa4:3f54:5a5d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:456 errors:0 dropped:0 overruns:0 frame:0
TX packets:95 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:79614 (79.6 KB) TX bytes:13045 (13.0 KB)
6
7|Page
mininet>
mininet> c0 ifconfig -a
enp0s3 Link encap:Ethernet HWaddr 08:00:27:6f:c0:96
inet addr:192.168.5.104 Bcast:192.168.5.255 Mask:255.255.255.0
inet6 addr: fe80::2911:4fe7:890c:8688/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:15198 errors:0 dropped:0 overruns:0 frame:0
TX packets:3124 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21224146 (21.2 MB) TX bytes:276334 (276.3 KB)
7
8|Page
mininet>
Khi ng MiniEdit
# sudo python mininet/examples/miniedit.py
8
9|Page
http://192.168.5.104:8181/index.html#
Username : admin
Password : admin
9
10 | P a g e
10
11 | P a g e
11
12 | P a g e
12
13 | P a g e
h4 -> h1 h2 h3
*** Results: 0% dropped (12/12 received)
mininet> h1 ping -f h3
PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.
. ^C
--- 10.0.0.3 ping statistics ---
4664573 packets transmitted, 4664573 received, 0% packet loss, time
534243ms
rtt min/avg/max/mdev = 0.008/0.043/145.194/0.128 ms, pipe 2, ipg/ewma
0.114/0.031 ms
mininet>
http://192.168.5.103:8008/agents/html
C th m rng sFlow bng cch nh ngha cc Flow theo di lu lng trn giao
din web realtime.
#!/usr/bin/env python
import requests
import json
rt = 'http://127.0.0.1:8008'
flow = {'keys':'link:inputifindex,ipsource,ipdestination','value':'bytes'}
requests.put(rt+'/flow/pair/json',data=json.dumps(flow))
threshold = {'metric':'pair','value':1000000/8,'byFlow':True,'timeout':1}
requests.put(rt+'/threshold/elephant/json',data=json.dumps(threshold))
eventurl = rt+'/events/json?thresholdID=elephant&maxEvents=10&timeout=60'
eventID = -1
while 1 == 1:
r = requests.get(eventurl + "&eventID=" + str(eventID))
if r.status_code != 200: break
events = r.json()
if len(events) == 0: continue
13
14 | P a g e
eventID = events[0]["eventID"]
events.reverse()
for e in events:
print e['flowKey']
http://blog.sflow.com/2013/08/restflow.html
http://sflow-rt.com/writing_applications.php
14