*I have created a network using the following code, and pox as remote
controller with l2.learning module.*


#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf

def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    #info( '*** Adding controller\n' )
    #c0=net.addController(name='c0',
     #                 controller=None)
    info( '*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
    info( '*** Add hosts\n')

    h1 = net.addHost('h1', cls=Host, mac='00:00:00:00:00:01', ip='
10.0.0.2/24', defaultRoute='h1-eth0')
    h2 = net.addHost('h2', cls=Host, mac='00:00:00:00:00:02', ip='
10.0.0.3/24', defaultRoute='h2-eth0')
    h4 = net.addHost('h4', cls=Host, mac='00:00:00:00:00:04', ip='
20.0.0.3/24', defaultRoute='h4-eth0')
    h3 = net.addHost('h3', cls=Host, mac='00:00:00:00:00:03', ip='
30.0.0.2/24', defaultRoute='h3-eth0')
    h5 = net.addHost('h5', cls=Host, mac='00:00:00:00:00:05', ip='
20.0.0.3/24', defaultRoute='h5-eth0')

    info( '*** Add links\n')
    linkBW = {'bw':100}
    net.addLink(h1, s1, cls=TCLink , **linkBW)
    net.addLink(h2, s1, cls=TCLink , **linkBW)
    net.addLink(h3, s2, cls=TCLink , **linkBW)
    net.addLink(h4, s3, cls=TCLink , **linkBW)
    net.addLink(h5, s3, cls=TCLink , **linkBW)
    net.addLink(s1, s2, cls=TCLink , **linkBW)
    net.addLink(s3, s2, cls=TCLink , **linkBW)
    info( '*** Starting network\n')
    net.build()
    #info( '*** Starting controllers\n')
    #for controller in net.controllers:
     #   controller.start()
    info( '*** Starting switches\n')
    net.get('s1')#.start([c0])
    net.get('s2')#.start([c0])
    net.get('s3')#.start([c0])
    info( '*** Configuring switches\n')

    CLI(net)
    net.stop()

if __name__ == '__main__':
    setLogLevel( 'info' )
    myNetwork()


*I am able to ping to each other.*
*But now I want add an entry to all switch. If h2 sends packet to h3 then
divert it to h5 on the basis of IP addresses by the following code.*


from pox.core import core
import pox.openflow.libopenflow_01 as of
from pox.lib.revent import *
from pox.lib.util import dpidToStr
from pox.lib.addresses import EthAddr
from collections import namedtuple
import os

log = core.getLogger()

class Diversion(EventMixin):
    def __init__ (self) :
        self.listenTo(core.openflow)
        log.debug("Enabling Diversion Module")

    def _handle_ConnectionUp (self, event):
        msg = of.ofp_flow_mod()
        msg.match = of.ofp_match(nw_src = IPAddr("10.0.0.3"),nw_dst =
IPAddr("10.0.0.3"))

msg.actions.append(ofp_action_nw_addr.set_dst(IPAddr("192.168.1.14")))
        self.connection.send(msg)
        log.debug(" rules installed on %s", dpidToStr(event.dpid))

def launch():
    core.registerNew(Diversion)


*But now i am not able to ping any of the host..*

*Please direct me to the error.*


Thanks and Regards.

Reply via email to