コード例 #1
0
ファイル: actions.py プロジェクト: pred/oftest
    def runTest(self):
        ports = openflow_ports(3)
        in_port = ports[0]
        out_ports = ports[1:3]

        actions = [ofp.action.output(x) for x in out_ports]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
                table_id=test_param_get("table", 0),
                match=packet_to_flow_match(self, pkt),
                instructions=[
                    ofp.instruction.apply_actions(actions)],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)
        self.controller.message_send(request)

        do_barrier(self.controller)

        pktstr = str(pkt)

        logging.info("Sending packet, expecting output to ports %r", out_ports)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, out_ports)
コード例 #2
0
    def runTest(self):
        ports = openflow_ports(4)
        in_port = ports[0]
        out_ports = ports[1:4]

        actions = [ofp.action.output(x) for x in out_ports]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
            table_id=0,
            match=packet_to_flow_match(self, pkt),
            instructions=[ofp.instruction.apply_actions(actions)],
            buffer_id=ofp.OFP_NO_BUFFER,
            priority=1000)
        self.controller.message_send(request)

        do_barrier(self.controller)

        pktstr = str(pkt)

        logging.info("Sending packet, expecting output to ports %r", out_ports)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, out_ports)
コード例 #3
0
ファイル: route.py プロジェクト: jungwoo-lee/oftest
    def verify_modify(self, actions, pkt, exp_pkt):
        in_port, out_port = openflow_ports(2)
        print "in_port = "+str(in_port)
        print "out_port = "+str(out_port)

        actions = actions + [ofp.action.output(out_port)]
        ##actions = actions + [ofp.action.output(ofp.OFPP_CONTROLLER)]

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
                table_id=test_param_get("table", 0),
                match=packet_to_flow_match(self, pkt),
                instructions=[
                    ofp.instruction.apply_actions(actions)],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)
        self.controller.message_send(request)

        do_barrier(self.controller)

        logging.info("Sending packet, expecting output to port %d", out_port)
        time.sleep(5)
        self.dataplane.send(in_port, str(pkt))
        verify_packets(self, str(exp_pkt), [out_port])
コード例 #4
0
ファイル: actions.py プロジェクト: narayana1208/oftest
    def verify_modify(self, actions, pkt, exp_pkt):
        in_port, out_port = openflow_ports(2)

        actions = actions + [ofp.action.output(out_port)]

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
                table_id=0,
                match=packet_to_flow_match(self, pkt),
                instructions=[
                    ofp.instruction.apply_actions(actions)],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)
        self.controller.message_send(request)

        do_barrier(self.controller)

        logging.info("Sending packet, expecting output to port %d", out_port)
        self.dataplane.send(in_port, str(pkt))
        receive_pkt_check(self.dataplane, str(exp_pkt), [out_port],
                          set(openflow_ports()) - set([out_port]), self)
コード例 #5
0
ファイル: route.py プロジェクト: jungwoo-lee/oftest
    def runTest(self):
        #in_port, = openflow_ports(1)
        print "adding ports"
        in_port, out_port = openflow_ports(2)

        print "in_port = "+str(in_port)
        print "out_port = "+str(out_port)
        actions = [ofp.action.output(out_port)]

        #match = ofp.match([
        #                ofp.oxm.in_port(in_port)
        #                        ])
        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)
        #time.sleep(5)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
                table_id=test_param_get("table", 0),
                match=packet_to_flow_match(self, pkt[0]),
                #match=match,
                instructions=[
                    ofp.instruction.apply_actions(actions)],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)
        self.controller.message_send(request)

        do_barrier(self.controller)
        print "installing a flow..."
        #time.sleep(20)

        pktstr = str(pkt[0])

        print pktstr
        print pkt[1]
        logging.info("Sending packet, expecting output to port %d", out_port)
        #logging.info("Sending packet, expecting output to port %d", ofp.OFPP_CONTROLLER)
        self.dataplane.send(in_port, pktstr)
        print "sent the first packet."
        self.dataplane.send(in_port, pktstr)
        print "sent the second packet."
        self.dataplane.send(in_port, pktstr)
        print "sent the third packet."
        #time.sleep(20)
        #verify_packets(self, pktstr, [ofp.OFPP_CONTROLLER])
        verify_packets(self, pktstr, [out_port])
コード例 #6
0
ファイル: actions.py プロジェクト: lparkes/oftest
    def verify_modify(self, actions, pkt, exp_pkt):
        in_port, out_port = openflow_ports(2)

        actions = actions + [ofp.action.output(out_port)]

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        FuncUtils.flow_entry_install(self.controller,
                                     "flow_add",
                                     match=packet_to_flow_match(self, pkt),
                                     instructions=[ofp.instruction.apply_actions(actions)]
                                     )

        logging.info("Sending packet, expecting output to port %d", out_port)
        self.dataplane.send(in_port, str(pkt))
        verify_packets(self, str(exp_pkt), [out_port])
コード例 #7
0
    def verify_modify(self, actions, pkt, exp_pkt):
        in_port, out_port = openflow_ports(2)

        actions = actions + [ofp.action.output(out_port)]

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        FuncUtils.flow_entry_install(
            self.controller,
            "flow_add",
            match=packet_to_flow_match(self, pkt),
            instructions=[ofp.instruction.apply_actions(actions)])

        logging.info("Sending packet, expecting output to port %d", out_port)
        self.dataplane.send(in_port, str(pkt))
        verify_packets(self, str(exp_pkt), [out_port])
