Beispiel #1
0
    def verify_capture_ip4(self, rx_if, sent, dst_mac=None):
        rxd = rx_if.get_capture(len(sent))

        try:
            capture = self.verify_filter(rxd, sent)

            self.assertEqual(len(capture), len(sent))

            for i in range(len(capture)):
                tx = sent[i]
                rx = capture[i]

                eth = rx[Ether]
                self.assertEqual(eth.type, 0x800)

                tx_ip = tx[IP]
                rx_ip = rx[IP]

                if dst_mac is None:
                    dst_mac = getmacbyip(rx_ip.dst)

                # check the MAC address on the RX'd packet is correctly formed
                self.assertEqual(eth.dst, dst_mac)

                self.assertEqual(rx_ip.src, tx_ip.src)
                self.assertEqual(rx_ip.dst, tx_ip.dst)
                # IP processing post pop has decremented the TTL
                self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)

        except:
            raise
Beispiel #2
0
    def verify_capture_ip4(self, src_if, sent):
        rxd = self.pg1.get_capture(N_PKTS_IN_STREAM)

        try:
            capture = self.verify_filter(rxd, sent)

            self.assertEqual(len(capture), len(sent))

            for i in range(len(capture)):
                tx = sent[i]
                rx = capture[i]

                # the rx'd packet has the MPLS label popped
                eth = rx[Ether]
                self.assertEqual(eth.type, 0x800)

                tx_ip = tx[IP]
                rx_ip = rx[IP]

                # check the MAC address on the RX'd packet is correctly formed
                self.assertEqual(eth.dst, getmacbyip(rx_ip.dst))

                self.assertEqual(rx_ip.src, tx_ip.src)
                self.assertEqual(rx_ip.dst, tx_ip.dst)
                # IP processing post pop has decremented the TTL
                self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)

        except:
            raise
Beispiel #3
0
    def verify_capture_ip4(self, rx_if, sent, dst_mac=None):
        rxd = rx_if.get_capture(len(sent))

        try:
            capture = self.verify_filter(rxd, sent)

            self.assertEqual(len(capture), len(sent))

            for i in range(len(capture)):
                tx = sent[i]
                rx = capture[i]

                eth = rx[Ether]
                self.assertEqual(eth.type, 0x800)

                tx_ip = tx[IP]
                rx_ip = rx[IP]

                if dst_mac is None:
                    dst_mac = getmacbyip(rx_ip.dst)

                # check the MAC address on the RX'd packet is correctly formed
                self.assertEqual(eth.dst, dst_mac)

                self.assertEqual(rx_ip.src, tx_ip.src)
                self.assertEqual(rx_ip.dst, tx_ip.dst)
                # IP processing post pop has decremented the TTL
                self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)

        except:
            raise
Beispiel #4
0
    def create_stream_ip4(self, src_if, src_ip, dst_ip, payload_size=0):
        pkts = []
        # default to small packet sizes
        p = (Ether(dst=getmacbyip(dst_ip), src=src_if.remote_mac) /
             IP(src=src_ip, dst=dst_ip) / UDP(sport=1234, dport=1234))
        if not payload_size:
            payload_size = 64 - len(p)
            p = p / Raw(b'\xa5' * payload_size)

        for i in range(0, N_PKTS_IN_STREAM):
            pkts.append(p)
        return pkts
Beispiel #5
0
    def test_ip_mcast_vrf(self):
        """IP Multicast Replication in non-default table"""

        MRouteItfFlags = VppEnum.vl_api_mfib_itf_flags_t
        MRouteEntryFlags = VppEnum.vl_api_mfib_entry_flags_t

        #
        # An (S,G).
        # one accepting interface, pg0, 2 forwarding interfaces
        #
        route_1_1_1_1_232_1_1_1 = VppIpMRoute(
            self,
            "1.1.1.1",
            "232.1.1.1",
            64,
            MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
            [
                VppMRoutePath(self.pg8.sw_if_index,
                              MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
                VppMRoutePath(self.pg1.sw_if_index,
                              MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD),
                VppMRoutePath(self.pg2.sw_if_index,
                              MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD),
            ],
            table_id=10,
        )
        route_1_1_1_1_232_1_1_1.add_vpp_config()

        #
        # a stream that matches the route for (1.1.1.1,232.1.1.1)
        #  small packets
        #
        self.vapi.cli("clear trace")
        tx = self.create_stream_ip4(self.pg8, "1.1.1.1", "232.1.1.1")
        self.pg8.add_stream(tx)

        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        # We expect replications on Pg1 & 2
        self.verify_capture_ip4(self.pg1, tx)
        self.verify_capture_ip4(self.pg2, tx)

        #
        # An (S,G). for for-us
        #
        route_0_0_0_0_224_0_0_5 = VppIpMRoute(
            self,
            "0.0.0.0",
            "224.0.0.5",
            32,
            MRouteEntryFlags.MFIB_API_ENTRY_FLAG_NONE,
            [
                VppMRoutePath(self.pg8.sw_if_index,
                              MRouteItfFlags.MFIB_API_ITF_FLAG_ACCEPT),
                VppMRoutePath(
                    0xFFFFFFFF,
                    MRouteItfFlags.MFIB_API_ITF_FLAG_FORWARD,
                    type=FibPathType.FIB_PATH_TYPE_LOCAL,
                ),
            ],
            table_id=10,
        )
        route_0_0_0_0_224_0_0_5.add_vpp_config()

        #
        # a stream that matches the route for (0.0.0.0, 224.0.0.5)
        #  small packets
        #
        self.vapi.cli("clear trace")
        self.pg8.resolve_arp()

        #
        # send a ping to mcast address from peer on pg8
        #  expect a response
        #
        icmp_id = 0xB
        icmp_seq = 5
        icmp_load = b"\x0a" * 18
        tx = (Ether(dst=getmacbyip("224.0.0.5"), src=self.pg8.remote_mac) /
              IP(src=self.pg8.remote_ip4, dst="224.0.0.5") /
              ICMP(id=icmp_id, seq=icmp_seq) / Raw(load=icmp_load)) * 2

        self.send_and_expect(self.pg8, tx, self.pg8)