Пример #1
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()

        act_all = action.action_output()
        act_all.port = ofp.OFPP_ALL
        act_ing = action.action_output()
        act_ing.port = ofp.OFPP_IN_PORT
        actions = [act_all, act_ing]

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")

            flow_mod = testutils.flow_msg_create(
                self,
                pkt,
                ing_port=ingress_port,
                action_list=actions,
                inst_app_flag=testutils.APPLY_ACTIONS_INSTRUCTION)
            pa_logger.info(flow_mod.show())

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, flow_mod)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            testutils.receive_pkt_check(self.dataplane, pkt, of_ports, [],
                                        self, pa_logger)
Пример #2
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) +
                           " all non-ingress ports")
            actions = []
            for egress_port in of_ports:
                act = action.action_output()
                if egress_port == ingress_port:
                    continue
                act.port = egress_port
                actions.append(act)
            request = testutils.flow_msg_create(
                self,
                pkt,
                ing_port=ingress_port,
                action_list=actions,
                inst_app_flag=testutils.APPLY_ACTIONS_INSTRUCTION)

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, request)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set(of_ports).difference([ingress_port])
            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports,
                                        [ingress_port], self, pa_logger)
Пример #3
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")

            request = testutils.flow_msg_create(self,
                                                pkt,
                                                ing_port=ingress_port,
                                                egr_port=ofp.OFPP_ALL)

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, request)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set(of_ports).difference([ingress_port])
            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports,
                                        [ingress_port], self, pa_logger)
Пример #4
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()
        
        act_all = action.action_output()
        act_all.port = ofp.OFPP_ALL
        act_ing = action.action_output()
        act_ing.port = ofp.OFPP_IN_PORT
        actions = [ act_all, act_ing]

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
        
            flow_mod = testutils.flow_msg_create(self, pkt, 
                                                 ing_port=ingress_port, 
                                                 action_list=actions, 
                                                 wildcards=~ofp.OFPFW_IN_PORT)
            flow_mod.buffer_id = 0xffffffff
            pa_logger.info(flow_mod.show())

            pa_logger.info("Inserting flow")
            rv = self.controller.message_send(flow_mod)
            self.assertTrue(rv != -1, "Error installing flow mod")
            testutils.do_barrier(self.controller)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            testutils.receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
                              pa_logger)
Пример #5
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()
        
        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")    
            actions = []
            for egress_port in of_ports:
                act = action.action_output()
                if egress_port == ingress_port:
                    act.port = ofp.OFPP_IN_PORT
                else:
                    act.port = egress_port
                actions.append(act)
            request = testutils.flow_msg_create(self, pkt, ingress_port, action_list=actions)
            request.buffer_id = 0xffffffff
            # pa_logger.info(request.show())

            pa_logger.info("Inserting flow")
            rv = self.controller.message_send(request)
            self.assertTrue(rv != -1, "Error installing flow mod")
            testutils.do_barrier(self.controller)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            testutils.receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
                              pa_logger)
Пример #6
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()

        act_all = action.action_output()
        act_all.port = ofp.OFPP_ALL
        act_ing = action.action_output()
        act_ing.port = ofp.OFPP_IN_PORT
        actions = [ act_all, act_ing]

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")

            flow_mod = testutils.flow_msg_create(self, pkt,
                                                 ing_port=ingress_port,
                                                 action_list=actions,
                                                 inst_app_flag=testutils.APPLY_ACTIONS_INSTRUCTION
                                                 )
            pa_logger.info(flow_mod.show())

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, flow_mod)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            testutils.receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
                              pa_logger)
Пример #7
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) +
                           " all non-ingress ports")
            actions = []
            for egress_port in of_ports:
                act = action.action_output()
                if egress_port == ingress_port:
                    continue
                act.port = egress_port
                actions.append(act)
            request = testutils.flow_msg_create(self, pkt, ing_port=ingress_port,
                                action_list=actions, inst_app_flag=testutils.APPLY_ACTIONS_INSTRUCTION)

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, request)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set(of_ports).difference([ingress_port])
            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
                              self, pa_logger)
Пример #8
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()
        match = parse.packet_to_flow_match(pkt)
        match.wildcards &= ~ofp.OFPFW_IN_PORT
        self.assertTrue(match is not None, 
                        "Could not generate flow match from pkt")
        act1 = action.action_output()
        act2 = action.action_output()

        for idx in range(len(of_ports)):
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            ingress_port = of_ports[idx]
            egress_port1 = of_ports[(idx + 1) % len(of_ports)]
            egress_port2 = of_ports[(idx + 2) % len(of_ports)]
            pa_logger.info("Ingress " + str(ingress_port) + 
                           " to egress " + str(egress_port1) + " and " +
                           str(egress_port2))

            match.in_port = ingress_port

            act1.port = egress_port1
            act2.port = egress_port2
            
            request = testutils.flow_msg_create(self, pkt, ingress_port, action_list=[act1, act2])
            request.buffer_id = 0xffffffff
            
            pa_logger.info("Inserting flow")
            rv = self.controller.message_send(request)
            self.assertTrue(rv != -1, "Error installing flow mod")
            testutils.do_barrier(self.controller)

            pa_logger.info("Sending packet to dp port " + 
                           str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set([egress_port1, egress_port2])
            no_ports = set(of_ports).difference(yes_ports)

            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports,
                              self, pa_logger)
Пример #9
0
    def runTest(self):

        # Config
        of_ports = pa_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port = of_ports[3]
        
        # Remove flows
        rc = nxm_delete_all_flows()
        self.assertEqual(rc, 0, "Failed to delete all flows")

        # Add entry with invalid arguments (wrong dl_type for a IPv4 packet)
        flow_match = "wildcards=none,dl_type=0x7000,nw_src=192.168.0.1"
        flow_acts = "apply:output=" + str(egr_port)
        rc = nxm_send_flow_mod_add(flow_match,flow_acts,pa_logger)
        self.assertEqual(rc, 0, "Failed to add flow entry")
       
	
        #Send IPv4 packet 

        pkt = testutils.simple_tcp_packet()

        pa_logger.info("Sending IPv4 packet to " + str(ing_port))
        pa_logger.debug("Data: " + str(pkt).encode('hex'))

        pkt = testutils.simple_tcp_packet()
        pa_logger.info("Sending IPv4 packet to " + str(ing_port))
        pa_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))
        
        #Should not receive packet
        exp_pkt = testutils.simple_tcp_packet()
	testutils.receive_pkt_check(self.dataplane, exp_pkt, [], of_ports, self,
                              pa_logger)

        #See flow match
        request_flow_stats()

#        rc = testutils.delete_all_flows(self.controller, pa_logger)
        rc = nxm_delete_all_flows()
        self.assertEqual(rc, 0, "Failed to delete all flows")
Пример #10
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()
        match_fields = testutils.packet_to_exact_flow_match(pkt)
        self.assertTrue(match_fields is not None,
                        "Could not generate flow match from pkt")
        act1 = action.action_output()
        act2 = action.action_output()

        for idx in range(len(of_ports)):
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            ingress_port = of_ports[idx]
            egress_port1 = of_ports[(idx + 1) % len(of_ports)]
            egress_port2 = of_ports[(idx + 2) % len(of_ports)]
            pa_logger.info("Ingress " + str(ingress_port) + " to egress " +
                           str(egress_port1) + " and " + str(egress_port2))

            act1.port = egress_port1
            act2.port = egress_port2
            request = testutils.flow_msg_create(
                self,
                pkt,
                ing_port=ingress_port,
                action_list=[act1, act2],
                inst_app_flag=testutils.APPLY_ACTIONS_INSTRUCTION)

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, request)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set([egress_port1, egress_port2])
            no_ports = set(of_ports).difference(yes_ports)

            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports,
                                        no_ports, self, pa_logger)
Пример #11
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()
#        match = parse.packet_to_flow_match(pkt)
#        match.wildcards &= ~ofp.OFPFW_IN_PORT
#        self.assertTrue(match is not None, 
#                        "Could not generate flow match from pkt")
#        act = action.action_output()

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
#            match.in_port = ingress_port
#
#            request = message.flow_mod()
#            request.match = match
#            request.buffer_id = 0xffffffff
#            act.port = ofp.OFPP_ALL
#            self.assertTrue(request.actions.add(act), 
#                            "Could not add ALL port action")
            request = testutils.flow_msg_create(self, pkt, ing_port=ingress_port, 
                                                egr_port=ofp.OFPP_ALL)
            # already done in flow_msg_create
            #pa_logger.info(request.show())

            pa_logger.info("Inserting flow")
            rv = self.controller.message_send(request)
            self.assertTrue(rv != -1, "Error installing flow mod")
            testutils.do_barrier(self.controller)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set(of_ports).difference([ingress_port])
            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
                              self, pa_logger)
