Learning POX OpenFlow controller : Proactive approach

15 Jun

The application name is topo_proactive.py.

This module works in a proactive mode. It is dependant on discovery module and can work with spanning_tree module in the topology with loops.

The idea behind this module is to assign all switches and hosts topology aware IP addresses. Knowning all IP addresses in advance, routing rules are installed.
Routing is based on the short path calculation. Hosts and switches get IP addresses by DHCP protocol from the controller.
Rules for creating IP addresses look the following way:

  • Switch address has a format of 10.<switch_id>.0.1
  • Network address has a format of 10.<switch_id>.0.0
  • Host address has a format of 10.<switch_id>.<switch_port_id>.<host_id>

Where

  • switch_id is generated by controller reflection just the ordering number
  • switch_port_id is a switch port number where host is connected to
  • host_id is the ordering number of a host

Example topology
Topology

The proactive nature of the module is encapsulated in the send_table method of TopoSwitch class. The logic inside this method populates the following rules to a switch:

  • Redirect all DHCP, LLDP, ARP, NDP packets to controller
  • Redirect packets with destination IP address from a network owned by known switch to a next hop port calculated by short path algorithm
  • Redirect packets with destination IP from a network owned by current switch  to a particular port where host with this IP was previously seen

Rules in OVS, retrieved using sudo ovs-ofctl dump-flows s1 command, will look the folllowing way.

1
2
3
4
5
6
7
8
9
10
11
cookie=0x0, duration=150.350s, table=0, n_packets=0, n_bytes=0, idle_age=150, ip,nw_dst=10.3.0.0/16 actions=output:1
 cookie=0x0, duration=150.350s, table=0, n_packets=0, n_bytes=0, idle_age=150, ip,nw_dst=10.2.0.0/16 actions=output:1
 cookie=0x0, duration=150.350s, table=0, n_packets=5, n_bytes=1711, idle_age=90, udp,tp_src=68,tp_dst=67 actions=CONTROLLER:65535
 cookie=0x0, duration=90.025s, table=0, n_packets=0, n_bytes=0, idle_age=90, ip,nw_dst=10.1.3.1 actions=mod_dl_src:00:00:00:00:00:01,mod_dl_dst:f2:5e:b1:0d:1f:3e,output:3
 cookie=0x0, duration=93.717s, table=0, n_packets=0, n_bytes=0, idle_age=93, ip,nw_dst=10.1.2.1 actions=mod_dl_src:00:00:00:00:00:01,mod_dl_dst:ea:2b:ce:81:3d:ca,output:2
 cookie=0x0, duration=150.350s, table=0, n_packets=0, n_bytes=0, idle_age=150, priority=32767,ip,nw_dst=255.255.255.255 actions=output:2,output:3
 cookie=0x0, duration=150.053s, table=0, n_packets=0, n_bytes=0, idle_age=150, ip,nw_dst=10.1.1.1 actions=mod_dl_src:00:00:00:00:00:01,mod_dl_dst:6a:c2:7e:06:13:98,output:1
 cookie=0x0, duration=150.350s, table=0, n_packets=29, n_bytes=1189, idle_age=0, priority=65000,dl_dst=01:23:20:00:00:01,dl_type=0x88cc actions=CONTROLLER:65535
 cookie=0x0, duration=150.350s, table=0, n_packets=0, n_bytes=0, idle_age=150, priority=32767,ip,nw_dst=10.1.3.0/24 actions=CONTROLLER:65535
 cookie=0x0, duration=150.350s, table=0, n_packets=0, n_bytes=0, idle_age=150, priority=32767,ip,nw_dst=10.1.1.0/24 actions=CONTROLLER:65535
 cookie=0x0, duration=150.350s, table=0, n_packets=0, n_bytes=0, idle_age=150, priority=32767,ip,nw_dst=10.1.2.0/24 actions=CONTROLLER:65535

Start POX using the following command line.
./pox.py log.level –DEBUG openflow.of_01 forwarding.topo_proactive openflow.discovery

Mininet script (proactive_net.py)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, Node
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import Link, Intf
def aggNet():
    CONTROLLER_IP='127.0.0.1'
    net = Mininet( topo=None,
                build=False)
    net.addController( 'c0',
                    controller=RemoteController,
                    ip=CONTROLLER_IP,
                    port=6633)
    h1 = net.addHost( 'h1', ip='0.0.0.0' )
    h2 = net.addHost( 'h2', ip='0.0.0.0' )
    h3 = net.addHost( 'h3', ip='0.0.0.0' )
    h4 = net.addHost( 'h4', ip='0.0.0.0' )
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    net.addLink( s1, s2 )
    net.addLink( s2, s3 )
    net.addLink( h1, s1 )
    net.addLink( h2, s1 )
    net.addLink( h3, s3 )
    net.addLink( h4, s3 )
    net.start()
    CLI( net )
    net.stop()
if __name__ == '__main__':
    setLogLevel( 'info' )
    aggNet()

After executing “sudo python proactive_net.py” execute the following commands inside mininet shell.

1
2
3
4
h1 dhclient h1-eth0
h2 dhclient h2-eth0
h3 dhclient h3-eth0
h4 dhclient h4-eth0

References

Source: http://haryachyy.wordpress.com/2014/06/14/learning-pox-openflow-controller-proactive-approach/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: