def topology(): "Create a network." net = Mininet( wirelessRadios=3, controller=Controller, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' ) sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' ) sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' ) ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' ) c1 = net.addController( 'c1', controller=Controller ) print "*** Creating links" net.addLink(ap1, h1, 1, 0) net.addLink(ap1, sta1) net.addLink(ap1, sta2) print "*** Starting network" net.build() c1.start() ap1.start( [c1] ) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def setup(): cos = [] for d in CTLS.keys(): co = CO(d) ctls = CTLS[d] for i in range(len(ctls)): co.addController('c%s%s' % (d, i), controller=RemoteController, ip=ctls[i]) co.build() cos.append(co) # make/setup Mininet object net = Mininet() for co in cos: co.injectInto(net) #co.dumpCfg('co%d.json' % co.getId()) vls = VLANS.get(co.getId()) lf1_ifs = LF1_INFS.get(co.getId()) lf2_ifs = LF2_INFS.get(co.getId()) co.bootstrap(net, vls, lf1_ifs, lf2_ifs) # start everything, let it run its course net.build() for co in cos: # remove IP from trunk interface of EE host (assigned by Mininet) ee = net.get('h%d11' % co.getId()) ee.defaultIntf().ifconfig('inet', '0') co.start() CLI(net) net.stop()
def sdnTopo(interface_name): CONTROLLER_IP='10.0.0.200' net = Mininet( topo=None, build=False) # Create nodes h1 = net.addHost( 'h1', ip='10.0.0.1/8' ) h2 = net.addHost( 'h2', ip='10.0.0.2/8' ) # Create switches s1 = net.addSwitch( 's1') net.addLink(h1, s1, ) net.addLink(h2, s1, ) # Add Controllers odl_ctrl = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER_IP) info( "*** Creation de l'architecture réseau\n" ) net.build() # Connect each switch to a different controller s1.start( [odl_ctrl] ) info( "*** Ajout de l'interface",interface_name,"au switch" ) _intf = Intf( interface_name, node=s1) net.start() CLI( net ) net.stop()
def startNetworkWithLinearTopo( hostCount ): global net net = Mininet(topo=LinearTopo(hostCount), build=False) remote_ip = getControllerIP() info('** Adding Floodlight Controller\n') net.addController('c1', controller=RemoteController, ip=remote_ip, port=6653) # Build the network net.build() net.start() # Start DHCP ret = enableDHCPServer() print(ret) addDHCPInstance1('mininet-dhcp-1') ret = addNodePortTupleToDHCPInstance1('mininet-dhcp-1') print(ret) addDHCPInstance2('mininet-dhcp-2') ret = addNodePortTupleToDHCPInstance2('mininet-dhcp-2') print(ret) hosts = net.hosts for host in hosts: mountPrivateResolvconf(host) startDHCPclient(host) waitForIP(host)
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' ) ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' ) c1 = net.addController( 'c1', controller=Controller ) print "*** adding Link" net.addLink(sta1, ap1) print "*** Starting network" net.build() c1.start() ap1.start( [c1] ) """uncomment to plot graph""" net.plotGraph(max_x=100, max_y=100) getTrace(sta1, 'examples/replaying/replayingBandwidth/throughputData.dat') replayingBandwidth() print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def build( self ): print "Build network based on our topology." net = Mininet( topo=None, build=False, link=TCLink, ipBase=self.minieditIpBase ) net.controllers = self.addControllers() # Make nodes print "Getting Hosts and Switches." for widget in self.widgetToItem: name = widget[ 'text' ] tags = self.canvas.gettags( self.widgetToItem[ widget ] ) nodeNum = int( name[ 1: ] ) if 'Switch' in tags: net.addSwitch( name ) elif 'Host' in tags: ipBaseNum, prefixLen = netParse( self.minieditIpBase ) ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum) net.addHost( name, ip=ip ) else: raise Exception( "Cannot create mystery node: " + name ) # Make links print "Getting Links." for link in self.links.values(): ( src, dst, linkopts ) = link srcName, dstName = src[ 'text' ], dst[ 'text' ] src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ] net.addLink(src, dst, **linkopts) self.printInfo() # Build network (we have to do this separately at the moment ) net.build() return net
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' ) sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' ) ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' ) c1 = net.addController( 'c1', controller=Controller ) """uncomment to plot graph""" #net.plotGraph(max_x=60, max_y=60) print "*** Creating links" net.addLink(ap1, sta1) net.addLink(ap1, sta2) print "*** Starting network" net.build() c1.start() ap1.start( [c1] ) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def PyPath(): net = Mininet( switch=OVSSwitch, build=False) print "** Creating controllers" c1 = net.addController('c1', port=6633) print "*** Creating switches" s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') print "*** Creating hosts" host1 = [ net.addHost('h%d' % n) for n in range(1,33)] #hosts for switch1 host2 = [ net.addHost('h%d' % n) for n in range(33,65)] #hosts for switch2 print "*** Creating links" for h in host1: net.addLink (s1, h) for h in host2: net.addLink (s2, h) for i in range(1,33): #links for back-to-back connection net.addLink(s1, s2) print "*** Starting network" net.build() s1.start ( [ c1 ]) s2.start ( [ c1 ]) print "*** Running CLI" CLI( net )
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) #wirelessRadios = Number of STAs + APs print "*** Creating nodes" ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5" ) sta1 = net.addStation( 'sta1', ip='192.168.0.1/24' ) sta2 = net.addStation( 'sta2', ip='192.168.0.2/24' ) h3 = net.addHost( 'h3', ip='192.168.0.3/24' ) h4 = net.addHost( 'h4', ip='192.168.0.4/24' ) c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 ) print "*** Adding Link" net.addLink(sta1, ap1) net.addLink(sta2, ap1) net.addLink(h3, ap1) net.addLink(h4, ap1) print "*** Starting network" net.build() c0.start() ap1.start( [c0] ) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def myNet(): #OpenDayLight controller CONTROLLER1_IP='127.0.0.1' #Floodlight controller net = Mininet( topo=None, build=False) # Create nodes h1 = net.addHost( 'h1', mac='01:00:00:00:01:00', ip='192.168.0.1/24' ) # Create switches s1 = net.addSwitch( 's1', listenPort=6634, mac='00:00:00:00:00:01' ) print "*** Creating links" net.addLink(h1, s1 ) # Add Controllers c0 = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER1_IP, port=6633) net.build() # Connect each switch to a different controller s1.start([c0]) s1.cmdPrint('ovs-vsctl show') CLI( net ) net.stop()
def myNet(): MultiSwitch13 = partial( MultiSwitch, protocols='OpenFlow13' ) #tree_topo = TreeTopo(depth=3,fanout=2) tree_topo = SingleSwitchTopo(n=14) net = Mininet(controller=RemoteController, topo=tree_topo, switch=MultiSwitch13, build=False, autoSetMacs=True) info( '*** Adding controllers\n') #c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.1", port=6633) c1 = net.addController('c1', controller=RemoteController, ip="192.168.1.1", port=6633) c2 = net.addController('c2', controller=RemoteController, ip="192.168.1.2", port=6633) c3 = net.addController('c3', controller=RemoteController, ip="192.168.1.3", port=6633) # info( '*** Add hosts\n') # h1 = net.addHost( 'h1', ip='10.0.0.1' ) # h2 = net.addHost( 'h2', ip='10.0.0.2' ) # h3 = net.addHost( 'h3', ip='10.0.0.3' ) # h4 = net.addHost( 'h4', ip='10.0.0.4' ) # info( '*** Add switches\n') # s1 = net.addSwitch( 's1', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s2 = net.addSwitch( 's2', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s3 = net.addSwitch( 's3', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s4 = net.addSwitch( 's4', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # info( '*** Add links\n') # s1.linkTo( h1 ) # s1.linkTo( s2 ) # s2.linkTo( h2 ) # s2.linkTo( s3 ) # s3.linkTo( h3 ) # s3.linkTo( s4 ) # s4.linkTo( h4 ) info( '*** Starting network\n') net.build() info( '*** Starting controllers\n') c1.start() c2.start() c3.start() # info( '*** Starting switches\n') # s1.start([c1,c2,c3]) # s2.start([c1,c2,c3]) # s3.start([c1,c2,c3]) # s4.start([c1,c2,c3]) net.start() net.staticArp() # i = 0; # while i < 10: # h1, h2 = random.choice(net.hosts), random.choice(net.hosts) # print h1.IP(), "-->", h2.IP() # sent, received, rttmin, rttavg, rttmax, rttdev = ping(h1, h2) # print received,"/",sent # i = i + 1 # sleep(1) CLI( net ) net.stop()
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/24" ) sta2 = net.addStation( 'sta2', ip="192.168.0.2/24" ) sta3 = net.addStation( 'sta3', ip="192.168.0.3/24" ) sta4 = net.addStation( 'sta4', ip="192.168.0.4/24" ) ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel="1" ) ap2 = net.addBaseStation( 'ap2', ssid="ssid_2", mode="b", channel="6" ) c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6653 ) print "*** Adding Link" net.addLink(ap1, ap2) #wired connection net.addLink(sta1, ap1) net.addLink(sta2, ap1) net.addLink(sta3, ap2) net.addLink(sta4, ap2) print "*** Starting network" net.build() c0.start() ap1.start( [c0] ) ap2.start( [c0] ) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def build( self ): "Build network based on our topology." net = Mininet(controller=RemoteController, topo=None ) # Make controller net.addController( 'c0' ) # Make nodes for widget in self.widgetToItem: name = widget[ 'text' ] tags = self.canvas.gettags( self.widgetToItem[ widget ] ) nodeNum = int( name[ 1: ] ) if 'Switch' in tags: net.addSwitch( name ) elif 'Host' in tags: net.addHost( name, ip=ipStr( nodeNum ) ) else: raise Exception( "Cannot create mystery node: " + name ) # Make links for link in self.links.values(): ( src, dst ) = link srcName, dstName = src[ 'text' ], dst[ 'text' ] src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ] src.linkTo( dst ) # Build network (we have to do this separately at the moment ) net.build() return net
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' ) sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' ) ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' ) c1 = net.addController( 'c1', controller=Controller ) print "*** Associating and Creating links" net.addLink(ap1, sta1) net.addLink(ap1, sta2) print "*** Starting network" net.build() c1.start() ap1.start( [c1] ) """uncomment to plot graph""" net.plotGraph(max_x=100, max_y=100) """Seed""" net.seed(20) "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomDirection', max_x=60, max_y=60, min_v=0.5, max_v=0.5) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' ) h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='10.0.0.2/8' ) h3 = net.addHost( 'h3', mac='00:00:00:00:00:03', ip='10.0.0.3/8' ) s4 = net.addSwitch( 's4', mac='00:00:00:00:00:10') s5 = net.addSwitch( 's5', mac='00:00:00:00:00:11') c6 = net.addController( 'c6', controller=RemoteController, defaultIP="127.0.0.1", port=6633) print "*** Creating links" net.addLink(s4, s5, 3, 5, bw=100) net.addLink(s5, h3, 2, 0, bw=100) net.addLink(s5, h2, 1, 0, bw=100) net.addLink(s4, h2, 2, 0, bw=100) net.addLink(s4, h1, 1, 0, bw=100) print "*** Starting network" net.build() s5.start( [c6] ) s4.start( [c6] ) c6.start() print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet( controller=None, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/24' ) h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='10.0.0.2/24' ) h3 = net.addHost( 'h3', mac='00:00:00:00:00:03', ip='10.0.10.33/24' ) s1 = net.addSwitch ( 's1') print "*** Creating links" #direct connection between h1 and h2 net.addLink(h1, h2, intfName1='h1-eth0', intfName2='h2-eth0',bw=100) # connection via switch s1 net.addLink(h1, s1, intfName1='h1-eth1', intfName2='s1-eth1', bw=100) net.addLink(h2, s1, intfName1='h2-eth1', intfName2='s1-eth2', bw=100) net.addLink(h3, s1, intfName1='h3-eth0', intfName2='s1-eth0', bw=100) h1.cmd('ifconfig h1-eth1 10.0.10.11 netmask 255.255.255.0') h2.cmd('ifconfig h2-eth1 10.0.10.22 netmask 255.255.255.0') print "*** Starting network" net.build() # start s1 switch s1.start('') s1.cmd('switch s1 start') # add flows in switch s1.cmd('ovs-ofctl add-flow s1 in_port=1,actions:output=2') s1.cmd('ovs-ofctl add-flow s1 in_port=3,actions:output=2') s1.cmd('ovs-ofctl add-flow s1 in_port=2,actions:output=1,3') print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def setup(argv): ctls = sys.argv[1].split(',') ifs = sys.argv[2].split(',') if len(sys.argv) > 1 else [] co = CO(1) for i in range (len(ctls)): co.addController('c%s' % i, controller=RemoteController, ip=ctls[i]) # make/setup Mininet object net = Mininet() co.build() co.injectInto(net) #co.dumpCfg('co.json') # add external ports - hard-codedish # add the ports that we will use as VxLAN endpoints x1 = net.get('ovs1001') x1.cmd('ip link add ovs1001-eth0 type veth peer name leaf101-eth0') x1.cmd('vconfig add ovs1001-eth0 100') attachDev(net, 'leaf101', 'leaf101-eth0') for i in ifs: attachDev(net, 'leaf102', i) # start everything net.build() co.start() # wire VxLAN endpoints to cross connects. attachDev(net, 'ovs1001', 'ovs1001-eth0.100') CLI(net) net.stop()
def Topology(): net = Mininet(controller= Cotroller, switch = OVSSwitch) print "******** Creating controller" c1= net.addController ('c1', ip='127.0.0.1', port = 6633) print "******** Creating switches" s1 = net.addSwitch( 's1' ) s2 = net.addSwitch( 's2' ) print "******** Creating host" h1 = net.addHost( 'h1' ) h2 = net.addHost( 'h2' ) print "******** Creating links" net.addLink (h1,s1) net.addLink (h2,s2) net.addLink (s1,s2) print "******* Starting network" net.build() c1.start s1.start([c1]) s2.start([c2]) net.start() print "******* Testing network" net.pingAll() print "****** Running CLI" CLI(net)
class MyTopo(object): def __init__(self, cname='onos', cips=['10.0.3.1']): # Create network with multiple controllers self.net = Mininet(controller=RemoteController, switch=OVSKernelSwitch, build=False, autoSetMacs=True) # Add controllers with input IPs to the network ctrls = [RemoteController(cname, cip, 6633) for cip in cips] for ctrl in ctrls: print ctrl.ip self.net.addController(ctrl) # Add components self.s1 = self.net.addSwitch('s1', dpid='00000000000000a1') h1 = self.net.addHost('h1', ip='10.0.0.11/24', mac='00:00:00:00:00:01') # Add links self.net.addLink(h1, self.s1) def run(self): self.net.build() self.net.start() self.s1.cmd('ovs-vsctl set bridge s1 protocols=OpenFlow13') self.s1.cmd('ovs-vsctl add-port s1 vxlan1') self.s1.cmd('ovs-vsctl set interface vxlan1 type=vxlan option:remote_ip=45.55.19.146 option:key=flow') CLI(self.net) self.net.stop()
def build( self ): # Add remote controllers c0 = self.addController( 'c0' ) # Add controller-bound switches s1 = self.addSwitch( 's1', dpid='0000000000000001' ) # Add client node self.h1 = self.addHost( 'h1' , ip='10.0.0.1', mac='000000000001' ) self.h2 = self.addHost( 'h2' , ip='10.0.0.2', mac='000000000002' ) self.mon = self.addHost( 'mon' , ip='10.0.0.3', mac='000000000003' ) # Add server nodes with private IP addresses self.servers.append( self.addHost( 'srv' , ip='10.0.0.4', mac='000000000101' ) ) self.servers.append( self.addHost( 'inet', ip='10.0.0.5', mac='000000000102' ) ) # Add links self.addLink( self.h1 , s1 ) self.addLink( self.h2 , s1 ) self.addLink( self.mon , s1 ) self.addLink( self.servers[0], s1 ) # srv self.addLink( self.servers[1], s1 ) # inet # Build Mininet Mininet.build( self )
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' ) sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' ) sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' ) ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='10,10,0' ) c1 = net.addController( 'c1', controller=Controller ) """uncomment to plot graph""" #net.plotGraph(max_x=60, max_y=60) print "*** Associating and Creating links" net.addLink(ap1, h1, 1, 0) net.addLink(ap1, sta1) net.addLink(ap1, sta2) print "*** Starting network" net.build() c1.start() ap1.start( [c1] ) "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***" net.startMobility(0, model='GaussMarkov', max_x=20, max_y=20, min_v=0.1, max_v=0.3) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) print "*** Creating nodes" sta1 = net.addStation( 'sta1', wlans=3 ) # 3 wlan added sta2 = net.addStation( 'sta2' ) # 1 wlan added ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel=5 ) # 1 wlan added c0 = net.addController('c0', controller=Controller) print "*** Associating..." net.addLink(ap1, sta1) net.addHoc(sta1, ssid='adhoc1', mode='g') net.addHoc(sta2, ssid='adhoc1', mode='g') print "*** Starting network" net.build() c0.start() ap1.start( [c0] ) print "***Addressing..." sta1.setIP('192.168.10.1/24', intf="sta1-wlan1") sta2.setIP('192.168.10.2/24', intf="sta2-wlan0") print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def customNet(): net = Mininet() #Adding hosts pc0 = net.addHost( 'h1' ) pc1 = net.addHost( 'h2' ) pc2 = net.addHost( 'h3' ) pc3 = net.addHost( 'h4' ) #Adding switches switch0 = net.addSwitch( 's1' ) switch1 = net.addSwitch( 's2' ) router2 = net.addSwitch( 'r2' ) router3 = net.addSwitch( 'r3' ) # Add links net.addLink( pc0, switch0 ) net.addLink( pc1, switch0 ) net.addLink( pc2, switch1 ) net.addLink( pc3, switch1 ) net.addLink( switch0, router3 ) net.addLink( switch1, router2 ) net.addLink( router2, router3 ) net.build() net.start() CLI( net ) net.stop()
def startNetwork(): global net topo = TreeTopo( depth=2, fanout=2 ) net = Mininet( topo=topo, build=False ) remote_ip = getControllerIP() info('** Adding Floodlight Controller\n') net.addController('c1', controller=RemoteController, ip=remote_ip, port=6653) # Build the network net.build() net.start() # Start DHCP ret = enableDHCPServer() print(ret) ret = addDHCPInstance1('mininet-dhcp-1') ret = addSwitchToDHCPInstance1('mininet-dhcp-1') print(ret) ret = addDHCPInstance2('mininet-dhcp-2') ret = addSwitchToDHCPInstance2('mininet-dhcp-2') print(ret) hosts = net.hosts for host in hosts: mountPrivateResolvconf(host) startDHCPclient(host) waitForIP(host)
def config( opts ): dhcp = bool(opts.dhcp) routers = bool(opts.routers) ipv6 = bool(opts.ipv6) ipv4 = bool(opts.ipv4) if opts.onosIp != '': controllers = opts.onosIp.split( ',' ) else: controllers = ['127.0.0.1'] topo = ComcastLeafSpineFabric(dhcp=dhcp, routers=routers, ipv6=ipv6, ipv4=ipv4) net = Mininet( topo=topo, link=TCLink, build=False, controller=None, autoSetMacs=True ) i = 0 for ip in controllers: net.addController( "c%s" % ( i ), controller=RemoteController, ip=ip ) i += 1 net.build() net.start() CLI( net ) net.stop()
def topology(): "Create a network." net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch ) image = 'shub1905/chaos:hostapd_latest' image2 = 'shub1905/ubuntu:updated_wpa' cmd = '/bin/ash' cmd2 = '/bin/bash' print "*** Creating nodes" sta1 = net.addStation( 'sta1', ip='10.0.0.1', passwd='123456789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 ) sta2 = net.addStation( 'sta2', ip='10.0.0.2', passwd='12346789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 ) sta3 = net.addStation( 'sta3', ip='10.0.0.3', passwd='123456789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 ) # sta1 = net.addStation( 'sta1', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep) # sta2 = net.addStation( 'sta2', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep) ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5", passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep) c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 ) print "*** Associating Stations" net.addLink(sta1, ap1) net.addLink(sta2, ap1) net.addLink(sta3, ap1) print "*** Starting network" net.build() c0.start() ap1.start( [c0] ) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def myNetwork(): net = Mininet( topo=None, build=False, ipBase='10.0.0.0/8') info( '*** Adding controller\n' ) info( '*** Add switches\n') s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone') info( '*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) info( '*** Add links\n') net.addLink(s1, h1) net.addLink(s1, h2) 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([]) info( '*** Post configure switches and hosts\n') CLI(net) net.stop()
def main(argv): global _remControl global _controllers remote_ip = '127.0.0.1' lan = 2 try: opts, args = getopt(argv[1:], 'r:l:', ['remote-ip=','lan=']) except GetoptError as err: print err.msg, err.opt exit(1); print opts print args for opt, arg in opts: if opt in ('-r', '--remote-ip'): remote_ip = arg if opt in ('-l', '--lan'): lan = int(arg) _remControl = RemoteController('Remote Controller', ip=remote_ip) _controllers['remote'] = _remControl topo = HomeTopo(ethHosts=lan) net = Mininet(topo=topo, switch=MultiController, host=CPULimitedHost, link=TCLink, autoPinCpus=True, build=False) net.addController(_controller) net.build() topo.routerSetup(net) net.start() dumpNodeConnections(net.hosts) CLI( net ) net.stop()
def MininetTopo(switchnum): # 存放 switch 參照 switchlist = [] # 產生一個 Mininet Object net = Mininet() # 在 Mininet 中加入兩個 hosts info("Create host nodes.\n") lefthost = net.addHost("h1") righthost = net.addHost("h2") info("Create switch node.\n") # 連接至 remote controller, 6633 為 Ryu controller 預設 port info("Connect to controller node.\n") c1 = net.addController(name='c1',controller=RemoteController,ip='192.168.89.129',port=6633) c2 = net.addController(name='c2',controller=RemoteController,ip='192.168.89.130',port=6634) count = 1 while count <= int(switchnum): # switch name 設為 s1, s2, s3... switchname = "s" + str(count) # 加入新的 switch, switch 種類使用 OVSSwitch (即 OpenvSwitch) 取代預設的 Linux OVSKernelSwitch, OpenFlow protocol 使用 1.3 版, 最後將參照存放進 list switchlist.append(net.addSwitch(switchname, switch=OVSSwitch, protocols='OpenFlow13', failMode='secure')) count+=1 # 加入 link, 串起 h1 和 s1 info("Create Links.\n") net.addLink(lefthost, switchlist[0]) # s2 之後每台 switch 和前一台連接 count=1 while count <= int(switchnum)-1: net.addLink(switchlist[count-1],switchlist[count]) count+=1 # 加入 link, 串起 sn 和 h2 net.addLink(righthost, switchlist[len(switchlist)-1]) info("build and start.\n") # 建立 topo net.build() c1.start() c2.start() switchlist[0].start([c1]) switchlist[1].start([c1]) switchlist[2].start([c1]) switchlist[3].start([c2]) switchlist[4].start([c2]) switchlist[5].start([c2]) # 啟動 switches 和 controller #net.start() # 進入 Command Line Interface CLI(net)
def setup( argv ): ctlsets = argv[ 1: ] domains = [] metro = None # things that can be statically config'd are grouped as domain 0 # 1,2, and 3 are sites A, B, and C, respectively. domains.insert( 0, StaticNodes() ) domains.insert( 1, CO( 1 ) ) domains.insert( 2, CO( 2 ) ) domains.insert( 3, CO( 3 ) ) # create all domains, unless ading debug hosts domains.insert( 4, EtherEdge(1, vmap=VLANS_SITEA ) ) domains.insert( 5, EtherEdge(2, vmap=VLANS_SITEB ) ) domains.insert( 6, EtherEdge(3, vmap=VLANS_SITEC ) ) domains.insert( 7, MetroCore(4) ) metro = domains[ 7 ] # connect domains to controllers according to configuration assignCtls( domains, ctlsets ) # build network out map( lambda d : d.build(), domains ) net = Mininet() map( lambda d : d.injectInto( net ), domains ) net.build() # wire domains together since domains are still unconnected at this point wireTopo( domains, net ) # start network, do static configs, and launch CLI map( lambda d : d.start(), domains ) cfgStatic( metro ) CLI( net ) net.stop()
#run sshd on each host sshd(network=net, ip='10.0.0.100/8', switch=s1) #run services on n2,n3,n4,n5 for i, host in enumerate([n1, n2, n3, n4, n5]): if i in (1, 2, 3, 4): for n, muxer in enumerate(muxers[i]): host.cmd( 'python run_daemon.py start muxer_h%s_n%s /usr/bin/tcpmux %s' % (i, n, muxer)) host.cmd('/usr/bin/stunnel conf/stunnel-n%s.conf & ' % (i + 1)) host.cmd( 'python run_daemon.py start qcrypt_h%s /usr/bin/qcrypt conf/qcrypt-n%s.cfg' % (i + 1, i + 1)) net.build() net.start() CLI(net) except Exception as e: print 'exception', e finally: #remove processes on hosts for i, host in enumerate([n1, n2, n3, n4, n5]): if i in (1, 2, 3, 4): for n, muxer in enumerate(muxers[i]): host.cmd('python run_daemon.py stop muxer_h%s_n%s' % (i, n)) host.cmd('python run_daemon.py stop qcrypt_h%s' % (i + 1))
def TwoSite(): ''' This is the topology that we will be building here. +-------+ VLAN | miah1 | 1800 VLAN +-------+ VLAN 1000 |1 1200 +-------+1 1 | 1 1+------+ | atlh1 +----+ 3 3 |1 4 3 +----+ gru1 | +-------+ +-----------+ +-----------+ +-----------+ +------+ | atlswitch +----+ miaswitch +----+ gruswitch | +-------+ +-----+-----+ +-----------+ +-----+-----+ +------+ | atlh2 +----+ | 4 |2 4 | +----+ gru2 | +-------+1 2 | | | 2 1+------+ VLAN | |1 | VLAN 2000 | 1 +-------+ VLAN 1 | 2200 +--------+ | miah2 | 2800 +--------+ | atldtn | +-------+ | grudtn | +--------+ +--------+ ''' # Hosts and switches net = Mininet(topo=None, build=False) atlswitch = net.addSwitch('sw1', listenPort=6633, mac='00:00:00:00:00:01') miaswitch = net.addSwitch('sw2', listenPort=6643, mac='00:00:00:00:00:02') gruswitch = net.addSwitch('sw3', listenPort=6653, mac='00:00:00:00:00:03') atlh1 = net.addHost('atlh1', mac='00:00:00:00:10:00', cls=VLANHost, vlan=1000) atlh2 = net.addHost('atlh2', mac='00:00:00:00:11:00', cls=VLANHost, vlan=2000) miah1 = net.addHost('miah1', mac='00:00:00:00:20:00', cls=VLANHost, vlan=1800) miah2 = net.addHost('miah2', mac='00:00:00:00:21:00', cls=VLANHost, vlan=2800) gruh1 = net.addHost('gruh1', mac='00:00:00:00:30:00', cls=VLANHost, vlan=1200) gruh2 = net.addHost('gruh2', mac='00:00:00:00:31:00', cls=VLANHost, vlan=2200) atldtn = net.addHost('atldtn', mac='00:00:00:10:00:00', cls=VLANHost, vlan=100) miadtn = net.addHost('miadtn', mac='00:00:00:20:00:00', cls=VLANHost, vlan=200) grudtn = net.addHost('grudtn', mac='00:00:00:20:00:00', cls=VLANHost, vlan=300) # Wiring net.addLink(atlswitch, atlh1, port1=1, port2=1) net.addLink(atlswitch, atlh2, port1=2, port2=1) net.addLink(miaswitch, miah1, port1=1, port2=1) net.addLink(miaswitch, miah2, port1=2, port2=1) net.addLink(gruswitch, gruh1, port1=1, port2=1) net.addLink(gruswitch, gruh2, port1=2, port2=1) net.addLink(atlswitch, atldtn, port1=4, port2=1) net.addLink(miaswitch, miadtn, port1=5, port2=1) net.addLink(gruswitch, grudtn, port1=4, port2=1) net.addLink(atlswitch, miaswitch, port1=3, port2=3) net.addLink(miaswitch, gruswitch, port1=4, port2=3) # Add controllers # https://stackoverflow.com/questions/23677291/how-to-connect-different-switches-to-different-remote-controllers-in-mininet atlctlr = net.addController('catl', controller=RemoteController, ip='127.0.0.1', port=6633) miactlr = net.addController('cmia', controller=RemoteController, ip='127.0.0.1', port=6643) gructlr = net.addController('cgru', controller=RemoteController, ip='127.0.0.1', port=6653) net.build() print "net.build" atlswitch.start([atlctlr]) miaswitch.start([miactlr]) gruswitch.start([gructlr]) #net.start() print "net.start" CLI(net) print "CLI(net)" net.stop() print "net.stop"
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP) print "*** Creating nodes" sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8') sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8') sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8') sta4 = net.addStation('sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8') sta5 = net.addStation('sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8') sta6 = net.addStation('sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8') sta7 = net.addStation('sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8') sta8 = net.addStation('sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8') sta9 = net.addStation('sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8') sta10 = net.addStation('sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8') ap1 = net.addAccessPoint('ap1', ssid='ssid-ap1', mode='g', channel='1', position='50,50,0') ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', mode='g', channel='6', position='70,50,0', range=30) #range: set the AP range ap3 = net.addAccessPoint('ap3', ssid='ssid-ap3', mode='g', channel='11', position='90,50,0') c1 = net.addController('c1', controller=Controller) print "*** Configuring wifi nodes" net.configureWifiNodes() print "*** Associating and Creating links" net.addLink(ap1, ap2) net.addLink(ap2, ap3) print "*** Starting network" net.build() c1.start() ap1.start([c1]) ap2.start([c1]) ap3.start([c1]) """uncomment to plot graph""" net.plotGraph(max_x=120, max_y=120) """association control""" net.associationControl('ssf') """Seed""" net.seed(1) """ *** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov *** Association Control (AC) - mechanism that optimizes the use of the APs: llf (Least-Loaded-First) ssf (Strongest-Signal-First)""" net.startMobility(startTime=0, model='RandomWayPoint', max_x=120, max_y=120, min_v=0.3, max_v=0.5) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def myNetwork(topo_file): #number of switch S in the topology n_switchs = 0 #number of links between switch S in the topology n_links = 0 global arrayIpHost global arrayHost global NumLinkHT, NumLinkSS, NumLinkTS G = nx.read_graphml(topo_file, str) info("*** Graph %s has %d nodes with %d edges\n" % (G.name, nx.number_of_nodes(G), nx.number_of_edges(G))) n_switchs = nx.number_of_nodes(G) n_links = nx.number_of_edges(G) net = Mininet(topo=None, link=TCLink, autoStaticArp=True, build=False, ipBase="10.0.0.0/8") info("*** Adding controller \n") c0 = net.addController(name="c0", controller=RemoteController, ip="127.0.0.1", protocol="tcp", port=6633) info("*** Add switches S \n") for switch in G.nodes(): switch_id = "s" + str(int(switch) + 1) id_node = int(int(switch) + 1) s = net.addSwitch(switch_id, dpid=hex(id_node)[2:], cls=OVSKernelSwitch) debug("Switch S: %s\n" % s) info("*** Add switches T \n") for switch in G.nodes(): val = int(int(switch) + 1) + N switch_id = "s" + str(val) id_node = int(int(switch) + 1) t = net.addSwitch(switch_id, cls=OVSKernelSwitch) debug("Switch T: %s\n" % t) info("*** Add hosts H \n") for host in G.nodes(data=True): host_id = "h" + str(int(host[0]) + 1) ris = int(int(host[0]) + 1) + int(10) host_mac = "00:00:00:00:00:" + str(ris) host_ip = "10.0.0." + str(int(host[0]) + 1) h = net.addHost(host_id, cls=Host, ip=host_ip, mac=host_mac, defaultRoute=None) debug("Host H: %s\n" % h) #if host[1]["label"]=="Milan": #print "Country is Milan" #IP_Italy=host_ip #MAC_Italy=host_mac #print "IP IT",IP_Italy #print "MAC IT",MAC_Italy debug("Host MAC: %s " % host_mac) debug("Host IP: %s\n" % host_ip) arrayIpHost.append(host_ip) arrayHost.append(h) info("*** Add links between switch S \n") for edge in G.edges(): edge0_id = "s" + str(int(edge[0]) + 1) edge1_id = "s" + str(int(edge[1]) + 1) debug("Add Links between switch S: %s and %s\n" % (edge0_id, edge1_id)) net.addLink(edge0_id, edge1_id) NumLinkSS = NumLinkSS + 1 info("*** Tot Link between switch S: %s\n" % NumLinkSS) info("*** Add links between switch S and switch T \n") for nod in G.nodes(): val = int(int(nod) + 1) + N tswitch_ID = "s" + str(val) switch_ID = "s" + str(int(nod) + 1) port1 = 2 port2 = 52 net.addLink(tswitch_ID, switch_ID, port1, port2) debug("Add Links between S and T: %s and %s\n" % (tswitch_ID, switch_ID)) NumLinkTS = NumLinkTS + 1 info("*** Tot Link between switch S and switch T: %s\n" % NumLinkTS) info("*** Add links between host H and switch T \n") for hos in G.nodes(): val = int(int(hos) + 1) + N host_ID = "h" + str(int(hos) + 1) tswitch_ID = "s" + str(val) port1 = 51 port2 = 1 net.addLink(host_ID, tswitch_ID, port1, port2) debug("Add Links between host and T: %s and %s\n" % (host_ID, tswitch_ID)) NumLinkHT = NumLinkHT + 1 info("*** Tot Link between switch T and host H: %s\n" % NumLinkHT) info("*** Starting network\n") net.build() info("*** Starting controllers\n") for controller in net.controllers: controller.start() info("*** Starting switches S\n") for sw in G.nodes(): s_id = "s" + str(int(sw) + 1) net.get(s_id).start([c0]) info("*** Starting switches T\n") for sw in G.nodes(): w = int(int(sw) + 1) + N s_id = "s" + str(w) net.get(s_id).start([c0]) #time.sleep(150) time.sleep(90) #time.sleep(60) #time.sleep(50) info("*** Test in progress\n") H1 = arrayHost[0] H1.cmd("rm -rf /tmp/pnpm >> error.log 2>&1 ") H1.cmd("screen -S Server -d -m python -m trace -t Server.py" + " " + str(H1.IP()) + " ") for h in net.hosts: debug("Host Src: %s\n" % h) arrayIpHost.remove(h.IP()) debug("Host Dst: %s\n" % arrayIpHost) s = "" for h1 in arrayIpHost: s = s + h1 + " " arrayIpHost.append(h.IP()) h.cmd("python Client.py" + " " + str(H1.IP()) + " " + str(h.IP()) + " " + str(s) + " >> error.log 2>&1 &") CLI(net) # Stop Server H1.cmd("screen -S Server -X stuff ^C") net.stop()
def topology(): "Create a network." net = Mininet(controller=RemoteController, link=TCLink, switch=OVSKernelSwitch) print "*** Creating nodes" h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8') h2 = net.addHost('h2', mac='00:00:00:00:00:02', ip='10.0.0.2/8') s3 = net.addSwitch('s3', listenPort=6634, mac='00:00:00:00:00:03') s4 = net.addSwitch('s4', listenPort=6635, mac='00:00:00:00:00:04') s5 = net.addSwitch('s5', listenPort=6636, mac='00:00:00:00:00:05') s6 = net.addSwitch('s6', listenPort=6637, mac='00:00:00:00:00:06') c7 = net.addController('c7', controller=RemoteController, ip='127.0.0.1', port=6633) print "*** Creating links" net.addLink(s4, h2, 3, 0) net.addLink(s6, s4, 2, 2) net.addLink(s5, s6, 2, 1) net.addLink(s3, s5, 3, 1) net.addLink(s3, s4, 2, 1) net.addLink(h1, s3, 0, 1) print "*** Starting network" net.build() s4.start([c7]) s6.start([c7]) s5.start([c7]) s3.start([c7]) c7.start() print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def myNetwork(): net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8') info('*** Adding controller\n') c0 = net.addController(name='c0', controller=RemoteController, protocol='tcp', port=6653) info('*** Add switches\n') s2 = net.addSwitch('s2', cls=OVSKernelSwitch,protocols='OpenFlow15',ip="10.0.0.3") s1 = net.addSwitch('s1', cls=OVSKernelSwitch,protocols='OpenFlow15',ip="10.0.0.4") print("ssss") #s2.cmd('sudo ethtool -s s2-eth1 speed 100') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute="via 140.128.102.174") h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) meter=0*1000 delay="100ms" info('*** Add links\n') #https://github.com/mininet/mininet/blob/de28f67a97fc8915cc1586c984465d89a016d8eb/mininet/link.py#L314 net.addLink(s1, h1,cls=TCLink, bw=1000,jitter="0ms",delay="0ms",loss=0,max_queue_size=55) net.addLink(h2, s2,cls=TCLink, bw=1000,jitter="0ms",delay="0ms",loss=0,max_queue_size=55) net.addLink(s1, s2,port1=10,port2=10,cls=TCLink, bw=1000,jitter="0ms",delay="300ms",loss=0,max_queue_size=None) net.addLink(s1, s2,port1=11,port2=11,cls=TCLink, bw=1000,jitter="0ms",delay="200ms",loss=0,max_queue_size=None) net.addLink(s1, s2,port1=12,port2=12,cls=TCLink, bw=1000,jitter="0ms",delay="0ms",loss=0,max_queue_size=None) net.addLink(s1, s2,port1=14,port2=14,cls=TCLink, bw=1000,jitter="0ms",delay="0ms",loss=0,max_queue_size=None) #mininet 的delay,jitter,loss底層是依靠netem(Network Emulation)模擬 #由於mininet底層呼叫netem時沒有設定jitter的分佈狀態,所以netem依照默認設定是normal(常態分佈) #https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/man/man8/tc-netem.8#n89 #在netem指令之下jitter可以設定三種 #https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/man/man8/tc-netem.8#n23 #uniform " | " normal " | " pareto " | " paretonormal #net.addLink(s1, s2,port1=888,port2=321,cls=TCLink, bw=1000,jitter="450ms",delay="0.75s",loss=11,max_queue_size=23) #print(str(l),"****jjjjjjjjjjjjjjjjjj****") #net.addLink(s1, s2,port1=433,port2=32232,cls=TCLink, bw=10,jitter="0ms",delay="0s",loss=0,max_queue_size=2223) #print(a) #a.cmd("sudo ethtool -s s1-eth1 speed 100") #a.cmd("sudo ethtool -s s2-eth1 speed 100") info('*** Starting network\n') net.build() ## #print(s1.cmd('sudo ethtool -s s1-eth888 speed 1000')) #s1.cmd('sudo ethtool -s s1-eth433 speed 10') #s1.cmd('sudo ethtool -s s2-eth321 speed 1000') #s1.cmd('sudo ethtool -s s2-eth32232 speed 10') #s2.cmd('sudo ethtool -s s2-eth32232 speed 1000') #print(s1.cmd('sudo ethtool -s s2-eth1 speed 1000000')) ## info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') #net.get('s2').start([c0]) net.get('s1').start([c0]) net.get('s2').start([c0]) info('*** Post configure switches and hosts\n') #net.pingAll(0.1) CLI(net) net.stop()
def myNetwork(): net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8') info('*** Adding controller\n') c0 = net.addController(name='c0', controller=RemoteController, ip='127.0.0.1', protocol='tcp', port=6633) info('*** Add switches\n') s9 = net.addSwitch('s9', cls=OVSKernelSwitch) s5 = net.addSwitch('s5', cls=OVSKernelSwitch) s3 = net.addSwitch('s3', cls=OVSKernelSwitch) s7 = net.addSwitch('s7', cls=OVSKernelSwitch) s4 = net.addSwitch('s4', cls=OVSKernelSwitch) s8 = net.addSwitch('s8', cls=OVSKernelSwitch) s6 = net.addSwitch('s6', cls=OVSKernelSwitch) s1 = net.addSwitch('s1', cls=OVSKernelSwitch) s2 = net.addSwitch('s2', cls=OVSKernelSwitch) info('*** Add hosts\n') h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None) h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None) h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) info('*** Add links\n') net.addLink(s1, s2) net.addLink(s1, s5) net.addLink(s5, s6) net.addLink(s2, s6) net.addLink(s2, s3) net.addLink(s6, s3) net.addLink(s3, s4) net.addLink(s4, s8) net.addLink(s8, s7) net.addLink(s7, s9) net.addLink(s7, s6) net.addLink(s9, s5) net.addLink(s1, h1) net.addLink(s3, h4) net.addLink(s4, h5) net.addLink(s6, h3) net.addLink(h2, s8) net.addLink(h7, s9) net.addLink(h6, s5) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('s9').start([c0]) net.get('s5').start([c0]) net.get('s3').start([c0]) net.get('s7').start([c0]) net.get('s4').start([c0]) net.get('s8').start([c0]) net.get('s6').start([c0]) net.get('s1').start([c0]) net.get('s2').start([c0]) info('*** Post configure switches and hosts\n') CLI(net) net.stop()
def myNetwork(): net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8') info('*** Adding controller\n') c0 = net.addController(name='c0', controller=RemoteController, ip='127.0.0.1', port=6633) info('*** Add switches\n') s1 = net.addSwitch('s1', cls=OVSKernelSwitch) s4 = net.addSwitch('s4', cls=OVSKernelSwitch) s7 = net.addSwitch('s7', cls=OVSKernelSwitch) s2 = net.addSwitch('s2', cls=OVSKernelSwitch) s6 = net.addSwitch('s6', cls=OVSKernelSwitch) s3 = net.addSwitch('s3', cls=OVSKernelSwitch) s5 = net.addSwitch('s5', cls=OVSKernelSwitch) s8 = net.addSwitch('s8', cls=OVSKernelSwitch) info('*** Add hosts\n') h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) h8 = net.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None) h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None) h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None) info('*** Add links\n') h1s1 = {'bw': 100, 'delay': '2ms'} net.addLink(h1, s1, cls=TCLink, **h1s1) h2s2 = {'bw': 100, 'delay': '2ms'} net.addLink(h2, s2, cls=TCLink, **h2s2) s2s1 = {'bw': 100, 'delay': '2ms'} net.addLink(s2, s1, cls=TCLink, **s2s1) s2s3 = {'bw': 100, 'delay': '2ms'} net.addLink(s2, s3, cls=TCLink, **s2s3) s3h3 = {'bw': 100, 'delay': '2ms'} net.addLink(s3, h3, cls=TCLink, **s3h3) s3s4 = {'bw': 100, 'delay': '2ms'} net.addLink(s3, s4, cls=TCLink, **s3s4) s4h4 = {'bw': 100, 'delay': '2ms'} net.addLink(s4, h4, cls=TCLink, **s4h4) s4s5 = {'bw': 100, 'delay': '2ms'} net.addLink(s4, s5, cls=TCLink, **s4s5) s5h5 = {'bw': 100, 'delay': '2ms'} net.addLink(s5, h5, cls=TCLink, **s5h5) s5s6 = {'bw': 100, 'delay': '2ms'} net.addLink(s5, s6, cls=TCLink, **s5s6) s6h6 = {'bw': 100, 'delay': '2ms'} net.addLink(s6, h6, cls=TCLink, **s6h6) s6s7 = {'bw': 100, 'delay': '2ms'} net.addLink(s6, s7, cls=TCLink, **s6s7) s7h7 = {'bw': 100, 'delay': '2ms'} net.addLink(s7, h7, cls=TCLink, **s7h7) s7s8 = {'bw': 100, 'delay': '2ms'} net.addLink(s7, s8, cls=TCLink, **s7s8) s8h8 = {'bw': 100, 'delay': '2ms'} net.addLink(s8, h8, cls=TCLink, **s8h8) 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('s4').start([c0]) net.get('s7').start([c0]) net.get('s2').start([c0]) net.get('s6').start([c0]) net.get('s3').start([c0]) net.get('s5').start([c0]) net.get('s8').start([c0]) info('*** Configuring switches\n') CLI(net) net.stop()
def topology(): "Create a network." net = Mininet(controller=RemoteController, link=TCLink, switch=OVSKernelSwitch) print "*** Creating nodes" h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/24') h2 = net.addHost('h2', mac='00:00:00:00:00:02', ip='10.0.0.2/24') h3 = net.addHost('h3', mac='00:00:00:00:00:03', ip='10.0.0.3/24') h4 = net.addHost('h4', mac='00:00:00:00:00:04', ip='10.0.0.4/24') h5 = net.addHost('h5', mac='00:00:00:00:00:05', ip='10.0.0.5/24') s1 = net.addSwitch('s1', listenPort=6671) s2 = net.addSwitch('s2', listenPort=6672) s3 = net.addSwitch('s3', listenPort=6673) s4 = net.addSwitch('s4', listenPort=6674) s5 = net.addSwitch('s5', listenPort=6675) c7 = net.addController('c7', controller=RemoteController, ip='127.0.0.1', port=6633) print "*** Creating links" net.addLink(s1, h1) net.addLink(s2, h2) net.addLink(s3, h3) net.addLink(s4, h4) net.addLink(s5, h5) net.addLink(s1, s2) net.addLink(s2, s3) net.addLink(s3, s4) net.addLink(s4, s5) net.addLink(s3, h2) # Link(h2, s3, intfName1='h2-eth1') net.addLink(s4, h3) # Link(h3, s4, intfName1='h3-eth1') h2.cmd('ifconfig h2-eth1 10.0.0.12 netmask 255.255.255.0') # h2.cmd('ip route add 10.0.0.1/32 dev h2-eth0') # h2.cmd('ip route add 10.0.0.5/32 dev h2-eth1') h3.cmd('ifconfig h3-eth1 10.0.0.13 netmask 255.255.255.0') print "*** Starting network" net.build() h2.cmd( 'ip route add 10.0.0.1/32 dev h2-eth0; ip route add 10.0.0.5/32 dev h2-eth1' ) h2.cmd( 'ip route add 10.0.0.253/32 dev h2-eth0; ip route add 10.0.0.254/32 dev h2-eth1' ) h2.cmd('sudo arp -i h2-eth0 -s 10.0.0.253 01:02:03:04:05:06') h2.cmd('sudo arp -i h2-eth1 -s 10.0.0.254 11:12:13:14:15:16') h3.cmd( 'ip route add 10.0.0.1/32 dev h3-eth0; ip route add 10.0.0.5/32 dev h3-eth1' ) h3.cmd( 'ip route add 10.0.0.253/32 dev h3-eth0; ip route add 10.0.0.254/32 dev h3-eth1' ) h3.cmd('sudo arp -i h3-eth0 -s 10.0.0.253 01:02:03:04:05:06') h3.cmd('sudo arp -i h3-eth1 -s 10.0.0.254 11:12:13:14:15:16') c7.start() s1.start([c7]) s2.start([c7]) s3.start([c7]) s4.start([c7]) s5.start([c7]) # net.start() #h2_out=h2.cmd("./json_register.py --reg='{name='forwarder1', vnf_id=555, type_id=1, group_id=1, iftype=1, bidirectional=False, geo_location='server1.rack2.row3.room4'}' -a 10.0.0.253 -p 30012 -n registration") #h2.cmd("./json_register.py --reg='{name='forwarder1', vnf_id=555, type_id=1, group_id=1, iftype=1, bidirectional=False, geo_location='server1.rack2.row3.room4'}' -a 10.0.0.254 -p 30012 -n registration") h2.cmd( './json_register.py --file=forwarder1.txt -a 10.0.0.253 -p 30012 -n registration' ) h2.cmd( './json_register.py --file=forwarder1-2.txt -a 10.0.0.254 -p 30012 -n registration' ) #print "H2 OUTPUT:", h2_out h3.cmd( './json_register.py --file=forwarder2-1.txt -a 10.0.0.253 -p 30012 -n registration' ) h3.cmd( './json_register.py --file=forwarder2-2.txt -a 10.0.0.254 -p 30012 -n registration' ) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def CreateTopology(): net = Mininet(controller=RemoteController, link=TCLink, switch=OVSKernelSwitch) print 'Creating nodes...' h = {} for i in range(1, 101): h[i] = net.addHost('h' + str(i), mac='00:00:00:00:00:' + str(i), ip='10.0.0.' + str(i) + '/24') s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') c0 = net.addController('c0', controller=RemoteController, ip='127.0.0.1', port=6653) print 'Creating links...' for i in range(1, 51): net.addLink(h[i], s1, bw=100) for i in range(51, 101): net.addLink(h[i], s2, bw=100) net.addLink(s1, s2, bw=100) print 'Starting network...' net.build() c0.start() s1.start([c0]) s2.start([c0]) print 'Verifying connectivity...' #loss = net.pingAll() host = {} print '*** Mausezahn flood...' for i in range(1, 101): host[i] = net.getNodeByName('h' + str(i)) # Wait until end of second t = datetime.datetime.utcnow() sleeptime = 1 - (t.microsecond / 1000000.0) time.sleep(sleeptime) # # NoNAttack traffic for 25 users for each 2 seconds x = 1 for count in range(0, 25): BaseTraffic(host, x, x + 25, 2, 2) x += 25 if x >= 54: x = 1 WaitTillEndOfSec(2) # ------ # ------ print '#Wave pattern...' thread.start_new_thread(WaveTrafficThread, (host,)) # POISON RANDOM for p in range(0, 50): for j in range(0, 50): x = random.randint(1, 79) BaseTraffic(host, x, x + 1, 1, 1) WaitTillEndOfSec(1) # x = 1 # for count in range(0, 16): # # BaseTraffic(host, x, x + 10, 3, 3) # BaseTraffic(host, x + 10, x + 15, 4, 3) # x += 15 # # if x >= 64: # x = 1 # # WaitTillEndOfSec(3) # # BaseTraffic(host, 65, 75, 3, 2) # BaseTraffic(host, 75, 80, 4, 2) # # ------ print 'Running CLI...' CLI(net) print 'Stopping network...' net.stop()
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') info('*** Add switches\n') s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone') s2 = net.addSwitch('s2', cls=OVSKernelSwitch, failMode='standalone') s3 = net.addSwitch('s3', cls=OVSKernelSwitch, failMode='standalone') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host) h2 = net.addHost('h2', cls=Host) info('*** Add links\n') linkProp1 = {'bw': 1, 'delay': '100ms'} linkProp2 = {'bw': 2, 'delay': '100ms'} linkProp3 = {'bw': 3, 'delay': '100ms'} net.addLink(h1, s1, cls=TCLink, **linkProp1) net.addLink(h1, s2, cls=TCLink, **linkProp2) net.addLink(h1, s3, cls=TCLink, **linkProp3) net.addLink(h2, s1, cls=TCLink, **linkProp1) net.addLink(h2, s2, cls=TCLink, **linkProp2) net.addLink(h2, s3, cls=TCLink, **linkProp3) 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([]) net.get('s2').start([]) net.get('s3').start([]) info('*** Post configure switches and hosts\n') h1.cmd("ifconfig h1-eth0 10.0.1.1 netmask 255.255.255.0") h1.cmd("ifconfig h1-eth1 192.168.2.1 netmask 255.255.255.0") h1.cmd("ifconfig h1-eth2 172.16.3.1 netmask 255.255.255.0") h2.cmd("ifconfig h2-eth0 10.0.1.2 netmask 255.255.255.0") h2.cmd("ifconfig h2-eth1 192.168.2.2 netmask 255.255.255.0") h2.cmd("ifconfig h2-eth2 172.16.3.2 netmask 255.255.255.0") # CLI(net) # waitTime = 120 # # host = "h1" # dtHdr = "" # dtBdy = "" # dtRes = "" # for intf in xrange(3): # dtHdr += "dt%d1=$(cat /sys/class/net/%s-eth%d/statistics/tx_bytes); \n"%(intf, host, intf) # dtBdy += "dt%d=$(cat /sys/class/net/%s-eth%d/statistics/tx_bytes); "%(intf, host, intf) \ # + "dt%dr=$(echo $dt%d-$dt%d1|bc); dt%d1=$dt%d; \n" %(intf, intf, intf, intf, intf) # dtRes += "$dt%dr $dt%d "%(intf, intf) # getstatcmd = """ # %s # sleep 1; # tm0=$(date "+%%s"); # for x in `seq %d`; # do tm=$(date "+%%s"); # tmr=$(echo $tm-$tm0|bc); # %s # echo $tmr $tm %s; # sleep 1; # done | tee /tmp/dt.csv # """%(dtHdr, waitTime, dtBdy, dtRes) # # print getstatcmd # getstatcmd = "python ./dynamic_plot.py" # for intf in xrange(3): # getstatcmd += " %s-eth%d"%(host, intf) # # server = "./goserver.sh 9876" # client = "./goclient.sh 10.0.1.2 9876" # primaryDown = "ifconfig h2-eth0 down" # primaryUp = "ifconfig h2-eth0 up" server = "iperf -s" client = "iperf -c 10.0.1.2 -t 200" # otherDown = "ifconfig h2-eth1 down; ifconfig h2-eth2 down" # otherUp = "ifconfig h2-eth1 up; ifconfig h2-eth2 up" # markAsBackup = "kill -USR1 `cat /tmp/tcpClient.pid`" # # writeExe("/tmp/getstat", getstatcmd) # # termSt, popenSt = runX11(h1, "xterm -e "+"/tmp/getstat") # time.sleep(3) termSr, popenSr = runX11(h2, "xterm -e " + server) termCl, popenCl = runX11(h1, "xterm -e " + client) # time.sleep(15) # h1.cmd(markAsBackup) # time.sleep(20) # h2.cmd(primaryDown) # time.sleep(20) # h2.cmd(primaryUp) # time.sleep(20) # h2.cmd(otherDown) # time.sleep(20) # h2.cmd(otherUp) time.sleep(25) popenSt.terminate() popenCl.terminate() popenSr.terminate() net.stop()
def BeginSimulation(): # We begin mininet initially net = Mininet(controller=Controller, switch=OVSSwitch) print "*** Creating (reference) controllers On 192.168.2.50/51 Change if necessary" c0 = RemoteController( 'c0', ip='192.168.56.102', port=6633) #This is parent controller (change tomcat 8081) c1 = RemoteController('c1', ip='192.168.56.102', port=6633) c2 = RemoteController('c2', ip='192.168.56.102', port=6633) print "*** Creating switches" s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') s3 = net.addSwitch('s3') s4 = net.addSwitch('s4') gs1 = net.addSwitch('gs1') gs2 = net.addSwitch('gs2') print "*** Creating hosts" print "*** Creating hosts" hosts1 = [addHost1(net, n) for n in 1, 2, 3, 4] hosts2 = [addHost2(net, n) for n in 5, 6, 7, 8] hosts3 = [addHost3(net, n) for n in 9, 10, 11, 12] hosts4 = [addHost4(net, n) for n in 13, 14, 15, 16] # These are the hsots that move to other side. We will bring the links up when we want to show the host movement s3_temp_host1 = net.addHost('h17', ip='10.0.0.66', mac='00:00:00:00:00:1') s3_temp_host2 = net.addHost('h18', ip='10.0.0.67', mac='00:00:00:00:00:2') print "*** Creating links" for h in hosts1: net.addLink(s1, h) for h in hosts2: net.addLink(s2, h) for h in hosts3: net.addLink(s3, h) for h in hosts4: net.addLink(s4, h) net.addLink(s1, s2) net.addLink(s3, s4) net.addLink(s2, s3) net.addLink(gs1, gs2) # Additional links to simlulate host movement (handover). Note that this link will be down initially net.addLink(s3, s3_temp_host1) net.addLink(s3, s3_temp_host2) print "*** Starting network" net.build() c0.start() c1.start() c2.start() s1.start([c1]) s2.start([c1]) s3.start([c2]) s4.start([c2]) gs1.start([c0]) gs2.start([c0]) # Remember that these two links will be down initially and needs to be manually pulled up whenever we need handover net.configLinkStatus('h17', 's3', 'down') net.configLinkStatus('h18', 's3', 'down') CLI(net)
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch) print("*** Creating nodes") sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8') sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8') ap1 = net.addBaseStation('ap1', ssid='new-ssid1', mode='g', channel='1', position='15,50,0') ap2 = net.addBaseStation('ap2', ssid='new-ssid2', mode='g', channel='6', position='25,30,0') c1 = net.addController('c1', controller=Controller) print("*** Creating links") net.addLink(ap1, ap2) net.addLink(ap1, sta1) net.addLink(ap1, sta2) print("*** Starting network") net.build() c1.start() ap1.start([c1]) ap2.start([c1]) "Configure IP addresses on APs for binding Wishful agent" ap1.cmd('ifconfig ap1-eth1 20.0.0.2/8') ap2.cmd('ifconfig ap2-eth1 20.0.0.3/8') print("*** Starting Wishful framework") folder = './' print("*** ... agents ...") agent1 = WishfulAgent(ap1, folder + 'agent', folder + 'agent1_cfg.yaml') agent2 = WishfulAgent(ap2, folder + 'agent', folder + 'agent2_cfg.yaml') agent1.start() agent2.start() print("*** ... controller ...") wf_ctrl = WishfulController(ap1, folder + 'global_controller', folder + 'controller_cfg.yaml') wf_ctrl.start() print("*** Starting network") """uncomment to plot graph""" if GUI: net.plotGraph(max_x=100, max_y=100) if MOBILITY: net.startMobility(startTime=0) net.mobility('sta1', 'start', time=0, position='10,45,0') net.mobility('sta1', 'stop', time=60, position='50,20,0') net.mobility('sta2', 'start', time=0, position='0,60,0') net.mobility('sta2', 'stop', time=60, position='30,10,0') net.stopMobility(stopTime=60) print("*** Starting network") print("*** wait for node discovery") time.sleep(3) print("*** perform ping") sta1.cmd('ping -c20 %s' % sta2.IP()) print("*** Check that Wishful agents/controllers are still running ...") if not wf_ctrl.check_is_running() or not agent1.check_is_running( ) or not agent2.check_is_running(): raise Exception( "Error; wishful controller or agents not running; check logfiles ... " ) else: print("*** Wishful agents/controllers: OK") if MN_CLI: print("*** Running CLI") CLI(net) # Show controller log file print('WiSHFUL agent #1 logfile content:') print(agent1.read_log_file()) print('') print('WiSHFUL agent #2 logfile content:') print(agent2.read_log_file()) print('') print('WiSHFUL controller logfile content:') print(wf_ctrl.read_log_file()) print('') print("*** Stopping network") wf_ctrl.stop() agent1.stop() agent2.stop() net.stop()
def MininetTopo(): ''' Prepare Your Topology ''' net = Mininet(topo=None, link=TCLink, build=False) c0 = net.addController(name='c0', controller=RemoteController, ip=REMOTE_CONTROLLER_IP, port=6633) info("Create Host node\n") h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1') h2 = net.addHost('h2', mac='00:00:00:00:00:02', ip='10.0.0.2') h3 = net.addHost('h3', mac='00:00:00:00:00:03', ip='10.0.0.3') h4 = net.addHost('h4', mac='00:00:00:00:00:04', ip='10.0.0.4') h5 = net.addHost('h5', mac='00:00:00:00:00:05', ip='10.0.0.5') h6 = net.addHost('h6', mac='00:00:00:00:00:06', ip='10.0.0.6') info("Create Switch node\n") s1 = net.addSwitch('s1', protocols='OpenFlow13') s2 = net.addSwitch('s2', protocols='OpenFlow13') s3 = net.addSwitch('s3', protocols='OpenFlow13') s4 = net.addSwitch('s4', protocols='OpenFlow13') # s1 = net.addSwitch('s1', cls=LinuxBridge, stp=True, protocols='OpenFlow13') # s2 = net.addSwitch('s2', cls=LinuxBridge, stp=True, protocols='OpenFlow13') # s3 = net.addSwitch('s3', cls=LinuxBridge, stp=True, protocols='OpenFlow13') # s4 = net.addSwitch('s4', cls=LinuxBridge, stp=True, protocols='OpenFlow13') info("Link switch to host\n") # net.addLink(s1, h1, 4, bw=BW) # net.addLink(s1, h2, 5, bw=BW) # net.addLink(s1, h3, 6, bw=BW) # net.addLink(s3, h4, 4, bw=BW) # net.addLink(s3, h5, 5, bw=BW) # net.addLink(s3, h6, 6, bw=BW) # net.addLink(s1, s2, 1, 1, bw=BW) # net.addLink(s2, s3, 2, 1, bw=BW) # net.addLink(s3, s4, 2, 2, bw=BW) # net.addLink(s4, s1, 1, 2, bw=BW) # net.addLink(s1, s3, 3, 3, bw=BW) # net.addLink(s2, s4, 3, 3, bw=BW) # net.addLink(s1, h1, 4, bw=BW) # net.addLink(s1, h2, 5, bw=BW) # net.addLink(s1, h3, 6, bw=BW) # net.addLink(s3, h4, 4, bw=BW) # net.addLink(s3, h5, 5, bw=BW) # net.addLink(s3, h6, 6, bw=BW) net.addLink(s1, h1, 4) net.addLink(s1, h2, 5) net.addLink(s1, h3, 6) net.addLink(s3, h4, 4) net.addLink(s3, h5, 5) net.addLink(s3, h6, 6) net.addLink(s1, s2, 1, 1, bw=BW) net.addLink(s2, s3, 2, 1, bw=BW) net.addLink(s3, s4, 2, 2, bw=BW) net.addLink(s4, s1, 1, 2, bw=BW) net.addLink(s1, s3, 3, 3, bw=BW) net.addLink(s2, s4, 3, 3, bw=BW) ''' Working your topology ''' info("Start network\n") net.build() c0.start() s1.start([c0]) s2.start([c0]) s3.start([c0]) s4.start([c0]) # s1.cmd("ovs−vsctl set bridge s1 other_config:stp-priority=0x8000") # s2.cmd("ovs−vsctl set bridge s2 other_config:stp-priority=0x9000") # s3.cmd("ovs−vsctl set bridge s3 other_config:stp-priority=0xa000") # s4.cmd("ovs−vsctl set bridge s4 other_config:stp-priority=0xb000") # s1.cmd("ovs-vsctl set bridge s1 stp_enable=true") # s2.cmd("ovs-vsctl set bridge s2 stp_enable=true") # s3.cmd("ovs-vsctl set bridge s3 stp_enable=true") # s4.cmd("ovs-vsctl set bridge s4 stp_enable=true") # info("Start xterm\n") # net.terms.append(makeTerm(c0)) info("Dumping host connections\n") dumpNodeConnections(net.hosts) sleep(60) print "Testing network connectivity" net.pingAll() net.pingAll() print "Testing wget" h1.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn") h2.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn") h3.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn") h4.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn") h5.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn") h6.cmd("echo 1 > /proc/sys/net/ipv4/tcp_ecn") sleep(3) h1.cmd("python -m SimpleHTTPServer 5001 &") h1.cmd("python -m SimpleHTTPServer 5002 &") h1.cmd("python -m SimpleHTTPServer 5003 &") h1.cmd("python -m SimpleHTTPServer 5004 &") h2.cmd("python -m SimpleHTTPServer 5001 &") h2.cmd("python -m SimpleHTTPServer 5002 &") h2.cmd("python -m SimpleHTTPServer 5003 &") h2.cmd("python -m SimpleHTTPServer 5004 &") h3.cmd("python -m SimpleHTTPServer 5001 &") h3.cmd("python -m SimpleHTTPServer 5002 &") h3.cmd("python -m SimpleHTTPServer 5003 &") h3.cmd("python -m SimpleHTTPServer 5004 &") sleep(1) print "wget from h1 to h4 via port 5001" h4.cmd( "wget --limit-rate=3.125m http://10.0.0.1:5001/625M.log -o h4_tcp_p5001.txt &" ) sleep(10) print "wget from h2 to h5 via port 5001" h5.cmd( "wget --limit-rate=3.125m http://10.0.0.2:5001/625M.log -o h5_tcp_p5001.txt &" ) sleep(10) print "wget from h3 to h6 via port 5001" h6.cmd( "wget --limit-rate=3.125m http://10.0.0.3:5001/625M.log -o h6_tcp_p5001.txt &" ) sleep(10) print "wget from h1 to h4 via port 5002" h4.cmd( "wget --limit-rate=3.125m http://10.0.0.1:5002/625M.log -o h4_tcp_p5002.txt &" ) sleep(10) print "wget from h2 to h5 via port 5002" h5.cmd( "wget --limit-rate=3.125m http://10.0.0.2:5002/625M.log -o h5_tcp_p5002.txt &" ) sleep(10) print "wget from h3 to h6 via port 5002" h6.cmd( "wget --limit-rate=3.125m http://10.0.0.3:5002/625M.log -o h6_tcp_p5002.txt &" ) sleep(10) print "wget from h1 to h4 via port 5003" h4.cmd( "wget --limit-rate=3.125m http://10.0.0.1:5003/625M.log -o h4_tcp_p5003.txt &" ) sleep(10) print "wget from h2 to h5 via port 5003" h5.cmd( "wget --limit-rate=3.125m http://10.0.0.2:5003/625M.log -o h5_tcp_p5003.txt &" ) sleep(10) print "wget from h3 to h6 via port 5003" h6.cmd( "wget --limit-rate=3.125m http://10.0.0.3:5003/625M.log -o h6_tcp_p5003.txt &" ) sleep(10) print "wget from h1 to h4 via port 5004" h4.cmd( "wget --limit-rate=3.125m http://10.0.0.1:5004/625M.log -o h4_tcp_p5004.txt &" ) sleep(10) print "wget from h2 to h5 via port 5004" h5.cmd( "wget --limit-rate=3.125m http://10.0.0.2:5004/625M.log -o h5_tcp_p5004.txt &" ) sleep(10) print "wget from h3 to h6 via port 5004" h6.cmd( "wget --limit-rate=3.125m http://10.0.0.3:5004/625M.log -o h6_tcp_p5004.txt &" ) CLI(net) ''' Clean mininet ''' net.stop()
def myNetwork(): net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8') info('*** Adding controller\n') info('*** Add switches\n') S5 = net.addSwitch('S5', cls=OVSKernelSwitch, failMode='standalone') S9 = net.addSwitch('S9', cls=OVSKernelSwitch, failMode='standalone') S10 = net.addSwitch('S10', cls=OVSKernelSwitch, failMode='standalone') R1 = net.addHost('R1', cls=Node, intf='R1-eth0', ip='209.165.201.11/27') R4 = net.addHost('R4', cls=Node, intf='R4-eth0', ip='209.165.201.1/27') R1.cmd('sysctl -w net.ipv4.ip_forward=1') R4.cmd('sysctl -w net.ipv4.ip_forward=1') info('*** Add hosts\n') H1 = net.addHost('H1', cls=Host, ip='192.168.0.11/24', defaultRoute='via 192.168.0.1') H2 = net.addHost('H2', cls=Host, ip='192.168.0.12/24', defaultRoute='via 192.168.0.1') H3 = net.addHost('H3', cls=Host, ip='192.168.0.13/24', defaultRoute='via 192.168.0.1') H4 = net.addHost('H4', cls=Host, ip='192.168.0.14/24', defaultRoute='via 192.168.0.1') H5 = net.addHost('H5', cls=Host, ip='209.165.200.235/27', defaultRoute='via 209.165.200.225') H6 = net.addHost('H6', cls=Host, ip='209.165.200.236/27', defaultRoute='via 209.165.200.225') H7 = net.addHost('H7', cls=Host, ip='192.168.1.17/24', defaultRoute='via 192.168.1.1') H8 = net.addHost('H8', cls=Host, ip='192.168.1.18/24', defaultRoute='via 192.168.1.1') H9 = net.addHost('H9', cls=Host, ip='198.51.100.171/24', defaultRoute='via 198.51.100.1') H10 = net.addHost('H10', cls=Host, ip='209.165.202.133/27', defaultRoute='via 209.165.202.129') H11 = net.addHost('H11', cls=Host, ip='203.0.113.202/24', defaultRoute='via 203.0.113.1') info('*** Add links\n') #net.addLink( R1, R4, intfName2='R4-eth0', params2={ 'ip' : '209.165.201.1/27' } ) net.addLink(R1, R4) net.addLink(H9, R4, intfName2='R4-eth1', params2={'ip': '198.51.100.1/24'}) net.addLink(H10, R4, intfName2='R4-eth2', params2={'ip': '209.165.202.129/27'}) net.addLink(H11, R4, intfName2='R4-eth3', params2={'ip': '203.0.113.1/24'}) net.addLink(S5, R1, intfName2='R1-eth1', params2={'ip': '209.165.200.225/27'}) net.addLink(S9, R1, intfName2='R1-eth2', params2={'ip': '192.168.0.1/24'}) net.addLink(S10, R1, intfName2='R1-eth3', params2={'ip': '192.168.1.1/24'}) net.addLink(H1, S9) net.addLink(H2, S9) net.addLink(H3, S9) net.addLink(H4, S9) net.addLink(H7, S10) net.addLink(H8, S10) net.addLink(H6, S5) net.addLink(H5, S5) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('S9').start([]) net.get('S10').start([]) net.get('S5').start([]) info('*** Add routes\n') R1.cmd('ip route add default via 209.165.201.1') R4.cmd('ip route add to 209.165.200.224/27 via 209.165.201.11') R4.cmd('ip route add to 192.168.0.0/16 via 209.165.201.11') info('*** Post configure switches and hosts\n') CLI(net) net.stop()
def multiControllerNet(): net = Mininet(controller=Controller, switch=OVSSwitch, link=TCLink) info("*** Creating switches\n") s1 = net.addSwitch('s1') #switches for the data network s2 = net.addSwitch('s2') s3 = net.addSwitch('s3') #switch for the control network info("*** Creating hosts\n") agent1 = net.addHost('agent1', ip='10.0.0.11') agent2 = net.addHost('agent2', ip='10.0.0.21') client1 = net.addHost('client1', ip='10.0.0.111') server1 = net.addHost('server1', ip='10.0.0.211') #controller = net.addHost('controller', ip='10.0.2.150') #controller.cmd("cd /home/vagrant/sos-for-floodlight && java -jar target/floodlight.jar") info("*** Creating data links\n") net.addLink(s1, client1) net.addLink(s1, agent1) net.addLink(s1, s2, delay='50ms') net.addLink(s2, server1) net.addLink(s2, agent2) info("*** Creating control links\n") Link(agent1, s3, intfName1='agent1-eth1') agent1.cmd('ifconfig agent1-eth1 192.168.100.1 netmask 255.255.255.0') Link(agent2, s3, intfName1='agent2-eth1') agent2.cmd('ifconfig agent2-eth1 192.168.100.2 netmask 255.255.255.0') info("*** Starting network\n") net.build() makeTerms([agent1, agent2, server1, client1]) info("*** Creating controllers\n") local = net.addController('localctl', port=6633) #controller for control network local.start() s3.start([local]) info("*** Assigning IP to host interface\n") #call ('sudo', '/sbin/ifconfig', 's3', '192.168.100.10/24', 'up', shell=True) subprocess.Popen('sudo ifconfig s3 192.168.100.10/24 up', shell=True) remote = RemoteController( 'remotectl', ip='192.168.100.10', port=6663) #controller for data network (floodlight IP) remote.start() s1.start([remote]) s2.start([remote]) #info( "*** Testing network\n" ) #net.pingAll() #info( "*** Running CLI\n" ) CLI(net) #info( "*** Stopping network\n" ) cleanUpScreens() net.stop() local.stop()
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, switch=UserSwitch) print "*** Creating nodes" sta1 = net.addStation('sta1', position='10,60,0') sta2 = net.addStation('sta2', position='20,15,0') sta3 = net.addStation('sta3', position='10,25,0') sta4 = net.addStation('sta4', position='50,30,0') sta5 = net.addStation('sta5', position='45,65,0') ap1 = net.addBaseStation('ap1', ssid="ssid,ssid1,ssid2,ssid3,ssid4", mode="g", channel="1", position='30,40,0') c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6653) """uncomment to plot graph""" net.plotGraph(max_x=100, max_y=100) print "*** Starting network" net.build() c0.start() ap1.start([c0]) sta1.setRange(15) sta2.setRange(15) sta3.setRange(15) sta4.setRange(15) sta5.setRange(15) sta1.cmd('iwconfig sta1-wlan0 essid %s ap %s' % (ap1.params['ssid'][1], ap1.params['mac'][1])) sta2.cmd('iwconfig sta2-wlan0 essid %s ap %s' % (ap1.params['ssid'][2], ap1.params['mac'][2])) sta3.cmd('iwconfig sta3-wlan0 essid %s ap %s' % (ap1.params['ssid'][2], ap1.params['mac'][2])) sta4.cmd('iwconfig sta4-wlan0 essid %s ap %s' % (ap1.params['ssid'][3], ap1.params['mac'][3])) sta5.cmd('iwconfig sta5-wlan0 essid %s ap %s' % (ap1.params['ssid'][4], ap1.params['mac'][4])) ap1.cmd( 'dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=1 drop:rate=100') ap1.cmd( 'dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=2 drop:rate=200') ap1.cmd( 'dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=3 drop:rate=300') ap1.cmd( 'dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=4 drop:rate=400') ap1.cmd( 'dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=2 meter:1 apply:output=flood' ) ap1.cmd( 'dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=3 meter:2 apply:output=flood' ) ap1.cmd( 'dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=4 meter:3 apply:output=flood' ) ap1.cmd( 'dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=5 meter:4 apply:output=flood' ) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def MininetTopo(argv): net = Mininet() info("Create host nodes.\n") host_ip = [] hostlist = [] hostlist.append(net.addHost('h1',ip="11.1.4.10/8",mac="00:00:00:00:00:10")) host_ip.append("11.1.4.10") count = 2 for i in range(1,4): for j in range(1,4): hostname = "h"+str(count) host_ip.append("11."+str(i)+"."+str(j)+".10") ip_str = "11."+str(i)+"."+str(j)+".10/8" mac_str = "00:00:00:00:00:0"+str(count-1) hostlist.append (net.addHost(hostname,ip=ip_str,mac=mac_str)) count+=1 server = net.addHost('server',ip="10.0.1.10/8",mac="00:00:00:00:00:11") info("Create switch node.\n") s1 = net.addSwitch('s1',switch = OVSSwitch,failMode = 'standalone',protocols = 'OpenFlow13') s2 = net.addSwitch('s2',switch = OVSSwitch,failMode = 'standalone',protocols = 'OpenFlow13') s3 = net.addSwitch('s3',switch = OVSSwitch,failMode = 'standalone',protocols = 'OpenFlow13') s4 = net.addSwitch('s4',switch = OVSSwitch,failMode = 'standalone',protocols = 'OpenFlow13') s5 = net.addSwitch('s5',switch = OVSSwitch,failMode = 'standalone',protocols = 'OpenFlow13') info("Create router node.\n") r1 = net.addHost('r1') r2 = net.addHost('r2') info("Create Links.\n") net.addLink(server,s1) net.addLink(s1,r1) for i in range(0,4): net.addLink(hostlist[i],s3) for i in range(4,7): net.addLink(hostlist[i],s4) for i in range(7,10): net.addLink(hostlist[i],s5) net.addLink(s3,s2) net.addLink(s4,s2) net.addLink(s5,s2) net.addLink(s2,r2) net.addLink(r1,r2) info("Create Controller.\n") #c0 = net.addController(name = 'c0',controller = RemoteController,port = 6633) info("Build and start network.\n") net.build() net.start() r1.cmd("ifconfig r1-eth0 0") r1.cmd("ifconfig r1-eth1 0") r1.cmd("ifconfig r1-eth0 hw ether 00:00:00:00:01:01") r1.cmd("ifconfig r1-eth1 hw ether 00:00:00:00:01:02") r1.cmd("ip addr add 10.0.1.1/8 brd + dev r1-eth0") r1.cmd("ip addr add 12.0.3.1/8 brd + dev r1-eth1") r1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward") r2.cmd("ifconfig r2-eth0 0") r2.cmd("ifconfig r2-eth1 0") r2.cmd("ifconfig r2-eth0 hw ether 00:00:00:00:02:01") r2.cmd("ifconfig r2-eth1 hw ether 00:00:00:00:02:02") r2.cmd("ip addr add 11.0.2.1/8 brd + dev r2-eth0") r2.cmd("ip addr add 12.0.3.2/8 brd + dev r2-eth1") r2.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward") for i in range(0,10): hostlist[i].cmd("ip route add default via 11.0.2.1") server.cmd("ip route add default via 10.0.1.1") r1.cmd("ip route add default via 12.0.3.2") r2.cmd("ip route add default via 12.0.3.1") server.cmdPrint('cd ./file') server.cmdPrint("python -m SimpleHTTPServer 80 &") time.sleep(5) #s4.cmdPrint("xterm &") #hostlist[0].cmdPrint("xterm &") r1.cmdPrint("python sniffer.py r1 0 >"+argv[0]+"/r1.txt &") r2.cmdPrint("python sniffer.py r2 0 >"+argv[0]+"/r2.txt &") s1.cmdPrint("python sniffer.py s1 1 >"+argv[0]+"/s1.txt &") s2.cmdPrint("python sniffer.py s2 4 >"+argv[0]+"/s2.txt &") s3.cmdPrint("python sniffer.py s3 1 >"+argv[0]+"/s3.txt &") s4.cmdPrint("python sniffer.py s4 1 >"+argv[0]+"/s4.txt &") #s5.cmdPrint("python sniffer.py s5 1 2 3 >tran/s5.txt &") t = time.time() normal = threading.Thread(target = normal_testing,args = ([hostlist[4]])) normal.start() attack = threading.Thread(target = attack_testing,args = ([hostlist[0]])) attack.start() """
def startNetworkWithTreeTopo(): global net topo = TreeTopo(depth=2, fanout=3) net = Mininet(topo=topo, build=False) remote_ip = getControllerIP() info('** Adding Floodlight Controller\n') net.addController('c1', controller=RemoteController, ip=remote_ip, port=6653) # Build the network net.build() net.start() # Start L3 Routing ret = enableL3Routing() print(ret) ret = addVirtualGateway('mininet-gateway-1') print(ret) ret = addInterfaceToGateway('mininet-gateway-1') print(ret) ret = addSwitchToGateway('mininet-gateway-1') print(ret) # Need to configure default gw for host host1 = net.getNodeByName('h1') host1.setIP('10.0.0.10', prefixLen=24) defaultGatewayIP1 = "10.0.0.1" configureDefaultGatewayForHost(host1, defaultGatewayIP1) host2 = net.getNodeByName('h2') host2.setIP('20.0.0.10', prefixLen=24) defaultGatewayIP2 = "20.0.0.1" configureDefaultGatewayForHost(host2, defaultGatewayIP2) host3 = net.getNodeByName('h3') host3.setIP('30.0.0.10', prefixLen=24) defaultGatewayIP3 = "30.0.0.1" configureDefaultGatewayForHost(host3, defaultGatewayIP3) host4 = net.getNodeByName('h4') host4.setIP('40.0.0.10', prefixLen=24) defaultGatewayIP4 = "40.0.0.1" configureDefaultGatewayForHost(host4, defaultGatewayIP4) host5 = net.getNodeByName('h5') host5.setIP('50.0.0.10', prefixLen=24) defaultGatewayIP5 = "50.0.0.1" configureDefaultGatewayForHost(host5, defaultGatewayIP5) host6 = net.getNodeByName('h6') host6.setIP('60.0.0.10', prefixLen=24) defaultGatewayIP6 = "60.0.0.1" configureDefaultGatewayForHost(host6, defaultGatewayIP6) host7 = net.getNodeByName('h7') host7.setIP('70.0.0.10', prefixLen=24) defaultGatewayIP7 = "70.0.0.1" configureDefaultGatewayForHost(host7, defaultGatewayIP7) host8 = net.getNodeByName('h8') host8.setIP('80.0.0.10', prefixLen=24) defaultGatewayIP8 = "80.0.0.1" configureDefaultGatewayForHost(host8, defaultGatewayIP8) host9 = net.getNodeByName('h9') host9.setIP('90.0.0.10', prefixLen=24) defaultGatewayIP9 = "90.0.0.1" configureDefaultGatewayForHost(host9, defaultGatewayIP9)
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') # Change port and IP accordingly (c0 is Local controller, rest are Global controllers) c1 = net.addController(name='c1', controller=InbandController, ip='10.0.0.1', protocol='tcp', port=6653) c0 = net.addController(name='c0', controller=RemoteController, ip='0.0.0.0', protocol='tcp', port=6653) c3 = net.addController(name='c3', controller=InbandController, ip='10.0.0.3', protocol='tcp', port=6653) c2 = net.addController(name='c2', controller=InbandController, ip='10.0.0.2', protocol='tcp', port=6653) info('*** Add switches\n') s1 = net.addSwitch('s1', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s2 = net.addSwitch('s2', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s3 = net.addSwitch('s3', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s4 = net.addSwitch('s4', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s5 = net.addSwitch('s5', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s6 = net.addSwitch('s6', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s7 = net.addSwitch('s7', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s8 = net.addSwitch('s8', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s9 = net.addSwitch('s9', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s10 = net.addSwitch('s10', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s11 = net.addSwitch('s11', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s12 = net.addSwitch('s12', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s13 = net.addSwitch('s13', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s14 = net.addSwitch('s14', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s15 = net.addSwitch('s15', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s16 = net.addSwitch('s16', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s17 = net.addSwitch('s17', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s18 = net.addSwitch('s18', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s19 = net.addSwitch('s19', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s20 = net.addSwitch('s20', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s21 = net.addSwitch('s21', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s22 = net.addSwitch('s22', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s23 = net.addSwitch('s23', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s24 = net.addSwitch('s24', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s25 = net.addSwitch('s25', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s26 = net.addSwitch('s26', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s27 = net.addSwitch('s27', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s28 = net.addSwitch('s28', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s29 = net.addSwitch('s29', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s30 = net.addSwitch('s30', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s31 = net.addSwitch('s31', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s32 = net.addSwitch('s32', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s33 = net.addSwitch('s33', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s34 = net.addSwitch('s34', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s35 = net.addSwitch('s35', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s36 = net.addSwitch('s36', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s37 = net.addSwitch('s37', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s38 = net.addSwitch('s38', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s39 = net.addSwitch('s39', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s40 = net.addSwitch('s40', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s41 = net.addSwitch('s41', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s42 = net.addSwitch('s42', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s43 = net.addSwitch('s43', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s44 = net.addSwitch('s44', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s45 = net.addSwitch('s45', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s46 = net.addSwitch('s46', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s47 = net.addSwitch('s47', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s48 = net.addSwitch('s48', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s49 = net.addSwitch('s49', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s50 = net.addSwitch('s50', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s51 = net.addSwitch('s51', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s52 = net.addSwitch('s52', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s53 = net.addSwitch('s53', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s54 = net.addSwitch('s54', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s55 = net.addSwitch('s55', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s56 = net.addSwitch('s56', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s57 = net.addSwitch('s57', cls=OVSSwitch, inband=True, protocols='OpenFlow13') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) # Add in link options for different experiments linkopts = dict(bw=1000) info('*** Add links\n') net.addLink(s1, h1, cls=TCLink, **linkopts) #s1 Perth: 5 single switches attached net.addLink(s50, h2, cls=TCLink, **linkopts) net.addLink(s22, h3, cls=TCLink, **linkopts) net.addLink(s1, s2, cls=TCLink, **linkopts) net.addLink(s1, s3, cls=TCLink, **linkopts) net.addLink(s1, s4, cls=TCLink, **linkopts) net.addLink(s1, s5, cls=TCLink, **linkopts) net.addLink(s1, s6, cls=TCLink, **linkopts) net.addLink(s1, s7, cls=TCLink, **linkopts) #s7 Darwin: 0 net.addLink(s1, s8, cls=TCLink, **linkopts) #s8 Adelaide: 11 net.addLink(s8, s7, cls=TCLink, **linkopts) net.addLink(s8, s9, cls=TCLink, **linkopts) net.addLink(s8, s10, cls=TCLink, **linkopts) net.addLink(s8, s11, cls=TCLink, **linkopts) net.addLink(s8, s12, cls=TCLink, **linkopts) net.addLink(s8, s13, cls=TCLink, **linkopts) net.addLink(s8, s14, cls=TCLink, **linkopts) net.addLink(s8, s15, cls=TCLink, **linkopts) # net.addLink(s8, s16, cls=TCLink, **linkopts) net.addLink(s8, s17, cls=TCLink, **linkopts) net.addLink(s8, s18, cls=TCLink, **linkopts) net.addLink(s8, s19, cls=TCLink, **linkopts) net.addLink(s8, s20, cls=TCLink, **linkopts) #s20 Melbourne: 8 net.addLink(s20, s21, cls=TCLink, **linkopts) net.addLink(s20, s22, cls=TCLink, **linkopts) net.addLink(s20, s23, cls=TCLink, **linkopts) net.addLink(s20, s24, cls=TCLink, **linkopts) net.addLink(s20, s25, cls=TCLink, **linkopts) net.addLink(s20, s26, cls=TCLink, **linkopts) net.addLink(s20, s27, cls=TCLink, **linkopts) net.addLink(s20, s28, cls=TCLink, **linkopts) net.addLink(s20, s29, cls=TCLink, **linkopts) #s29 Hobart: 2 net.addLink(s20, s30, cls=TCLink, **linkopts) #s30 Canberra: 0 net.addLink(s29, s31, cls=TCLink, **linkopts) net.addLink(s29, s32, cls=TCLink, **linkopts) net.addLink(s30, s33, cls=TCLink, **linkopts) #s33 Sydney: 14 net.addLink(s33, s34, cls=TCLink, **linkopts) net.addLink(s33, s35, cls=TCLink, **linkopts) net.addLink(s33, s36, cls=TCLink, **linkopts) net.addLink(s33, s37, cls=TCLink, **linkopts) net.addLink(s33, s38, cls=TCLink, **linkopts) net.addLink(s33, s39, cls=TCLink, **linkopts) net.addLink(s33, s40, cls=TCLink, **linkopts) net.addLink(s33, s41, cls=TCLink, **linkopts) net.addLink(s33, s42, cls=TCLink, **linkopts) net.addLink(s33, s43, cls=TCLink, **linkopts) net.addLink(s33, s44, cls=TCLink, **linkopts) net.addLink(s33, s45, cls=TCLink, **linkopts) net.addLink(s33, s46, cls=TCLink, **linkopts) net.addLink(s33, s47, cls=TCLink, **linkopts) net.addLink(s33, s48, cls=TCLink, **linkopts) #s48 Brisbane: 9 net.addLink(s48, s49, cls=TCLink, **linkopts) net.addLink(s48, s50, cls=TCLink, **linkopts) net.addLink(s48, s51, cls=TCLink, **linkopts) net.addLink(s48, s52, cls=TCLink, **linkopts) net.addLink(s48, s53, cls=TCLink, **linkopts) net.addLink(s48, s54, cls=TCLink, **linkopts) net.addLink(s48, s55, cls=TCLink, **linkopts) net.addLink(s48, s56, cls=TCLink, **linkopts) net.addLink(s48, s57, cls=TCLink, **linkopts) info('*** Starting network\n') net.build() info('*** Starting controllers\n') c0.start() c1.start() c2.start() c3.start() info('*** Starting switches\n') net.get('s1').start([c0, c1]) net.get('s2').start([c0]) net.get('s3').start([c0]) net.get('s4').start([c0]) net.get('s5').start([c0]) net.get('s6').start([c0]) net.get('s7').start([c0]) net.get('s8').start([c0]) net.get('s9').start([c0]) net.get('s10').start([c0]) net.get('s11').start([c0]) net.get('s12').start([c0]) net.get('s13').start([c0]) net.get('s14').start([c0]) net.get('s15').start([c0]) net.get('s16').start([c0]) net.get('s17').start([c0]) net.get('s18').start([c0]) net.get('s19').start([c0]) net.get('s20').start([c0]) net.get('s21').start([c0]) net.get('s22').start([c0, c3]) net.get('s23').start([c0]) net.get('s24').start([c0]) net.get('s25').start([c0]) net.get('s26').start([c0]) net.get('s27').start([c0]) net.get('s28').start([c0]) net.get('s29').start([c0]) net.get('s30').start([c0]) net.get('s31').start([c0]) net.get('s32').start([c0]) net.get('s33').start([c0]) net.get('s34').start([c0]) net.get('s35').start([c0]) net.get('s36').start([c0]) net.get('s37').start([c0]) net.get('s38').start([c0]) net.get('s39').start([c0]) net.get('s40').start([c0]) net.get('s41').start([c0]) net.get('s42').start([c0]) net.get('s43').start([c0]) net.get('s44').start([c0]) net.get('s45').start([c0]) net.get('s46').start([c0]) net.get('s47').start([c0]) net.get('s48').start([c0]) net.get('s49').start([c0]) net.get('s50').start([c0, c2]) net.get('s51').start([c0]) net.get('s52').start([c0]) net.get('s53').start([c0]) net.get('s54').start([c0]) net.get('s55').start([c0]) net.get('s56').start([c0]) net.get('s57').start([c0]) info('*** Post configure switches and hosts\n') s1.cmd('ifconfig s1 10.0.0.21 up') s50.cmd('ifconfig s50 10.0.0.60 up') s22.cmd('ifconfig s22 10.0.0.42 up') s22.cmd('route add 10.0.0.3 dev s22') s50.cmd('route add 10.0.0.2 dev s50') s1.cmd('route add 10.0.0.1 dev s1') rootdir = '/sys/class/net' h1.cmd('ifconfig h1-eth0 mtu 10000') h2.cmd('ifconfig h2-eth0 mtu 10000') h3.cmd('ifconfig h3-eth0 mtu 10000') for switch in net.switches: for subdir, dirs, files in os.walk(rootdir): for dir in dirs: if (str(switch) == dir.split("-")[0]): switch.cmd('ifconfig ' + dir + ' mtu 10000') net.staticArp() #time.sleep(30) info("Starting Global Controller") #h1.cmd('cd ../controllers_used_in_labs/floodlight_global') #h1.cmd('java -jar target/floodlight.jar &') info("C1 started") #h2.cmd('cd ../controllers_used_in_labs/floodlight_global2') #h2.cmd('java -jar target/floodlight.jar &') info("C2 started") #h3.cmd('cd ../controllers_used_in_labs/floodlight_global3') #h3.cmd('java -jar target/floodlight.jar &') info("C3 started") CLI(net) #info("Stopping Network") net.stop()
def MyNetwork(): net = Mininet(topo=None, build=False, ipBase='192.168.1.0/24', link=TCLink) info("*** Creating Network") print("") print("") info("*** Adding Controller 1 and Controller 2") print("") print("") # add Controller 1 c1 = net.addController(name='Controller1', controller=RemoteController, ip='192.168.56.101', port=6633) # add Controller 2 c2 = net.addController(name='Controller2', controller=RemoteController, ip='192.168.56.102', port=6634) info("*** Adding 16 switch") print("") # add switch switch1 = net.addSwitch('switch1') switch2 = net.addSwitch('switch2') switch3 = net.addSwitch('switch3') switch4 = net.addSwitch('switch4') switch5 = net.addSwitch('switch5') switch6 = net.addSwitch('switch6') switch7 = net.addSwitch('switch7') switch8 = net.addSwitch('switch8') switch9 = net.addSwitch('switch9') switch10 = net.addSwitch('switch10') switch11 = net.addSwitch('switch11') switch12 = net.addSwitch('switch12') switch13 = net.addSwitch('switch13') switch14 = net.addSwitch('switch14') switch15 = net.addSwitch('switch15') switch16 = net.addSwitch('switch16') print("(16 switch)") print("") # add host host1 = net.addHost('h1', ip='192.168.1.1') host2 = net.addHost('h2', ip='192.168.1.2') host3 = net.addHost('h3', ip='192.168.1.3') host4 = net.addHost('h4', ip='192.168.1.4') host5 = net.addHost('h5', ip='192.168.1.5') host6 = net.addHost('h6', ip='192.168.1.6') host7 = net.addHost('h7', ip='192.168.1.7') host8 = net.addHost('h8', ip='192.168.1.8') host9 = net.addHost('h9', ip='192.168.1.9') host10 = net.addHost('h10', ip='192.168.1.10') host11 = net.addHost('h11', ip='192.168.1.11') host12 = net.addHost('h12', ip='192.168.1.12') host13 = net.addHost('h13', ip='192.168.1.13') host14 = net.addHost('h14', ip='192.168.1.14') host15 = net.addHost('h15', ip='192.168.1.15') host16 = net.addHost('h16', ip='192.168.1.16') host17 = net.addHost('h17', ip='192.168.1.17') host18 = net.addHost('h18', ip='192.168.1.18') host19 = net.addHost('h19', ip='192.168.1.19') host20 = net.addHost('h20', ip='192.168.1.20') host21 = net.addHost('h21', ip='192.168.1.21') host22 = net.addHost('h22', ip='192.168.1.22') host23 = net.addHost('h23', ip='192.168.1.23') host24 = net.addHost('h24', ip='192.168.1.24') host25 = net.addHost('h25', ip='192.168.1.25') host26 = net.addHost('h26', ip='192.168.1.26') host27 = net.addHost('h27', ip='192.168.1.27') host28 = net.addHost('h28', ip='192.168.1.28') host29 = net.addHost('h29', ip='192.168.1.29') host30 = net.addHost('h30', ip='192.168.1.30') host31 = net.addHost('h31', ip='192.168.1.31') host32 = net.addHost('h32', ip='192.168.1.32') # add link net.addLink(host1, switch1) net.addLink(host2, switch1) net.addLink(host3, switch2) net.addLink(host4, switch2) net.addLink(host5, switch3) net.addLink(host6, switch3) net.addLink(host7, switch4) net.addLink(host8, switch4) net.addLink(host9, switch5) net.addLink(host10, switch5) net.addLink(host11, switch6) net.addLink(host12, switch6) net.addLink(host13, switch7) net.addLink(host14, switch7) net.addLink(host15, switch8) net.addLink(host16, switch8) net.addLink(host17, switch9) net.addLink(host18, switch9) net.addLink(host19, switch10) net.addLink(host20, switch10) net.addLink(host21, switch11) net.addLink(host22, switch11) net.addLink(host23, switch12) net.addLink(host24, switch12) net.addLink(host25, switch13) net.addLink(host26, switch13) net.addLink(host27, switch14) net.addLink(host28, switch14) net.addLink(host29, switch15) net.addLink(host30, switch15) net.addLink(host31, switch16) net.addLink(host32, switch16) net.addLink(switch1, switch2) net.addLink(switch2, switch3) net.addLink(switch3, switch4) net.addLink(switch4, switch5) net.addLink(switch5, switch6) net.addLink(switch6, switch7) net.addLink(switch7, switch8) net.addLink(switch8, switch9) net.addLink(switch9, switch10) net.addLink(switch10, switch11) net.addLink(switch11, switch12) net.addLink(switch12, switch13) net.addLink(switch13, switch14) net.addLink(switch14, switch15) net.addLink(switch15, switch16) net.build() for controller in net.controllers: controller.start() net.get('switch1').start([c1]) net.get('switch2').start([c1]) net.get('switch3').start([c1]) net.get('switch4').start([c1]) net.get('switch5').start([c1]) net.get('switch6').start([c1]) net.get('switch7').start([c1]) net.get('switch8').start([c1]) net.get('switch9').start([c2]) net.get('switch10').start([c2]) net.get('switch11').start([c2]) net.get('switch12').start([c2]) net.get('switch13').start([c2]) net.get('switch14').start([c2]) net.get('switch15').start([c2]) net.get('switch16').start([c2]) print("") CLI(net) net.stop()
def setupTopology(controller_addr): global net,c1,s1,s2,s3 global h1,h2,h3,h4,h5,h6,h7,h8,h9,h10 "Create and run multiple link network" net = Mininet(controller=RemoteController) print "mininet created" c1 = net.addController('c1', ip=controller_addr,port=6653) # h1: IOT Device. # h2 : StatciDHCPD # h3 : router / NAT # h4 : Non IOT device. h1 = net.addHost('h1') h2 = net.addHost('h2') h3 = net.addHost('h3') h4 = net.addHost('h4') h5 = net.addHost('h5') h6 = net.addHost('h6') h7 = net.addHost('h7') h8 = net.addHost('h8') h9 = net.addHost('h9') h10 = net.addHost('h10') hosts.append(h1) hosts.append(h2) hosts.append(h3) hosts.append(h4) hosts.append(h5) hosts.append(h6) hosts.append(h7) hosts.append(h8) hosts.append(h9) hosts.append(h10) s2 = net.addSwitch('s2',dpid="2") s3 = net.addSwitch('s3',dpid="3") s1 = net.addSwitch('s1',dpid="1") s1.linkTo(h1) s1.linkTo(h2) s1.linkTo(h3) s1.linkTo(h4) s1.linkTo(h5) s1.linkTo(h6) s1.linkTo(h7) s2.linkTo(h8) s3.linkTo(h8) s3.linkTo(h9) s3.linkTo(h10) # S2 is the NPE switch. # Direct link between S1 and S2 s1.linkTo(s2) h8.cmdPrint('echo 0 > /proc/sys/net/ipv4/ip_forward') # Flush old rules. h8.cmdPrint('iptables -F') h8.cmdPrint('iptables -t nat -F') h8.cmdPrint('iptables -t mangle -F') h8.cmdPrint('iptables -X') h8.cmdPrint('echo 1 > /proc/sys/net/ipv4/ip_forward') # Set up h3 to be our router (it has two interfaces). # Set up iptables to forward as NAT h8.cmdPrint('iptables -t nat -A POSTROUTING -o h8-eth1 -s 10.0.0.0/24 -j MASQUERADE') net.build() net.build() c1.start() s1.start([c1]) s2.start([c1]) s3.start([c1]) net.start() # Clean up any traces of the previous invocation (for safety) h1.setMAC("00:00:00:00:00:c1","h1-eth0") h2.setMAC("00:00:00:00:00:c2","h2-eth0") h3.setMAC("00:00:00:00:00:c3","h3-eth0") h4.setMAC("00:00:00:00:00:c4","h4-eth0") h5.setMAC("00:00:00:00:00:c5","h5-eth0") h6.setMAC("00:00:00:00:00:c6","h6-eth0") h7.setMAC("00:00:00:00:00:c7","h7-eth0") h8.setMAC("00:00:00:00:00:c8","h8-eth0") h9.setMAC("00:00:00:00:00:c9","h9-eth0") h10.setMAC("00:00:00:00:00:cA","h10-eth0") # Set up a routing rule on h2 to route packets via h3 h1.cmdPrint('ip route del default') h1.cmdPrint('ip route add default via 10.0.0.8 dev h1-eth0') # Set up a routing rule on h2 to route packets via h3 h2.cmdPrint('ip route del default') h2.cmdPrint('ip route add default via 10.0.0.8 dev h2-eth0') # Set up a routing rule on h2 to route packets via h7 h3.cmdPrint('ip route del default') h3.cmdPrint('ip route add default via 10.0.0.8 dev h3-eth0') # Set up a routing rule on h2 to route packets via h3 h4.cmdPrint('ip route del default') h4.cmdPrint('ip route add default via 10.0.0.8 dev h4-eth0') # Set up a routing rule on h5 to route packets via h3 h5.cmdPrint('ip route del default') h5.cmdPrint('ip route add default via 10.0.0.8 dev h5-eth0') # h6 is a localhost. h6.cmdPrint('ip route del default') h6.cmdPrint('ip route add default via 10.0.0.8 dev h6-eth0') # The IDS runs on h8 h7.cmdPrint('ip route del default') h7.cmdPrint('ip route add default via 10.0.0.8 dev h7-eth0') # h9 is our fake host. It runs our "internet" web server. h9.cmdPrint('ifconfig h9-eth0 203.0.113.13 netmask 255.255.255.0') # Start a web server there. h9.cmdPrint('python ../util/http-server.py -H 203.0.113.13&') # h10 is our second fake host. It runs another internet web server that we cannot reach h10.cmdPrint('ifconfig h10-eth0 203.0.113.14 netmask 255.255.255.0') # Start a web server there. h10.cmdPrint('python ../util/http-server.py -H 203.0.113.14&') # Start dnsmasq (our dns server). h5.cmdPrint('/usr/sbin/dnsmasq --server 10.0.4.3 --pid-file=/tmp/dnsmasq.pid' ) # Set up our router routes. h8.cmdPrint('ip route add 203.0.113.13/32 dev h8-eth1') h8.cmdPrint('ip route add 203.0.113.14/32 dev h8-eth1') h8.cmdPrint('ifconfig h8-eth1 203.0.113.1 netmask 255.255.255.0') #subprocess.Popen(cmd,shell=True, stdin= subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) h7.cmdPrint("python ../util/udpping.py --port 4000 --server &") h7.cmdPrint('python ../util/http-server.py -H 10.0.0.7&') h1.cmdPrint('python ../util/http-server.py -H 10.0.0.1&') net.waitConnected() print "*********** System ready *********" return net
def myNetwork(): net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8') info('*** Adding controller\n') info('*** Add switches\n') swd1 = net.addSwitch('swd1', cls=OVSKernelSwitch, failMode='standalone') rcentral = net.addHost('rcentral', cls=Node, ip='0.0.0.0') rcentral.cmd('sysctl -w net.ipv4.ip_forward=1') swd2 = net.addSwitch('swd2', cls=OVSKernelSwitch, failMode='standalone') swd3 = net.addSwitch('swd3', cls=OVSKernelSwitch, failMode='standalone') swd4 = net.addSwitch('swd4', cls=OVSKernelSwitch, failMode='standalone') swd5 = net.addSwitch('swd5', cls=OVSKernelSwitch, failMode='standalone') rd1 = net.addHost('rd1', cls=Node, ip='0.0.0.0') rd1.cmd('sysctl -w net.ipv4.ip_forward=1') rd2 = net.addHost('rd2', cls=Node, ip='0.0.0.0') rd2.cmd('sysctl -w net.ipv4.ip_forward=1') rd3 = net.addHost('rd3', cls=Node, ip='0.0.0.0') rd3.cmd('sysctl -w net.ipv4.ip_forward=1') rd4 = net.addHost('rd4', cls=Node, ip='0.0.0.0') rd4.cmd('sysctl -w net.ipv4.ip_forward=1') rd5 = net.addHost('rd5', cls=Node, ip='0.0.0.0') rd5.cmd('sysctl -w net.ipv4.ip_forward=1') sld1 = net.addSwitch('sld1', cls=OVSKernelSwitch, failMode='standalone') sld2 = net.addSwitch('sld2', cls=OVSKernelSwitch, failMode='standalone') sld3 = net.addSwitch('sld3', cls=OVSKernelSwitch, failMode='standalone') sld4 = net.addSwitch('sld4', cls=OVSKernelSwitch, failMode='standalone') sld5 = net.addSwitch('sld5', cls=OVSKernelSwitch, failMode='standalone') rd1_e1 = net.addHost('rd1_e1', cls=Node, ip='0.0.0.0') rd1_e1.cmd('sysctl -w net.ipv4.ip_forward=1') rd1_e2 = net.addHost('rd1_e2', cls=Node, ip='0.0.0.0') rd1_e2.cmd('sysctl -w net.ipv4.ip_forward=1') rd1_e3 = net.addHost('rd1_e3', cls=Node, ip='0.0.0.0') rd1_e3.cmd('sysctl -w net.ipv4.ip_forward=1') sld1_e1 = net.addSwitch('sld1_e1', cls=OVSKernelSwitch, failMode='standalone') sld1_e2 = net.addSwitch('sld1_e2', cls=OVSKernelSwitch, failMode='standalone') sld1_e3 = net.addSwitch('sld1_e3', cls=OVSKernelSwitch, failMode='standalone') info('*** Add hosts\n') h1_d1 = net.addHost('h1_e3', cls=Host, ip='10.0.0.95/8', defaultRoute=None) h1_e1 = net.addHost('h1_e1', cls=Host, ip='192.168.0.1/24', defaultRoute=None) h1_e2 = net.addHost('h1_e2', cls=Host, ip='192.168.0.1/24', defaultRoute=None) h1_e3 = net.addHost('h1_d1', cls=Host, ip='192.168.0.1/24', defaultRoute=None) info('*** Add links\n') net.addLink(rcentral, swd1) net.addLink(rcentral, swd2) net.addLink(rcentral, swd3) net.addLink(rcentral, swd4) net.addLink(rcentral, swd5) net.addLink(swd1, rd1) net.addLink(swd2, rd2) net.addLink(swd3, rd3) net.addLink(swd4, rd4) net.addLink(swd5, rd5) net.addLink(rd1, sld1) net.addLink(rd2, sld2) net.addLink(rd3, sld3) net.addLink(rd4, sld4) net.addLink(rd5, sld5) net.addLink(sld1, rd1_e1) net.addLink(sld1, rd1_e2) net.addLink(sld1, rd1_e3) net.addLink(sld1, h1_d1) net.addLink(rd1_e1, sld1_e3) net.addLink(rd1_e2, sld1_e2) net.addLink(rd1_e3, sld1_e1) net.addLink(sld1_e3, h1_e1) net.addLink(sld1_e2, h1_e2) net.addLink(sld1_e1, h1_e3) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('sld2').start([]) net.get('sld1_e2').start([]) net.get('sld1').start([]) net.get('sld4').start([]) net.get('sld1_e1').start([]) net.get('swd3').start([]) net.get('swd2').start([]) net.get('sld1_e3').start([]) net.get('swd4').start([]) net.get('sld5').start([]) net.get('sld3').start([]) net.get('swd5').start([]) net.get('swd1').start([]) info('*** Post configure switches and hosts\n') h1_e1.cmd('ip route add default via 192.168.0.254 ') net['h1_e2'].cmd('ip route add 10.0.1.0/24 via 192.168.100.1') CLI(net) net.stop()
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch, accessPoint=OVSKernelAP) global gnet gnet = net print "*** Creating nodes " car = [] stas = [] for x in range(0, 4): car.append(x) stas.append(x) for x in range(0, 4): car[x] = net.addCar('car%s' % (x), wlans=2, ip='10.0.0.%s/8' % (x + 1), \ mac='00:00:00:00:00:0%s' % x, mode='b') eNodeB1 = net.addAccessPoint('eNodeB1', ssid='eNodeB1', dpid='1000000000000000', mode='ac', channel='1', position='80,75,0', range=60) eNodeB2 = net.addAccessPoint('eNodeB2', ssid='eNodeB2', dpid='2000000000000000', mode='ac', channel='6', position='180,75,0', range=70) rsu1 = net.addAccessPoint('rsu1', ssid='rsu1', dpid='3000000000000000', mode='g', channel='11', position='140,120,0', range=40) c1 = net.addController('c1', controller=Controller) client = net.addHost('client') switch = net.addSwitch('switch', dpid='4000000000000000') net.plotNode(client, position='125,230,0') net.plotNode(switch, position='125,200,0') print "*** Configuring wifi nodes" net.configureWifiNodes() print "*** Creating links " net.addLink(eNodeB1, switch) net.addLink(eNodeB2, switch) net.addLink(rsu1, switch) net.addLink(switch, client) print "*** Starting network" net.build() c1.start() eNodeB1.start([c1]) eNodeB2.start([c1]) rsu1.start([c1]) switch.start([c1]) for sw in net.vehicles: sw.start([c1]) print "*** Configuring interfaces " i = 1 j = 2 for c in car: c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i)) c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i)) c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j) i += 2 j += 2 i = 1 j = 2 for v in net.vehiclesSTA: v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j)) v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i)) v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') i += 1 j += 2 for v1 in net.vehiclesSTA: i = 1 j = 1 for v2 in net.vehiclesSTA: if v1 != v2: v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i)) i += 1 j += 2 client.cmd('ifconfig client-eth0 200.0.10.2') net.vehiclesSTA[0].cmd('ifconfig car0STA-eth0 200.0.10.50') # Bonding interfaces for car0 car[0].cmd('modprobe bonding mode=3') car[0].cmd('ip link add bond0 type bond') car[0].cmd('ip link set bond0 address 02:01:02:03:04:08') car[0].cmd('ip link set car0-eth0 down') car[0].cmd('ip link set car0-eth0 address 00:00:00:00:00:11') car[0].cmd('ip link set car0-eth0 master bond0') car[0].cmd('ip link set car0-wlan0 down') car[0].cmd('ip link set car0-wlan0 address 00:00:00:00:00:15') car[0].cmd('ip link set car0-wlan0 master bond0') car[0].cmd('ip link set car0-wlan1 down') car[0].cmd('ip link set car0-wlan1 address 00:00:00:00:00:13') car[0].cmd('ip link set car0-wlan1 master bond0') car[0].cmd('ip addr add 200.0.10.100/24 dev bond0') car[0].cmd('ip link set bond0 up') # more configuring and routing commands car[3].cmd('ifconfig car3-wlan0 200.0.10.150') client.cmd('ip route add 192.168.1.8 via 200.0.10.150') client.cmd('ip route add 10.0.0.1 via 200.0.10.150') net.vehiclesSTA[3].cmd('ip route add 200.0.10.2 via 192.168.1.7') net.vehiclesSTA[3].cmd('ip route add 200.0.10.100 via 10.0.0.1') net.vehiclesSTA[0].cmd('ip route add 200.0.10.2 via 10.0.0.4') car[0].cmd('ip route add 10.0.0.4 via 200.0.10.50') car[0].cmd('ip route add 192.168.1.7 via 200.0.10.50') car[0].cmd('ip route add 200.0.10.2 via 200.0.10.50') car[3].cmd('ip route add 200.0.10.100 via 192.168.1.8') car[0].cmdPrint( "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'car0' &") car[3].cmdPrint( "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'car3' &") client.cmdPrint( "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'client' &") """plot graph""" net.plotGraph(max_x=250, max_y=250) net.startGraph() # remove previous data os.system('rm *.vanetdata') # stream video using VLC car[0].cmdPrint( "vlc -vvv /home/mininet/Desktop/bunnyMob.mp4 --sout '#duplicate{dst=rtp{dst=200.0.10.2,port=5004,mux=ts},dst=display}' :sout-keep &" ) client.cmdPrint("vlc rtp://@200.0.10.2:5004 &") # starting positions for cars car[0].moveNodeTo('95,100,0') car[1].moveNodeTo('80,100,0') car[2].moveNodeTo('65,100,0') car[3].moveNodeTo('50,100,0') # delete all previous flow rules os.system('ovs-ofctl del-flows switch') # sleep... time.sleep(3) # start experiment, 20 secs for each phase apply_experiment(car, client, switch) # Uncomment the line below to generate the graph that you implemented graphic() # kills all the xterms that have been opened #os.system('pkill xterm') print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def myNetwork(N): net = Mininet(topo=None, build=False, ipBase='10.0.0.0/8') info('*** Adding controller\n') c3 = net.addController(name='c3', controller=Controller, protocol='tcp', port=6633) c1 = net.addController(name='c1', controller=Controller, protocol='tcp', port=6633) c2 = net.addController(name='c2', controller=Controller, protocol='tcp', port=6633) info('*** Add switches\n') s5 = net.addSwitch('s5', cls=OVSKernelSwitch) s4 = net.addSwitch('s4', cls=OVSKernelSwitch) s3 = net.addSwitch('s3', cls=OVSKernelSwitch) info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) info('*** Add links\n') h1s3 = {'bw': 10, 'delay': str(N), 'loss': 0, 'max_queue_size': 10} net.addLink(h1, s3, cls=TCLink, **h1s3) h2s4 = {'bw': 10, 'delay': str(N), 'loss': 0, 'max_queue_size': 10} net.addLink(h2, s4, cls=TCLink, **h2s4) s4s5 = {'bw': 10, 'delay': str(N), 'loss': 0, 'max_queue_size': 10} net.addLink(s4, s5, cls=TCLink, **s4s5) s3s5 = {'bw': 10, 'delay': str(N), 'loss': 0, 'max_queue_size': 10} net.addLink(s3, s5, cls=TCLink, **s3s5) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('s5').start([c1]) net.get('s4').start([c3]) net.get('s3').start([c2]) net.addNAT().configDefault() net.start() info('*** Post configure switches and hosts\n') h1.cmd('cd server') m1 = h1.cmd('python3 server.py 0.0.0.0 {} > log.txt &'.format(N // 100 + 500)) time.sleep(0.5) begin = time.time() m2 = h2.cmd( 'cd client && python3 client.py 10.0.0.1 {} <test.txt'.format(N // 100 + 500)) print('#' * 100) print(m1) print('*' * 100) print(m2) return N, time.time() - begin
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP) print "*** Creating nodes" net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8') net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8') net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8') net.addStation('sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8') net.addStation('sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8') net.addStation('sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8') net.addStation('sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8') net.addStation('sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8') net.addStation('sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8') net.addStation('sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8') ap1 = net.addAccessPoint('ap1', ssid='ssid-ap1', mode='g', channel='1', position='50,50,0') ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', mode='g', channel='6', position='70,50,0', range=30) ap3 = net.addAccessPoint('ap3', ssid='ssid-ap3', mode='g', channel='11', position='90,50,0') c1 = net.addController('c1', controller=Controller) net.propagationModel("logDistancePropagationLossModel", exp=5) print "*** Configuring wifi nodes" net.configureWifiNodes() print "*** Associating and Creating links" net.addLink(ap1, ap2) net.addLink(ap2, ap3) net.plotGraph(max_x=120, max_y=120) net.associationControl('ssf') net.seed(1) net.startMobility(time=0, model='RandomWayPoint', max_x=120, max_y=120, min_v=0.3, max_v=0.5) print "*** Starting network" net.build() c1.start() ap1.start([c1]) ap2.start([c1]) ap3.start([c1]) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, accessPoint=OVSKernelAP) print "*** Creating nodes" sta1 = net.addStation('sta1') sta2 = net.addStation('sta2') sta3 = net.addStation('sta3') ap1 = net.addAccessPoint('ap1', ssid='ssid-ap1', mode='g', channel='11', position='100,100,0', range=100) c1 = net.addController('c1', controller=Controller) print "*** Configuring wifi nodes" net.configureWifiNodes() sta1.setIP('10.0.0.1/8', intf="sta1-wlan0") sta2.setIP('10.0.0.2/8', intf="sta2-wlan0") sta3.setIP('10.0.0.3/8', intf="sta3-wlan0") print "*** Starting network" net.build() c1.start() ap1.start([c1]) net.plotGraph(max_x=200, max_y=200) net.associationControl('ssf') net.startMobility(time=0) net.mobility(sta1, 'start', time=1, position='8,100,0') net.mobility(sta2, 'start', time=1, position='1,107,0') net.mobility(sta3, 'start', time=1, position='1,93,0') net.mobility(sta1, 'stop', time=250, position='199,100,0') net.mobility(sta2, 'stop', time=250, position='192,107,0') net.mobility(sta3, 'stop', time=250, position='192,93,0') net.stopMobility(time=250) sleep(2) s1 = net.get('sta1') s2 = net.get('sta2') s3 = net.get('sta3') popens = {} # Python subprocess.Popen objects keyed by Mininet hosts startTime = int(time()) + SYNC_START endTime = startTime + EXPERIMENT_DURATION print "*** Starting %d second experiment in %d second(s) - at Unix epoch: %d..." % ( EXPERIMENT_DURATION, (startTime - int(time())), startTime) popens[s1] = s1.popen(EXECUTABLE_PATH, '-role=l', '-addr=%s' % s1.IP(), '-dsts=%s,%s' % (s2.IP(), s3.IP()), '-start=%d' % startTime) popens[s2] = s2.popen(EXECUTABLE_PATH, '-role=f', '-addr=%s' % s2.IP(), '-start=%d' % startTime) popens[s3] = s3.popen(EXECUTABLE_PATH, '-role=f', '-addr=%s' % s3.IP(), '-start=%d' % startTime) with open(OUTPUT_FILE, 'w') as f: for h, line in pmonitor(popens, timeoutms=500): if h: f.write('<%s>: %s' % (h.name, line)) if time() >= endTime: break popens[s1].send_signal(SIGINT) popens[s2].send_signal(SIGINT) popens[s3].send_signal(SIGINT) f.close() print "*** Ending experiment..." print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def simplePolska(): if len(sys.argv) < 2: info( '*** Specify time [s] of simulation! --> python simple-polska-script.py <time>...\n' ) return simulationTime = int(sys.argv[1]) info('*** Starting controller...\n') cmd = "java -jar target/floodlight.jar -cf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/floodlightdefault.properties" proc = subprocess.Popen(cmd.split(), cwd='/home/sszwaczyk/WAT/PhD/impl/floodlight') info('*** Sleep 5 seconds to let controller start...\n') sleep(5) net = Mininet(topo=None, build=False, ipBase='10.0.0.0/24', autoSetMacs=True, autoStaticArp=True) info('*** Adding controller\n') c0 = net.addController(name='c0', controller=RemoteController, ip='127.0.0.1', protocol='tcp', port=6653) info('*** Add switches\n') kolobrzeg = net.addSwitch('kolobrzeg', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:01') gdansk = net.addSwitch('gdansk', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:02') szczecin = net.addSwitch('szczecin', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:03') bydgoszcz = net.addSwitch('bydgoszcz', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:04') bialystok = net.addSwitch('bialystok', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:05') poznan = net.addSwitch('poznan', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:06') warsaw = net.addSwitch('warsaw', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:07') lodz = net.addSwitch('lodz', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:08') wroclaw = net.addSwitch('wroclaw', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:09') katowice = net.addSwitch('katowice', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:10') krakow = net.addSwitch('krakow', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:11') rzeszow = net.addSwitch('rzeszow', cls=OVSKernelSwitch, dpid='00:00:00:00:00:00:00:12') info('*** Add hosts\n') userOneHost = net.addHost('User1', cls=Host, ip='10.0.0.101/24') userTwoHost = net.addHost('User2', cls=Host, ip='10.0.0.102/24') userThreeHost = net.addHost('User3', cls=Host, ip='10.0.0.103/24') userFourHost = net.addHost('User4', cls=Host, ip='10.0.0.104/24') userFiveHost = net.addHost('User5', cls=Host, ip='10.0.0.105/24') userSixHost = net.addHost('User6', cls=Host, ip='10.0.0.106/24') userSevenHost = net.addHost('User7', cls=Host, ip='10.0.0.107/24') userEightHost = net.addHost('User8', cls=Host, ip='10.0.0.108/24') userNineHost = net.addHost('User9', cls=Host, ip='10.0.0.109/24') userTenHost = net.addHost('User10', cls=Host, ip='10.0.0.110/24') userElevenHost = net.addHost('User11', cls=Host, ip='10.0.0.111/24') userTwelveHost = net.addHost('User12', cls=Host, ip='10.0.0.112/24') userThirteenHost = net.addHost('User13', cls=Host, ip='10.0.0.113/24') userFourteenHost = net.addHost('User14', cls=Host, ip='10.0.0.114/24') userFifteenHost = net.addHost('User15', cls=Host, ip='10.0.0.115/24') userSixteenHost = net.addHost('User16', cls=Host, ip='10.0.0.116/24') userSeventeenHost = net.addHost('User17', cls=Host, ip='10.0.0.117/24') userEighteenHost = net.addHost('User18', cls=Host, ip='10.0.0.118/24') userNineteenHost = net.addHost('User19', cls=Host, ip='10.0.0.119/24') userTwentyHost = net.addHost('User20', cls=Host, ip='10.0.0.120/24') userTwentyOneHost = net.addHost('User21', cls=Host, ip='10.0.0.121/24') serviceOneHost = net.addHost('Service1', cls=Host, ip='10.0.0.1/24') serviceTwoHost = net.addHost('Service2', cls=Host, ip='10.0.0.2/24') serviceThreeHost = net.addHost('Service3', cls=Host, ip='10.0.0.3/24') serviceFourHost = net.addHost('Service4', cls=Host, ip='10.0.0.4/24') serviceFiveHost = net.addHost('Service5', cls=Host, ip='10.0.0.5/24') info('*** Add links\n') # Add links between switches net.addLink(kolobrzeg, gdansk, cls=TCLink, bw=100) net.addLink(kolobrzeg, szczecin, cls=TCLink, bw=100) net.addLink(kolobrzeg, bydgoszcz, cls=TCLink, bw=100) net.addLink(gdansk, bialystok, cls=TCLink, bw=100) net.addLink(gdansk, warsaw, cls=TCLink, bw=100) net.addLink(szczecin, poznan, cls=TCLink, bw=100) net.addLink(bydgoszcz, poznan, cls=TCLink, bw=100) net.addLink(bydgoszcz, warsaw, cls=TCLink, bw=100) net.addLink(bialystok, warsaw, cls=TCLink, bw=100) net.addLink(bialystok, rzeszow, cls=TCLink, bw=100) net.addLink(poznan, wroclaw, cls=TCLink, bw=100) net.addLink(warsaw, lodz, cls=TCLink, bw=100) net.addLink(warsaw, krakow, cls=TCLink, bw=100) net.addLink(lodz, wroclaw, cls=TCLink, bw=100) net.addLink(lodz, katowice, cls=TCLink, bw=100) net.addLink(wroclaw, katowice, cls=TCLink, bw=100) net.addLink(katowice, krakow, cls=TCLink, bw=100) net.addLink(krakow, rzeszow, cls=TCLink, bw=100) # Add links to services net.addLink(kolobrzeg, serviceOneHost, cls=TCLink, bw=100) net.addLink(bialystok, serviceTwoHost, cls=TCLink, bw=100) net.addLink(warsaw, serviceThreeHost, cls=TCLink, bw=100) net.addLink(wroclaw, serviceFourHost, cls=TCLink, bw=100) net.addLink(rzeszow, serviceFiveHost, cls=TCLink, bw=100) #Add links to users net.addLink(gdansk, userOneHost, cls=TCLink, bw=100) net.addLink(szczecin, userTwoHost, cls=TCLink, bw=100) net.addLink(bydgoszcz, userThreeHost, cls=TCLink, bw=100) net.addLink(poznan, userFourHost, cls=TCLink, bw=100) net.addLink(lodz, userFiveHost, cls=TCLink, bw=100) net.addLink(katowice, userSixHost, cls=TCLink, bw=100) net.addLink(krakow, userSevenHost, cls=TCLink, bw=100) net.addLink(gdansk, userEightHost, cls=TCLink, bw=100) net.addLink(szczecin, userNineHost, cls=TCLink, bw=100) net.addLink(bydgoszcz, userTenHost, cls=TCLink, bw=100) net.addLink(poznan, userElevenHost, cls=TCLink, bw=100) net.addLink(lodz, userTwelveHost, cls=TCLink, bw=100) net.addLink(katowice, userThirteenHost, cls=TCLink, bw=100) net.addLink(krakow, userFourteenHost, cls=TCLink, bw=100) net.addLink(gdansk, userFifteenHost, cls=TCLink, bw=100) net.addLink(szczecin, userSixteenHost, cls=TCLink, bw=100) net.addLink(bydgoszcz, userSeventeenHost, cls=TCLink, bw=100) net.addLink(poznan, userEighteenHost, cls=TCLink, bw=100) net.addLink(lodz, userNineteenHost, cls=TCLink, bw=100) net.addLink(katowice, userTwentyHost, cls=TCLink, bw=100) net.addLink(krakow, userTwentyOneHost, cls=TCLink, bw=100) info('*** Starting network\n') net.build() info('*** Starting switches\n') net.get('kolobrzeg').start([c0]) net.get('gdansk').start([c0]) net.get('szczecin').start([c0]) net.get('bydgoszcz').start([c0]) net.get('bialystok').start([c0]) net.get('poznan').start([c0]) net.get('warsaw').start([c0]) net.get('lodz').start([c0]) net.get('wroclaw').start([c0]) net.get('katowice').start([c0]) net.get('krakow').start([c0]) net.get('rzeszow').start([c0]) info('*** Sleep 15 seconds to let controller get topology...\n') sleep(15) popens = {} info('*** Starting services\n') serviceOneCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/http-server/target/http-server-0.0.1-SNAPSHOT.jar --usersFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/users.json --servicesFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json --logging.file=./service-one.log --exitStatsFile=./service-one-exit.xlsx' popens[serviceOneHost] = serviceOneHost.popen(serviceOneCommand.split()) serviceTwoCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/http-server/target/http-server-0.0.1-SNAPSHOT.jar --usersFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/users.json --servicesFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json --logging.file=./service-Two.log --exitStatsFile=./service-Two-exit.xlsx' popens[serviceTwoHost] = serviceTwoHost.popen(serviceTwoCommand.split()) serviceThreeCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/http-server/target/http-server-0.0.1-SNAPSHOT.jar --usersFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/users.json --servicesFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json --logging.file=./service-Three.log --exitStatsFile=./service-Three-exit.xlsx' popens[serviceThreeHost] = serviceThreeHost.popen( serviceThreeCommand.split()) serviceFourCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/http-server/target/http-server-0.0.1-SNAPSHOT.jar --usersFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/users.json --servicesFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json --logging.file=./service-Four.log --exitStatsFile=./service-Four-exit.xlsx' popens[serviceFourHost] = serviceFourHost.popen(serviceFourCommand.split()) serviceFiveCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/http-server/target/http-server-0.0.1-SNAPSHOT.jar --usersFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/users.json --servicesFile=/home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json --logging.file=./service-Five.log --exitStatsFile=./service-Five-exit.xlsx' popens[serviceFiveHost] = serviceFiveHost.popen(serviceFiveCommand.split()) info('*** Sleep 30 seconds to let services start...\n') sleep(30) info('*** Starting requests generators...\n') userOneCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-one -st ./user-one-exit.xlsx -er ./user-one-every-request.xlsx -s 11111 -g uniform -ming 30 -maxg 60' popens[userOneHost] = userOneHost.popen(userOneCommand.split()) sleep(1) userTwoCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-two -st ./user-two-exit.xlsx -er ./user-two-every-request.xlsx -s 22222 -g uniform -ming 30 -maxg 60' popens[userTwoHost] = userTwoHost.popen(userTwoCommand.split()) sleep(1) userThreeCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-three -st ./user-three-exit.xlsx -er ./user-three-every-request.xlsx -s 33333 -g uniform -ming 30 -maxg 60' popens[userThreeHost] = userThreeHost.popen(userThreeCommand.split()) sleep(1) userFourCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-four -st ./user-four-exit.xlsx -er ./user-four-every-request.xlsx -s 44444 -g uniform -ming 30 -maxg 60' popens[userFourHost] = userFourHost.popen(userFourCommand.split()) sleep(1) userFiveCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-five -st ./user-five-exit.xlsx -er ./user-five-every-request.xlsx -s 55555 -g uniform -ming 30 -maxg 60' popens[userFiveHost] = userFiveHost.popen(userFiveCommand.split()) sleep(1) userSixCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-six -st ./user-six-exit.xlsx -er ./user-six-every-request.xlsx -s 66666 -g uniform -ming 30 -maxg 60' popens[userSixHost] = userSixHost.popen(userSixCommand.split()) sleep(1) userSevenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-seven -st ./user-seven-exit.xlsx -er ./user-seven-every-request.xlsx -s 77777 -g uniform -ming 30 -maxg 60' popens[userSevenHost] = userSevenHost.popen(userSevenCommand.split()) sleep(1) userEightCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-eight -st ./user-eight-exit.xlsx -er ./user-eight-every-request.xlsx -s 88888 -g uniform -ming 30 -maxg 60' popens[userEightHost] = userEightHost.popen(userEightCommand.split()) sleep(1) userNineCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Nine -st ./user-Nine-exit.xlsx -er ./user-Nine-every-request.xlsx -s 99999 -g uniform -ming 30 -maxg 60' popens[userNineHost] = userNineHost.popen(userNineCommand.split()) sleep(1) userTenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Ten -st ./user-Ten-exit.xlsx -er ./user-Ten-every-request.xlsx -s 1010101010 -g uniform -ming 30 -maxg 60' popens[userTenHost] = userTenHost.popen(userTenCommand.split()) sleep(1) userElevenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Eleven -st ./user-Eleven-exit.xlsx -er ./user-Eleven-every-request.xlsx -s 1111111111 -g uniform -ming 30 -maxg 60' popens[userElevenHost] = userElevenHost.popen(userElevenCommand.split()) sleep(1) userTwelveCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Twelve -st ./user-Twelve-exit.xlsx -er ./user-Twelve-every-request.xlsx -s 1212121212 -g uniform -ming 30 -maxg 60' popens[userTwelveHost] = userTwelveHost.popen(userTwelveCommand.split()) sleep(1) userThirteenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Thirteen -st ./user-Thirteen-exit.xlsx -er ./user-Thirteen-every-request.xlsx -s 1313131313 -g uniform -ming 30 -maxg 60' popens[userThirteenHost] = userThirteenHost.popen( userThirteenCommand.split()) sleep(1) userFourteenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Fourteen -st ./user-Fourteen-exit.xlsx -er ./user-Fourteen-every-request.xlsx -s 1414141414 -g uniform -ming 30 -maxg 60' popens[userFourteenHost] = userFourteenHost.popen( userFourteenCommand.split()) sleep(1) userFifteenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Fifteen -st ./user-Fifteen-exit.xlsx -er ./user-Fifteen-every-request.xlsx -s 1515151515 -g uniform -ming 30 -maxg 60' popens[userFifteenHost] = userFifteenHost.popen(userFifteenCommand.split()) sleep(1) userSixteenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Sixteen -st ./user-Sixteen-exit.xlsx -er ./user-Sixteen-every-request.xlsx -s 1616161616 -g uniform -ming 30 -maxg 60' popens[userSixteenHost] = userSixteenHost.popen(userSixteenCommand.split()) sleep(1) userSeventeenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Seventeen -st ./user-Seventeen-exit.xlsx -er ./user-Seventeen-every-request.xlsx -s 1717171717 -g uniform -ming 30 -maxg 60' popens[userSeventeenHost] = userSeventeenHost.popen( userSeventeenCommand.split()) sleep(1) userEighteenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Eighteen -st ./user-Eighteen-exit.xlsx -er ./user-Eighteen-every-request.xlsx -s 1818181818 -g uniform -ming 30 -maxg 60' popens[userEighteenHost] = userEighteenHost.popen( userEighteenCommand.split()) sleep(1) userNineteenCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Nineteen -st ./user-Nineteen-exit.xlsx -er ./user-Nineteen-every-request.xlsx -s 1919191919 -g uniform -ming 30 -maxg 60' popens[userNineteenHost] = userNineteenHost.popen( userNineteenCommand.split()) sleep(1) userTwentyCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-Twenty -st ./user-Twenty-exit.xlsx -er ./user-Twenty-every-request.xlsx -s 2020202020 -g uniform -ming 30 -maxg 60' popens[userTwentyHost] = userTwentyHost.popen(userTwentyCommand.split()) sleep(1) userTwentyOneCommand = 'java -jar /home/sszwaczyk/WAT/PhD/impl/requests-generator/target/requests-generator-1.0-SNAPSHOT.jar -sf /home/sszwaczyk/WAT/PhD/impl/floodlight/scenarios/simple-polska/mininet/services.json -lf user-TwentyOne -st ./user-TwentyOne-exit.xlsx -er ./user-TwentyOne-every-request.xlsx -s 2121212121 -g uniform -ming 30 -maxg 60' popens[userTwentyOneHost] = userTwentyOneHost.popen( userTwentyOneCommand.split()) # CLI(net) info("Simulating for", simulationTime, "seconds\n") endTime = time() + simulationTime for h, line in pmonitor(popens, timeoutms=500): if h: info('<%s>: %s' % (h.name, line)) if time() >= endTime: for p in popens.values(): info('*** Stopping requests generators and services...\n') p.send_signal(SIGTERM) info('*** Stopping net...\n') net.stop() info('*** Stopping controller...\n') os.kill(proc.pid, signal.SIGTERM)
def treeTopo(): net = Mininet(controller=Controller) info('*** Adding controller\n') c0 = net.addController(name='c0', controller=RemoteController, ip='127.0.0.1', protocol='tcp', port=6653) info('*** Adding hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', mac='00:00:00:00:00:01', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', mac='00:00:00:00:00:02', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', mac='00:00:00:00:00:03', defaultRoute=None) h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', mac='00:00:00:00:00:04', defaultRoute=None) h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', mac='00:00:00:00:00:05', defaultRoute=None) h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', mac='00:00:00:00:00:06', defaultRoute=None) h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', mac='00:00:00:00:00:07', defaultRoute=None) info('*** Adding switches\n') s1 = net.addSwitch('s1', cls=OVSKernelSwitch) s2 = net.addSwitch('s2', cls=OVSKernelSwitch) s3 = net.addSwitch('s3', cls=OVSKernelSwitch) info('*** Creating links\n') s2h1 = {'bw': 1000} net.addLink(h1, s2, cls=TCLink, **s2h1) s2h2 = {'bw': 1000} net.addLink(h2, s2, cls=TCLink, **s2h2) s2h3 = {'bw': 1000} net.addLink(h3, s2, cls=TCLink, **s2h3) s2h4 = {'bw': 1000} net.addLink(h4, s2, cls=TCLink, **s2h4) s3h5 = {'bw': 1000} net.addLink(h5, s3, cls=TCLink, **s3h5) s3h6 = {'bw': 1000} net.addLink(h6, s3, cls=TCLink, **s3h6) s3h7 = {'bw': 1000} net.addLink(h7, s3, cls=TCLink, **s3h7) root = s1 layer1 = [s2, s3] for idx, l1 in enumerate(layer1): rootl1 = {'bw': 10000} net.addLink(root, l1) 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('*** Running CLI\n') CLI(net) info('*** Stopping network') net.stop()
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch) print "*** Creating nodes" car1 = net.addVehicle('car1', wlans=2, mac='00:00:00:00:00:01', ip='10.0.0.1/8', min_speed=1, max_speed=5) car2 = net.addVehicle('car2', wlans=2, mac='00:00:00:00:00:02', ip='10.0.0.2/8', min_speed=5, max_speed=10) car3 = net.addVehicle('car3', mac='00:00:00:00:00:03', ip='10.0.0.3/8', min_speed=10, max_speed=15) car4 = net.addVehicle('car4', mac='00:00:00:00:00:04', ip='10.0.0.4/8', min_speed=15, max_speed=20) car5 = net.addVehicle('car5', mac='00:00:00:00:00:05', ip='10.0.0.5/8', min_speed=15, max_speed=20) bs1 = net.addBaseStation('BS1', ssid='new-ssid1', mode='g', channel='1') bs2 = net.addBaseStation('BS2', ssid='new-ssid2', mode='g', channel='6') bs3 = net.addBaseStation('BS3', ssid='new-ssid3', mode='g', channel='11') c1 = net.addController('c1', controller=Controller) print "*** Associating and Creating links" net.addMesh(car1, ssid='mesh') net.addMesh(car2, ssid='mesh') net.addMesh(car3, ssid='mesh') net.addMesh(car4, ssid='mesh') net.addMesh(car5, ssid='mesh') net.addLink(bs1, bs2) net.addLink(bs1, bs3) print "*** Starting network" net.build() c1.start() bs1.start([c1]) bs2.start([c1]) bs3.start([c1]) """uncomment to plot graph""" net.plotGraph(max_x=500, max_y=500) """Number of Roads""" net.roads(4) """Seed""" net.seed(20) """Start Mobility""" net.startMobility(startTime=0) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()