コード例 #1
0
    def runTest(self):
        print "Test queue report Quota"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)
        config = SwitchConfig(self, params)
        bind_postcard_pkt()  # jsut to parse report
        bind_mirror_on_drop_pkt()

        pkt_in = simple_tcp_packet(eth_dst=params.mac_self,
                                   eth_src=params.mac_nbr[0],
                                   ip_dst=params.ipaddr_nbr[1],
                                   ip_src=params.ipaddr_nbr[0],
                                   ip_id=105,
                                   ip_ttl=64,
                                   pktlen=256)

        exp_pkt_out = simple_tcp_packet(eth_dst=params.mac_nbr[1],
                                        eth_src=params.mac_self,
                                        ip_dst=params.ipaddr_nbr[1],
                                        ip_src=params.ipaddr_nbr[0],
                                        ip_id=105,
                                        ip_ttl=63,
                                        pktlen=256)

        input_port = swports[0]

        exp_dod_inner = mod_report(packet=pkt_in,
                                   switch_id=SID,
                                   ingress_port=swports[0],
                                   egress_port=swports[1],
                                   queue_id=0,
                                   drop_reason=71)  # drop traffic manager

        exp_dod_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_MOD,
            dropped=1,
            congested_queue=0,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_dod_inner)

        exp_e2e_inner_1 = postcard_report(packet=exp_pkt_out,
                                          switch_id=SID,
                                          ingress_port=swports[0],
                                          egress_port=swports[1],
                                          queue_id=0,
                                          queue_depth=0,
                                          egress_tstamp=0)

        exp_e2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_e2e_inner_1)

        queue_report_enabled = False
        mod_enabled = False
        # ignore changes for this test
        self.client.switch_api_dtel_latency_quantization_shift(
            device=device, quant_shift=high_quantization_shift)
        try:
            # enable dod
            # Don't generate DoD on queue we don't monitor and is not in MoD
            # watchlist
            dtel_checkDoD(self, swports[0], swports[1],
                          swports[params.report_ports[0]], pkt_in, exp_pkt_out,
                          False)
            print "Pass no DoD if no queue report or MoD"

            # enable mod
            self.client.switch_api_dtel_drop_report_enable(device)
            dtel_checkDoD(self, swports[0], swports[1],
                          swports[params.report_ports[0]], pkt_in, exp_pkt_out,
                          False)
            print "Pass no DoD if no queue report or MoD"

            # add entry without dod
            ap = switcht_twl_drop_params_t(report_queue_tail_drops=False)
            self.client.switch_api_dtel_drop_watchlist_entry_create(
                device, twl_kvp, priority=1, watch=True, action_params=ap)
            mod_enabled = True
            dtel_checkDoD(self, swports[0], swports[1],
                          swports[params.report_ports[0]], pkt_in, exp_pkt_out,
                          False)
            print "Pass no DoD if no queue report and Dod=false in MoD watchlist"

            # add entry with dod
            ap = switcht_twl_drop_params_t(report_queue_tail_drops=True)
            self.client.switch_api_dtel_drop_watchlist_entry_update(
                device, twl_kvp, priority=1, watch=True, action_params=ap)
            dtel_checkDoD(self, swports[0], swports[1],
                          swports[params.report_ports[0]], pkt_in, exp_pkt_out,
                          True, exp_dod_pkt)
            print "Pass get DoD if no queue report and Dod in MoD watchlist"

            if test_param_get('target') == 'asic-model':
                self.client.switch_api_dtel_queue_report_create(
                    device, swports[1], 0, hex_to_i32(0xfff),
                    hex_to_i32(0xffffffff), 1024, True)
                queue_report_enabled = True
                exp_dod_pkt[DTEL_REPORT_HDR].congested_queue = 1
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                print "Pass get DoD if queue report and Dod in MoD watchlist"
                quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                    device, swports[1], 0)
                self.assertTrue(quota == 1023,
                                "Remaining quota is not correct")

                ap = switcht_twl_drop_params_t(report_queue_tail_drops=False)
                self.client.switch_api_dtel_drop_watchlist_entry_update(
                    device, twl_kvp, priority=1, watch=True, action_params=ap)
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                print "Pass get DoD if queue report and Dod=false in MoD watchlist"

                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_DROP_REPORT, 5)
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                print "Pass change MoD DSCP"

                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_Q_REPORT_TAIL_DROP, 3)
                exp_dod_pkt[IP].tos = 3 << 2
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                print "Pass change DoD DSCP"

                exp_dod_pkt[IP].tos = 0
                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_Q_REPORT_TAIL_DROP, 0)
                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_DROP_REPORT, 0)

                self.client.switch_api_dtel_queue_report_update(
                    device, swports[1], 0, hex_to_i32(0xfff),
                    hex_to_i32(0xffffffff), 1, True)
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                send_packet(self, swports[0], str(pkt_in))
                verify_packet(self, exp_pkt_out, swports[1])
                verify_postcard_packet(self, exp_e2e_pkt,
                                       swports[params.report_ports[0]])
                verify_no_other_packets(self)
                print "Pass queue report if quota is finished after prvious DoD and DoD=false in MOD watchlist"

                self.client.switch_api_dtel_queue_report_update(
                    device, swports[1], 0, 0, 0, 1, True)
                send_packet(self, swports[0], str(pkt_in))
                verify_packet(self, exp_pkt_out, swports[1])
                verify_postcard_packet(self, exp_e2e_pkt,
                                       swports[params.report_ports[0]])
                verify_no_other_packets(self)
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, None, 8)
                print "Pass no DoD if quota is finished and DoD=false in MOD watchlist"

                ap = switcht_twl_drop_params_t(report_queue_tail_drops=True)
                self.client.switch_api_dtel_drop_watchlist_entry_update(
                    device, twl_kvp, priority=1, watch=True, action_params=ap)
                exp_dod_pkt[DTEL_REPORT_HDR].congested_queue = 0
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                print "Pass get DoD if quota is finished and DoD in MOD watchlist"

                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_Q_REPORT_TAIL_DROP, 3)
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                print "Pass change DoD DSCP"

                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_DROP_REPORT, 5)
                exp_dod_pkt[IP].tos = 5 << 2
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                print "Pass change MoD DSCP"
                exp_dod_pkt[IP].tos = 0
                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_Q_REPORT_TAIL_DROP, 0)
                self.client.switch_api_dtel_event_set_dscp(
                    device, SWITCH_DTEL_EVENT_TYPE_DROP_REPORT, 0)

                self.client.switch_api_dtel_queue_report_update(
                    device, swports[1], 0, hex_to_i32(0xfff),
                    hex_to_i32(0xffffffff), 1, False)
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                    device, swports[1], 0)
                self.assertTrue(quota == 1, "Remaining quota is not correct")
                print "Pass get DoD if DoD=false in qreport and DoD in MOD watchlist"

                mod_enabled = False
                self.client.switch_api_dtel_drop_watchlist_entry_delete(
                    device=device, twl_kvp=twl_kvp)
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, False)
                print "Pass no DoD if DoD=false in qreport and DoD=false in MOD watchlist"

                self.client.switch_api_dtel_queue_report_update(
                    device, swports[1], 0, hex_to_i32(0xfff),
                    hex_to_i32(0xffffffff), 1024, True)
                exp_dod_pkt[DTEL_REPORT_HDR].congested_queue = 1
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, True, exp_dod_pkt)
                quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                    device, swports[1], 0)
                self.assertTrue(quota == 1023,
                                "Remaining quota is not correct")
                print "Pass get DoD if renable DoD in qreport and no MOD watchlist"

                self.client.switch_api_dtel_queue_report_delete(
                    device, swports[1], 0)
                queue_report_enabled = False
                dtel_checkDoD(self, swports[0], swports[1],
                              swports[params.report_ports[0]], pkt_in,
                              exp_pkt_out, False)
                print "Pass no DoD if remove queue report and no mod in MOD watchlist"

        finally:
            print "Test Cleanup"
            split_mirror_on_drop_pkt()
            split_postcard_pkt()
            if queue_report_enabled:
                self.client.switch_api_dtel_queue_report_delete(
                    device, swports[1], 0)
            self.client.switch_api_dtel_drop_report_disable(device)
            self.client.switch_api_dtel_event_set_dscp(
                device, SWITCH_DTEL_EVENT_TYPE_Q_REPORT_TAIL_DROP, 0)
            self.client.switch_api_dtel_event_set_dscp(
                device, SWITCH_DTEL_EVENT_TYPE_DROP_REPORT, 0)
            if mod_enabled:
                self.client.switch_api_dtel_drop_watchlist_entry_delete(
                    device=device, twl_kvp=twl_kvp)
            config.cleanup(self)
コード例 #2
0
    def runTest(self):
        print "Test queue report Change"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)
        config = SwitchConfig(self, params)
        bind_postcard_pkt()  # jsut to parse report

        payload = 'int l45'
        # make input frame to inject to sink
        pkt = simple_udp_packet(eth_dst=params.mac_self,
                                eth_src=params.mac_nbr[0],
                                ip_id=108,
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_ttl=64,
                                udp_sport=101,
                                with_udp_chksum=False,
                                pktlen=256,
                                udp_payload=payload)

        exp_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                    eth_src=params.mac_self,
                                    ip_dst=params.ipaddr_nbr[1],
                                    ip_src=params.ipaddr_nbr[0],
                                    ip_id=108,
                                    ip_ttl=63,
                                    pktlen=256,
                                    udp_sport=101,
                                    with_udp_chksum=False,
                                    udp_payload=payload)

        exp_e2e_inner_1 = postcard_report(packet=exp_pkt,
                                          switch_id=SID,
                                          ingress_port=swports[0],
                                          egress_port=swports[1],
                                          queue_id=0,
                                          queue_depth=0,
                                          egress_tstamp=0)

        exp_e2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_e2e_inner_1)

        exp_mod_inner_1 = mod_report(packet=exp_pkt,
                                     switch_id=SID,
                                     ingress_port=swports[0],
                                     egress_port=swports[1],
                                     queue_id=0,
                                     drop_reason=70)  # drop mtu check fail

        exp_mod_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_MOD,
            dropped=1,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_mod_inner_1)

        small_pkt = simple_udp_packet(eth_dst=params.mac_self,
                                      eth_src=params.mac_nbr[0],
                                      ip_id=108,
                                      ip_dst=params.ipaddr_nbr[1],
                                      ip_src=params.ipaddr_nbr[0],
                                      ip_ttl=64,
                                      udp_sport=101,
                                      with_udp_chksum=False,
                                      pktlen=64,
                                      udp_payload=payload)
        exp_small_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                          eth_src=params.mac_self,
                                          ip_dst=params.ipaddr_nbr[1],
                                          ip_src=params.ipaddr_nbr[0],
                                          ip_id=108,
                                          ip_ttl=63,
                                          pktlen=64,
                                          udp_sport=101,
                                          with_udp_chksum=False,
                                          udp_payload=payload)

        exp_small_e2e_inner_1 = postcard_report(packet=exp_small_pkt,
                                                switch_id=SID,
                                                ingress_port=swports[0],
                                                egress_port=swports[1],
                                                queue_id=0,
                                                queue_depth=0,
                                                egress_tstamp=0)

        exp_small_e2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_small_e2e_inner_1)

        queue_report_enabled = False
        try:
            #  Don't generate queue report if queue<threshold even if there is
            #  a change
            self.client.switch_api_dtel_latency_quantization_shift(
                device=device, quant_shift=low_quantization_shift)
            self.client.switch_api_dtel_queue_report_create(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            queue_report_enabled = True

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)
            print "Passed below threshold change don't make a report"
            # Don't generate queue report if queue >= threshold but no change
            # and quota is finished (done in QueueReport_Quota_Test)

            if test_param_get('target') != 'asic-model':
                # Generate queue report if queue >= threshold and change if quota
                # is not finished and if finished
                self.client.switch_api_dtel_queue_report_update(
                    device, swports[1], 0, 0, 0, 2, False)
                self.client.switch_api_dtel_latency_quantization_shift(
                    device=device, quant_shift=low_quantization_shift)
                send_packet(self, swports[0], str(pkt))
                verify_packet(self, exp_pkt, swports[1])

                # verify e2e mirrored packet
                verify_postcard_packet(self, exp_e2e_pkt,
                                       swports[params.report_ports[0]])
                verify_no_other_packets(self)

                send_packet(self, swports[0], str(small_pkt))
                verify_packet(self, exp_small_pkt, swports[1])

                # verify e2e mirrored packet
                verify_postcard_packet(self, exp_small_e2e_pkt,
                                       swports[params.report_ports[0]])
                verify_no_other_packets(self)
                quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                    device, swports[1], 0)
                self.assertTrue(quota == 0, "Remaining quota is not correct")

                received = False
                for i in range(20):
                    # first two use quota
                    # later should just go because of change (small vs large cause
                    # chagne)
                    send_packet(self, swports[0], str(pkt))
                    verify_packet(self, exp_pkt, swports[1])

                    # verify e2e mirrored packet
                    (_, rcv_port, rcv_pkt, pkt_time) = \
                            self.dataplane.poll(port_number=swports[params.report_ports[0]], timeout=1, exp_pkt=None)
                    if rcv_pkt != None:
                        print "received a change report after sending %d packets" % i
                        received = True
                        break
                self.assertTrue(
                    received, "Didn't receive any report because of change!")

                print "Passed generate queue reports regardless of quota"

        finally:
            print "Test Cleanup"
            split_postcard_pkt()
            if queue_report_enabled:
                self.client.switch_api_dtel_queue_report_delete(
                    device, swports[1], 0)
            config.cleanup(self)
コード例 #3
0
    def runTest(self):
        print "Test INT L45 Digest transit device - add and encode 2hop info"
        prepare_int_l45_bindings()
        config = SwitchConfig(self, params)

        # Enable INT transit processing
        self.client.switch_api_dtel_int_transit_enable(device)

        # create a packet coming from INT src - i.e.
        #   - It has INT meta header, but no INT data
        #   Each transit device will fill the data
        payload = 'int l45'
        pkt = simple_udp_packet(eth_dst=params.mac_self,
                                eth_src=params.mac_nbr[0],
                                ip_id=0,
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_ttl=64,
                                udp_sport=101,
                                with_udp_chksum=False,
                                udp_payload=payload)

        int_pkt = int_l45_src_packet(test=self,
                                     int_inst_mask=0xDC00,
                                     int_inst_cnt=5,
                                     pkt=pkt)

        exp_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                    eth_src=params.mac_self,
                                    ip_id=0,
                                    ip_dst=params.ipaddr_nbr[1],
                                    ip_src=params.ipaddr_nbr[0],
                                    ip_ttl=63,
                                    udp_sport=101,
                                    with_udp_chksum=False,
                                    udp_payload=payload)

        exp_pkt = int_l45_src_packet(test=self,
                                     int_inst_mask=0xDC00,
                                     int_inst_cnt=5,
                                     pkt=exp_pkt)

        # add 1 hop info to the packet
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=5)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x0)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x0)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x0)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt,
                                              val=0x22222222,
                                              incr_cnt=1)
        # add Digest headers
        digest = 0xab12
        digest_pkt = int_l45_packet_add_update_digest(Packet=int_pkt,
                                                      encoding=digest)

        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x5)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x0)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x0)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x0)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt,
                                              val=0x22222222,
                                              incr_cnt=1)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x7FFFFFFF)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x7FFFFFFF)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x7FFFFFFF)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt,
                                              val=int_port_ids_pack(
                                                  swports[0], swports[1]))
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt,
                                              val=switch_id,
                                              incr_cnt=1)
        # add Digest headers
        exp_encoding = digest ^ (switch_id - 0)  # latency unknown
        exp_pkt = int_l45_packet_add_update_digest(
            Packet=exp_pkt,
            encoding=exp_encoding)  #exp_encoding will be ignore

        # set quantization shift
        self.client.switch_api_dtel_latency_quantization_shift(device=device,
                                                               quant_shift=0)

        try:
            send_packet(self, swports[0], str(digest_pkt))
            (rcv_encoding, rcv_metadata,
             nrcv) = verify_int_packet(test=self,
                                       pkt=exp_pkt,
                                       port=swports[1],
                                       digest=True,
                                       ignore_hop_indices=[3, 4, 5])
            rcv_latency = rcv_metadata[2] - rcv_metadata[1]
            ports = nrcv.getlayer(INT_hop_info, 2)  # ports

            # fields must be extended up to their length, then concatenate
            v = rcv_latency  # 32 bit latency
            v = (v << 9) | ((ports.val >> 16) & 0x1ff)  # 9 bits ingress port
            v = (v << 9) | (ports.val & 0x1ff)  # 9 bits egress ports
            # we ignore switch ID in encoding
            # v = (v << 32) | (switch_id) # 32 bits switchid
            v = (v << 16) | digest
            v_len = ceil((32 + 9 + 9 + 16) / 4.0)
            v_hex = '%x' % v
            if (v_len % 2 == 1):
                v_len += 1
            while (len(v_hex) < v_len):
                v_hex = '0' + v_hex
            crc32 = crcmod.Crc(0x18005, initCrc=0, xorOut=0x0000)
            crc32.update(bytes(bytearray.fromhex(v_hex)))
            exp_encoding = crc32.crcValue

            print("expected %x received %x latency %d\n" %
                  (exp_encoding, rcv_encoding, rcv_latency))

            self.assertTrue(rcv_encoding == exp_encoding,
                            "Digest encoding doesn't match.")

            verify_no_other_packets(self)

        finally:
            ### Cleanup
            cleanup_int_l45_bindings()
            self.client.switch_api_dtel_int_transit_disable(device)
            config.cleanup(self)
