Last active
November 1, 2015 16:17
-
-
Save samuelregev/f03660d48cb176ce1efd to your computer and use it in GitHub Desktop.
Mininet ex2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We started a network with 3 hosts, one switch and one controller | |
mininet@mininet-vm:~$ sudo mn --topo single,3 --mac --switch ovsk --controller remote | |
*** Creating network | |
*** Adding controller | |
Unable to contact the remote controller at 127.0.0.1:6633 | |
*** Adding hosts: | |
h1 h2 h3 | |
*** Adding switches: | |
s1 | |
*** Adding links: | |
(h1, s1) (h2, s1) (h3, s1) | |
*** Configuring hosts | |
h1 h2 h3 | |
*** Starting controller | |
c0 | |
*** Starting 1 switches | |
s1 | |
*** Starting CLI: | |
mininet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Learning to use mininet, see the nodes, help, | |
Find the first mininet host IP (h1) and open xterm windows on two hosts | |
mininet> nodes | |
available nodes are: | |
c0 h1 h2 h3 s1 | |
mininet> help | |
Documented commands (type help <topic>): | |
======================================== | |
EOF gterm iperfudp nodes pingpair py switch | |
dpctl help link noecho pingpairfull quit time | |
dump intfs links pingall ports sh x | |
exit iperf net pingallfull px source xterm | |
You may also send a command to a node using: | |
<node> command {args} | |
For example: | |
mininet> h1 ifconfig | |
The interpreter automatically substitutes IP addresses | |
for node names when a node is the first arg, so commands | |
like | |
mininet> h2 ping h3 | |
should work. | |
Some character-oriented interactive commands require | |
noecho: | |
mininet> noecho h2 vi foo.py | |
However, starting up an xterm/gterm is generally better: | |
mininet> xterm h2 | |
mininet> h1 ifconfig | |
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:0 errors:0 dropped:0 overruns:0 frame:0 | |
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0 | |
collisions:0 txqueuelen:1000 | |
RX bytes:0 (0.0 B) TX bytes:738 (738.0 B) | |
lo Link encap:Local Loopback | |
inet addr:127.0.0.1 Mask:255.0.0.0 | |
inet6 addr: ::1/128 Scope:Host | |
UP LOOPBACK RUNNING MTU:65536 Metric:1 | |
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 | |
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 | |
collisions:0 txqueuelen:0 | |
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) | |
mininet> xterm h1 h2 | |
mininet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dpctl allow us to control a single switch's flow table | |
mininet@mininet-vm:~$ dpctl show tcp:127.0.0.1:6634 | |
features_reply (xid=0x8caef9b0): ver:0x1, dpid:1 | |
n_tables:254, n_buffers:256 | |
features: capabilities:0xc7, actions:0xfff | |
1(s1-eth1): addr:d2:45:80:d7:c4:0f, config: 0, state:0 | |
current: 10GB-FD COPPER | |
2(s1-eth2): addr:66:3a:2d:fc:4c:a4, config: 0, state:0 | |
current: 10GB-FD COPPER | |
3(s1-eth3): addr:6e:50:9c:90:fc:1e, config: 0, state:0 | |
current: 10GB-FD COPPER | |
LOCAL(s1): addr:de:d8:74:06:6f:4e, config: 0, state:0 | |
get_config_reply (xid=0x6b587d9f): miss_send_len=0 | |
mininet@mininet-vm:~$ dpctl dump-flows tcp:127.0.0.1:6634 | |
stats_reply (xid=0xf3f77aa1): flags=none type=1(flow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
we do a ping test from h1 to h2 through the controller | |
but the switch flow table is empty and no controller connected to the switch so the switch doesn't know what to do with incoming traffic. | |
that's why the ping failed. | |
mininet> h1 ping -c3 h2 | |
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. | |
From 10.0.0.1 icmp_seq=1 Destination Host Unreachable | |
From 10.0.0.1 icmp_seq=2 Destination Host Unreachable | |
From 10.0.0.1 icmp_seq=3 Destination Host Unreachable | |
--- 10.0.0.2 ping statistics --- | |
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2014ms | |
pipe 3 | |
mininet> | |
now we will use dpctl to manually install this flows | |
mininet@mininet-vm:~$ dpctl add-flow tcp:127.0.0.1:6634 in_port=1,actions=output:2 | |
mininet@mininet-vm:~$ dpctl add-flow tcp:127.0.0.1:6634 in_port=2,actions=output:1 | |
and we verify that by checking the flow-table | |
mininet@mininet-vm:~$ dpctl dump-flows tcp:127.0.0.1:6634 | |
stats_reply (xid=0xb80bd821): flags=none type=1(flow) | |
cookie=0, duration_sec=51s, duration_nsec=175000000s, table_id=0, priority=32768, n_packets=0, n_bytes=0, idle_timeout=60,hard_timeout=0,in_port=2,actions=output:1 | |
mininet@mininet-vm:~$ | |
try to ping again, it failed because I waited more then 60 seconds (the default time-out), I re-enter the flows and tried to ping right away. | |
this time it worked | |
mininet> h1 ping -c4 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=0.554 ms | |
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.040 ms | |
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.050 ms | |
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.051 ms | |
--- 10.0.0.2 ping statistics --- | |
4 packets transmitted, 4 received, 0% packet loss, time 3002ms | |
rtt min/avg/max/mdev = 0.040/0.173/0.554/0.220 ms | |
mininet> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i started the wireshark and start capture lo interface(loopback), set 'of' filter | |
sudo wireshark & | |
[1] 5862 | |
mininet@mininet-vm:~$ Gtk-Message: Failed to load module "pk-gtk-module" | |
Gtk-Message: Failed to load module "canberra-gtk-module" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now the Wireshark is listening, we start the OpenFlow reference controller. | |
mininet@mininet-vm:~$ controller ptcp: | |
This starts a simple controller that acts as a learning switch without installing any flow-entries. | |
now in the wireshark we see bunch of messages of the mininet. | |
i tried to set the filter in the wireshark in order to ignore echo-request/reply but the filter is not working. | |
i run the ping command again and saw the messages in the wireshark | |
--- | |
first we see the broadcast when h1 is looking for h2 | |
then we see h2 answer h1 (by mac address 00:00:00:00:00:02 -> ..00:01) | |
and after then we can see them "talking" (ping) form 10.0.0.1 to 10.0.0.2 back and forth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iperf is used to check speed between two computers | |
mininet> iperf | |
*** Iperf: testing TCP bandwidth between h1 and h3 | |
Waiting for iperf to start up...*** Results: ['14.3 Gbits/sec', '14.3 Gbits/sec'] | |
the mininet runs the iperf on two virtual hosts. once they connected they send packets between them and print out the result as shown above. | |
now we compare it to the user-space switch | |
mininet@mininet-vm:~$ sudo mn --topo single,3 --mac --controller remote --switch user | |
*** Creating network | |
*** Adding controller | |
*** Adding hosts: | |
h1 h2 h3 | |
*** Adding switches: | |
s1 | |
*** Adding links: | |
(h1, s1) (h2, s1) (h3, s1) | |
*** Configuring hosts | |
h1 h2 h3 | |
*** Starting controller | |
c0 | |
*** Starting 1 switches | |
s1 | |
*** Starting CLI: | |
mininet> iperf | |
*** Iperf: testing TCP bandwidth between h1 and h3 | |
Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...Waiting for iperf to start up...^C | |
Interrupt | |
it much slower this way, because the packets must cross from user-space to kernel-space and back on every hop. | |
we use user-space switch because it's easy to modify, but slower for simulation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment