Ejemplo n.º 1
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        PBBR1 = pv.vars['PBBR1']
        PBBR1_ETH = pv.vars['PBBR1_ETH']
        PBBR2 = pv.vars['PBBR2']
        PBBR2_ETH = pv.vars['PBBR2_ETH']
        ROUTER1 = pv.vars['ROUTER1']
        ROUTER2 = pv.vars['ROUTER2']
        HOST_ETH = pv.vars['Host_ETH']
        HOST_BGUA = pv.vars['Host_BGUA']

        ROUTER1_DUA = pv.vars['ROUTER1_DUA']
        ROUTER2_DUA = pv.vars['ROUTER2_DUA']

        ROUTER1_RLOC16 = pv.vars['ROUTER1_RLOC16']

        #
        # Verify Host ping MA1 to R1 and R2
        #

        # Host should send ping MA1 in the Backbone link
        ping_ma1 = pkts.filter_eth_src(HOST_ETH).filter_ipv6_src_dst(HOST_BGUA, MA1).filter_ping_request().must_next()

        with pkts.save_index():
            # PBBR1 should forward ping reply to the Backbone link
            pkts.filter_eth_src(PBBR1_ETH).filter_ipv6_src_dst(
                ROUTER1_DUA, HOST_BGUA).filter_ping_reply(identifier=ping_ma1.icmpv6.echo.identifier).must_next()

        # PBBR2 should forward ping reply to the Backbone link
        pkts.filter_eth_src(PBBR2_ETH).filter_ipv6_src_dst(
            ROUTER2_DUA, HOST_BGUA).filter_ping_reply(identifier=ping_ma1.icmpv6.echo.identifier).must_next()

        #
        # Verify R1 pings MA2 to Host and R2
        #

        # ROUTER1 should send the multicast ping request
        ping_ma2 = pkts.filter_wpan_src64(ROUTER1).filter_AMPLFMA(
            mpl_seed_id=ROUTER1_RLOC16).filter_ping_request().must_next()

        # PBBR1 should forward the multicast ping request to the Backbone link
        pkts.filter_eth_src(PBBR1_ETH).filter_ipv6_src_dst(
            ROUTER1_DUA, MA2).filter_ping_request(identifier=ping_ma2.icmpv6.echo.identifier).must_next()

        with pkts.save_index():
            # Host should send ping reply to Router1
            pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(ROUTER1_DUA).filter_ping_reply(
                identifier=ping_ma2.icmpv6.echo.identifier).must_next()

        # PBBR2 should forward the multicast ping request to Thread network at CH2
        pkts.filter_wpan_src64(PBBR2).filter_AMPLFMA().filter_ping_request(
            identifier=ping_ma2.icmpv6.echo.identifier).must_next()

        # ROUTER2 should send ping reply back to ROUTER1
        pkts.filter_wpan_src64(ROUTER2).filter_ipv6_src_dst(
            ROUTER2_DUA, ROUTER1_DUA).filter_ping_reply(identifier=ping_ma2.icmpv6.echo.identifier).must_next()
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        ROUTER = pv.vars['ROUTER']
        PBBR = pv.vars['PBBR']
        MM = pv.vars['MM_PORT']
        HOST_ETH = pv.vars['Host_ETH']
        HOST_BGUA = pv.vars['Host_BGUA']

        start = pkts.index

        # Verify that Router sends MLR.req for MA1
        pkts.filter_wpan_src64(ROUTER).filter_coap_request(
            '/n/mr', port=MM).must_next().must_verify(
                'thread_meshcop.tlv.ipv6_addr == {ipv6_addr}', ipv6_addr=[MA1])

        mr_index = pkts.index

        # Host pings Router before MLR.reg
        before_mr_pkts = pkts.range(start, mr_index, cascade=False)
        ping = before_mr_pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()

        # PBBR should not forward this ping request to Thread network
        before_mr_pkts.filter_wpan_src64(PBBR).filter_ipv6_dst(
            MA1).filter_ping_request(
                identifier=ping.icmpv6.echo.identifier).must_not_next()

        # Host pings Router after MLR.req
        ping = pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()
        # PBBR should forward this ping request to Thread network
        pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter_ping_request(
            identifier=ping.icmpv6.echo.identifier).must_next()
        # Router should reply
        pkts.filter_wpan_src64(ROUTER).filter_ipv6_dst(
            HOST_BGUA).filter_ping_reply(
                identifier=ping.icmpv6.echo.identifier).must_next()

        # Host pings Router after Router unsubscribed MA
        ping = pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()
        # PBBR should forward this ping request to Thread network because MA doesn't expire yet
        pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter_ping_request(
            identifier=ping.icmpv6.echo.identifier).must_next()
        # Router should NOT reply because it has unsubcribed the multicast address
        pkts.filter_wpan_src64(ROUTER).filter_ipv6_dst(
            HOST_BGUA).filter_ping_reply(
                identifier=ping.icmpv6.echo.identifier).must_not_next()

        # Host pings Router after MLR timeout
        ping = pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()
        # PBBR should NOT forward this ping request to Thread network because MLR has timeout
        pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter_ping_request(
            identifier=ping.icmpv6.echo.identifier).must_not_next()
Ejemplo n.º 3
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        PBBR = pv.vars['PBBR']
        PBBR2 = pv.vars['PBBR2']
        ROUTER1 = pv.vars['ROUTER1']
        ROUTER2 = pv.vars['ROUTER2']
        SBBR = pv.vars['SBBR']
        PBBR_DUA = pv.vars['PBBR_DUA']
        SBBR_DUA = pv.vars['SBBR_DUA']
        ROUTER1_DUA = pv.vars['ROUTER1_DUA']
        ROUTER2_DUA = pv.vars['ROUTER2_DUA']
        HOST_BGUA = pv.vars['HOST_BGUA']
        PBBR_ETH = pv.vars['PBBR_ETH']
        PBBR2_ETH = pv.vars['PBBR2_ETH']

        # Verify that SBBR should not foward any Ping Request to the Thread network.
        # Use `ipv6.hlim == 63` to avoid false fails because SBBR might still forward Ping Request from PBBR to ROUTER1
        pkts.filter_wpan_src64(SBBR).filter_ping_request().filter(
            'ipv6.hlim == 63').must_not_next()

        # Step 1: Host pings PBBR's DUA
        # PBBR should not forward the Ping Request to Thread network
        ping1_pkts = pkts.filter_ipv6_src_dst(HOST_BGUA,
                                              PBBR_DUA).filter_ping_request()
        ping1_pkts.filter_eth().must_next()
        ping1_pkts.filter_wpan().must_not_next()

        # Step 2: Host pings SBBR's DUA
        # PBBR should forward the Ping Request to Thread network according to DUA routes
        ping2_pkts = pkts.filter_ipv6_src_dst(HOST_BGUA,
                                              SBBR_DUA).filter_ping_request()
        ping2_pkts.filter_eth().must_next()
        ping2_pkts.filter_wpan().must_next()

        # Step 3: Host pings ROUTER1's DUA
        # PBBR should forward the Ping Request to Thread network according to DUA routes
        ping3_pkts = pkts.filter_ipv6_src_dst(
            HOST_BGUA, ROUTER1_DUA).filter_ping_request()
        ping3_pkts.filter_eth().must_next()
        ping3_pkts.filter_wpan().must_next()

        # Step 4: ROUTER2 pings ROUTER1
        # Verify Ping Request: ROUTER2 -> PBBR2 -> PBBR -> ROUTER1
        ping4_request_pkts = pkts.filter_ipv6_src_dst(ROUTER2_DUA, ROUTER1_DUA)
        ping4_id = ping4_request_pkts.filter_wpan_src64(
            ROUTER2).filter_ping_request().must_next().icmpv6.echo.identifier
        ping4_request_pkts.filter_eth_src(PBBR2_ETH).filter_ping_request(
            identifier=ping4_id).must_next()
        ping4_request_pkts.filter_wpan_src64(PBBR).filter_ping_request(
            identifier=ping4_id).must_next()
        # Verify Ping Reply: ROUTER1 -> PBBR -> PBBR2 -> ROUTER2
        ping4_reply_pkts = pkts.filter_ipv6_src_dst(
            ROUTER1_DUA, ROUTER2_DUA).filter_ping_reply(identifier=ping4_id)
        ping4_reply_pkts.filter_eth_src(PBBR_ETH).must_next()