Пример #12
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 2, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()
        match_fields = testutils.packet_to_exact_flow_match(pkt)
        self.assertTrue(match_fields is not None,
                        "Could not generate flow match from pkt")
        act1 = action.action_output()
        act2 = action.action_output()

        for idx in range(len(of_ports)):
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            ingress_port = of_ports[idx]
            egress_port1 = of_ports[(idx + 1) % len(of_ports)]
            egress_port2 = of_ports[(idx + 2) % len(of_ports)]
            pa_logger.info("Ingress " + str(ingress_port) +
                           " to egress " + str(egress_port1) + " and " +
                           str(egress_port2))

            act1.port = egress_port1
            act2.port = egress_port2
            request = testutils.flow_msg_create(self, pkt, ing_port=ingress_port,
                            action_list=[act1, act2], inst_app_flag=testutils.APPLY_ACTIONS_INSTRUCTION)

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, request)

            pa_logger.info("Sending packet to dp port " +
                           str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set([egress_port1, egress_port2])
            no_ports = set(of_ports).difference(yes_ports)

            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports,
                              self, pa_logger)
Пример #13
0
    def runTest(self):
        of_ports = pa_port_map.keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        pkt = testutils.simple_tcp_packet()

        for ingress_port in of_ports:
            rv = testutils.delete_all_flows(self.controller, pa_logger)
            self.assertEqual(rv, 0, "Failed to delete all flows")

            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")

            request = testutils.flow_msg_create(self, pkt, ing_port=ingress_port,
                                                egr_port=ofp.OFPP_ALL)

            pa_logger.info("Inserting flow")
            testutils.ofmsg_send(self, request)

            pa_logger.info("Sending packet to dp port " + str(ingress_port))
            self.dataplane.send(ingress_port, str(pkt))
            yes_ports = set(of_ports).difference([ingress_port])
            testutils.receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
                              self, pa_logger)
Пример #14
0
    def runTest(self):

        # Config
        of_ports = pa_port_map.keys()
        of_ports.sort()
        ing_port = of_ports[0]
        egr_port =   of_ports[3]
        
        # Remove flows
        rc = nxm_delete_all_flows()
#        rc = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")

        # Add entry match all 
	#sudo dpctl unix:/tmp/ofd -F nxm flow-mod cmd=add,table=0,idle=100 wildcards=none,in_port=1,hbh_ipv6 apply:output=4

        flow_match = "wildcards=none,hbh_ipv6,rh_ipv6"
        flow_acts = "apply:output=" + str(egr_port)

        rc = nxm_send_flow_mod_add(flow_match,flow_acts,pa_logger)
        self.assertEqual(rc, 0, "Failed to add flow entry")

	#Send IPv6 packet with Routing Header

        pkt = simple_ipv6_packet(EH = True,  EHpkt = scapy.IPv6ExtHdrRouting())

        pa_logger.info("Sending IPv6 RH packet to " + str(ing_port))
        pa_logger.debug("Data: " + str(pkt).encode('hex'))
        self.dataplane.send(ing_port, str(pkt))
        
        #Receive packet
        #exp_pkt = testutils.simple_tcp_packet()
	testutils.receive_pkt_check(self.dataplane, pkt, [], of_ports, self,
                              pa_logger)

        #See flow match
        request_flow_stats()
	
	#Send IPv6 packet with both Headers
        #pkt = simple_ipv6_packet()        
	pktv6 = simple_ipv6_packet(EH = True,  EHpkt = scapy.IPv6ExtHdrHopByHop()/scapy.IPv6ExtHdrRouting()) 
        print "Sending IPv6 HBH+RH packet to " + str(ing_port)
        pa_logger.info("Sending IPv6 HBH+RH packet to " + str(ing_port))
        pa_logger.debug("Data: " + str(pkt).encode('hex'))
        
	self.dataplane.send(ing_port, str(pktv6))


        #Receive packet
        #exp_pkt = simple_ipv6_packet()
        exp_pktv6 = simple_ipv6_packet(EH = True,  EHpkt = scapy.IPv6ExtHdrHopByHop()/scapy.IPv6ExtHdrRouting()) 

        testutils.receive_pkt_verify(self, egr_port, exp_pktv6)

        #See flow match
        request_flow_stats()
        
        #Remove flows
        rc = nxm_delete_all_flows()
#        rc = testutils.delete_all_flows(self.controller, pa_logger)
        self.assertEqual(rc, 0, "Failed to delete all flows")