Пример #1
0
 def __init__(self, connection):
     self.tcprules = {}
     self.udprules = {}
     self.icmprules = {}
     self.arprules = {}
     self.DNSpool = (IPAddr('100.0.0.25'), )
     self.Webpool = (IPAddr('100.0.0.45'), )
     self.Publicpool = (IPAddr('100.0.0.12'), IPAddr('100.0.0.11'))
     self.Privatepool = (IPAddr('100.0.0.1'), )
     LearningSwitch.__init__(self, connection, False)
Пример #2
0
 def _handle_ConnectionUp(self,event):
     ConnectionUp(event.connection,event.ofp)
     #log.info("Switch %s has come up.",dpid_to_str(event.dpid))
     if event.dpid in [1,2,3,4,5]:
        LearningSwitch(event.connection,False)
     elif event.dpid == 6:
        Firewall(event.connection)
     elif event.dpid == 7:
        Firewall(event.connection)
     else:
        LearningSwitch(event.connection,False)
        log.info("Not supported Switch")
Пример #3
0
    def _handle_ConnectionUp(self, event):

        data_path_id = dpid_to_str(event.dpid)
        log.debug("Handling the connection up event for DPID : %s" %
                  data_path_id)
        if (data_path_id == "00-00-00-00-02-01"):
            LearningSwitch(event.connection, False)
Пример #4
0
    def _handle_ConnectionUp(self, event):
        dpid = event.dpid

        if dpid == 1 or dpid == 2 or dpid == 3 or dpid == 4 or dpid == 5:
            LearningSwitch(event.connection, False)

        elif dpid == 6:
            task1_FireWall6(event.connection)

        elif dpid == 7:
            task1_FireWall7(event.connection)

        elif dpid == 8:
            os.system(
                'sudo /usr/local/bin/click /home/click/ik2220-assign-phase2-team6/application/nfv/lb1.click &'
            )

        elif dpid == 9:
            os.system(
                'sudo /usr/local/bin/click /home/click/ik2220-assign-phase2-team6/application/nfv/lb2.click &'
            )

        elif dpid == 10:
            os.system(
                'sudo /usr/local/bin/click /home/click/ik2220-assign-phase2-team6/application/nfv/ids.click &'
            )

        elif dpid == 11:
            os.system(
                'sudo /usr/local/bin/click /home/click/ik2220-assign-phase2-team6/application/nfv/napt.click &'
            )