コード例 #4
0
    def runTest(self):
        print "Test queue report Quota"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)
        config = SwitchConfig(self, params)
        bind_postcard_pkt()  # jsut to parse report

        payload = 'qreport'
        # make input frame to inject to sink
        pkt = simple_udp_packet(eth_dst=params.mac_self,
                                eth_src=params.mac_nbr[0],
                                ip_id=108,
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_ttl=64,
                                udp_sport=101,
                                with_udp_chksum=False,
                                pktlen=256,
                                udp_payload=payload)

        exp_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                    eth_src=params.mac_self,
                                    ip_dst=params.ipaddr_nbr[1],
                                    ip_src=params.ipaddr_nbr[0],
                                    ip_id=108,
                                    ip_ttl=63,
                                    pktlen=256,
                                    udp_sport=101,
                                    with_udp_chksum=False,
                                    udp_payload=payload)

        exp_e2e_inner_1 = postcard_report(packet=exp_pkt,
                                          switch_id=SID,
                                          ingress_port=swports[0],
                                          egress_port=swports[1],
                                          queue_id=0,
                                          queue_depth=0,
                                          egress_tstamp=0)

        exp_e2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_e2e_inner_1)

        exp_mod_inner_1 = mod_report(packet=exp_pkt,
                                     switch_id=SID,
                                     ingress_port=swports[0],
                                     egress_port=swports[1],
                                     queue_id=0,
                                     drop_reason=92)  # drop egress acl deny

        exp_mod_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_MOD,
            dropped=1,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_mod_inner_1)

        queue_report_enabled = False
        mod_enabled = False
        acl_enabled = False
        try:

            # quota cannot be 0
            self.client.switch_api_dtel_queue_report_create(
                device, swports[1], 0, 0, 0, 0, False)
            queue_report_enabled = True
            # verify that it is not programmed!
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)
            queue_report_enabled = False
            print "Passed quota cannot be 0"

            # default quota cannot be 0: tested as quota!=0 when qreport=false
            # and we didn't get a report

            # don't generate report if queue<threshold even if quota is there
            # if queue < threshold, remaining quota = remaining quota
            self.client.switch_api_dtel_queue_report_create(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            queue_report_enabled = True
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)

            quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                device, swports[1], 0)
            self.assertTrue(quota == 1024, "Remaining quota is not correct")
            print "Passed no report if queue < threshold"
            print "Passed remaining quota doesn't change if no report"

            # make sure the latency higher bits are zeroed
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0x000fffff), 1024, False)
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)
            print "Passed no report if latency < threshold"

            # if queue >= threshold, generate report if remaining quota > 0.
            # remaining quota should be updated

            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])

            # verify e2e mirrored packet
            verify_postcard_packet(self, exp_e2e_pkt,
                                   swports[params.report_ports[0]])
            verify_no_other_packets(self)

            quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                device, swports[1], 0)
            self.assertTrue(
                quota == 1023, "Remaining quota is not decremented"
                " (%d)" % quota)
            print "Passed remaining quota decrements per report"

            self.client.switch_api_dtel_report_udp_dstport_set(
                device, UDP_PORT_DTEL_REPORT ^ 0x1111)
            bind_layers(UDP,
                        DTEL_REPORT_HDR,
                        dport=UDP_PORT_DTEL_REPORT ^ 0x1111)
            split_layers(UDP, DTEL_REPORT_HDR, dport=UDP_PORT_DTEL_REPORT)
            exp_e2e_pkt[UDP].dport = UDP_PORT_DTEL_REPORT ^ 0x1111
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])

            # verify e2e mirrored packet
            verify_postcard_packet(self, exp_e2e_pkt,
                                   swports[params.report_ports[0]])
            verify_no_other_packets(self)
            split_layers(UDP,
                         DTEL_REPORT_HDR,
                         dport=UDP_PORT_DTEL_REPORT ^ 0x1111)
            bind_layers(UDP, DTEL_REPORT_HDR, dport=UDP_PORT_DTEL_REPORT)
            self.client.switch_api_dtel_report_udp_dstport_set(
                device, UDP_PORT_DTEL_REPORT)
            exp_e2e_pkt[UDP].dport = UDP_PORT_DTEL_REPORT
            print "Passed queue report + Report UDP port"

            # if queue >= threshold, generate report if remaining quota > 0.
            # remaining quota should be updated, even if big change
            # no harm to run in model
            # set quantization shift
            self.client.switch_api_dtel_latency_quantization_shift(
                device=device, quant_shift=low_quantization_shift)
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)
            num = 10
            for i in range(num):
                send_packet(self, swports[0], str(pkt))
                verify_packet(self, exp_pkt, swports[1])

                # verify e2e mirrored packet
                verify_postcard_packet(self, exp_e2e_pkt,
                                       swports[params.report_ports[0]])
            quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                device, swports[1], 0)
            self.assertTrue(
                quota == (1024 - num), "Remaining quota is not decremented"
                " (%d)" % quota)
            # set quantization shift
            self.client.switch_api_dtel_latency_quantization_shift(
                device=device, quant_shift=high_quantization_shift)
            print "Passed remaining quota decrements per report with change"

            # if queue >= threshold, don't generate report if remaining quota==0
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1, False)
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_postcard_packet(self, exp_e2e_pkt,
                                   swports[params.report_ports[0]])
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)
            print "Passed don't generate report if quota = 0"

            if test_param_get('target') != 'asic-model':
                # (HARDWARE) if queue >= threshold and quota is finished, and now queue <
                # threshold for the first time, genereate 1 report (even if it is
                # not a big change)
                # software queue size is == 0
                self.client.switch_api_dtel_latency_quantization_shift(
                    device=device, quant_shift=high_quantization_shift)
                # send large packet first.
                # send small packet later it will be smaller than threshold!
                small_pkt = simple_udp_packet(eth_dst=params.mac_self,
                                              eth_src=params.mac_nbr[0],
                                              ip_id=108,
                                              ip_dst=params.ipaddr_nbr[1],
                                              ip_src=params.ipaddr_nbr[0],
                                              ip_ttl=64,
                                              udp_sport=101,
                                              with_udp_chksum=False,
                                              pktlen=64,
                                              udp_payload=payload)
                exp_small_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                                  eth_src=params.mac_self,
                                                  ip_dst=params.ipaddr_nbr[1],
                                                  ip_src=params.ipaddr_nbr[0],
                                                  ip_id=108,
                                                  ip_ttl=63,
                                                  pktlen=64,
                                                  udp_sport=101,
                                                  with_udp_chksum=False,
                                                  udp_payload=payload)

                exp_small_e2e_inner_1 = postcard_report(
                    packet=exp_small_pkt,
                    switch_id=SID,
                    ingress_port=swports[0],
                    egress_port=swports[1],
                    queue_id=0,
                    queue_depth=0,
                    egress_tstamp=0)

                exp_small_e2e_pkt = ipv4_dtel_pkt(
                    eth_dst=params.mac_nbr[params.report_ports[0]],
                    eth_src=params.mac_self,
                    ip_src=params.ipaddr_report_src[0],
                    ip_dst=params.ipaddr_report_dst[0],
                    ip_id=0,
                    ip_ttl=64,
                    next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
                    dropped=0,
                    congested_queue=1,
                    path_tracking_flow=0,
                    hw_id=hw_id,
                    inner_frame=exp_small_e2e_inner_1)

                # each cell is 80B, so 10 should be at > one packet
                q_threshold = len(str(pkt)) / 80
                self.client.switch_api_dtel_queue_report_update(
                    device, swports[1], 0, q_threshold, hex_to_i32(0xffffffff),
                    1, False)

                # send large packet
                # quota of 1 should be finished here
                send_packet(self, swports[0], str(pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_postcard_packet(self, exp_e2e_pkt,
                                       swports[params.report_ports[0]])

                # small packet should be below the threshold but still report
                # as quota is finsihed
                send_packet(self, swports[0], str(small_pkt))
                verify_packet(self, exp_small_pkt, swports[1])
                verify_postcard_packet(self, exp_small_e2e_pkt,
                                       swports[params.report_ports[0]])

                print "Passed received packet below threshold when quota is finished"

            # if queue >= threshold and we drop packet at egress, we still
            # update the quota and generate report if MoD is disabled/enabled
            acl = self.client.switch_api_acl_list_create(
                device, SWITCH_API_DIRECTION_EGRESS,
                SWITCH_ACL_TYPE_EGRESS_SYSTEM, SWITCH_HANDLE_TYPE_PORT)
            # create kvp to match egress port and deflect bit
            kvp = []
            port = self.client.switch_api_port_id_to_handle_get(
                device, swports[1])
            kvp_val = switcht_acl_value_t(value_num=port)
            kvp_mask = switcht_acl_value_t(value_num=0xff)
            kvp.append(
                switcht_acl_key_value_pair_t(
                    SWITCH_ACL_EGRESS_SYSTEM_FIELD_DEST_PORT, kvp_val,
                    kvp_mask))
            action = SWITCH_ACL_EGRESS_SYSTEM_ACTION_DROP
            action_params = switcht_acl_action_params_t(
                drop=switcht_acl_action_drop(
                    reason_code=92))  # egress acl deny
            opt_action_params = switcht_acl_opt_action_params_t()
            ace = self.client.switch_api_acl_egress_system_rule_create(
                device, acl, 11, 1, kvp, action, action_params,
                opt_action_params)
            self.client.switch_api_acl_reference(device, acl, port)
            acl_enabled = True
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)

            send_packet(self, swports[0], str(pkt))

            # verify e2e mirrored packet
            verify_postcard_packet(self, exp_e2e_pkt,
                                   swports[params.report_ports[0]])
            verify_no_other_packets(self)
            quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                device, swports[1], 0)
            self.assertTrue(quota == 1023,
                            "Remaining quota is not decremented")
            print "Passed update quota even if original packet dropped"

            # now test with MoD
            # Add MoD watchlist
            ap = switcht_twl_drop_params_t(report_queue_tail_drops=False)
            self.client.switch_api_dtel_drop_watchlist_entry_create(
                device, twl_kvp, priority=1, watch=True, action_params=ap)
            self.client.switch_api_dtel_drop_report_enable(device)
            mod_enabled = True

            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)

            exp_e2e_pkt[DTEL_REPORT_HDR].dropped = 1
            send_packet(self, swports[0], str(pkt))
            # verify e2e mirrored packet
            verify_dtel_packet(self, exp_mod_pkt,
                               swports[params.report_ports[0]])
            verify_no_other_packets(self)
            quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                device, swports[1], 0)
            self.assertTrue(quota == 1023,
                            "Remaining quota is not decremented")
            print "Passed update quota even if original packet dropped+mod"

            # qbit is not set for MoD packets when quota is finished even though
            # queue>=threshold
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1, False)
            send_packet(self, swports[0], str(pkt))
            # verify e2e mirrored packet
            verify_dtel_packet(self, exp_mod_pkt,
                               swports[params.report_ports[0]])
            verify_no_other_packets(self)

            # quota finished now
            exp_mod_pkt[DTEL_REPORT_HDR].congested_queue = 0
            send_packet(self, swports[0], str(pkt))
            # verify e2e mirrored packet
            verify_dtel_packet(self, exp_mod_pkt,
                               swports[params.report_ports[0]])
            verify_no_other_packets(self)
            exp_e2e_pkt[DTEL_REPORT_HDR].congested_queue = 1
            exp_e2e_pkt[DTEL_REPORT_HDR].dropped = 0

            self.client.switch_api_acl_dereference(device, acl, port)
            self.client.switch_api_acl_rule_delete(device, acl, ace)
            self.client.switch_api_acl_list_delete(device, acl)
            acl_enabled = False
            self.client.switch_api_dtel_drop_report_disable(device)
            self.client.switch_api_dtel_drop_watchlist_entry_delete(
                device=device, twl_kvp=twl_kvp)
            mod_enabled = False

            # disable queue report
            self.client.switch_api_dtel_queue_report_delete(
                device, swports[1], 0)
            queue_report_enabled = False
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)
            print "Passed disable queue report"

        finally:
            print "Test Cleanup"
            split_layers(UDP,
                         DTEL_REPORT_HDR,
                         dport=UDP_PORT_DTEL_REPORT ^ 0x1111)
            bind_layers(UDP, DTEL_REPORT_HDR, dport=UDP_PORT_DTEL_REPORT)
            self.client.switch_api_dtel_report_udp_dstport_set(
                device, UDP_PORT_DTEL_REPORT)
            split_mirror_on_drop_pkt()
            split_postcard_pkt()
            if queue_report_enabled:
                self.client.switch_api_dtel_queue_report_delete(
                    device, swports[1], 0)
            if acl_enabled:
                self.client.switch_api_acl_dereference(device, acl, port)
                self.client.switch_api_acl_rule_delete(device, acl, ace)
                self.client.switch_api_acl_list_delete(device, acl)
            if mod_enabled:
                self.client.switch_api_dtel_drop_report_disable(device)
                self.client.switch_api_dtel_drop_watchlist_entry_delete(
                    device=device, twl_kvp=twl_kvp)
            config.cleanup(self)