Ejemplo n.º 4
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        ROUTER = pv.vars['ROUTER']
        PBBR = pv.vars['PBBR']
        MM = pv.vars['MM_PORT']
        HOST_ETH = pv.vars['Host_ETH']
        HOST_BGUA = pv.vars['Host_BGUA']

        start = pkts.index

        # Verify that Router sends MLR.req for MA1 with Commissioner timeout
        pkts.filter_wpan_src64(ROUTER).filter_coap_request(
            '/n/mr', port=MM).must_next().must_verify(
                """
                thread_meshcop.tlv.ipv6_addr == {ipv6_addr}
                and thread_nm.tlv.timeout == {timeout}
                and {NM_COMMISSIONER_SESSION_ID_TLV} in thread_nm.tlv.type
            """,
                ipv6_addr=[MA1],
                timeout=COMMISSIONER_MLR_TIMEOUT,
                NM_COMMISSIONER_SESSION_ID_TLV=NM_COMMISSIONER_SESSION_ID_TLV)

        mr_index = pkts.index

        # Ping 1: Host pings Router before MLR.reg
        before_mr_pkts = pkts.range(start, mr_index, cascade=False)
        ping1 = before_mr_pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()

        # PBBR should not forward Ping 1 to Thread network
        before_mr_pkts.filter_wpan_src64(PBBR).filter_ipv6_dst(
            MA1).filter_ping_request(
                identifier=ping1.icmpv6.echo.identifier).must_not_next()

        # Ping 2: Host pings Router after MLR.req
        ping2 = pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()
        # PBBR should forward this ping request to Thread network
        pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter_ping_request(
            identifier=ping2.icmpv6.echo.identifier).must_next()

        # Ping 3: Host pings Router after delayed MLR Timeout
        ping3 = pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()
        # PBBR should forward this ping request to Thread network because MA doesn't expire yet
        pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter_ping_request(
            identifier=ping3.icmpv6.echo.identifier).must_next()

        # Ping 4: Host pings Router after delayed Commissioner MLR Timeout
        ping4 = pkts.filter_eth_src(HOST_ETH).filter_ipv6_dst(
            MA1).filter_ping_request().must_next()
        # PBBR should NOT forward this ping request to Thread network because MLR has timeout
        pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter_ping_request(
            identifier=ping4.icmpv6.echo.identifier).must_not_next()
Ejemplo n.º 5
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()
        pv.verify_attached('BR_1')

        MM = pv.vars['MM_PORT']
        BB = pv.vars['BB_PORT']
        BR_1 = pv.vars['BR_1']
        BR_1_ETH = pv.vars['BR_1_ETH']
        Host_ETH = pv.vars['Host_ETH']
        BR_1_BGUA = pv.vars['BR_1_BGUA']
        Host_BGUA = pv.vars['Host_BGUA']
        Dg = pv.vars['Dg']  # DUA of Router_2

        # Step 3: BR_1: Checks received Network Data and determines that it needs to send its BBR Dataset to the
        #               leader to become primary BBR.
        pkts.filter_wpan_src64(BR_1).filter_coap_request(
            '/a/sd', port=MM).must_next().must_verify("""
            thread_nwd.tlv.server_16 is not null
            and thread_nwd.tlv.service.s_data.seqno is not null
            and thread_nwd.tlv.service.s_data.rrdelay is not null
            and thread_nwd.tlv.service.s_data.mlrtimeout is not null
        """)

        # Step 9: BR_1: Responds to the DUA registration.
        pkts.filter_wpan_src64(BR_1).filter_coap_ack(
            '/n/dr',
            port=MM).must_next().must_verify('thread_nm.tlv.status == 0')

        # TODO: (DUA) Step 10: BR_1: Performs DAD on the backbone link.
        pkts.filter_eth_src(BR_1_ETH).filter_coap_request(
            '/b/bq', port=BB).must_not_next()

        # Verify Host ping BBR
        pkts.filter_eth_src(Host_ETH).filter_ipv6_src_dst(
            Host_BGUA, BR_1_BGUA).filter_ping_request().must_next()
        pkts.filter_eth_src(BR_1_ETH).filter_ipv6_src_dst(
            BR_1_BGUA, Host_BGUA).filter_ping_reply().must_next()

        # Verify BR_1 ping Host
        pkts.filter_eth_src(BR_1_ETH).filter_ipv6_src_dst(
            BR_1_BGUA, Host_BGUA).filter_ping_request().must_next()
        pkts.filter_eth_src(Host_ETH).filter_ipv6_src_dst(
            Host_BGUA, BR_1_BGUA).filter_ping_reply().must_next()

        # Step 16: Host: Queries DUA, Dg, with ND-NS
        # TODO: setup radvd on Host
        pkts.filter_eth_src(Host_ETH).filter_icmpv6_nd_ns(Dg).must_not_next()

        # Step 17: BR_1: Responds with a neighbor advertisement.
        # TODO: (DUA) implement ND proxy on PBBR
        pkts.filter_eth_src(BR_1_ETH).filter_icmpv6_nd_na(Dg).must_not_next()
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        with pkts.save_index():
            pv.verify_attached('ROUTER')

        PBBR = pv.vars['PBBR']
        ROUTER = pv.vars['ROUTER']

        # PBBR MUST NOT send ICMPv6 Destination Unreachable
        pkts.filter_wpan_src64(PBBR).filter_wpan_dst64(ROUTER).filter(
            f'icmpv6.type == {ICMPV6_TYPE_DESTINATION_UNREACHABLE}').must_not_next()
