Example #1
0
    def runTest(self):
        pkt = Ether(dst="11:11:11:11:11:11") / MPLS(
            label=20, cos=5, s=1,
            ttl=64) / simple_ip_only_packet(ip_dst="192.168.1.1")
        exp_pkt = Ether(dst="11:11:11:11:11:11") / simple_ip_only_packet(
            ip_dst="192.168.1.1")

        send_packet(self, (0, 1), pkt)
        verify_packets(self, exp_pkt, device_number=0, ports=[2])
Example #2
0
    def create_ipv4_inner_pkt_only(self,
                                   src_ip,
                                   dst_ip,
                                   tos,
                                   encap=False,
                                   ttl=64):
        """Creates an IP only packet for the test
        @param src_ip: source ip
        @param dst_ip: destination ip
        @param tos: type of service field
        @param encap: build encapsulated packet.
                      If @encap is True the return packet would be:
                      IP(@src_ip, @dst_ip, @tos) / IP(dst_ip=4.4.4.4, src_ip=3.3.3.3) / TCP()
        @param ttl: ttl field
        """

        inner_pkt = simple_ip_only_packet(ip_dst=dst_ip,
                                          ip_src=src_ip,
                                          ip_ttl=ttl,
                                          ip_tos=tos)
        if encap:
            inner_pkt2 = self.create_ipv4_inner_pkt_only(
                self.DEFAULT_INNER2_V4_PKT_SRC_IP,
                self.DEFAULT_INNER2_V4_PKT_DST_IP, 0)
            inner_pkt = simple_ipv4ip_packet(
                ip_src=src_ip,
                ip_dst=dst_ip,
                ip_tos=tos,
                ip_ttl=ttl,
                inner_frame=inner_pkt2).getlayer(
                    scapy.IP)  # get only the IP layer

        return inner_pkt
Example #3
0
 def mpls_packet(self, setup, ptfadapter):
     """ create MPLS packet for testing """
     return testutils.simple_mpls_packet(
         eth_dst=setup['eth_dst'],
         eth_src=ptfadapter.dataplane.get_mac(0, 10),
         mpls_tags=[{
             'label': 1000001,
             'ttl': 255,
             's': 1
         }],
         inner_frame=testutils.simple_ip_only_packet(
             ip_dst='192.168.0.1',
             ip_src='10.0.0.21',
         ))
Example #4
0
 def mpls_stack_packet(self, setup, ptfadapter):
     """ create MPLS packet for testing """
     return testutils.simple_mpls_packet(
         eth_dst=setup['src_mac'],
         eth_src=ptfadapter.dataplane.get_mac(0, setup['src_pid']),
         mpls_tags=[{
             'label': 1000001,
             'ttl': 255,
             's': 0
         }, {
             'label': 1000010,
             'ttl': 255,
             's': 0
         }, {
             'label': 1000011,
             'ttl': 255,
             's': 1
         }],
         inner_frame=testutils.simple_ip_only_packet(
             ip_dst='192.168.0.1',
             ip_src=setup['src_addr'],
         ))