Пример #5
0
    def _handle_ConnectionUp(self, event):
        switch_id = dpid_to_str(event.dpid)
        print("Switch came up", switch_id)

        #Switches
        if (
                #Switch 1
                switch_id in "00-00-00-00-00-01"
                #Switch 2
                or switch_id in "00-00-00-00-00-02"
                #Switch 3
                or switch_id in "00-00-00-00-00-03"
                #Switch 4
                or switch_id in "00-00-00-00-00-04"
                #Switch 5
                or switch_id in "00-00-00-00-00-05"):
            print("Network entity is a switch", switch_id)
            LearningSwitch(event.connection, False)

        #Firewall 1
        elif switch_id in "00-00-00-00-00-15":
            print("Network entity is a Firewall Type 1", switch_id)
            firewall1(event.connection, False)

        #Firewall 2
        elif switch_id in "00-00-00-00-00-16":
            print("Network entity is a Firewall Type 2", switch_id)
            firewall2(event.connection, False)

        #Load balancer 1 for DNS servers
        elif switch_id in "00-00-00-00-00-0b":
            print("Network entity is Load balancer DNS Servers", switch_id)
            Popen([
                "click", path + "lb.click", "Name=lb1", "MAC0=03", "port=53",
                "proto=udp", "MAC1=04", "VIP=100.0.0.25", "DIP0=100.0.0.20",
                "DIP1=100.0.0.21", "DIP2=100.0.0.22"
            ])

        #Load balancer 2 for Web servers
        elif switch_id in "00-00-00-00-00-0c":
            print("Network entity is Load Balancer Web Servers", switch_id)
            Popen([
                "click", path + "lb.click", "Name=lb2", "MAC0=05", "port=80",
                "proto=tcp", "MAC1=06", "VIP=100.0.0.45", "DIP0=100.0.0.40",
                "DIP1=100.0.0.41", "DIP2=100.0.0.42"
            ])

        #IDS server
        elif switch_id in "00-00-00-00-00-0d":
            print("Network entity is IDS", switch_id)
            Popen(["click", path + "ids.click"])

        #NAPT
        elif switch_id in "00-00-00-00-00-1f":
            print("Network entity is NAPT", switch_id)
            Popen(["click", path + "napt.click"])

        #Unknown elements
        else:
            log.debug("Network entity is an unknown entity", switch_id)
	def _handle_ConnectionUp (self, event):
		dpid = event.dpid

		if(dpid == 2 or dpid == 9):
			log.debug("Firewall triggered:")
			if(dpid == 2):
				LearningFireWall1(event.connection)
				log.debug("This is firewall 1.")
			else:
				LearningFireWall2(event.connection)
				log.debug("This is firewall 2.")
		
		elif (dpid == 1 or dpid == 3 or dpid == 5 or dpid == 8 or dpid == 11):
			LearningSwitch(event.connection, False)
			log.debug("Switch triggered.")
		
		elif (dpid == 4):
			#LearningSwitch(event.connection, False)
			Popen(["sudo","/usr/local/bin/click","/home/click/ik2220-assign-phase2-team3/application/nfv/lb.click","Name=s4","MAC0=03","port=53","proto=udp","MAC1=04","VIP=100.0.0.25","DIP0=100.0.0.20","DIP1=100.0.0.21","DIP2=100.0.0.22","Report=lb1"])
			log.debug("Load balancer DNS Servers triggered.",dpid)
		elif (dpid == 7):
			#LearningSwitch(event.connection, False)
			Popen(["sudo","/usr/local/bin/click","/home/click/ik2220-assign-phase2-team3/application/nfv/lb.click","Name=s7","MAC0=05","port=80","proto=tcp","MAC1=06","VIP=100.0.0.45","DIP0=100.0.0.40","DIP1=100.0.0.41","DIP2=100.0.0.42","Report=lb2"])
			log.debug("Load Balancer Web Servers triggered.")
		elif (dpid == 6):
			#LearningSwitch(event.connection, False)
			Popen(["sudo","/usr/local/bin/click","/home/click/ik2220-assign-phase2-team3/application/nfv/ids.click"])
			log.debug("IDS triggered.")
		elif (dpid == 10):
			#Popen(["click",path+"napt.click"])
			#LearningSwitch(event.connection, False)
			Popen(["sudo","/usr/local/bin/click","/home/click/ik2220-assign-phase2-team3/application/nfv/napt.click"])
			log.debug("NAPT triggered.")
		else:
			log.debug("Network entity is an unknown entity", dpid)
Пример #7
0
 def _handle_ConnectionUp(self, event):
     global rPath
     log.debug("Connection %s" % (event.connection, ))
     log.debug("report rPath %s ", rPath)
     #FirewallSwitch(event.connection, self.transparent)
     log.debug("###################DPID#############:%s ",
               dpid_to_str(event.connection.dpid))
     # Allow arp based on dl_type for in_port 1 to output 2
     #if dpid_to_str(event.connection.dpid) == "00-00-00-00-00-01":
     #	return
     if dpid_to_str(event.connection.dpid) == "00-00-00-00-00-0a":
         fw1 = FW1(event.connection, self.transparent)
         fw1.AddRule(event.connection)
     elif dpid_to_str(event.connection.dpid) == "00-00-00-00-00-0b":
         fw2 = FW2(event.connection, self.transparent)
         fw2.AddRule(event.connection)
     if dpid_to_str(event.connection.dpid) == "00-00-00-00-00-08":
         os.system(
             'sudo /usr/local/bin/click /opt/ik2220/pox/ext/ids.click rPath='
             + rPath + ' &')
     elif dpid_to_str(event.connection.dpid) == "00-00-00-00-00-06":
         os.system(
             'sudo /usr/local/bin/click /opt/ik2220/pox/ext/lb_update.click LB=lb6 VIP=100.0.0.25 prt_n=53 prt=udp port1=eth2 port2=eth1 DIP_1=100.0.0.20 DIP_2=100.0.0.21 DIP_3=100.0.0.22 rPath='
             + rPath + ' &')
     elif dpid_to_str(event.connection.dpid) == "00-00-00-00-00-07":
         os.system(
             'sudo /usr/local/bin/click /opt/ik2220/pox/ext/lb_update.click LB=lb7 VIP=100.0.0.45 prt_n=80 prt=tcp port1=eth1 port2=eth2 DIP_1=100.0.0.40 DIP_2=100.0.0.41 DIP_3=100.0.0.42 rPath='
             + rPath + ' &')
     elif dpid_to_str(event.connection.dpid) == "00-00-00-00-00-09":
         #os.system('sudo /usr/local/bin/click /opt/ik2220/click/n9.click &')
         os.system(
             'sudo /usr/local/bin/click /opt/ik2220/pox/ext/napt.click rPath='
             + rPath + ' &')
     else:
         LearningSwitch(event.connection, False)
Пример #8
0
 def _handle_ConnectionUp(self, event):
     dpid = event.dpid
     if dpid == 10:
         Firewall_1(event.connection)
     elif dpid == 11:
         Firewall_2(event.connection)
     elif dpid == 6:
         os.system('sudo /usr/local/bin/click addr=100.0.0.25 \
                                              eth_server=lb6-eth2\
                                              eth_client=lb6-eth1\
                                              dstaddr1=100.0.0.20\
                                              dstaddr2=100.0.0.21\
                                              dstaddr3=100.0.0.22\
                                              IPtype=udp\
                                              portnum=53\
                                              filename=lb1.report\
                                              nfv/lb.click &')
     elif dpid == 7:
         os.system('sudo /usr/local/bin/click addr=100.0.0.45 \
                                              eth_server=lb7-eth2\
                                              eth_client=lb7-eth1\
                                              dstaddr1=100.0.0.40\
                                              dstaddr2=100.0.0.41\
                                              dstaddr3=100.0.0.42\
                                              IPtype=tcp\
                                              portnum=80\
                                              filename=lb2.report\
                                              nfv/lb.click &')
     elif dpid == 8:
         os.system('sudo /usr/local/bin/click ~/assignment/nfv/ids.click &')
     else:
         LearningSwitch(event.connection, self)
     print("Switch %s has come up." % dpid_to_str(event.dpid))
Пример #9
0
 def _handle_ConnectionUp(event):
     if dpid_to_str(event.dpid) == "00-00-00-00-00-01":
         core.getLogger().info("Connection %s" % (event.connection, ))
         Firewall(event.connection, False)
     elif dpid_to_str(event.dpid) == "00-00-00-00-00-02":
         core.getLogger().info("Connection %s" % (event.connection, ))
         Firewall(event.connection, False)
     elif dpid_to_str(event.dpid) == "00-00-00-00-00-05":
         core.getLogger().info("Connection %s" % (event.connection, ))
         LearningSwitch(event.connection, False)
     elif dpid_to_str(event.dpid) == "00-00-00-00-00-03":
         core.getLogger().info("Connection %s" % (event.connection, ))
         LearningSwitch(event.connection, False)
         #LoadBalancer(event.connection)
     elif dpid_to_str(event.dpid) == "00-00-00-00-00-04":
         core.getLogger().info("Connection %s" % (event.connection, ))
         LearningSwitch(event.connection, False)
Пример #10
0
 def _handle_ConnectionUp(self, event):
     dpid = event.dpid
     if dpid == 10:
         Firewall_1(event.connection)
     elif dpid == 11:
         Firewall_2(event.connection)
     else:
         LearningSwitch(event.connection, self)
     print("Switch %s has come up." % dpid_to_str(event.dpid))
Пример #11
0
    def _handle_ConnectionUp(self, event):
        dpid = event.dpid

        if dpid == 1 or dpid == 2 or dpid == 3 or dpid == 4 or dpid == 5 or dpid == 8 or dpid == 9 or dpid == 10 or dpid == 11:
            LearningSwitch(event.connection, False)

        elif dpid == 6:
            task1_FireWall6(event.connection)

        elif dpid == 7:
            task1_FireWall7(event.connection)
Пример #12
0
    def _handle_ConnectionUp(self, event):

        data_path_id = dpid_to_str(event.dpid)
        log.debug("Handling the connection up event for DPID : %s" %
                  data_path_id)
        if (data_path_id == "00-00-00-00-02-01"
                or data_path_id == "00-00-00-00-02-02"):
            LearningSwitch(event.connection, False)
        elif (data_path_id == "00-00-00-00-02-03"):
            log.debug("Invoking Firewall 1")
            firewall(event.connection, False, 1)
    def _handle_ConnectionUp(self, event):
        dpid = event.dpid

        if dpid == 1 or dpid == 3 or dpid == 4 or dpid == 5 or dpid == 6 or dpid == 7 or dpid == 8 or dpid == 10 or dpid == 11:
            LearningSwitch(event.connection, False)

        elif dpid == 2:
            LearningFireWall1(event.connection)

        elif dpid == 9:
            LearningFireWall2(event.connection)
        else:
            print("Unknown device.")
Пример #14
0
    def _handle_ConnectionUp(event):
        global _dpid
        if _dpid is None:
            log.info("IP Load Balancer Ready.")
            core.registerNew(iplb, event.connection, IPAddr(ip), servers)
            _dpid = event.dpid
        if event.dpid != ignore_dpid:
            core.getLogger().info("Connection %s" % (event.connection, ))
            LearningSwitch(event.connection, False)

        if _dpid != event.dpid:
            log.warn("Ignoring switch %s", event.connection)
        else:
            log.info("Load Balancing on %s", event.connection)

            # Gross hack
            core.iplb.con = event.connection
            event.connection.addListeners(core.iplb)
    def _handle_ConnectionUp(event):
        global _dpid
        if _dpid is None:
            _dpid = event.dpid

        if _dpid != event.dpid:
            log.warn("Ignoring switch %s", event.connection)
            LearningSwitch(event.connection, False)
        else:
            if not core.hasComponent('iplb'):
                # Need to initialize first...
                core.registerNew(iplb, event.connection, IPAddr(ip), servers)
                #log.info("DPID:", _dpid)
                log.info("IP Load Balancer Ready.")
            log.info("Load Balancing on %s", event.connection)

            core.iplb.con = event.connection
            event.connection.addListeners(core.iplb)
Пример #16
0
    def _handle_ConnectionUp(self, event):
        if event.dpid == self.DPID_L2_SWITCH_CLIENTS or \
           event.dpid == self.DPID_L2_SWITCH_SERVERS:
            # We make the switch which is connected by the clients (servers)
            # a learning switch so that the clients (servers) can communicate
            # with each other.
            # The switch is named 's1' ('s3') in Mininet.
            LearningSwitch(event.connection, False)
            log.debug('Learning switch %d' % event.dpid)
        elif event.dpid == self.DPID_BALANCER:
            # We make the switch which is connected by the servers a load-balancer.
            # The switch is named 's2' in Mininet.
            if self.balancer is None:
                self.balancer = LoadBalancer(1, 2)

            self.balancer.connect(event.connection)

            log.debug('Balancer switch %d' % event.dpid)
        else:
            log.error('Unrecognized switch (dpid = %d)' % event.dpid)