Ejemplo n.º 7
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()
        pv.verify_attached('BR_1')

        MM = pv.vars['MM_PORT']
        BB = pv.vars['BB_PORT']
        BR_1 = pv.vars['BR_1']
        BR_1_ETH = pv.vars['BR_1_ETH']
        Host_ETH = pv.vars['Host_ETH']
        BR_1_BGUA = pv.vars['BR_1_BGUA']
        Host_BGUA = pv.vars['Host_BGUA']
        Dg = pv.vars['Dg']  # DUA of Router_2
        ROUTER2 = pv.vars['Router_2']

        # Step 3: BR_1: Checks received Network Data and determines that it needs to send its BBR Dataset to the
        #               leader to become primary BBR.
        pkts.filter_wpan_src64(BR_1).filter_coap_request(
            '/a/sd', port=MM).must_next().must_verify("""
            thread_nwd.tlv.server_16 is not null
            and thread_nwd.tlv.service.s_data.seqno is not null
            and thread_nwd.tlv.service.s_data.rrdelay is not null
            and thread_nwd.tlv.service.s_data.mlrtimeout is not null
        """)

        pv.verify_dua_registration(ROUTER2,
                                   Dg,
                                   pbbr_eth=BR_1_ETH,
                                   pbbr_src64=BR_1)

        # Verify Host ping BBR
        pkts.filter_eth_src(Host_ETH).filter_ipv6_src_dst(
            Host_BGUA, BR_1_BGUA).filter_ping_request().must_next()
        pkts.filter_eth_src(BR_1_ETH).filter_ipv6_src_dst(
            BR_1_BGUA, Host_BGUA).filter_ping_reply().must_next()

        # Verify BR_1 ping Host
        pkts.filter_eth_src(BR_1_ETH).filter_ipv6_src_dst(
            BR_1_BGUA, Host_BGUA).filter_ping_request().must_next()
        pkts.filter_eth_src(Host_ETH).filter_ipv6_src_dst(
            Host_BGUA, BR_1_BGUA).filter_ping_reply().must_next()

        # Step 16: Host: Queries DUA, Dg, with ND-NS
        pkts.filter_eth_src(Host_ETH).filter_icmpv6_nd_ns(Dg).must_next()

        # Step 17: BR_1: Responds with a neighbor advertisement.
        pkts.filter_eth_src(BR_1_ETH).filter_icmpv6_nd_na(Dg).must_next()
Ejemplo n.º 8
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()
        pv.verify_attached('ROUTER1')

        ROUTER1 = pv.vars['ROUTER1']
        COMMISSIONER = pv.vars['COMMISSIONER']
        PBBR_ETH = pv.vars['PBBR_ETH']
        SBBR_ETH = pv.vars['SBBR_ETH']

        # Verify SBBR must not send `/b/bmr` during the test.
        pkts.filter_eth_src(SBBR_ETH).filter_coap_request('/b/bmr').must_not_next()

        # Verify PBBR sends `/b/bmr` on the Backbone link for MA1 with default timeout.
        pkts.filter_eth_src(PBBR_ETH).filter_coap_request('/b/bmr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA1}']
            and thread_bl.tlv.timeout == {MLR_TIMEOUT}
            and ipv6.src.is_link_local
        """)

        # Router registers MA2 with default timeout
        pkts.filter_wpan_src64(ROUTER1).filter_coap_request('/n/mr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA2}']
            and thread_bl.tlv.timeout is null
        """)
        # Verify PBBR sends `/b/bmr` on the Backbone link for MA2 with default timeout.
        pkts.filter_eth_src(PBBR_ETH).filter_coap_request('/b/bmr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA2}']
            and thread_bl.tlv.timeout == {MLR_TIMEOUT}
            and ipv6.src.is_link_local
        """)

        # Commissioner registers MA3 with deafult timeout
        pkts.filter_wpan_src64(COMMISSIONER).filter_coap_request('/n/mr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA3}']
            and thread_bl.tlv.timeout is null
        """)
        # Verify PBBR sends `/b/bmr` on the Backbone link for MA3 with default timeout.
        pkts.filter_eth_src(PBBR_ETH).filter_coap_request('/b/bmr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA3}']
            and thread_bl.tlv.timeout == {MLR_TIMEOUT}
            and ipv6.src.is_link_local
        """)

        # Commissioner registers MA4 with custom timeout
        pkts.filter_wpan_src64(COMMISSIONER).filter_coap_request('/n/mr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA4}']
            and thread_nm.tlv.timeout == {CUSTOM_MLR_TIMEOUT}
        """)
        # Verify PBBR sends `/b/bmr` on the Backbone link for MA4 with custom timeout.
        pkts.filter_eth_src(PBBR_ETH).filter_coap_request('/b/bmr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA4}']
            and thread_bl.tlv.timeout == {CUSTOM_MLR_TIMEOUT}
            and ipv6.src.is_link_local
        """)

        # Commissioner unregisters MA5
        pkts.filter_wpan_src64(COMMISSIONER).filter_coap_request('/n/mr').must_next().must_verify(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA5}']
            and thread_nm.tlv.timeout == 0
        """)
        # Verify PBBR not sends `/b/bmr` on the Backbone link for MA5.
        pkts.filter_eth_src(PBBR_ETH).filter_coap_request('/b/bmr').filter(f"""
            thread_meshcop.tlv.ipv6_addr == ['{MA5}']
            and ipv6.src.is_link_local
        """).must_not_next()
