Exemple #1
0
  def run(self):
    print self.receivelinkevent
    
    setLogLevel("info")
    OVSKernelSwitch.setup()#"Make sure Open vSwitch is installed and working"

    info("****creating network****\n")
    self.net = Mininet(listenPort = self.listenPort)

    controller = RemoteController("mirrorController",   ip = "127.0.0.1")
    self.net.addController(controller)
    #self.gettoptly()
    timesnum=0;
    while core.running:
      try:
        while True:
          rlist, wlist, elist = yield Select([self.receivelinkevent], [], [], 5)
          if len(rlist) == 0 and len(wlist) == 0 and len(elist) == 0:
            #self.gettoptly()
            if not core.running: break
          #if len(rlist)!=0:
            #print self.receivelinkevent
          if self.receivelinkevent==1:
            self.gettoptly()
            timesnum+=1
            if timesnum==5:
              self.net.pingAll()    
      except exceptions.KeyboardInterrupt:
        break
    self.net.stop()
Exemple #2
0
  def run (self):
    setLogLevel("info")
    OVSKernelSwitch.setup()#"Make sure Open vSwitch is installed and working"

    info("****creating network****\n")
    self.net = Mininet(listenPort = 6666)

    controller = RemoteController("mirrorController",   ip = "127.0.0.1")
    self.net.addController(controller)
    while core.running:
      try:
        time.sleep(3)
        if not core.running: break
        '''
        self.net.pingAll()
        if len(self.addswitches)!=0:
          for i in self.addswitches:
            print self.addswitches[i].dpctl('show')
        '''
        if self.rectopolyreply==1:
          mutex.acquire()
          self.createtoptly()
          self.rectopolyreply=0
          mutex.release()
      except exceptions.KeyboardInterrupt:
        break
      except:
        log.exception("Exception SendMes running ")
        break
    self.net.stop()
Exemple #3
0
def main(inputfiles = []):
    OVSKernelSwitch.setup()
    net = Mininet(
        topo= GeneratedTopo(),
        switch=OVSKernelSwitch,
        build=False,
        link=TCLink,
        host=CPULimitedHost
    )
    c = RemoteController('c0', ip='127.0.0.1', port=6633)
    net.addController(c)
    net.build()
    net.start()
    #net.staticArp()
    
    num_h = len(net.hosts)
    p_start = -1
    count = 1
    ip_map = {}
    
    for f in inputfiles:
        print(f)
        with PcapReader(f) as pcap_reader:
            for pkt in pcap_reader:
                if IP not in pkt:
                    continue
                if pkt.src not in ip_map.keys():
                    ip_map[pkt.src] = net.nameToNode('h%d' % count) 
                    count = (count + 1) % num_h
                if pkt.dst not in ip_map.kesy():
                    ip_map[pkt.dst] = net.nameToNode('h%d' % count)
                    count = (count + 1) % num_h
                
                h = ip_map.get(pkt.src)
                pkt.src = h.IP()
                pkt.dst = ip_map.get(pkt.dst).IP()
                
                if pkt.src != pkt.dst:
                    thread.start_new_thread(ReadyToSend, (h, pkt, p_start))

    CLI( net )
    net.stop()
Exemple #4
0
from mininet.net import Mininet
from mininet.node import OVSKernelSwitch
from mininet.topolib import TreeTopo


def ifconfigTest(net):
    "Run ifconfig on all hosts in net."
    hosts = net.hosts
    for host in hosts:
        info(host.cmd('ifconfig'))


if __name__ == '__main__':
    lg.setLogLevel('info')
    info("*** Initializing Mininet and kernel modules\n")
    OVSKernelSwitch.setup()
    info("*** Creating network\n")
    network = Mininet(TreeTopo(depth=2, fanout=2),
                      switch=OVSKernelSwitch,
                      waitConnected=True)
    info("*** Starting network\n")
    network.start()
    info("*** Running ping test\n")
    network.pingAll()
    info("*** Running ifconfig test\n")
    ifconfigTest(network)
    info("*** Starting CLI (type 'exit' to exit)\n")
    CLI(network)
    info("*** Stopping network\n")
    network.stop()
            filler = '0000000000000000'
            return filler[:len(filler) - len(dpid)] + dpid
        elif len(dpid) > 16:
            print 'DPID: %s is too long' % dpid
            sys.exit(3)


topos = { 'fabric' : FabricTopo}

if __name__ == '__main__':
    lg.setLogLevel( 'info' )

    call(['ovs-vsctl', 'set-manager', 'tcp:%s:6640' % odl_controller])

    info( "*** Initializing Mininet and kernel modules\n" )
    OVSKernelSwitch.setup()

    info( "*** Creating network\n" )
    network = Mininet( FabricTopo(), switch=ExtendOVSSwitch ,controller=None)

    network.addController(name='c0', controller=RemoteController, ip=odl_controller)

    info( "*** Starting network\n" )
    network.start()

    info( "*** Starting CLI (type 'exit' to exit)\n" )
    CLI( network )

    info( "*** Stopping network\n" )
    network.stop()