Вы находитесь на странице: 1из 8

LAB

1
CREATE TOPOLOGY BY USING MININET

I. OBJECTIVES

This exercise is divided into two parts: (1) create a simple topology by using
Mininet and (2) add flow entries to Open vSwitchs by run command through CLI.
By doing that, students will archive the brief knowledge of Mininet and
understand how an Open vSwitch works.

II. DISCUSSION

Mininet is a network emulator which creates a network of virtual hosts, switches,


controllers, and links. Mininet hosts run standard Linux network software, and its
switches support OpenFlow for highly flexible custom routing and Software-
Defined Networking.

Mininet supports research, development, learning, prototyping, testing,


debugging, and any other tasks that could benefit from having a complete
experimental network on a laptop or other PC.

Mininet provides the following features:

 Provides a simple and inexpensive network testbed for developing


OpenFlow applications
 Enables multiple concurrent developers to work independently on
the same topology
 Supports system-level regression tests, which are repeatable and
easily packaged
 Enables complex topology testing, without the need to wire up a
physical network
 Includes a CLI that is topology-aware and OpenFlow-aware, for
debugging or running network-wide tests
 Supports arbitrary custom topologies, and includes a basic set of
parametrized topologies
 Provides a straightforward and extensible Python API for network
creation and experimentation

Mininet networks run real code including standard Unix/Linux network


applications as well as the real Linux kernel and network stack (including any
kernel extensions which you may have available, as long as they are compatible
with network namespaces.)

Because of this, the code user develops and tests on Mininet, for an OpenFlow
controller, modified switch, or host, can move to a real system with minimal
changes, for real-world testing, performance evaluation, and deployment.
Importantly this means that a design that works in Mininet can usually move
directly to hardware switches for line-rate packet forwarding.

III. REQUIREMENTS

This exercise requires a PC or Laptop that runs Ubuntu 12.04 and already
installed Mininet.

IV. TUTORIAL

As mentioned before, students will be required to create a simple topology and


add flow entries to the Open vSwitch.

 1. Create a simple topology by using Mininet

Run the following command

sudo mn --topo single, 3 --controller remote


Mininet will create a topology that consists of one Open vSwitch and there hosts:
h1, h2, h3.

The terminal’s screen shows the information of topology, which is created by


Mininet.

user@machinename:~$ sudo mn --topo single,3 --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>

With the option --controller remote we mean that Mininet will change Open
vSwitch’s controller address to Ip=127.0.0.1 (localhost) and port=6633.

After that, run pingall command


mininet> pingall

*** Ping: testing ping reachability

h1 -> X X

h2 -> X X

h3 -> X X

*** Results: 100% dropped (0/6 received)

mininet>

As we know, in the SDN environment, switches simply forward packets base on


an action filed in flow entries. These flow entries are generated by the controller
and add to flow table through open flow messages. In this exercise, flow tables
are empty. Therefore switches do not know what to do with incoming packets. As
a result, hosts cannot ping each other.

 2. Add flow entries to flow table of switches

Hình 1. Topology 1 switch kết nối 3 host

 Firstly, host 1 will need to send an ARP request to host 3 to get its MAC
address. To do this, we are required to install two flow entries into the flow
table of switches - one to forward ARP request from host 1 and another to
handle ARP reply from host 3.

Run the following commands:


sudo ovs-ofctl add-flow s1 dl_type=0x0806,nw_dst=10.0.0.3,action=output:3
sudo ovs-ofctl add-flow s1 dl_type=0x0806,nw_dst=10.0.0.1,action=output:1

 After host 1 gets the MAC address of host 3 by ARP, it now can normally
add this to MAC frame and send to host 3 through ICMP packet. Similarly,
we now need to install two flow entries into switches to handle echo-
request and echo-reply messages (ICMP - IPv4).
D
o
sudo ovs-ofctl add-flow s1 dl_type=0x0800,nw_dst=10.0.0.3,action=output:3
sudo ovs-ofctl add-flow s1 dl_type=0x0800,nw_dst=10.0.0.1,action=output:2
t
his by run the following commands:

Use the following command to check port-name and port-number:

sudo ovs-ofctl show s1

OFPT_FEATURES_REPLY (xid=0x1): ver:0x1,


dpid:0000000000000001

n_tables:255, n_buffers:256

features: capabilities:0xc7, actions:0xfff

1(s1-eth1): addr:0e:cd:fc:f0:cb:1f

config: 0

state: 0
current: 10GB-FD COPPER

2(s1-eth3): addr:f6:95:c5:60:e5:79

config: 0

state: 0

current: 10GB-FD COPPER

3(s1-eth2): addr:ca:7f:49:ba:fb:d0

config: 0

state: 0

current: 10GB-FD COPPER

LOCAL(s1): addr:6e:10:83:64:b5:47

config: PORT_DOWN

state: LINK_DOWN

OFPT_GET_CONFIG_REPLY (xid=0x3): frags=normal


miss_send_len=0

Use the port numbers above to create flow entries and then install these flow
entries into the switch S1 by using the following command

sdnlab@sdnlab:~$ sudo ovs-ofctl add-flow s1


dl_type=0x0800,nw_dst=10.0.0.3,action=output:2
sdnlab@sdnlab:~$ sudo ovs-ofctl add-flow s1
dl_type=0x0806,nw_dst=10.0.0.3,action=output:2
sdnlab@sdnlab:~$ sudo ovs-ofctl add-flow s1
dl_type=0x0806,nw_dst=10.0.0.1,action=output:1
sdnlab@sdnlab:~$ sudo ovs-ofctl add-flow s1
dl_type=0x0800,nw_dst=10.0.0.1,action=output:1
Now, h1 can ping h3 successfully because switch 1 knows exactly which ports
number to forward packets.

We will look in some more details.

 With dl_type=0x0806 we mean that packet type is ARP and


dl_type=0x0800 associated with IPv4 packets.
 The second noticeable option in these commands is nw_dst. With
nw_dst=10.0.0.1 we mean that packet is sent to host 1.

In addition to this, we also need to point out what we want to do with this packets.
Therefore, we use action=output:2 to forwarding the message to port 2 in the
switch.

V. CONCLUSION

Through this exercise, students have learned how to create a simple topology by
using Mininet as well as the structure of flow entry.

VI. QUESTIONS

1. What are the flow table and flow entry?

……………………………………………………………………………………………
……………………………………………………………………………………………
…………………………………………………………………………………………...

2. Use different ways to create flow-entry in Step 2 for scenarios: h1 ping h2 and
h2 ping h3.

……………………………………………………………………………………………
……………………………………………………………………………………………
…………………………………………………………………………………………...

3. What is the time-out of a flow entry in a flow table?


……………………………………………………………………………………………
……………………………………………………………………………………………
…………………………………………………………………………………………...

Вам также может понравиться