Ejemplo n.º 9
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        PBBR_DUA = pv.vars['PBBR_DUA']
        SBBR_DUA = pv.vars['SBBR_DUA']
        ROUTER1_DUA = pv.vars['ROUTER1_DUA']
        PBBR_ETH = pv.vars['PBBR_ETH']
        SBBR_ETH = pv.vars['SBBR_ETH']
        HOST_ETH = pv.vars['HOST_ETH']
        HOST_BGUA = pv.vars['HOST_BGUA']

        # SBBR must not send NA for any DUA
        pkts.filter_eth_src(SBBR_ETH).filter_LLANMA().filter_icmpv6_nd_na(
            PBBR_DUA).must_not_next()
        pkts.filter_eth_src(SBBR_ETH).filter_LLANMA().filter_icmpv6_nd_na(
            SBBR_DUA).must_not_next()
        pkts.filter_eth_src(SBBR_ETH).filter_LLANMA().filter_icmpv6_nd_na(
            ROUTER1_DUA).must_not_next()

        # PBBR must send unsolicited NA for PBBR's DUA
        pkts.filter_eth_src(PBBR_ETH).filter_LLANMA().filter_icmpv6_nd_na(
            PBBR_DUA).filter(
                'icmpv6.nd.na.flag.s == 0').must_next().must_verify(
                    """
            icmpv6.opt.linkaddr == {PBBR_ETH}
            and icmpv6.nd.na.flag.r == 1
            and icmpv6.nd.na.flag.o == 1
            and icmpv6.nd.na.flag.rsv == 0
        """,
                    PBBR_ETH=PBBR_ETH)

        # PBBR must send unsolicited NA for SBBR's DUA
        pkts.filter_eth_src(PBBR_ETH).filter_LLANMA().filter_icmpv6_nd_na(
            SBBR_DUA).filter(
                'icmpv6.nd.na.flag.s == 0').must_next().must_verify(
                    """
            icmpv6.opt.linkaddr == {PBBR_ETH}
            and icmpv6.nd.na.flag.r == 1
            and icmpv6.nd.na.flag.o == 1
            and icmpv6.nd.na.flag.rsv == 0
        """,
                    PBBR_ETH=PBBR_ETH)

        # PBBR must send unsolicited NA for ROUTER1's DUA
        pkts.filter_eth_src(PBBR_ETH).filter_LLANMA().filter_icmpv6_nd_na(
            ROUTER1_DUA).filter(
                'icmpv6.nd.na.flag.s == 0').must_next().must_verify(
                    """
            icmpv6.opt.linkaddr == {PBBR_ETH}
            and icmpv6.nd.na.flag.r == 1
            and icmpv6.nd.na.flag.o == 1
            and icmpv6.nd.na.flag.rsv == 0
        """,
                    PBBR_ETH=PBBR_ETH)

        # HOST should send NS for PBBR's DUA
        pkts.filter_eth_src(HOST_ETH).filter_icmpv6_nd_ns(PBBR_DUA).must_next()
        # PBBR must send solicited NA for PBBR's DUA
        pkts.filter_eth_src(PBBR_ETH).filter_ipv6_dst(
            HOST_BGUA).filter_icmpv6_nd_na(PBBR_DUA).filter(
                'icmpv6.nd.na.flag.s == 1').must_next().must_verify(
                    """
            icmpv6.opt.linkaddr == {PBBR_ETH}
            and icmpv6.nd.na.flag.r == 1
            and icmpv6.nd.na.flag.o == 0
            and icmpv6.nd.na.flag.rsv == 0
        """,
                    PBBR_ETH=PBBR_ETH)

        # Host should send NS for SBBR's DUA
        pkts.filter_eth_src(HOST_ETH).filter_icmpv6_nd_ns(SBBR_DUA).must_next()
        # PBBR must send solicited NA for SBBR's DUA
        pkts.filter_eth_src(PBBR_ETH).filter_ipv6_dst(
            HOST_BGUA).filter_icmpv6_nd_na(SBBR_DUA).filter(
                'icmpv6.nd.na.flag.s == 1').must_next().must_verify(
                    """
            icmpv6.opt.linkaddr == {PBBR_ETH}
            and icmpv6.nd.na.flag.r == 1
            and icmpv6.nd.na.flag.o == 0
            and icmpv6.nd.na.flag.rsv == 0
        """,
                    PBBR_ETH=PBBR_ETH)

        # Host should send NS for ROUTER1's DUA
        pkts.filter_eth_src(HOST_ETH).filter_icmpv6_nd_ns(
            ROUTER1_DUA).must_next()
        # PBBR must send solicited NA for ROUTER1's DUA
        pkts.filter_eth_src(PBBR_ETH).filter_ipv6_dst(
            HOST_BGUA).filter_icmpv6_nd_na(ROUTER1_DUA).filter(
                'icmpv6.nd.na.flag.s == 1').must_next().must_verify(
                    """
            icmpv6.opt.linkaddr == {PBBR_ETH}
            and icmpv6.nd.na.flag.r == 1
            and icmpv6.nd.na.flag.o == 0
            and icmpv6.nd.na.flag.rsv == 0
        """,
                    PBBR_ETH=PBBR_ETH)
 def _verify_packets(self, test_info_path: str):
     pv = PacketVerifier(test_info_path)
     pv.add_common_vars()
     self.verify(pv)
     print("Packet verification passed: %s" % test_info_path,
           file=sys.stderr)
