Skip to content

MAC Learning Tutorial

Luca Pollini edited this page Oct 14, 2015 · 8 revisions

In this tutorial we'll execute the MAC Learning application leveraging OpenState features.

You first need to configure OpenState in Mininet as explained here http://openstate-sdn.github.io/

  1. Launch maclearning app in Ryu. Inside Mininet type the following command:

    $ ryu-manager ryu/ryu/app/openstate/maclearning.py

As you can see from the output this app support switches with a maximum of 4 ports:

loading app ryu/ryu/app/openstate/maclearning.py
loading app ryu.controller.ofp_handler
instantiating app ryu/ryu/app/openstate/maclearning.py of OSMacLearning
OpenState MAC Learning sample app initialized
Supporting MAX 4 ports per switch
...

To edit the number of ports you can simply edit the value SWITCH_PORTS inside maclearning.py

  1. Start Mininet with a single topology with 4 hosts:

    $ sudo mn --topo single,4 --mac --switch user --controller remote

  2. Test correct working... inside Mininet

    mininet> pingall

As you can see from the output the switch is correctly working as supposed:

*** Ping: testing ping reachability
h1 -> h2 h3 h4 
h2 -> h1 h3 h4 
h3 -> h1 h2 h4 
h4 -> h1 h2 h3 
*** Results: 0% dropped (12/12 received)
  1. To debug the flow table we need first to open a terminal window for switch s1, inside mininet:

    mininet> xterm s1

  2. Inside s1 terminal:

    sudo dpctl -c unix:/tmp/s1 stats-flow

Note how the rules installed don't match any MAC address but just the current state of the packet.

  1. To query the state table, in s1 terminal write:

    sudo dpctl -c unix:/tmp/s1 stats-state

OpenFlow comparison

Now let's compare OpenState-based MAC Learning with OpenFlow. To do this we'll use a more complex topology.

  1. Launch simple_switch_13 app in RYU

    $ ryu-manager ryu/ryu/app/simple_switch_13.py

  2. Start Mininet with a tree topology with:

    sudo mn --topo tree,4 --mac --switch user --controller remote

  3. Ping from h1 to h16, inside Mininet:

    mininet> h1 ping h16

Note how the time to complete the first ping is longer than the followings. This is due to the time needed for the first packet to go to the controller and back:

PING 10.0.0.16 (10.0.0.16) 56(84) bytes of data.
64 bytes from 10.0.0.16: icmp_req=1 ttl=64 time=51.7 ms
64 bytes from 10.0.0.16: icmp_req=2 ttl=64 time=1.99 ms
64 bytes from 10.0.0.16: icmp_req=3 ttl=64 time=2.60 ms
64 bytes from 10.0.0.16: icmp_req=4 ttl=64 time=2.81 ms
  1. Restart Mininet with same topology and RYU with OpenState maclearning app. Execute the same test, do you notice any difference?