Dear Professor,
        I saw your ppt(Lab 5) on the Internet about OpenFlow.
        What if I want a topology that contain two switch s1 and s2 and 4 hosts.    h1 h2 linked to s1 ; s1 linked to s2 ; h3 h4 linked to s2  . But h1 can only communicate to h3, h2 can only communicate to h4.
I’m just confused about how to add rules to the ports.
Really looking forward to your reply.
Best Wishes,





mininet-script (1104.py)




Script created by VND - Visual Network Description (SDN version)


from mininet.net import Mininet

from mininet.node import Controller, RemoteController, OVSKernelSwitch, UserSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from mininet.link import Link, TCLink


def topology():

    "Create a network."

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


    print "*** Creating nodes"

    s1 = net.addSwitch( 's1', listenPort=6673, mac='00:00:00:00:00:01' )

    s2 = net.addSwitch( 's2', listenPort=6674, mac='00:00:00:00:00:02' )

    h1 = net.addHost( 'h1', mac='00:00:00:00:00:11', ip='' )

    h2 = net.addHost( 'h2', mac='00:00:00:00:00:12', ip='' )

    h3 = net.addHost( 'h3', mac='00:00:00:00:00:13', ip='' )

    h4 = net.addHost( 'h4', mac='00:00:00:00:00:14', ip='' )

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


    print "*** Creating links"

    net.addLink(s1, h1)

    net.addLink(s1, h2)

    net.addLink(s1, s2)

    net.addLink(s2, h3)

    net.addLink(s2, h4)


    print "*** Starting network"



    s2.start( [c8] )

    s1.start( [c8] )


    print "*** Running CLI"

    CLI( net )


    print "*** Stopping network"



if __name__ == '__main__':

    setLogLevel( 'info' )



pyretic controller-route_1104.py

from pyretic.lib.corelib import*

from pyretic.lib.std import *


ip1 = IPAddr('')

ip2 = IPAddr('')

ip3 = IPAddr('')

ip4 = IPAddr('')



route1 = ((match(switch=1) >> fwd(3)) +

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



route2 = ((match(switch=2) >> fwd(1)) +

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



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

          (match(switch=2) >> fwd(3)))



route4 = ((match(switch=2) >> fwd(1)) +

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


myroute = (((match(srcip=ip1) & match(dstip=ip3)) >> route1) +

           ((match(srcip=ip3) & match(dstip=ip1)) >> route2) +

           ((match(srcip=ip2) & match(dstip=ip4)) >> route3) +

           ((match(srcip=ip4) & match(dstip=ip2)) >> route4))


def main():

   return myroute








Dr. Chih-Heng Ke (smallko@gmail.com)

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.