Ejemplo n.º 11
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        PBBR = pv.vars['PBBR']
        ROUTER1 = pv.vars['ROUTER1']
        PBBR2 = pv.vars['PBBR2']
        MED1 = pv.vars['MED1']
        MED2 = pv.vars['MED2']
        MED1_DUA = pv.vars['MED1_DUA']
        ROUTER1_DUA = pv.vars['ROUTER1_DUA']
        PBBR_DUA = pv.vars['PBBR_DUA']
        PBBR2_DUA = pv.vars['PBBR2_DUA']
        MED2_DUA = pv.vars['MED2_DUA']
        PBBR_ETH = pv.vars['PBBR_ETH']
        PBBR2_ETH = pv.vars['PBBR2_ETH']

        # PBBR should never send Address Query for MED1 (Child)
        pkts.filter_wpan_src64(PBBR).filter_RLARMA().filter_coap_request(ADDR_QRY_URI) \
            .filter('thread_address.tlv.target_eid == {eid}', eid=MED1_DUA) \
            .must_not_next()

        # PBBR2 should never send Address Query for MED2 (Child)
        pkts.filter_wpan_src64(PBBR2).filter_RLARMA().filter_coap_request(ADDR_QRY_URI) \
            .filter('thread_address.tlv.target_eid == {eid}', eid=MED2_DUA) \
            .must_not_next()

        # MEDs should never send Address Query
        pkts.filter_wpan_src64(MED1).filter_RLARMA().filter_coap_request(
            ADDR_QRY_URI).must_not_next()
        pkts.filter_wpan_src64(MED2).filter_RLARMA().filter_coap_request(
            ADDR_QRY_URI).must_not_next()

        # PBBR pings PBBR2 should succeed
        ping_id = pkts.filter_ipv6_src_dst(PBBR_DUA, PBBR2_DUA).filter_eth_src(
            PBBR_ETH).filter_ping_request().must_next().icmpv6.echo.identifier
        pkts.filter_ipv6_src_dst(
            PBBR2_DUA, PBBR_DUA).filter_eth_src(PBBR2_ETH).filter_ping_reply(
                identifier=ping_id).must_next()

        # MED1 pings ROUTER1
        ping_request_pkts = pkts.filter_ipv6_src_dst(MED1_DUA, ROUTER1_DUA)
        # MED1 sends the Ping Request
        ping_pkt = ping_request_pkts.filter_wpan_src64(
            MED1).filter_ping_request().must_next()
        ping_id = ping_pkt.icmpv6.echo.identifier
        # PBBR sends Address Query for ROUTER1_DUA
        pkts.filter_wpan_src64(PBBR).filter_RLARMA().filter_coap_request(ADDR_QRY_URI) \
            .filter('thread_address.tlv.target_eid == {eid}', eid=ROUTER1_DUA) \
            .must_next()
        # PBBR sends Backbone Query for ROUTER1_DUA
        pkts.filter_eth_src(PBBR_ETH).filter_coap_request(BACKBONE_QUERY_URI) \
            .filter('thread_bl.tlv.target_eid == {eid}', eid=ROUTER1_DUA) \
            .must_next()
        # ROUTER1 sends Address Answer for ROUTER1_DUA
        pkts.filter_wpan_src64(ROUTER1).filter_coap_request(ADDR_NTF_URI, confirmable=True) \
            .filter('thread_address.tlv.target_eid == {eid}', eid=ROUTER1_DUA) \
            .must_next()
        # PBBR forwards Ping Request to ROUTER1, decreasing TTL by 1
        ping_request_pkts.filter_wpan_src64(PBBR).filter_ping_request(
            identifier=ping_id).must_next().must_verify(
                'ipv6.hlim == {hlim}', hlim=ping_pkt.ipv6.hlim - 1)

        # MED1 pings MED2
        # Verify Ping Request: MED1 -> PBBR -> PBBR2 -> MED2
        ping_request_pkts = pkts.filter_ipv6_src_dst(MED1_DUA, MED2_DUA)
        # MED1 sends the Ping Request
        ping_pkt = ping_request_pkts.filter_wpan_src64(
            MED1).filter_ping_request().must_next()
        ping_id = ping_pkt.icmpv6.echo.identifier
        # PBBR sends Address Query for MED2_DUA
        pkts.filter_wpan_src64(PBBR).filter_RLARMA().filter_coap_request(ADDR_QRY_URI) \
            .filter('thread_address.tlv.target_eid == {eid}', eid=MED2_DUA) \
            .must_next()
        # PBBR sends Backbone Query for MED2_DUA
        pkts.filter_eth_src(PBBR_ETH).filter_coap_request(BACKBONE_QUERY_URI) \
            .filter('thread_bl.tlv.target_eid == {eid}', eid=MED2_DUA) \
            .must_next()
        # PBBR2 sends Backbone Answer for MED2_DUA
        pkts.filter_eth_src(PBBR2_ETH).filter_coap_request(BACKBONE_ANSWER_URI, confirmable=True) \
            .filter('thread_bl.tlv.target_eid == {eid}', eid=MED2_DUA) \
            .must_next()
        # PBBR forwards Ping Request to Backbone link, decreasing TTL by 1
        ping_request_pkts.filter_eth_src(PBBR_ETH).filter_ping_request(
            identifier=ping_id).must_next().must_verify(
                'ipv6.hlim == {hlim}', hlim=ping_pkt.ipv6.hlim - 1)
        ping_request_pkts.filter_wpan_src64(PBBR2).filter_ping_request(
            identifier=ping_id).must_next()
        # Verify Ping Reply: MED2 -> PBBR2 -> PBBR -> MED1
        ping_reply_pkts = pkts.filter_ipv6_src_dst(
            MED2_DUA, MED1_DUA).filter_ping_reply(identifier=ping_id)
        ping_reply_pkts.filter_eth_src(PBBR2_ETH).must_next()
