def runTest(self): vlan_id = 10 self.set_internal_vlan(self.port1, False, 0, 0, vlan_id) self.set_forwarding_type(self.port1, SWITCH_MAC, 0x800, FORWARDING_TYPE_UNICAST_IPV4) self.add_forwarding_unicast_v4_entry(HOST2_IPV4, 24, 500) grp_id = 77 mpls_label = 0xaba mbrs = {2: (self.port2, SWITCH_MAC, HOST2_MAC, mpls_label)} self.add_next_hop_mpls_v4_group(500, grp_id, mbrs) self.set_egress_vlan_pop(self.port2, vlan_id) pkt_1to2 = testutils.simple_tcp_packet(eth_src=HOST1_MAC, eth_dst=SWITCH_MAC, ip_src=HOST1_IPV4, ip_dst=HOST2_IPV4, ip_ttl=64) exp_pkt_1to2 = testutils.simple_mpls_packet(eth_src=SWITCH_MAC, eth_dst=HOST2_MAC, mpls_tags=[{ "label": mpls_label, "tc": 0, "s": 1, "ttl": DEFAULT_MPLS_TTL }], inner_frame=pkt_1to2[IP:]) testutils.send_packet(self, self.port1, str(pkt_1to2)) testutils.verify_packets(self, exp_pkt_1to2, [self.port2])
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', ))
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'], ))