Пример #17
0
	def _handle_ConnectionUp(self,event):

		dpid = event.dpid

		#log.debug("Switch %s has come up.", dpid_to_str(dpid))
		#LearningSwitch(event.connection,False)



        # switch sw1 and sw3 are regular learning switch
		if dpid == 1 or dpid ==3:
			log.debug("Switch %s has come up.", dpid_to_str(dpid))
			LearningSwitch(event.connection,False)

		# firewall 
		
		elif dpid == 6:
		
			log.debug("Firewall %s has come up.", dpid_to_str(dpid))
			Firewall(event.connection)
Пример #18
0
        def _handle_ConnectionUp(event):
            global _dpid, LBinitDone

            # if event.dpid is not same as provided LB's dpid, start learning switch
            if _dpid != event.dpid:
                log.warn("NOT LB switch %s. Will run learning mode",
                         event.connection)
                LearningSwitch(event.connection, False)
            else:
                # this is LB's switch. init if not done already
                if (LBinitDone != 1):
                    log.info("IP Load Balancer Ready.")
                    core.registerNew(iplb, event.connection, IPAddr(ip),
                                     servers, weights)
                    LBinitDone = 1

                log.info("Load Balancing on %s", event.connection)

                # Gross hack
                core.iplb.con = event.connection
                event.connection.addListeners(core.iplb)
Пример #19
0
	def _handle_ConnectionUp(self,event):

		dpid = event.dpid
		#LearningSwitch(event.connection,False)

		#log.debug("Switch %s has come up.", dpid_to_str(dpid))
		#LearningSwitch(event.connection,False)

		if dpid == 9:
			log.debug("Switch %s has come up." % (dpid_to_str(dpid)))
			os.system('sudo /usr/local/bin/click nfv/task3/lb2.click &')
			#LearningSwitch(event.connection,False)

		elif dpid ==8:
			log.debug("Switch %s has come up.", dpid_to_str(dpid))
			os.system('sudo /usr/local/bin/click nfv/task3/lb1.click &')

		elif dpid == 11:
			log.debug("Switch %s has come up.", dpid_to_str(dpid))
			os.system('sudo /usr/local/bin/click nfv/task3/napt.click &')

		elif dpid == 6:
			log.debug("Switch %s has come up.", dpid_to_str(dpid))
			Firewall1(event.connection)

		
		elif dpid == 7:
			log.debug("Switch %s has come up.", dpid_to_str(dpid))
			Firewall2(event.connection)

		elif dpid == 10:
			log.debug("Switch %s has come up.", dpid_to_str(dpid))
			os.system('sudo /usr/local/bin/click nfv/task3/ids.click &')


			

		else :
			log.debug("Switch %s has come up.", dpid_to_str(dpid))
			LearningSwitch(event.connection,False)
Пример #20
0
        def _handle_ConnectionUp(event):
            global _dpid, LBinitDone
            # if _dpid is None:
            # log.info("IP Load Balancer Ready.")
            # core.registerNew(iplb, event.connection, IPAddr(ip), servers)
            # _dpid = event.dpid

            if _dpid != event.dpid:
                log.warn("NOT LB switch %s. Will run learning mode",
                         event.connection)
                LearningSwitch(event.connection, False)
            else:
                if (LBinitDone != 1):
                    log.info("IP Load Balancer Ready.")
                    core.registerNew(iplb, event.connection, IPAddr(ip),
                                     servers)
                    LBinitDone = 1

                log.info("Load Balancing on %s", event.connection)

                # Gross hack
                core.iplb.con = event.connection
                event.connection.addListeners(core.iplb)
Пример #21
0
 def __init__(self, connection):
     #initial rule
     LearningSwitch.__init__(self, connection, False)
Пример #22
0
    def _handle_ConnectionUp(self, event):

        log.debug("Switch %s has come up.", dpid_to_str(event.dpid))

        LearningSwitch(event.connection, False)
Пример #23
0
	def __init__ (self, connection):
		LearningSwitch.__init__(self, connection, False)
Пример #24
0
 def __init__(self,connection):
     LearningSwitch.__init__(self,connection,False)
     log.info("Created Firewall")