コード例 #5
0
    def runTest(self):
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)
        print "Test INT L45 transit device with stateless suppression"
        prepare_int_l45_bindings()
        config = SwitchConfig(self, params)

        # create a packet coming from INT src - i.e.
        #   - It has INT meta header, but no INT data
        #   Each transit device will fill the data
        payload = 'int l45'
        pkt = simple_udp_packet(eth_dst=params.mac_self,
                                eth_src=params.mac_nbr[0],
                                ip_id=0,
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_ttl=64,
                                udp_sport=101,
                                with_udp_chksum=False,
                                udp_payload=payload)

        int_pkt = int_l45_src_packet(
            test=self,
            int_inst_mask=0xC000,  #switch id + ports
            int_inst_cnt=2,
            pkt=pkt)

        exp_pkt_noint = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                          eth_src=params.mac_self,
                                          ip_id=0,
                                          ip_dst=params.ipaddr_nbr[1],
                                          ip_src=params.ipaddr_nbr[0],
                                          ip_ttl=63,
                                          udp_sport=101,
                                          with_udp_chksum=False,
                                          udp_payload=payload)

        exp_pkt = int_l45_src_packet(
            test=self,
            int_inst_mask=0xC000,  #switch id + ports
            int_inst_cnt=2,
            pkt=exp_pkt_noint)

        # add 1 hop info to the packet
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=5)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt,
                                              val=0x22222222,
                                              incr_cnt=1)

        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt, val=0x5)
        exp_pkt_1hop = int_l45_packet_add_hop_info(Packet=exp_pkt,
                                                   val=0x22222222,
                                                   incr_cnt=1)
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt_1hop,
                                              val=int_port_ids_pack(
                                                  swports[0], swports[1]))
        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt,
                                              val=SID,
                                              incr_cnt=1)

        exp_inte2e_inner_1 = postcard_report(packet=exp_pkt_noint,
                                             switch_id=SID,
                                             ingress_port=swports[0],
                                             egress_port=swports[1],
                                             queue_id=0,
                                             queue_depth=0,
                                             egress_tstamp=0)

        exp_e2e_pkt_noint = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_inte2e_inner_1)

        exp_inte2e_inner_1 = postcard_report(packet=exp_pkt_1hop,
                                             switch_id=SID,
                                             ingress_port=swports[0],
                                             egress_port=swports[1],
                                             queue_id=0,
                                             queue_depth=0,
                                             egress_tstamp=0)

        exp_e2e_pkt_1hop = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=1,
            hw_id=hw_id,
            inner_frame=exp_inte2e_inner_1)

        exp_inte2e_inner_1 = postcard_report(packet=exp_pkt,
                                             switch_id=SID,
                                             ingress_port=swports[0],
                                             egress_port=swports[1],
                                             queue_id=0,
                                             queue_depth=0,
                                             egress_tstamp=0)

        exp_e2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=1,
            hw_id=hw_id,
            inner_frame=exp_inte2e_inner_1)

        queue_report_enabled = False
        transit_enabled = False
        try:
            # Enable INT transit processing
            self.client.switch_api_dtel_int_transit_enable(device)
            transit_enabled = True

            print "send traffic without enabling the queue report"
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_no_other_packets(self)

            print "enable queue report threshold: high threshold"
            # set queue report with latency threshold max
            self.client.switch_api_dtel_queue_report_create(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            queue_report_enabled = True

            # high threshould should not set the report bit
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            #receive_print_packet(self, swports[1], exp_pkt, True, True)
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_no_other_packets(self)

            print "enable queue report threshold: low threshold"
            # set queue report with latency threshold 0
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)
            # low threshould should send the report
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt_noint, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            print "disable transit"
            self.client.switch_api_dtel_int_transit_disable(device)
            transit_enabled = False
            exp_e2e_pkt_1hop[DTEL_REPORT_HDR].path_tracking_flow = 0
            # low threshould should send the report
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt_1hop, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt_1hop, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt_noint, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            print "enable transit again"
            self.client.switch_api_dtel_int_transit_enable(device)
            transit_enabled = True
            exp_e2e_pkt_1hop[DTEL_REPORT_HDR].path_tracking_flow = 1
            # low threshould should set the report bit
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt_noint, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            print "change report dscp"
            self.client.switch_api_dtel_event_set_dscp(
                device, SWITCH_DTEL_EVENT_TYPE_Q_REPORT_THRESHOLD_BREACH, 10)

            exp_e2e_pkt[IP].tos = 10 << 2
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            exp_e2e_pkt_noint[IP].tos = 10 << 2
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt_noint, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            print "change report port"
            bind_layers(UDP,
                        DTEL_REPORT_HDR,
                        dport=UDP_PORT_DTEL_REPORT ^ 0x1111)
            split_layers(UDP, DTEL_REPORT_HDR, dport=UDP_PORT_DTEL_REPORT)
            self.client.switch_api_dtel_report_udp_dstport_set(
                device, UDP_PORT_DTEL_REPORT ^ 0x1111)
            exp_e2e_pkt[UDP].dport = UDP_PORT_DTEL_REPORT ^ 0x1111
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])
            verify_no_other_packets(self)
            exp_e2e_pkt[UDP].dport = UDP_PORT_DTEL_REPORT
            self.client.switch_api_dtel_report_udp_dstport_set(
                device, UDP_PORT_DTEL_REPORT)
            split_layers(UDP,
                         DTEL_REPORT_HDR,
                         dport=UDP_PORT_DTEL_REPORT ^ 0x1111)
            bind_layers(UDP, DTEL_REPORT_HDR, dport=UDP_PORT_DTEL_REPORT)

            print "enable queue report threshold: high threshold"
            # set queue report with latency threshold max
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            # high threshould should not set the report bit
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            #receive_print_packet(self, swports[1], exp_pkt, True, True)
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_no_other_packets(self)

            print "disable queue report"
            # disable queue report
            self.client.switch_api_dtel_queue_report_delete(
                device, swports[1], 0)
            queue_report_enabled = False
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)

            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_noint, swports[1])
            verify_no_other_packets(self)

        finally:
            ### Cleanup
            cleanup_int_l45_bindings()
            self.client.switch_api_dtel_report_udp_dstport_set(
                device, UDP_PORT_DTEL_REPORT)
            split_layers(UDP,
                         DTEL_REPORT_HDR,
                         dport=UDP_PORT_DTEL_REPORT ^ 0x1111)
            bind_layers(UDP, DTEL_REPORT_HDR, dport=UDP_PORT_DTEL_REPORT)
            self.client.switch_api_dtel_event_set_dscp(
                device, SWITCH_DTEL_EVENT_TYPE_Q_REPORT_THRESHOLD_BREACH, 0)
            if queue_report_enabled:
                self.client.switch_api_dtel_queue_report_delete(
                    device, swports[1], 0)
            if transit_enabled:
                self.client.switch_api_dtel_int_transit_disable(device)
            config.cleanup(self)
コード例 #6
0
    def runTest(self):
        print "Test INT L45 transit device - "
        print "Correctly routing DTel reports"
        prepare_int_l45_bindings()

        # send the test packet(s)
        payload = 'int l45'
        # create a packet coming from INT src - i.e.
        #   - It has INT meta header, but no INT data
        #   Each transit device will fill the data
        pkt = simple_udp_packet(eth_dst=params.mac_self,
                                eth_src=params.mac_nbr[0],
                                ip_id=0,
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_ttl=64,
                                udp_sport=101,
                                with_udp_chksum=False,
                                udp_payload=payload)

        int_pkt = int_l45_src_packet(test=self,
                                     int_inst_mask=0xDC00,
                                     int_inst_cnt=5,
                                     pkt=pkt)
        # add 2 hop info to the packet
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt,
                                              val=0x87654321,
                                              incr_cnt=1)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222221)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222222)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222223)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222224)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt,
                                              val=0x12345678,
                                              incr_cnt=1)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222225)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222226)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222227)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt, val=0x22222228)

        # make a DTel report packet
        exp_i2e_mirrored_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_self,
            eth_src=params.mac_nbr[0],
            ip_src=params.ipaddr_nbr[0],
            ip_dst=params.ipaddr_nbr[1],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_ETHERNET,
            dropped=0,
            congested_queue=0,
            path_tracking_flow=1,
            hw_id=0,
            inner_frame=int_pkt)

        try:
            print "Forward DTel report with no mirror session: neighbor"
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = params.ipaddr_nbr[1]
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            try:
                # Enable INT
                self.client.switch_api_dtel_int_enable(device)

                send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_no_other_packets(self)
            finally:
                self.client.switch_api_dtel_int_disable(device)
                config.cleanup(self)

            print "Forward DTel report with no mirror session: "
            print "static route"

            params.routes = [('192.168.0.1', 1)]
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = '192.168.0.1'
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            try:
                # Enable INT
                self.client.switch_api_dtel_int_enable(device)

                send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_no_other_packets(self)
            finally:
                self.client.switch_api_dtel_int_disable(device)
                config.cleanup(self)
                params.routes = []

            print "Forward DTel report with mirror session: "
            print "diff next hop as mirror: neighbor"
            params.report_ports = [0]
            params.ipaddr_report_src = ['172.21.124.31']
            params.ipaddr_report_dst = ['172.21.124.40']
            params.mirror_ids = [555]
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = params.ipaddr_nbr[1]
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            try:
                # Enable INT
                self.client.switch_api_dtel_int_enable(device)

                send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_no_other_packets(self)
            finally:
                self.client.switch_api_dtel_int_disable(device)
                config.cleanup(self)
                params.report_ports = None

            print "Forward DTel report with mirror session: "
            print "diff next hop as mirror: static"
            params.report_ports = [0]
            params.ipaddr_report_src = ['172.21.124.31']
            params.ipaddr_report_dst = ['172.21.124.40']
            params.mirror_ids = [555]
            params.routes = [('192.168.0.1', 1)]
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = '192.168.0.1'
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            try:
                # Enable INT
                self.client.switch_api_dtel_int_enable(device)

                send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_no_other_packets(self)
            finally:
                self.client.switch_api_dtel_int_disable(device)
                config.cleanup(self)
                params.report_ports = None
                params.routes = []

            print "Forward DTel report with mirror session: "
            print "same next hop as mirror: neighbor"
            params.report_ports = [1]
            params.ipaddr_report_src = ['172.21.124.31']
            params.ipaddr_report_dst = ['172.21.124.40']
            params.mirror_ids = [555]
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = params.ipaddr_nbr[1]
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            try:
                # Enable INT
                self.client.switch_api_dtel_int_enable(device)

                send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_no_other_packets(self)
            finally:
                self.client.switch_api_dtel_int_disable(device)
                config.cleanup(self)
                params.report_ports = None

            print "Forward DTel report with mirror session: "
            print "same next hop as mirror: static"
            params.report_ports = [1]
            params.ipaddr_report_src = ['172.21.124.31']
            params.ipaddr_report_dst = ['172.21.124.40']
            params.mirror_ids = [555]
            params.routes = [('192.168.0.1', 1)]
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = '192.168.0.1'
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)

            config.cleanup(self)
            params.report_ports = None
            params.routes = []

            print "Forward DTel report with mirror session: "
            print "same dst as mirror: neighbor"
            params.report_ports = [1]
            params.ipaddr_report_src = ['172.21.124.31']
            params.ipaddr_report_dst = ['172.21.124.40']
            params.mirror_ids = [555]
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = '172.21.124.40'
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            try:
                # Enable INT
                self.client.switch_api_dtel_int_enable(device)

                send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_no_other_packets(self)
            finally:
                self.client.switch_api_dtel_int_disable(device)
                config.cleanup(self)
                params.report_ports = None

            print "Forward DTel report with mirror session: "
            print "same next hop as mirror: static"
            params.report_ports = [1]
            params.ipaddr_report_src = ['172.21.124.31']
            params.ipaddr_report_dst = ['172.21.124.40']
            params.mirror_ids = [555]
            params.routes = [('172.21.124.40', 1)]
            config = SwitchConfig(self, params)

            exp_i2e_mirrored_pkt.getlayer(IP, 1).dst = '172.21.124.40'
            exp_pkt = exp_i2e_mirrored_pkt.copy()
            exp_pkt[Ether].src = params.mac_self
            exp_pkt[Ether].dst = params.mac_nbr[1]
            exp_pkt.getlayer(IP, 1).ttl = 63

            try:
                # Enable INT
                self.client.switch_api_dtel_int_enable(device)

                send_packet(self, swports[0], str(exp_i2e_mirrored_pkt))
                verify_packet(self, exp_pkt, swports[1])
                verify_no_other_packets(self)
            finally:
                self.client.switch_api_dtel_int_disable(device)
                config.cleanup(self)
                params.report_ports = None
                params.routes = []

        finally:
            ### Cleanup
            cleanup_int_l45_bindings()
