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()
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()
def start( self, *args, **kwargs ): OVSKernelSwitch.start( self, *args, **kwargs ) OVSBridgeSTP.prio += 1 self.cmd( 'ovs-vsctl set-fail-mode', self, 'standalone' ) self.cmd( 'ovs-vsctl set-controller', self ) self.cmd( 'ovs-vsctl set Bridge', self, 'stp_enable=true', 'other_config:stp-priority=%d' % OVSBridgeSTP.prio )
def add_switch(name, dpid, proto_version): if type(dpid) is unicode: dpid = dpid.encode('ascii','ignore') switch = OVSKernelSwitch(name, protocols=proto_version, inNamespace=False, dpid=dpid) switch.start(controllers) switches[name] = switch logger.debug("==> added switch name={}; dpid={}".format(name,dpid))
def __init__(self, name, custom_type=Type.SD_SWITCH, **pars): OVSKernelSwitch.__init__(self, name, **pars) print ("custom swtich has been initialized") self.Function_table = [] self.counter = 0 self.custom_type = custom_type self.MEC = [] """Content""" self.cLibrary = []
def add_switch_worker(): while True: name = names.get() switch = OVSKernelSwitch(name, protocols='OpenFlow13', inNamespace=False) switches[name] = switch switch.start(controllers) # time to here, 5 switches : 0.88s, 50sw : 2.8 (15), 200 : 22s (33) logger.debug("==> added switch name={}".format(name)) names.task_done()
def start( self, controllers ): OVSKernelSwitch.start(self, controllers) LegacyL2Switch.priority += 1 self.cmd( 'ovs-vsctl set Bridge', self.name,\ 'stp_enable=true',\ 'other_config:stp-priority=%d' % LegacyL2Switch.priority ) for intf in self.intfList(): if 'lo' not in intf.name: self.cmd( 'ovs-vsctl set Port %s other_config:stp-path-cost=1' % intf.name)
def __init__(self, name, custom_type="sd_car_switch", **pars): OVSKernelSwitch.__init__(self, name, **pars) print ("custom swtich has been initialized") self.Function_table = [] self.counter = 0 self.custom_type = custom_type self.MEC = [] """AR Content""" self.AR_Library = []
def start(self, controllers): OVSKernelSwitch.start(self, controllers) LegacyL2Switch.priority += 1 self.cmd( 'ovs-vsctl set Bridge', self.name,\ 'stp_enable=true',\ 'other_config:stp-priority=%d' % LegacyL2Switch.priority ) for intf in self.intfList(): if 'lo' not in intf.name: self.cmd('ovs-vsctl set Port %s other_config:stp-path-cost=1' % intf.name)
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()
def start( self, controllers ): return OVSKernelSwitch.start( self, controllers )
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()
for srcIntf, dstIntf in connections: print srcIntf, dstIntf result = srcIntf.ifconfig(status) if result: error('link src status change failed: %s\n' % result) result = dstIntf.ifconfig(status) if result: error('link dst status change failed: %s\n' % result) h0 = Host('h0') h1 = Host('h1') h2 = Host('h2') h3 = Host('h3') s0 = OVSKernelSwitch('s0', inNamespace=False) s1 = OVSKernelSwitch('s1', inNamespace=False) s2 = OVSKernelSwitch('s2', inNamespace=False) s3 = OVSKernelSwitch('s3', inNamespace=False) c0 = RemoteController('c0', ip='10.108.100.195') c1 = RemoteController('c1', ip='10.108.100.248') c2 = RemoteController('c2', ip='10.108.102.176') c3 = RemoteController('c3', ip='10.108.101.48') l1 = Link(h0, s1) Link(h1, s1) Link(h2, s2) Link(h3, s3) Link(s0, s1) Link(s0, s2)
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()
def start( self, controllers ): return OVSKernelSwitch.start( self, [ cmap[ self.name ] ] )
def __init__(self, name, *args, **kwargs): OVSKernelSwitch.__init__(self, name, *args, **kwargs)
def __init__(self, name, **params): failMode = 'standalone' datapath = 'kernel' OVSKernelSwitch.__init__(self, name, failMode, datapath, **params)
def start(self, controllers): return OVSKernelSwitch.start(self, controllers)
error( 'src and dst not connected: %s %s\n' % ( src, dst) ) for srcIntf, dstIntf in connections: print srcIntf,dstIntf result = srcIntf.ifconfig( status ) if result: error( 'link src status change failed: %s\n' % result ) result = dstIntf.ifconfig( status ) if result: error( 'link dst status change failed: %s\n' % result ) h0 = Host( 'h0' ) h1 = Host( 'h1' ) h2 = Host( 'h2' ) h3 = Host( 'h3' ) s0 = OVSKernelSwitch( 's0' ,inNamespace=False ) s1 = OVSKernelSwitch( 's1' ,inNamespace=False ) s2 = OVSKernelSwitch( 's2', inNamespace=False ) s3 = OVSKernelSwitch( 's3' ,inNamespace=False ) c0 = RemoteController( 'c0', ip = '10.108.100.195' ) c1 = RemoteController( 'c1', ip = '10.108.100.248' ) c2 = RemoteController( 'c2', ip = '10.108.102.176' ) c3 = RemoteController( 'c3', ip = '10.108.101.48' ) l1 = Link( h0, s1 ) Link( h1, s1 ) Link( h2, s2 ) Link( h3, s3 ) Link( s0, s1 ) Link( s0, s2 )
def start(self, a): return OVSKernelSwitch.start(self, [cmap[self.name]])
def __init__(self, name, **params ): failMode='standalone' datapath='kernel' OVSKernelSwitch.__init__(self, name, failMode, datapath, **params)
def start(self, controllers): return OVSKernelSwitch.start(self, [cmap[self.name]])