コード例 #8
0
ファイル: actions.py プロジェクト: lparkes/oftest
    def runTest(self):
        in_port, out_port = openflow_ports(2)

        actions = [ofp.action.output(out_port)]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        FuncUtils.flow_entry_install(self.controller,
                                     "flow_add",
                                     match=packet_to_flow_match(self, pkt),
                                     instructions=[ofp.instruction.write_actions(actions)]
                                     )

        pktstr = str(pkt)

        logging.info("Sending packet, expecting output to port %d", out_port)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, [out_port])
コード例 #9
0
    def runTest(self):
        in_port, out_port = openflow_ports(2)

        actions = [ofp.action.output(out_port)]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        FuncUtils.flow_entry_install(
            self.controller,
            "flow_add",
            match=packet_to_flow_match(self, pkt),
            instructions=[ofp.instruction.write_actions(actions)])

        pktstr = str(pkt)

        logging.info("Sending packet, expecting output to port %d", out_port)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, [out_port])
コード例 #10
0
    def verify_modify(self, actions, pkt, exp_pkt):
        in_port, out_port = openflow_ports(2)

        actions = actions + [ofp.action.output(out_port)]

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
            table_id=0,
            match=packet_to_flow_match(self, pkt),
            instructions=[ofp.instruction.apply_actions(actions)],
            buffer_id=ofp.OFP_NO_BUFFER,
            priority=1000)
        self.controller.message_send(request)

        do_barrier(self.controller)

        logging.info("Sending packet, expecting output to port %d", out_port)
        self.dataplane.send(in_port, str(pkt))
        verify_packets(self, str(exp_pkt), [out_port])
コード例 #11
0
ファイル: actions.py プロジェクト: lparkes/oftest
    def runTest(self):
        ports = openflow_ports(4)

        in_port = ports[0]
        out_ports = ports[1:4]

        actions = [ofp.action.output(x) for x in out_ports]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        FuncUtils.flow_entry_install(self.controller,
                                     "flow_add",
                                     match=packet_to_flow_match(self, pkt),
                                     instructions=[ofp.instruction.apply_actions(actions)]
                                     )
        logging.info("Sending packet, expecting output to ports %r", out_ports)
        pktstr = str(pkt)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, out_ports)
コード例 #12
0
    def runTest(self):
        ports = openflow_ports(4)

        in_port = ports[0]
        out_ports = ports[1:4]

        actions = [ofp.action.output(x) for x in out_ports]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        FuncUtils.flow_entry_install(
            self.controller,
            "flow_add",
            match=packet_to_flow_match(self, pkt),
            instructions=[ofp.instruction.apply_actions(actions)])
        logging.info("Sending packet, expecting output to ports %r", out_ports)
        pktstr = str(pkt)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, out_ports)
コード例 #13
0
    def runTest(self):
        logging.info("Running Testcase 100.30 output to multiple ports")
        ports = openflow_ports(4)
        in_port = ports[0]
        out_ports = ports[1:4]
        match = ofp.match([
            ofp.oxm.eth_type(0x0800)
        ])
        actions = [ofp.action.output(x) for x in out_ports]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
                table_id=test_param_get("table", 0),
                #match=packet_to_flow_match(self, pkt),
                match = match,
                instructions=[
                    ofp.instruction.apply_actions(actions)],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=1000)
        self.controller.message_send(request)
        logging.info("Inserting a flow to forwarded packet to port %r", out_ports)
        reply, _ = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=3)
        self.assertIsNone(reply, "Switch generated an error when inserting flow")
        #logging.info("Switch generated an error")
        do_barrier(self.controller)

        pktstr = str(pkt)

        logging.info("Sending packet, expecting output to ports %r", out_ports)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, out_ports)
コード例 #14
0
    def runTest(self):
        logging.info("Running Testcase 100.30 output to multiple ports")
        ports = openflow_ports(4)
        in_port = ports[0]
        out_ports = ports[1:4]
        match = ofp.match([ofp.oxm.eth_type(0x0800)])
        actions = [ofp.action.output(x) for x in out_ports]

        pkt = simple_tcp_packet()

        logging.info("Running actions test for %s", pp(actions))

        delete_all_flows(self.controller)

        logging.info("Inserting flow")
        request = ofp.message.flow_add(
            table_id=test_param_get("table", 0),
            #match=packet_to_flow_match(self, pkt),
            match=match,
            instructions=[ofp.instruction.apply_actions(actions)],
            buffer_id=ofp.OFP_NO_BUFFER,
            priority=1000)
        self.controller.message_send(request)
        logging.info("Inserting a flow to forwarded packet to port %r",
                     out_ports)
        reply, _ = self.controller.poll(exp_msg=ofp.OFPT_ERROR, timeout=3)
        self.assertIsNone(reply,
                          "Switch generated an error when inserting flow")
        #logging.info("Switch generated an error")
        do_barrier(self.controller)

        pktstr = str(pkt)

        logging.info("Sending packet, expecting output to ports %r", out_ports)
        self.dataplane.send(in_port, pktstr)
        verify_packets(self, pktstr, out_ports)