コード例 #7
0
    def runTest(self):
        print "Test INT L45 Sink, sending reports to multiple destinations"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)

        # set quantization shift size
        prepare_int_l45_bindings()
        config = SwitchConfig(self, params)

        # create an INT session
        self.client.switch_api_dtel_int_session_create(
            device=device, session_id=1,
            instruction=convert_int_instruction(0x8000), max_hop=8)

        # Add INT watchlist entry
        ap = switcht_twl_int_params_t(
            session_id=1, report_all_packets=True, flow_sample_percent=100)
        self.client.switch_api_dtel_int_watchlist_entry_create(
            device, twl_kvp, priority=1, watch=True, action_params=ap)

        # set quantization shift
        self.client.switch_api_dtel_latency_quantization_shift(
            device=device, quant_shift=quantization_shift)

        # enable int-ep
        self.client.switch_api_dtel_int_endpoint_enable(device=device)

        # add INT edge port
        self.client.switch_api_dtel_int_edge_ports_add(
            device=device, port=swports[1])
        payload = 'int l45'
        dst_port = 80
        try:
            max_itrs = 100
            random.seed(314159)
            mirror_sessions_num = len(params.report_ports)
            count = [0] * mirror_sessions_num
            mirror_ports = [0] * mirror_sessions_num
            selected_mirrors=[]
            exp_i2e_mirrored_pkt = [None] * mirror_sessions_num
            exp_e2e_mirrored_pkt = [None] * mirror_sessions_num
            for i in range(0, mirror_sessions_num):
                mirror_ports[i] = swports[params.report_ports[i]]
                self.client.switch_api_dtel_report_sequence_number_set(
                  device, params.mirror_ids[i], 0)
            for i in range(0, max_itrs):
                src_port = i*3 + 10000
                # make input frame to inject to sink
                pkt = simple_udp_packet(
                    eth_dst=params.mac_self,
                    eth_src=params.mac_nbr[0],
                    ip_id=108,
                    ip_dst=params.ipaddr_nbr[1],
                    ip_src=params.ipaddr_nbr[0],
                    ip_ttl=64,
                    udp_sport=src_port,
                    udp_dport=dst_port,
                    with_udp_chksum=False,
                    udp_payload=payload)
                int_pkt_orig = int_l45_src_packet(
                    test=self,
                    int_inst_mask=0x8000,  # swid
                    int_inst_cnt=1,
                    max_hop_cnt=8,
                    pkt=pkt)

                # add 2 hop info to the packet
                int_pkt = int_l45_packet_add_hop_info(
                    Packet=int_pkt_orig, val=0x66666666, incr_cnt=1)
                int_pkt = int_l45_packet_add_hop_info(
                    Packet=int_pkt, val=0x22222222, incr_cnt=1)

                exp_pkt = simple_udp_packet(
                    eth_dst=params.mac_nbr[1],
                    eth_src=params.mac_self,
                    ip_dst=params.ipaddr_nbr[1],
                    ip_src=params.ipaddr_nbr[0],
                    ip_id=108,
                    ip_ttl=63,
                    udp_sport=src_port,
                    udp_dport=dst_port,
                    with_udp_chksum=False,
                    udp_payload=payload)

                exp_inte2e_inner_1 = postcard_report(
                    packet=exp_pkt,
                    switch_id=SID,
                    ingress_port=swports[0],
                    egress_port=swports[1],
                    queue_id=0,
                    queue_depth=0,
                    egress_tstamp=0)

                for j in range (0, len(params.report_ports)):
                    # upstream report packet
                    exp_i2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_ETHERNET,
                        dropped=0,
                        congested_queue=0,
                        path_tracking_flow=1,
                        sequence_number=count[j]*2,
                        hw_id=hw_id,
                        inner_frame=int_pkt)

                    # local report packet
                    exp_e2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
                        dropped=0,
                        congested_queue=0,
                        path_tracking_flow=1,
                        sequence_number=1+count[j]*2,
                        hw_id=hw_id,
                        inner_frame=exp_inte2e_inner_1)

                m = Mask(exp_pkt)
                m.set_do_not_care_scapy(UDP, 'chksum')
                send_packet(self, swports[0], str(int_pkt))
                verify_packet(self, m, swports[1])

                rcv_idx1 = verify_any_dtel_packet_any_port(
                    self, exp_i2e_mirrored_pkt,
                    mirror_ports, ignore_seq_num=False)
                rcv_idx2 = verify_any_dtel_packet_any_port(
                    self, exp_e2e_mirrored_pkt,
                    mirror_ports, ignore_seq_num=False)
                self.assertTrue(rcv_idx1 == rcv_idx2, "Did not recevie i2e and"
                                "e2e of the same packet on the same port")
                print ("%d %d" % (i, rcv_idx1))
                selected_mirrors.append(rcv_idx1)
                #verify_no_other_packets(self, timeout=1)
                count[rcv_idx1] += 1

            for i in range(0, mirror_sessions_num):
                self.assertTrue((count[i] >= ((max_itrs / 4.0) * 0.50)),
                                "Not all mirror sessions are equally balanced"
                                " (%f %% < %f) for %d" %
                                (count[i], ((max_itrs / 4.0) * 0.50), i))

            print "passed balancing the load among telemery mirror sessions"

            # add mirror ids in reverse order
            for mirror_id in params.mirror_ids:
                self.client.switch_api_dtel_report_session_delete(
                    device,
                    mirror_id)

            for i in range(mirror_sessions_num - 1, -1, -1):
                self.client.switch_api_dtel_report_session_add(
                    device,
                    params.mirror_ids[i])

            # no need to check all above as 100 is to check balance
            max_itrs = 50
            for i in range(0, max_itrs):
                src_port = i*3 + 10000
                # make input frame to inject to sink
                pkt = simple_udp_packet(
                    eth_dst=params.mac_self,
                    eth_src=params.mac_nbr[0],
                    ip_id=108,
                    ip_dst=params.ipaddr_nbr[1],
                    ip_src=params.ipaddr_nbr[0],
                    ip_ttl=64,
                    udp_sport=src_port,
                    udp_dport=dst_port,
                    with_udp_chksum=False,
                    udp_payload=payload)
                int_pkt_orig = int_l45_src_packet(
                    test=self,
                    int_inst_mask=0x8000,  # swid
                    int_inst_cnt=1,
                    max_hop_cnt=8,
                    pkt=pkt)

                # add 2 hop info to the packet
                int_pkt = int_l45_packet_add_hop_info(
                    Packet=int_pkt_orig, val=0x66666666, incr_cnt=1)
                int_pkt = int_l45_packet_add_hop_info(
                    Packet=int_pkt, val=0x22222222, incr_cnt=1)

                exp_pkt = simple_udp_packet(
                    eth_dst=params.mac_nbr[1],
                    eth_src=params.mac_self,
                    ip_dst=params.ipaddr_nbr[1],
                    ip_src=params.ipaddr_nbr[0],
                    ip_id=108,
                    ip_ttl=63,
                    udp_sport=src_port,
                    udp_dport=dst_port,
                    with_udp_chksum=False,
                    udp_payload=payload)

                exp_inte2e_inner_1 = postcard_report(
                    packet=exp_pkt,
                    switch_id=SID,
                    ingress_port=swports[0],
                    egress_port=swports[1],
                    queue_id=0,
                    queue_depth=0,
                    egress_tstamp=0)

                for j in range (0, len(params.report_ports)):
                    # upstream report packet
                    exp_i2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_ETHERNET,
                        dropped=0,
                        congested_queue=0,
                        path_tracking_flow=1,
                        hw_id=hw_id,
                        inner_frame=int_pkt)

                    # local report packet
                    exp_e2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
                        dropped=0,
                        congested_queue=0,
                        path_tracking_flow=1,
                        hw_id=hw_id,
                        inner_frame=exp_inte2e_inner_1)

                m = Mask(exp_pkt)
                m.set_do_not_care_scapy(UDP, 'chksum')
                send_packet(self, swports[0], str(int_pkt))
                verify_packet(self, m, swports[1])

                rcv_idx1 = verify_any_dtel_packet_any_port(
                    self, exp_i2e_mirrored_pkt,
                    mirror_ports)
                rcv_idx2 = verify_any_dtel_packet_any_port(
                    self, exp_e2e_mirrored_pkt,
                    mirror_ports)
                self.assertTrue(rcv_idx1 == selected_mirrors[i],
                                "Did not recevie packet on the same mirror"
                                " session when changing the mirror add order"
                                " exp=%d, in=%d"%(selected_mirrors[i],
                                                  rcv_idx1))
                print ("%d %d" % (i, rcv_idx1))
            print "passed consistent mirroring with different order for adding mirror IDs"

            config.cleanup(self)

            params.ipaddr_report_src = list(reversed(params.ipaddr_report_src))
            params.ipaddr_report_dst = list(reversed(params.ipaddr_report_dst))
            config = SwitchConfig(self, params)

            for i in range(0, max_itrs):
                src_port = i*3 + 10000
                # make input frame to inject to sink
                pkt = simple_udp_packet(
                    eth_dst=params.mac_self,
                    eth_src=params.mac_nbr[0],
                    ip_id=108,
                    ip_dst=params.ipaddr_nbr[1],
                    ip_src=params.ipaddr_nbr[0],
                    ip_ttl=64,
                    udp_sport=src_port,
                    udp_dport=dst_port,
                    with_udp_chksum=False,
                    udp_payload=payload)
                int_pkt_orig = int_l45_src_packet(
                    test=self,
                    int_inst_mask=0x8000,  # swid
                    int_inst_cnt=1,
                    max_hop_cnt=8,
                    pkt=pkt)

                # add 2 hop info to the packet
                int_pkt = int_l45_packet_add_hop_info(
                    Packet=int_pkt_orig, val=0x66666666, incr_cnt=1)
                int_pkt = int_l45_packet_add_hop_info(
                    Packet=int_pkt, val=0x22222222, incr_cnt=1)

                exp_pkt = simple_udp_packet(
                    eth_dst=params.mac_nbr[1],
                    eth_src=params.mac_self,
                    ip_dst=params.ipaddr_nbr[1],
                    ip_src=params.ipaddr_nbr[0],
                    ip_id=108,
                    ip_ttl=63,
                    udp_sport=src_port,
                    udp_dport=dst_port,
                    with_udp_chksum=False,
                    udp_payload=payload)

                exp_inte2e_inner_1 = postcard_report(
                    packet=exp_pkt,
                    switch_id=SID,
                    ingress_port=swports[0],
                    egress_port=swports[1],
                    queue_id=0,
                    queue_depth=0,
                    egress_tstamp=0)

                for j in range (len(params.report_ports)):
                    # upstream report packet
                    exp_i2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_ETHERNET,
                        dropped=0,
                        congested_queue=0,
                        path_tracking_flow=1,
                        hw_id=hw_id,
                        inner_frame=int_pkt)

                    # local report packet
                    exp_e2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
                        dropped=0,
                        congested_queue=0,
                        path_tracking_flow=1,
                        hw_id=hw_id,
                        inner_frame=exp_inte2e_inner_1)

                # lists are reversed to get the same value as prev run, need to
                # make the exp packets array reversed
                exp_e2e_mirrored_pkt=list(reversed(exp_e2e_mirrored_pkt))
                exp_i2e_mirrored_pkt=list(reversed(exp_i2e_mirrored_pkt))

                m = Mask(exp_pkt)
                m.set_do_not_care_scapy(UDP, 'chksum')
                send_packet(self, swports[0], str(int_pkt))
                verify_packet(self, m, swports[1], timeout=5)

                rcv_idx1 = verify_any_dtel_packet_any_port(
                    self, exp_i2e_mirrored_pkt,
                    mirror_ports)
                rcv_idx2 = verify_any_dtel_packet_any_port(
                    self, exp_e2e_mirrored_pkt,
                    mirror_ports)
                self.assertTrue(rcv_idx1 == selected_mirrors[i],
                                "Did not recevie packet on the same mirror"
                                " session when changing the mirror add order"
                                " exp=%d, in=%d"%(selected_mirrors[i],
                                                  rcv_idx1))
                print ("%d %d" % (i, rcv_idx1))
            print "passed consistent mirroring with different order "
            print "of adding destination IPs"


        finally:
            cleanup_int_l45_bindings()
            self.client.switch_api_dtel_int_endpoint_disable(device=device)
            self.client.switch_api_dtel_int_watchlist_entry_delete(
                device=device, twl_kvp=twl_kvp)
            self.client.switch_api_dtel_int_session_delete(
                device=device, session_id=1)
            self.client.switch_api_dtel_int_edge_ports_delete(
                device=device, port=swports[1])
            config.cleanup(self)
