Test 1: mininet-wifi + pyretic

[Preparation]

  If you want to run the following example, I suggest that you can use SDN hub VM. And install the mininet-wifi.(See the installation part)

 

[Topology]

 

In this topology, ap1 is also an openvswitch that accepts openflow control messages from remote controller. ap1 has two ports: ap1-eth1 is connected to h1 and ap1-wlan0 is for wireless station connections.

 

[mininet-wifi Scripts: test_infrastructure.py]

#!/usr/bin/python

 

from mininet.net import Mininet

from mininet.node import  Controller, RemoteController, OVSKernelSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from mininet.link import TCLink

 

def topology():

    "Create a network."

    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

 

    print "*** Creating nodes"

    sta1 = net.addStation( 'sta1', ip="192.168.0.1" )

    sta2 = net.addStation( 'sta2', ip="192.168.0.2" )

    h1 = net.addHost( 'h1', ip="192.168.0.3" )

    ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel="1" )

    c0 = net.addController('c0', controller=RemoteController, ip='127.0.0.1', port=6633 )

 

    print "*** Adding Link"

    net.addLink(h1,ap1)

    net.addLink(sta1, ap1)

    net.addLink(sta2, ap1)

 

    print "*** Starting network"

    net.build()

    c0.start()

    ap1.start( [c0] )

   

    print "*** Running CLI"

    CLI( net )

    print "*** Stopping network"

    net.stop()

 

if __name__ == '__main__':

    setLogLevel( 'info' )

    topology()

 

[pyretic controller: test1.py. This file is placed under ~/pyretic/pyretic/modules folder.] Note: The following code will allow h1 to ping sta1, but not sta2.

from pyretic.lib.corelib import*

from pyretic.lib.std import *

 

ip1 = IPAddr('192.168.0.1')

ip2 = IPAddr('192.168.0.2')

ip3 = IPAddr('192.168.0.3')

 

route1 = match(switch=1) >> fwd(2)

 

route2 = match(switch=1) >> drop

 

route3 = match(switch=1) >> fwd(1)

 

myroute = ((match(dstip=ip1) >> route1) +

           (match(dstip=ip2) >> route2) +

           (match(dstip=ip3) >> route3))

 

def main():

   return myroute

 

[execution]

 

 

 

some basic openvswitch operations.

 

 

 

wireless information for ap1, sta1, and sta2.

 

Dr. Chih-Heng Ke

Department of Computer Science and Information Engineering, National Quemoy University, Kinmen, Taiwan

Email: smallko@gmail.com