Ejemplo n.º 12
0
 def _verify_packets(self, test_info_path: str):
     pv = PacketVerifier(test_info_path, self.CASE_WIRESHARK_PREFS)
     pv.add_common_vars()
     pv.pkts.filter_thread_unallowed_icmpv6().must_not_next()
     self.verify(pv)
     print("Packet verification passed: %s" % test_info_path, file=sys.stderr)
Ejemplo n.º 13
0
    def verify(self, pv: PacketVerifier):
        pkts = pv.pkts
        pv.add_common_vars()
        pv.summary.show()

        PBBR = pv.vars['PBBR']
        ROUTER1 = pv.vars['ROUTER1']
        ROUTER1_DUA = pv.vars['ROUTER1_DUA']
        ROUTER2 = pv.vars['ROUTER2']
        ROUTER2_DUA = pv.vars['ROUTER2_DUA']
        PBBR_ETH = pv.vars['PBBR_ETH']
        SBBR_ETH = pv.vars['SBBR_ETH']
        PBBR2 = pv.vars['PBBR2']
        PBBR2_ETH = pv.vars['PBBR2_ETH']

        MM = pv.vars['MM_PORT']
        BB = pv.vars['BB_PORT']

        # Verify the whole DAD process for ROUTER1
        pv.verify_dua_registration(ROUTER1,
                                   ROUTER1_DUA,
                                   pbbr_eth=PBBR_ETH,
                                   pbbr_src64=PBBR,
                                   sbbr_eth=SBBR_ETH)

        # Verify the whole DAD process for ROUTER2
        pv.verify_dua_registration(ROUTER2,
                                   ROUTER2_DUA,
                                   pbbr_eth=PBBR2_ETH,
                                   pbbr_src64=PBBR2)

        ###############################################################################################################
        # Now we verify Extending ADDR.qry to BB.qry works for the Ping Request from Router2 to Router1
        ###############################################################################################################

        # Router2 should send ADDR.qry in the Thread network for Router1's DUA
        pkts.filter_wpan_src64(ROUTER2).filter_coap_request(
            '/a/aq',
            port=MM).filter('thread_address.tlv.target_eid == {ROUTER1_DUA}',
                            ROUTER1_DUA=ROUTER1_DUA).must_next()
        # PBBR2 should extend ADDR.qry to BB.qry
        pkts.filter_backbone_query(ROUTER1_DUA, eth_src=PBBR2_ETH,
                                   port=BB).must_next()
        # SBBR should not answer with BB.ans
        pkts.filter_backbone_query(ROUTER1_DUA, eth_src=SBBR_ETH,
                                   port=BB).must_not_next()
        # PBBR1 should answer with BB.ans
        pkts.filter_backbone_answer(ROUTER1_DUA, eth_src=PBBR_ETH,
                                    port=BB).must_next()
        # PBBR2 should send ADDR.ntf to Router2
        pkts.filter_wpan_src64(PBBR2).filter_coap_request(
            '/a/an',
            port=MM).filter('thread_address.tlv.target_eid == {ROUTER1_DUA}',
                            ROUTER1_DUA=ROUTER1_DUA).must_next()

        # Now, Router2 should send the Ping Request to PBBR2
        pkts.filter_wpan_src64(ROUTER2).filter_ping_request().filter_ipv6_dst(
            ROUTER1_DUA).must_next()

        ###############################################################################################################
        # Now we start to verify that DAD duplicate is handled correctly
        ###############################################################################################################

        # PBBR should send /b/bq for DUPLICATE_DUA
        pkts.filter_backbone_query(DUPLICATE_DUA, eth_src=PBBR_ETH,
                                   port=BB).must_next()

        # PBBR2 should send /b/ba for DUPLICATE_DUA
        ba = pkts.filter_backbone_answer(DUPLICATE_DUA,
                                         eth_src=PBBR2_ETH,
                                         port=BB).must_next()
        ba.must_verify("""
            set(thread_bl.tlv.type) == {tlvs}
            and thread_bl.tlv.last_transaction_time > 0
            and thread_meshcop.tlv.net_name == {NET_NAME}
        """,
                       tlvs={0, 3, 6, 12},
                       **pv.vars)

        # PBBR should NOT send /b/bq for DUPLICATE_DUA anymore
        pkts.filter_backbone_query(DUPLICATE_DUA, eth_src=PBBR_ETH,
                                   port=BB).must_not_next()

        # PBBR should send ADDR_ERR.ntf to Router1
        ROUTER1_RLOC = pv.vars['ROUTER1_RLOC']
        pkts.filter_wpan_src64(PBBR).filter_ipv6_dst(ROUTER1_RLOC).filter_coap_request('/a/ae', port=MM).must_next() \
            .must_verify("""
                thread_address.tlv.target_eid == {DUPLICATE_DUA}
                and thread_address.tlv.ml_eid == {ml_eid} 
            """, DUPLICATE_DUA=DUPLICATE_DUA, ml_eid=ba.thread_bl.tlv.ml_eid)

        # Router1 should generate new DUA and register again
        # Router1 should generate and register a new DUA
        with pkts.save_index():
            new_dr = pkts.filter_wpan_src64(ROUTER1).filter_coap_request(
                '/n/dr',
                port=MM).must_next().must_verify("""
                thread_nm.tlv.target_eid != {DUPLICATE_DUA}
            """,
                                                 DUPLICATE_DUA=DUPLICATE_DUA)
            router1_dua2 = new_dr.thread_nm.tlv.target_eid

        # Verify the DAD process for the new DUA
        pv.verify_dua_registration(ROUTER1,
                                   router1_dua2,
                                   pbbr_eth=PBBR_ETH,
                                   pbbr_src64=PBBR,
                                   sbbr_eth=SBBR_ETH)

        ###############################################################################################################
        # Now we start to verify that PRO_BB.ntf is handled correctly
        ###############################################################################################################

        # Scripted: PBBR2 should send PRO_BB.ntf for Router1's DUA
        pkts.filter_eth_src(PBBR2_ETH).filter_backbone_answer(
            router1_dua2, port=BB, confirmable=False,
            mliid=DUPLICATE_IID).must_next()

        # PBBR should broadcaset /a/ae to the Thread network
        pkts.filter_wpan_src64(PBBR).filter_coap_request(
            '/a/ae', port=MM, confirmable=False).filter_RLARMA().must_next()

        # Router1 should generate and register a new DUA
        with pkts.save_index():
            new_dr = pkts.filter_wpan_src64(ROUTER1).filter_coap_request(
                '/n/dr', port=MM).must_next()
            router1_dua3 = new_dr.thread_nm.tlv.target_eid

        # Verify the DAD process for the new DUA
        pv.verify_dua_registration(ROUTER1,
                                   router1_dua3,
                                   pbbr_eth=PBBR_ETH,
                                   pbbr_src64=PBBR,
                                   sbbr_eth=SBBR_ETH)