コード例 #8
0
    def runTest(self):
        print "Test Queue report sending reports of L2 traffic to multiple destinations"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)

        # set quantization shift size
        bind_postcard_pkt()  # jsut to parse report
        myparams = params
        myparams.vlans = {10: {0: False, 1: False}}
        config = SwitchConfig(self, myparams)

        # set quantization shift
        self.client.switch_api_dtel_latency_quantization_shift(
            device=device, quant_shift=quantization_shift)

        self.client.switch_api_dtel_queue_report_create(
            device, swports[1], 0, 0, 0, 1024, False)
        payload = 'q report'
        try:
            max_itrs = 100
            random.seed(314159)
            mirror_sessions_num = len(params.report_ports)
            count = [0] * mirror_sessions_num
            mirror_ports = [0] * mirror_sessions_num
            exp_e2e_mirrored_pkt = [None] * mirror_sessions_num
            for i in range(0, mirror_sessions_num):
                mirror_ports[i] = swports[params.report_ports[i]]
                self.client.switch_api_dtel_report_sequence_number_set(
                    device, params.mirror_ids[i], 0)
            for i in range(0, max_itrs):
                smac = '00:00:00:00:' + hex(i / 256)[2:].zfill(2)
                smac = smac + ':' + hex(i % 256)[2:].zfill(2)
                dmac = '00:00:00:00:' + hex((i + 1) / 256)[2:].zfill(2)
                dmac = dmac + ':' + hex((i + 1) % 256)[2:].zfill(2)
                # make input frame to inject to sink
                pkt = simple_udpv6_packet(
                    eth_src=params.mac_nbr[0],
                    eth_dst=dmac,
                    ipv6_dst='1234:5678:9abc:def0:4422:1133:5577:99aa',
                    ipv6_src='2000::%d' % i,
                    ipv6_hlim=64,
                    with_udp_chksum=False,
                    udp_payload=payload)

                exp_pkt = simple_udpv6_packet(
                    eth_src=params.mac_nbr[0],
                    eth_dst=dmac,
                    ipv6_dst='1234:5678:9abc:def0:4422:1133:5577:99aa',
                    ipv6_src='2000::%d' % i,
                    ipv6_hlim=64,
                    with_udp_chksum=False,
                    udp_payload=payload)

                exp_inte2e_inner_1 = postcard_report(packet=exp_pkt,
                                                     switch_id=SID,
                                                     ingress_port=swports[0],
                                                     egress_port=swports[1],
                                                     queue_id=0,
                                                     queue_depth=0,
                                                     egress_tstamp=0)

                for j in range(0, len(params.report_ports)):
                    # local report packet
                    exp_e2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
                        dropped=0,
                        congested_queue=1,
                        path_tracking_flow=0,
                        sequence_number=count[j],
                        hw_id=hw_id,
                        inner_frame=exp_inte2e_inner_1)

                send_packet(self, swports[0], str(pkt))
                verify_packet(self, exp_pkt, swports[1], timeout=5)

                rcv_idx1 = verify_any_dtel_packet_any_port(
                    self,
                    exp_e2e_mirrored_pkt,
                    mirror_ports,
                    ignore_seq_num=False)
                print("%d %d" % (i, rcv_idx1))
                #verify_no_other_packets(self, timeout=1)
                count[rcv_idx1] += 1

            for i in range(0, mirror_sessions_num):
                self.assertTrue(
                    (count[i] >= ((max_itrs / 4.0) * 0.50)),
                    "Not all mirror sessions are equally balanced"
                    " (%f %% < %f) for %d" % (count[i],
                                              ((max_itrs / 4.0) * 0.50), i))

            print "passed balancing the load among telemery mirror sessions"
        finally:
            split_postcard_pkt()
            self.client.switch_api_dtel_queue_report_delete(
                device, swports[1], 0)
            config.cleanup(self)
コード例 #9
0
    def runTest(self):
        print "Test Queue Report, sending reports to multiple destinations"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)

        # set quantization shift size
        bind_postcard_pkt()  # jsut to parse report
        config = SwitchConfig(self, params)

        # set quantization shift
        self.client.switch_api_dtel_latency_quantization_shift(
            device=device, quant_shift=quantization_shift)

        self.client.switch_api_dtel_queue_report_create(
            device, swports[1], 0, 0, 0, 1024, False)
        payload = 'q report'
        try:
            max_itrs = 100
            random.seed(314159)
            mirror_sessions_num = len(params.report_ports)
            count = [0] * mirror_sessions_num
            mirror_ports = [0] * mirror_sessions_num
            selected_mirrors = []
            exp_e2e_mirrored_pkt = [None] * mirror_sessions_num
            for i in range(0, mirror_sessions_num):
                mirror_ports[i] = swports[params.report_ports[i]]
                self.client.switch_api_dtel_report_sequence_number_set(
                    device, params.mirror_ids[i], 0)
            for i in range(0, max_itrs):
                src_port = i + 10000
                dst_port = i + 10001
                # make input frame to inject to sink
                pkt = simple_udp_packet(eth_dst=params.mac_self,
                                        eth_src=params.mac_nbr[0],
                                        ip_id=108,
                                        ip_dst=params.ipaddr_nbr[1],
                                        ip_src=params.ipaddr_nbr[0],
                                        ip_ttl=64,
                                        udp_sport=src_port,
                                        udp_dport=dst_port,
                                        with_udp_chksum=False,
                                        udp_payload=payload)

                exp_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                            eth_src=params.mac_self,
                                            ip_dst=params.ipaddr_nbr[1],
                                            ip_src=params.ipaddr_nbr[0],
                                            ip_id=108,
                                            ip_ttl=63,
                                            udp_sport=src_port,
                                            udp_dport=dst_port,
                                            with_udp_chksum=False,
                                            udp_payload=payload)

                exp_inte2e_inner_1 = postcard_report(packet=exp_pkt,
                                                     switch_id=SID,
                                                     ingress_port=swports[0],
                                                     egress_port=swports[1],
                                                     queue_id=0,
                                                     queue_depth=0,
                                                     egress_tstamp=0)

                for j in range(0, len(params.report_ports)):
                    # local report packet
                    exp_e2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
                        dropped=0,
                        congested_queue=1,
                        path_tracking_flow=0,
                        sequence_number=count[j],
                        hw_id=hw_id,
                        inner_frame=exp_inte2e_inner_1)

                send_packet(self, swports[0], str(pkt))
                verify_packet(self, exp_pkt, swports[1], timeout=5)

                rcv_idx1 = verify_any_dtel_packet_any_port(
                    self,
                    exp_e2e_mirrored_pkt,
                    mirror_ports,
                    ignore_seq_num=False)
                print("%d %d" % (i, rcv_idx1))
                selected_mirrors.append(rcv_idx1)
                #verify_no_other_packets(self, timeout=1)
                count[rcv_idx1] += 1

            for i in range(0, mirror_sessions_num):
                self.assertTrue(
                    (count[i] >= ((max_itrs / 4.0) * 0.50)),
                    "Not all mirror sessions are equally balanced"
                    " (%f %% < %f) for %d" % (count[i],
                                              ((max_itrs / 4.0) * 0.50), i))

            print "passed balancing the load among telemery mirror sessions"

            # add mirror ids in reverse order
            for mirror_id in params.mirror_ids:
                self.client.switch_api_dtel_report_session_delete(
                    device, mirror_id)

            for i in range(mirror_sessions_num - 1, -1, -1):
                self.client.switch_api_dtel_report_session_add(
                    device, params.mirror_ids[i])

            for i in range(0, max_itrs):
                src_port = i + 10000
                dst_port = i + 10001
                # make input frame to inject to sink
                pkt = simple_udp_packet(eth_dst=params.mac_self,
                                        eth_src=params.mac_nbr[0],
                                        ip_id=108,
                                        ip_dst=params.ipaddr_nbr[1],
                                        ip_src=params.ipaddr_nbr[0],
                                        ip_ttl=64,
                                        udp_sport=src_port,
                                        udp_dport=dst_port,
                                        with_udp_chksum=False,
                                        udp_payload=payload)

                exp_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                            eth_src=params.mac_self,
                                            ip_dst=params.ipaddr_nbr[1],
                                            ip_src=params.ipaddr_nbr[0],
                                            ip_id=108,
                                            ip_ttl=63,
                                            udp_sport=src_port,
                                            udp_dport=dst_port,
                                            with_udp_chksum=False,
                                            udp_payload=payload)

                exp_inte2e_inner_1 = postcard_report(packet=exp_pkt,
                                                     switch_id=SID,
                                                     ingress_port=swports[0],
                                                     egress_port=swports[1],
                                                     queue_id=0,
                                                     queue_depth=0,
                                                     egress_tstamp=0)

                for j in range(0, len(params.report_ports)):
                    # local report packet
                    exp_e2e_mirrored_pkt[j] = ipv4_dtel_pkt(
                        eth_dst=params.mac_nbr[params.report_ports[j]],
                        eth_src=params.mac_self,
                        ip_src=params.ipaddr_report_src[j],
                        ip_dst=params.ipaddr_report_dst[j],
                        ip_id=0,
                        ip_ttl=64,
                        next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
                        dropped=0,
                        congested_queue=1,
                        path_tracking_flow=0,
                        hw_id=hw_id,
                        inner_frame=exp_inte2e_inner_1)

                send_packet(self, swports[0], str(pkt))
                verify_packet(self, exp_pkt, swports[1], timeout=5)

                rcv_idx1 = verify_any_dtel_packet_any_port(
                    self, exp_e2e_mirrored_pkt, mirror_ports)
                self.assertTrue(
                    rcv_idx1 == selected_mirrors[i],
                    "Did not recevie packet on the same mirror"
                    " session when changing the mirror add order"
                    " exp=%d, in=%d" % (selected_mirrors[i], rcv_idx1))
                print("%d %d" % (i, rcv_idx1))

            print "passed consistent mirroring with different order for adding mirror IDs"

        finally:
            split_postcard_pkt()
            self.client.switch_api_dtel_queue_report_delete(
                device, swports[1], 0)
            config.cleanup(self)
コード例 #10
0
    def runTest(self):
        print "Test INT L45 Sink device - INT/StLess"
        print "local queue report"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)
        prepare_int_l45_bindings()
        config = SwitchConfig(self, params)

        # set quantization shift
        self.client.switch_api_dtel_latency_quantization_shift(
            device=device, quant_shift=high_quantization_shift)

        payload = 'int l45'
        # make input frame to inject to sink
        pkt = simple_udp_packet(eth_dst=params.mac_self,
                                eth_src=params.mac_nbr[0],
                                ip_id=108,
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_ttl=64,
                                udp_sport=101,
                                with_udp_chksum=False,
                                udp_payload=payload)
        int_pkt_orig = int_l45_src_packet(
            test=self,
            int_inst_mask=0x8000,  # swid
            int_inst_cnt=1,
            max_hop_cnt=8,
            pkt=pkt)

        # add 2 hop info to the packet
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt_orig,
                                              val=0x66666666,
                                              incr_cnt=1)
        int_pkt = int_l45_packet_add_hop_info(Packet=int_pkt,
                                              val=0x22222222,
                                              incr_cnt=1)

        # add Digest headers
        digest = 0x66666666 ^ 0x22222222  # assume zero latency
        int_digest_pkt = int_l45_packet_add_update_digest(Packet=int_pkt,
                                                          encoding=digest)

        # upstream report packet
        # add INT meta header and 2 hop info to the inner frame
        exp_i2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_ETHERNET,
            dropped=0,
            congested_queue=0,
            path_tracking_flow=1,
            hw_id=hw_id,
            inner_frame=int_pkt)

        # local report packet
        pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                eth_src=params.mac_self,
                                ip_id=108,
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_ttl=63,
                                udp_sport=101,
                                with_udp_chksum=False,
                                udp_payload=payload)

        exp_pkt = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                    eth_src=params.mac_self,
                                    ip_dst=params.ipaddr_nbr[1],
                                    ip_src=params.ipaddr_nbr[0],
                                    ip_id=108,
                                    ip_ttl=63,
                                    udp_sport=101,
                                    with_udp_chksum=False,
                                    udp_payload=payload)

        exp_inte2e_inner_1 = postcard_report(packet=exp_pkt,
                                             switch_id=SID,
                                             ingress_port=swports[0],
                                             egress_port=swports[1],
                                             queue_id=0,
                                             queue_depth=0,
                                             egress_tstamp=0)

        exp_e2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=0,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_inte2e_inner_1)

        exp_pkt_ = int_pkt.copy()
        exp_pkt_[IP].ttl -= 1
        exp_pkt_[Ether].src = exp_pkt[Ether].src
        exp_pkt_[Ether].dst = exp_pkt[Ether].dst

        exp_inte2e_inner_1 = postcard_report(packet=exp_pkt_,
                                             switch_id=SID,
                                             ingress_port=swports[0],
                                             egress_port=swports[1],
                                             queue_id=0,
                                             queue_depth=0,
                                             egress_tstamp=0)

        exp_e2e_pkt_ = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=0,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_inte2e_inner_1)

        print "Clear bloom filters. Can take up to %d secs." % min_sleeptime
        self.client.switch_api_dtel_flow_state_clear_cycle(device=device,
                                                           cycle=reset_cycle)
        time.sleep(min_sleeptime)

        if DEBUG: raw_input("Press Enter to continue...")
        print "Disable bloom filter clearing."
        self.client.switch_api_dtel_flow_state_clear_cycle(device=device,
                                                           cycle=0)
        time.sleep(2 * reset_cycle)

        queue_report_enabled = False
        endpoint_enabled = False
        try:
            ######## simple packet at end-point is tested in source test case
            ######## int packet without  enabling end-point
            # send a test pkt
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt_, swports[1])
            verify_no_other_packets(self)

            # send the packet again but now it should only have downstream
            print "enable queue report threshold: high threshold"
            # set queue report with max latency threshold
            self.client.switch_api_dtel_queue_report_create(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            queue_report_enabled = True

            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt_, swports[1])

            verify_no_other_packets(self)

            print "enable queue report threshold: low threshold"
            # set queue report with latency threshold 0
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)

            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt_, swports[1])

            exp_e2e_pkt_[DTEL_REPORT_HDR].congested_queue = 1
            # verify e2e mirrored packet
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt_, swports[params.report_ports[0]])

            verify_no_other_packets(self)
            print "Passed for queue report for an INT packet w/o enable int endpoint"

            ######## an INT packet without digest
            # reset quota
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)
            # enable int-ep
            exp_e2e_pkt[DTEL_REPORT_HDR].congested_queue = 1
            exp_e2e_pkt[DTEL_REPORT_HDR].path_tracking_flow = 1
            self.client.switch_api_dtel_int_endpoint_enable(device=device)
            # add INT edge port
            self.client.switch_api_dtel_int_edge_ports_add(device=device,
                                                           port=swports[1])
            endpoint_enabled = True

            # send a test pkt
            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])

            # verify i2e mirrored packet
            verify_int_l45_dtel_packet(self, exp_i2e_pkt,
                                       swports[params.report_ports[0]])

            # verify e2e mirrored packet
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            # if queue >= threshold and we generate INT report, we still
            # update the quota
            quota = self.client.switch_api_dtel_queue_remaining_report_quota_during_breach_get(
                device, swports[1], 0)
            self.assertTrue(quota == 1023,
                            "Remaining quota is not decremented")

            # send the packet again but now it should only have downstream
            print "enable queue report threshold: high threshold"
            exp_e2e_pkt[DTEL_REPORT_HDR].congested_queue = 0
            # set queue report with max latency threshold
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            queue_report_enabled = True

            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])

            # verify i2e mirrored packet
            verify_int_l45_dtel_packet(self, exp_i2e_pkt,
                                       swports[params.report_ports[0]])

            # verify e2e mirrored packet
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])

            verify_no_other_packets(self)

            print "enable queue report threshold: low threshold"
            # set queue report with latency threshold 0
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)

            send_packet(self, swports[0], str(int_pkt))
            verify_packet(self, exp_pkt, swports[1])

            # verify i2e mirrored packet
            verify_int_l45_dtel_packet(self, exp_i2e_pkt,
                                       swports[params.report_ports[0]])

            exp_e2e_pkt[DTEL_REPORT_HDR].congested_queue = 1
            # verify e2e mirrored packet
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])

            verify_no_other_packets(self)
            print "Passed for local stateless suppression for packet w/o digest"

            ####################################################################
            # int packet with digest
            # -> no upstream but downstream for stless with low threshold
            exp_i2e_pkt = ipv4_dtel_pkt(
                eth_dst=params.mac_nbr[params.report_ports[0]],
                eth_src=params.mac_self,
                ip_src=params.ipaddr_report_src[0],
                ip_dst=params.ipaddr_report_dst[0],
                ip_id=0,
                ip_ttl=64,
                next_proto=DTEL_REPORT_NEXT_PROTO_ETHERNET,
                dropped=0,
                congested_queue=0,
                path_tracking_flow=1,
                hw_id=hw_id,
                inner_frame=int_digest_pkt)

            print "Cleanup and disable the bloom filters"
            # wait to clear up the filter
            self.client.switch_api_dtel_flow_state_clear_cycle(
                device=device, cycle=reset_cycle)
            time.sleep(min_sleeptime)
            self.client.switch_api_dtel_flow_state_clear_cycle(device=device,
                                                               cycle=0)
            time.sleep(2 * reset_cycle)

            send_packet(self, swports[0], str(int_digest_pkt))
            verify_packet(self, exp_pkt, swports[1])

            # verify i2e mirrored packet
            verify_int_l45_dtel_packet(self, exp_i2e_pkt,
                                       swports[params.report_ports[0]])

            # verify e2e mirrored packet
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            # send the packet again but now it should only have downstream
            # if threshold is low
            print "enable queue report threshold: high threshold"
            exp_e2e_pkt[DTEL_REPORT_HDR].congested_queue = 0
            # set queue report with max latency threshold
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)

            send_packet(self, swports[0], str(int_digest_pkt))
            verify_packet(self, exp_pkt, swports[1])

            # no upstream or downstream report

            verify_no_other_packets(self)

            print "enable queue report threshold: low threshold"
            # set queue report with latency threshold 0
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)

            send_packet(self, swports[0], str(int_digest_pkt))
            verify_packet(self, exp_pkt, swports[1])

            # only downstream report

            # verify e2e mirrored packet
            exp_e2e_pkt[DTEL_REPORT_HDR].congested_queue = 1
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])

            verify_no_other_packets(self)

            print "disable queue report"
            # disable queue alsert
            self.client.switch_api_dtel_queue_report_delete(
                device, swports[1], 0)
            queue_report_enabled = False
            send_packet(self, swports[0], str(int_digest_pkt))
            verify_packet(self, exp_pkt, swports[1])

            # no upstream or downstream as suppressed by stful suppression

            verify_no_other_packets(self)
            print "Passed for local stateless suppression for packet w/ digest"

        finally:
            ### Cleanup
            print "Test Cleanup"
            cleanup_int_l45_bindings()
            if queue_report_enabled:
                self.client.switch_api_dtel_queue_report_delete(
                    device, swports[1], 0)
            if endpoint_enabled:
                self.client.switch_api_dtel_int_edge_ports_delete(
                    device=device, port=swports[1])
                self.client.switch_api_dtel_int_endpoint_disable(device=device)
            config.cleanup(self)
コード例 #11
0
    def runTest(self):
        print "Test INT L45 State less source device"
        pd_base_tests.ThriftInterfaceDataPlane.setUp(self)
        hw_id = get_pipeid(
            swport_to_devport(self, swports[params.report_ports[0]]))
        api_base_tests.ThriftInterfaceDataPlane.setUp(self)
        prepare_int_l45_bindings()
        config = SwitchConfig(self, params)

        payload = 'int_l45'
        pkt = simple_udp_packet(eth_dst=params.mac_self,
                                eth_src=params.mac_nbr[0],
                                ip_dst=params.ipaddr_nbr[1],
                                ip_src=params.ipaddr_nbr[0],
                                ip_id=108,
                                ip_ttl=64,
                                with_udp_chksum=False,
                                udp_payload=payload)
        exp_pkt_simple = simple_udp_packet(eth_dst=params.mac_nbr[1],
                                           eth_src=params.mac_self,
                                           ip_dst=params.ipaddr_nbr[1],
                                           ip_src=params.ipaddr_nbr[0],
                                           ip_id=108,
                                           ip_ttl=63,
                                           with_udp_chksum=False,
                                           udp_payload=payload)

        exp_pkt = int_l45_src_packet(test=self,
                                     int_inst_mask=0x8000,
                                     int_inst_cnt=1,
                                     max_hop_cnt=8,
                                     pkt=exp_pkt_simple)

        exp_pkt = int_l45_packet_add_hop_info(Packet=exp_pkt,
                                              val=SID,
                                              incr_cnt=1)

        exp_e2e_inner_1 = postcard_report(packet=exp_pkt_simple,
                                          switch_id=SID,
                                          ingress_port=swports[0],
                                          egress_port=swports[1],
                                          queue_id=0,
                                          queue_depth=0,
                                          egress_tstamp=0)

        exp_inte2e_inner_1 = postcard_report(packet=exp_pkt,
                                             switch_id=SID,
                                             ingress_port=swports[0],
                                             egress_port=swports[1],
                                             queue_id=0,
                                             queue_depth=0,
                                             egress_tstamp=0)

        exp_e2e_pkt = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=0,
            hw_id=hw_id,
            inner_frame=exp_e2e_inner_1)

        exp_e2e_pkt_int = ipv4_dtel_pkt(
            eth_dst=params.mac_nbr[params.report_ports[0]],
            eth_src=params.mac_self,
            ip_src=params.ipaddr_report_src[0],
            ip_dst=params.ipaddr_report_dst[0],
            ip_id=0,
            ip_ttl=64,
            next_proto=DTEL_REPORT_NEXT_PROTO_SWITCH_LOCAL,
            dropped=0,
            congested_queue=1,
            path_tracking_flow=1,
            hw_id=hw_id,
            inner_frame=exp_inte2e_inner_1)

        queue_report_enabled = False
        endpoint_enabled = False
        try:

            print "disable queue report"
            # disable queue alsert
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_simple, swports[1])
            verify_no_other_packets(self)

            print "add flow for INT Source"
            # create an INT session
            self.client.switch_api_dtel_int_session_create(
                device=device,
                session_id=1,
                instruction=convert_int_instruction(0x8000),
                max_hop=8)

            # Add INT watchlist entry
            ap = switcht_twl_int_params_t(session_id=1,
                                          report_all_packets=True,
                                          flow_sample_percent=100)
            self.client.switch_api_dtel_int_watchlist_entry_create(
                device, twl_kvp, priority=1, watch=True, action_params=ap)

            # set quantization shift
            self.client.switch_api_dtel_latency_quantization_shift(
                device=device, quant_shift=high_quantization_shift)

            # enable int-ep
            self.client.switch_api_dtel_int_endpoint_enable(device=device)
            endpoint_enabled = True

            print "enable queue report threshold: high threshold"
            # set queue report with max latency threshold
            self.client.switch_api_dtel_queue_report_create(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            queue_report_enabled = True

            # high threshould should not generate report
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)

            print "enable queue report threshold: low threshold"
            # set queue report with latency threshold 0
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)
            # low threshold generates report
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt_int, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            print "disable queue report"
            # disable queue alsert
            self.client.switch_api_dtel_queue_report_delete(
                device, swports[1], 0)
            queue_report_enabled = False
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt, swports[1])
            verify_no_other_packets(self)

            print "disable INT endpoint"
            self.client.switch_api_dtel_int_endpoint_disable(device=device)
            endpoint_enabled = False
            print "enable queue report threshold: high threshold"
            # set queue report with max latency threshold
            self.client.switch_api_dtel_queue_report_create(
                device, swports[1], 0, hex_to_i32(0xfff),
                hex_to_i32(0xffffffff), 1024, False)
            queue_report_enabled = True

            # high threshould should not generate report
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_simple, swports[1])
            verify_no_other_packets(self)

            print "enable queue report threshold: low threshold"
            # set queue report with latency threshold 0
            self.client.switch_api_dtel_queue_report_update(
                device, swports[1], 0, 0, 0, 1024, False)
            # low threshold generates report
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_simple, swports[1])
            verify_int_lasthop_dtel_report_packet(
                self, exp_e2e_pkt, swports[params.report_ports[0]])
            verify_no_other_packets(self)

            print "disable queue report"
            # disable queue alsert
            self.client.switch_api_dtel_queue_report_delete(
                device, swports[1], 0)
            queue_report_enabled = False
            send_packet(self, swports[0], str(pkt))
            verify_packet(self, exp_pkt_simple, swports[1])
            verify_no_other_packets(self)

        finally:
            ### Cleanup
            cleanup_int_l45_bindings()
            if queue_report_enabled:
                self.client.switch_api_dtel_queue_report_delete(
                    device, swports[1], 0)
            if endpoint_enabled:
                self.client.switch_api_dtel_int_endpoint_disable(device=device)
            self.client.switch_api_dtel_int_watchlist_entry_delete(
                device=device, twl_kvp=twl_kvp)
            self.client.switch_api_dtel_int_session_delete(device=device,
                                                           session_id=1)
            config.cleanup(self)