7 from scapy.contrib.mpls import MPLS
8 from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes
9 from scapy.layers.l2 import Ether, Dot1Q, ARP
10 from scapy.packet import Raw
13 from framework import VppTestCase, VppTestRunner
15 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
16 VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
17 VppMplsTable, VppIpTable, VppIpAddress
18 from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
21 class TestIPv4(VppTestCase):
22 """ IPv4 Test Case """
26 Perform test setup before test case.
29 - create 3 pg interfaces
30 - untagged pg0 interface
31 - Dot1Q subinterface on pg1
32 - Dot1AD subinterface on pg2
34 - put it into UP state
36 - resolve neighbor address using ARP
37 - configure 200 fib entries
39 :ivar list interfaces: pg interfaces and subinterfaces.
40 :ivar dict flows: IPv4 packet flows in test.
42 super(TestIPv4, self).setUp()
44 # create 3 pg interfaces
45 self.create_pg_interfaces(range(3))
47 # create 2 subinterfaces for pg1 and pg2
48 self.sub_interfaces = [
49 VppDot1QSubint(self, self.pg1, 100),
50 VppDot1ADSubint(self, self.pg2, 200, 300, 400)]
52 # packet flows mapping pg0 -> pg1.sub, pg2.sub, etc.
54 self.flows[self.pg0] = [self.pg1.sub_if, self.pg2.sub_if]
55 self.flows[self.pg1.sub_if] = [self.pg0, self.pg2.sub_if]
56 self.flows[self.pg2.sub_if] = [self.pg0, self.pg1.sub_if]
59 self.pg_if_packet_sizes = [64, 1500, 9020]
61 self.interfaces = list(self.pg_interfaces)
62 self.interfaces.extend(self.sub_interfaces)
64 # setup all interfaces
65 for i in self.interfaces:
70 # config 2M FIB entries
71 self.config_fib_entries(200)
74 """Run standard test teardown and log ``show ip arp``."""
75 super(TestIPv4, self).tearDown()
77 self.logger.info(self.vapi.cli("show ip arp"))
78 # info(self.vapi.cli("show ip fib")) # many entries
80 def config_fib_entries(self, count):
81 """For each interface add to the FIB table *count* routes to
82 "10.0.0.1/32" destination with interface's local address as next-hop
85 :param int count: Number of FIB entries.
87 - *TODO:* check if the next-hop address shouldn't be remote address
88 instead of local address.
90 n_int = len(self.interfaces)
93 dest_addr = socket.inet_pton(socket.AF_INET, "10.0.0.1")
95 for i in self.interfaces:
96 next_hop_address = i.local_ip4n
97 for j in range(count / n_int):
98 self.vapi.ip_add_del_route(
99 dest_addr, dest_addr_len, next_hop_address)
101 if counter / count * 100 > percent:
102 self.logger.info("Configure %d FIB entries .. %d%% done" %
106 def modify_packet(self, src_if, packet_size, pkt):
107 """Add load, set destination IP and extend packet to required packet
108 size for defined interface.
110 :param VppInterface src_if: Interface to create packet for.
111 :param int packet_size: Required packet size.
112 :param Scapy pkt: Packet to be modified.
114 dst_if_idx = packet_size / 10 % 2
115 dst_if = self.flows[src_if][dst_if_idx]
116 info = self.create_packet_info(src_if, dst_if)
117 payload = self.info_to_payload(info)
119 p[IP].dst = dst_if.remote_ip4
121 if isinstance(src_if, VppSubInterface):
122 p = src_if.add_dot1_layer(p)
123 self.extend_packet(p, packet_size)
127 def create_stream(self, src_if):
128 """Create input packet stream for defined interface.
130 :param VppInterface src_if: Interface to create packet stream for.
132 hdr_ext = 4 if isinstance(src_if, VppSubInterface) else 0
133 pkt_tmpl = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
134 IP(src=src_if.remote_ip4) /
135 UDP(sport=1234, dport=1234))
137 pkts = [self.modify_packet(src_if, i, pkt_tmpl)
138 for i in moves.range(self.pg_if_packet_sizes[0],
139 self.pg_if_packet_sizes[1], 10)]
140 pkts_b = [self.modify_packet(src_if, i, pkt_tmpl)
141 for i in moves.range(self.pg_if_packet_sizes[1] + hdr_ext,
142 self.pg_if_packet_sizes[2] + hdr_ext,
148 def verify_capture(self, dst_if, capture):
149 """Verify captured input packet stream for defined interface.
151 :param VppInterface dst_if: Interface to verify captured packet stream
153 :param list capture: Captured packet stream.
155 self.logger.info("Verifying capture on interface %s" % dst_if.name)
157 for i in self.interfaces:
158 last_info[i.sw_if_index] = None
160 dst_sw_if_index = dst_if.sw_if_index
161 if hasattr(dst_if, 'parent'):
163 for packet in capture:
165 # Check VLAN tags and Ethernet header
166 packet = dst_if.remove_dot1_layer(packet)
167 self.assertTrue(Dot1Q not in packet)
171 payload_info = self.payload_to_info(str(packet[Raw]))
172 packet_index = payload_info.index
173 self.assertEqual(payload_info.dst, dst_sw_if_index)
175 "Got packet on port %s: src=%u (id=%u)" %
176 (dst_if.name, payload_info.src, packet_index))
177 next_info = self.get_next_packet_info_for_interface2(
178 payload_info.src, dst_sw_if_index,
179 last_info[payload_info.src])
180 last_info[payload_info.src] = next_info
181 self.assertTrue(next_info is not None)
182 self.assertEqual(packet_index, next_info.index)
183 saved_packet = next_info.data
184 # Check standard fields
185 self.assertEqual(ip.src, saved_packet[IP].src)
186 self.assertEqual(ip.dst, saved_packet[IP].dst)
187 self.assertEqual(udp.sport, saved_packet[UDP].sport)
188 self.assertEqual(udp.dport, saved_packet[UDP].dport)
190 self.logger.error(ppp("Unexpected or invalid packet:", packet))
192 for i in self.interfaces:
193 remaining_packet = self.get_next_packet_info_for_interface2(
194 i.sw_if_index, dst_sw_if_index, last_info[i.sw_if_index])
195 self.assertTrue(remaining_packet is None,
196 "Interface %s: Packet expected from interface %s "
197 "didn't arrive" % (dst_if.name, i.name))
204 - Create IPv4 stream for pg0 interface
205 - Create IPv4 tagged streams for pg1's and pg2's sub-interface.
206 - Send and verify received packets on each interface.
209 pkts = self.create_stream(self.pg0)
210 self.pg0.add_stream(pkts)
212 for i in self.sub_interfaces:
213 pkts = self.create_stream(i)
214 i.parent.add_stream(pkts)
216 self.pg_enable_capture(self.pg_interfaces)
219 pkts = self.pg0.get_capture()
220 self.verify_capture(self.pg0, pkts)
222 for i in self.sub_interfaces:
223 pkts = i.parent.get_capture()
224 self.verify_capture(i, pkts)
227 class TestICMPEcho(VppTestCase):
228 """ ICMP Echo Test Case """
231 super(TestICMPEcho, self).setUp()
233 # create 1 pg interface
234 self.create_pg_interfaces(range(1))
236 for i in self.pg_interfaces:
242 super(TestICMPEcho, self).tearDown()
243 for i in self.pg_interfaces:
247 def test_icmp_echo(self):
248 """ VPP replies to ICMP Echo Request
252 - Receive ICMP Echo Request message on pg0 interface.
253 - Check outgoing ICMP Echo Reply message on pg0 interface.
258 icmp_load = '\x0a' * 18
259 p_echo_request = (Ether(src=self.pg0.remote_mac,
260 dst=self.pg0.local_mac) /
261 IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
262 ICMP(id=icmp_id, seq=icmp_seq) /
265 self.pg0.add_stream(p_echo_request)
266 self.pg_enable_capture(self.pg_interfaces)
269 rx = self.pg0.get_capture(1)
275 self.assertEqual(ether.src, self.pg0.local_mac)
276 self.assertEqual(ether.dst, self.pg0.remote_mac)
278 self.assertEqual(ipv4.src, self.pg0.local_ip4)
279 self.assertEqual(ipv4.dst, self.pg0.remote_ip4)
281 self.assertEqual(icmptypes[icmp.type], "echo-reply")
282 self.assertEqual(icmp.id, icmp_id)
283 self.assertEqual(icmp.seq, icmp_seq)
284 self.assertEqual(icmp[Raw].load, icmp_load)
287 class TestIPv4FibCrud(VppTestCase):
288 """ FIB - add/update/delete - ip4 routes
296 ..note:: Python API is too slow to add many routes, needs replacement.
299 def config_fib_many_to_one(self, start_dest_addr, next_hop_addr, count):
302 :param start_dest_addr:
303 :param next_hop_addr:
305 :return list: added ips with 32 prefix
308 dest_addr = int(binascii.hexlify(socket.inet_pton(socket.AF_INET,
309 start_dest_addr)), 16)
311 n_next_hop_addr = socket.inet_pton(socket.AF_INET, next_hop_addr)
312 for _ in range(count):
313 n_dest_addr = '{:08x}'.format(dest_addr).decode('hex')
314 self.vapi.ip_add_del_route(n_dest_addr, dest_addr_len,
316 added_ips.append(socket.inet_ntoa(n_dest_addr))
320 def unconfig_fib_many_to_one(self, start_dest_addr, next_hop_addr, count):
323 dest_addr = int(binascii.hexlify(socket.inet_pton(socket.AF_INET,
324 start_dest_addr)), 16)
326 n_next_hop_addr = socket.inet_pton(socket.AF_INET, next_hop_addr)
327 for _ in range(count):
328 n_dest_addr = '{:08x}'.format(dest_addr).decode('hex')
329 self.vapi.ip_add_del_route(n_dest_addr, dest_addr_len,
330 n_next_hop_addr, is_add=0)
331 removed_ips.append(socket.inet_ntoa(n_dest_addr))
335 def create_stream(self, src_if, dst_if, dst_ips, count):
338 for _ in range(count):
339 dst_addr = random.choice(dst_ips)
340 info = self.create_packet_info(src_if, dst_if)
341 payload = self.info_to_payload(info)
342 p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
343 IP(src=src_if.remote_ip4, dst=dst_addr) /
344 UDP(sport=1234, dport=1234) /
347 self.extend_packet(p, random.choice(self.pg_if_packet_sizes))
352 def _find_ip_match(self, find_in, pkt):
354 if self.payload_to_info(str(p[Raw])) == \
355 self.payload_to_info(str(pkt[Raw])):
356 if p[IP].src != pkt[IP].src:
358 if p[IP].dst != pkt[IP].dst:
360 if p[UDP].sport != pkt[UDP].sport:
362 if p[UDP].dport != pkt[UDP].dport:
368 def _match_route_detail(route_detail, ip, address_length=32, table_id=0):
369 if route_detail.address == socket.inet_pton(socket.AF_INET, ip):
370 if route_detail.table_id != table_id:
372 elif route_detail.address_length != address_length:
379 def verify_capture(self, dst_interface, received_pkts, expected_pkts):
380 self.assertEqual(len(received_pkts), len(expected_pkts))
381 to_verify = list(expected_pkts)
382 for p in received_pkts:
383 self.assertEqual(p.src, dst_interface.local_mac)
384 self.assertEqual(p.dst, dst_interface.remote_mac)
385 x = self._find_ip_match(to_verify, p)
387 self.assertListEqual(to_verify, [])
389 def verify_route_dump(self, fib_dump, ips):
391 def _ip_in_route_dump(ip, fib_dump):
392 return next((route for route in fib_dump
393 if self._match_route_detail(route, ip)),
397 self.assertTrue(_ip_in_route_dump(ip, fib_dump),
398 'IP {} is not in fib dump.'.format(ip))
400 def verify_not_in_route_dump(self, fib_dump, ips):
402 def _ip_in_route_dump(ip, fib_dump):
403 return next((route for route in fib_dump
404 if self._match_route_detail(route, ip)),
408 self.assertFalse(_ip_in_route_dump(ip, fib_dump),
409 'IP {} is in fib dump.'.format(ip))
414 #. Create and initialize 3 pg interfaces.
415 #. initialize class attributes configured_routes and deleted_routes
416 to store information between tests.
418 super(TestIPv4FibCrud, cls).setUpClass()
421 # create 3 pg interfaces
422 cls.create_pg_interfaces(range(3))
424 cls.interfaces = list(cls.pg_interfaces)
426 # setup all interfaces
427 for i in cls.interfaces:
432 cls.configured_routes = []
433 cls.deleted_routes = []
434 cls.pg_if_packet_sizes = [64, 512, 1518, 9018]
437 super(TestIPv4FibCrud, cls).tearDownClass()
441 super(TestIPv4FibCrud, self).setUp()
442 self.reset_packet_infos()
444 def test_1_add_routes(self):
447 - add 100 routes check with traffic script.
449 # config 1M FIB entries
450 self.configured_routes.extend(self.config_fib_many_to_one(
451 "10.0.0.0", self.pg0.remote_ip4, 100))
453 fib_dump = self.vapi.ip_fib_dump()
454 self.verify_route_dump(fib_dump, self.configured_routes)
456 self.stream_1 = self.create_stream(
457 self.pg1, self.pg0, self.configured_routes, 100)
458 self.stream_2 = self.create_stream(
459 self.pg2, self.pg0, self.configured_routes, 100)
460 self.pg1.add_stream(self.stream_1)
461 self.pg2.add_stream(self.stream_2)
463 self.pg_enable_capture(self.pg_interfaces)
466 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
467 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
469 def test_2_del_routes(self):
470 """ Delete 100 routes
472 - delete 10 routes check with traffic script.
474 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
475 "10.0.0.10", self.pg0.remote_ip4, 10))
476 for x in self.deleted_routes:
477 self.configured_routes.remove(x)
479 fib_dump = self.vapi.ip_fib_dump()
480 self.verify_route_dump(fib_dump, self.configured_routes)
482 self.stream_1 = self.create_stream(
483 self.pg1, self.pg0, self.configured_routes, 100)
484 self.stream_2 = self.create_stream(
485 self.pg2, self.pg0, self.configured_routes, 100)
486 self.stream_3 = self.create_stream(
487 self.pg1, self.pg0, self.deleted_routes, 100)
488 self.stream_4 = self.create_stream(
489 self.pg2, self.pg0, self.deleted_routes, 100)
490 self.pg1.add_stream(self.stream_1 + self.stream_3)
491 self.pg2.add_stream(self.stream_2 + self.stream_4)
492 self.pg_enable_capture(self.pg_interfaces)
495 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
496 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
498 def test_3_add_new_routes(self):
501 - re-add 5 routes check with traffic script.
502 - add 100 routes check with traffic script.
504 tmp = self.config_fib_many_to_one(
505 "10.0.0.10", self.pg0.remote_ip4, 5)
506 self.configured_routes.extend(tmp)
508 self.deleted_routes.remove(x)
510 self.configured_routes.extend(self.config_fib_many_to_one(
511 "10.0.1.0", self.pg0.remote_ip4, 100))
513 fib_dump = self.vapi.ip_fib_dump()
514 self.verify_route_dump(fib_dump, self.configured_routes)
516 self.stream_1 = self.create_stream(
517 self.pg1, self.pg0, self.configured_routes, 300)
518 self.stream_2 = self.create_stream(
519 self.pg2, self.pg0, self.configured_routes, 300)
520 self.stream_3 = self.create_stream(
521 self.pg1, self.pg0, self.deleted_routes, 100)
522 self.stream_4 = self.create_stream(
523 self.pg2, self.pg0, self.deleted_routes, 100)
525 self.pg1.add_stream(self.stream_1 + self.stream_3)
526 self.pg2.add_stream(self.stream_2 + self.stream_4)
527 self.pg_enable_capture(self.pg_interfaces)
530 pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
531 self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
533 def test_4_del_routes(self):
534 """ Delete 1.5k routes
536 - delete 5 routes check with traffic script.
537 - add 100 routes check with traffic script.
539 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
540 "10.0.0.0", self.pg0.remote_ip4, 15))
541 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
542 "10.0.0.20", self.pg0.remote_ip4, 85))
543 self.deleted_routes.extend(self.unconfig_fib_many_to_one(
544 "10.0.1.0", self.pg0.remote_ip4, 100))
545 fib_dump = self.vapi.ip_fib_dump()
546 self.verify_not_in_route_dump(fib_dump, self.deleted_routes)
549 class TestIPNull(VppTestCase):
550 """ IPv4 routes via NULL """
553 super(TestIPNull, self).setUp()
555 # create 2 pg interfaces
556 self.create_pg_interfaces(range(2))
558 for i in self.pg_interfaces:
564 super(TestIPNull, self).tearDown()
565 for i in self.pg_interfaces:
569 def test_ip_null(self):
570 """ IP NULL route """
573 # A route via IP NULL that will reply with ICMP unreachables
575 ip_unreach = VppIpRoute(self, "10.0.0.1", 32, [], is_unreach=1)
576 ip_unreach.add_vpp_config()
578 p_unreach = (Ether(src=self.pg0.remote_mac,
579 dst=self.pg0.local_mac) /
580 IP(src=self.pg0.remote_ip4, dst="10.0.0.1") /
581 UDP(sport=1234, dport=1234) /
584 self.pg0.add_stream(p_unreach)
585 self.pg_enable_capture(self.pg_interfaces)
588 rx = self.pg0.get_capture(1)
592 self.assertEqual(icmptypes[icmp.type], "dest-unreach")
593 self.assertEqual(icmpcodes[icmp.type][icmp.code], "host-unreachable")
594 self.assertEqual(icmp.src, self.pg0.remote_ip4)
595 self.assertEqual(icmp.dst, "10.0.0.1")
598 # ICMP replies are rate limited. so sit and spin.
603 # A route via IP NULL that will reply with ICMP prohibited
605 ip_prohibit = VppIpRoute(self, "10.0.0.2", 32, [], is_prohibit=1)
606 ip_prohibit.add_vpp_config()
608 p_prohibit = (Ether(src=self.pg0.remote_mac,
609 dst=self.pg0.local_mac) /
610 IP(src=self.pg0.remote_ip4, dst="10.0.0.2") /
611 UDP(sport=1234, dport=1234) /
614 self.pg0.add_stream(p_prohibit)
615 self.pg_enable_capture(self.pg_interfaces)
618 rx = self.pg0.get_capture(1)
623 self.assertEqual(icmptypes[icmp.type], "dest-unreach")
624 self.assertEqual(icmpcodes[icmp.type][icmp.code], "host-prohibited")
625 self.assertEqual(icmp.src, self.pg0.remote_ip4)
626 self.assertEqual(icmp.dst, "10.0.0.2")
628 def test_ip_drop(self):
629 """ IP Drop Routes """
631 p = (Ether(src=self.pg0.remote_mac,
632 dst=self.pg0.local_mac) /
633 IP(src=self.pg0.remote_ip4, dst="1.1.1.1") /
634 UDP(sport=1234, dport=1234) /
637 r1 = VppIpRoute(self, "1.1.1.0", 24,
638 [VppRoutePath(self.pg1.remote_ip4,
639 self.pg1.sw_if_index)])
642 rx = self.send_and_expect(self.pg0, p * 65, self.pg1)
645 # insert a more specific as a drop
647 r2 = VppIpRoute(self, "1.1.1.1", 32, [], is_drop=1)
650 self.send_and_assert_no_replies(self.pg0, p * 65, "Drop Route")
651 r2.remove_vpp_config()
652 rx = self.send_and_expect(self.pg0, p * 65, self.pg1)
655 class TestIPDisabled(VppTestCase):
656 """ IPv4 disabled """
659 super(TestIPDisabled, self).setUp()
661 # create 2 pg interfaces
662 self.create_pg_interfaces(range(2))
666 self.pg0.config_ip4()
667 self.pg0.resolve_arp()
669 # PG 1 is not IP enabled
673 super(TestIPDisabled, self).tearDown()
674 for i in self.pg_interfaces:
678 def test_ip_disabled(self):
683 # one accepting interface, pg0, 2 forwarding interfaces
685 route_232_1_1_1 = VppIpMRoute(
689 MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
690 [VppMRoutePath(self.pg1.sw_if_index,
691 MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
692 VppMRoutePath(self.pg0.sw_if_index,
693 MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
694 route_232_1_1_1.add_vpp_config()
696 pu = (Ether(src=self.pg1.remote_mac,
697 dst=self.pg1.local_mac) /
698 IP(src="10.10.10.10", dst=self.pg0.remote_ip4) /
699 UDP(sport=1234, dport=1234) /
701 pm = (Ether(src=self.pg1.remote_mac,
702 dst=self.pg1.local_mac) /
703 IP(src="10.10.10.10", dst="232.1.1.1") /
704 UDP(sport=1234, dport=1234) /
708 # PG1 does not forward IP traffic
710 self.send_and_assert_no_replies(self.pg1, pu, "IP disabled")
711 self.send_and_assert_no_replies(self.pg1, pm, "IP disabled")
716 self.pg1.config_ip4()
719 # Now we get packets through
721 self.pg1.add_stream(pu)
722 self.pg_enable_capture(self.pg_interfaces)
724 rx = self.pg0.get_capture(1)
726 self.pg1.add_stream(pm)
727 self.pg_enable_capture(self.pg_interfaces)
729 rx = self.pg0.get_capture(1)
734 self.pg1.unconfig_ip4()
737 # PG1 does not forward IP traffic
739 self.send_and_assert_no_replies(self.pg1, pu, "IP disabled")
740 self.send_and_assert_no_replies(self.pg1, pm, "IP disabled")
743 class TestIPSubNets(VppTestCase):
747 super(TestIPSubNets, self).setUp()
749 # create a 2 pg interfaces
750 self.create_pg_interfaces(range(2))
752 # pg0 we will use to experiemnt
755 # pg1 is setup normally
757 self.pg1.config_ip4()
758 self.pg1.resolve_arp()
761 super(TestIPSubNets, self).tearDown()
762 for i in self.pg_interfaces:
765 def test_ip_sub_nets(self):
769 # Configure a covering route to forward so we know
770 # when we are dropping
772 cover_route = VppIpRoute(self, "10.0.0.0", 8,
773 [VppRoutePath(self.pg1.remote_ip4,
774 self.pg1.sw_if_index)])
775 cover_route.add_vpp_config()
777 p = (Ether(src=self.pg1.remote_mac,
778 dst=self.pg1.local_mac) /
779 IP(dst="10.10.10.10", src=self.pg0.local_ip4) /
780 UDP(sport=1234, dport=1234) /
783 self.pg1.add_stream(p)
784 self.pg_enable_capture(self.pg_interfaces)
786 rx = self.pg1.get_capture(1)
789 # Configure some non-/24 subnets on an IP interface
791 ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
793 self.vapi.sw_interface_add_del_address(self.pg0.sw_if_index,
797 pn = (Ether(src=self.pg1.remote_mac,
798 dst=self.pg1.local_mac) /
799 IP(dst="10.10.0.0", src=self.pg0.local_ip4) /
800 UDP(sport=1234, dport=1234) /
802 pb = (Ether(src=self.pg1.remote_mac,
803 dst=self.pg1.local_mac) /
804 IP(dst="10.10.255.255", src=self.pg0.local_ip4) /
805 UDP(sport=1234, dport=1234) /
808 self.send_and_assert_no_replies(self.pg1, pn, "IP Network address")
809 self.send_and_assert_no_replies(self.pg1, pb, "IP Broadcast address")
811 # remove the sub-net and we are forwarding via the cover again
812 self.vapi.sw_interface_add_del_address(self.pg0.sw_if_index,
816 self.pg1.add_stream(pn)
817 self.pg_enable_capture(self.pg_interfaces)
819 rx = self.pg1.get_capture(1)
820 self.pg1.add_stream(pb)
821 self.pg_enable_capture(self.pg_interfaces)
823 rx = self.pg1.get_capture(1)
826 # A /31 is a special case where the 'other-side' is an attached host
827 # packets to that peer generate ARP requests
829 ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
831 self.vapi.sw_interface_add_del_address(self.pg0.sw_if_index,
835 pn = (Ether(src=self.pg1.remote_mac,
836 dst=self.pg1.local_mac) /
837 IP(dst="10.10.10.11", src=self.pg0.local_ip4) /
838 UDP(sport=1234, dport=1234) /
841 self.pg1.add_stream(pn)
842 self.pg_enable_capture(self.pg_interfaces)
844 rx = self.pg0.get_capture(1)
847 # remove the sub-net and we are forwarding via the cover again
848 self.vapi.sw_interface_add_del_address(self.pg0.sw_if_index,
852 self.pg1.add_stream(pn)
853 self.pg_enable_capture(self.pg_interfaces)
855 rx = self.pg1.get_capture(1)
858 class TestIPLoadBalance(VppTestCase):
859 """ IPv4 Load-Balancing """
862 super(TestIPLoadBalance, self).setUp()
864 self.create_pg_interfaces(range(5))
865 mpls_tbl = VppMplsTable(self, 0)
866 mpls_tbl.add_vpp_config()
868 for i in self.pg_interfaces:
875 for i in self.pg_interfaces:
879 super(TestIPLoadBalance, self).tearDown()
881 def send_and_expect_load_balancing(self, input, pkts, outputs):
882 input.add_stream(pkts)
883 self.pg_enable_capture(self.pg_interfaces)
886 rx = oo._get_capture(1)
887 self.assertNotEqual(0, len(rx))
889 def send_and_expect_one_itf(self, input, pkts, itf):
890 input.add_stream(pkts)
891 self.pg_enable_capture(self.pg_interfaces)
893 rx = itf.get_capture(len(pkts))
895 def test_ip_load_balance(self):
896 """ IP Load-Balancing """
899 # An array of packets that differ only in the destination port
905 # An array of packets that differ only in the source address
911 port_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.1") /
912 UDP(sport=1234, dport=1234 + ii) /
914 port_ip_pkts.append((Ether(src=self.pg0.remote_mac,
915 dst=self.pg0.local_mac) /
917 port_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
918 dst=self.pg0.local_mac) /
919 MPLS(label=66, ttl=2) /
922 src_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.%d" % ii) /
923 UDP(sport=1234, dport=1234) /
925 src_ip_pkts.append((Ether(src=self.pg0.remote_mac,
926 dst=self.pg0.local_mac) /
928 src_mpls_pkts.append((Ether(src=self.pg0.remote_mac,
929 dst=self.pg0.local_mac) /
930 MPLS(label=66, ttl=2) /
933 route_10_0_0_1 = VppIpRoute(self, "10.0.0.1", 32,
934 [VppRoutePath(self.pg1.remote_ip4,
935 self.pg1.sw_if_index),
936 VppRoutePath(self.pg2.remote_ip4,
937 self.pg2.sw_if_index)])
938 route_10_0_0_1.add_vpp_config()
940 binding = VppMplsIpBind(self, 66, "10.0.0.1", 32)
941 binding.add_vpp_config()
944 # inject the packet on pg0 - expect load-balancing across the 2 paths
945 # - since the default hash config is to use IP src,dst and port
947 # We are not going to ensure equal amounts of packets across each link,
948 # since the hash algorithm is statistical and therefore this can never
949 # be guaranteed. But wuth 64 different packets we do expect some
950 # balancing. So instead just ensure there is traffic on each link.
952 self.send_and_expect_load_balancing(self.pg0, port_ip_pkts,
953 [self.pg1, self.pg2])
954 self.send_and_expect_load_balancing(self.pg0, src_ip_pkts,
955 [self.pg1, self.pg2])
956 self.send_and_expect_load_balancing(self.pg0, port_mpls_pkts,
957 [self.pg1, self.pg2])
958 self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts,
959 [self.pg1, self.pg2])
962 # change the flow hash config so it's only IP src,dst
963 # - now only the stream with differing source address will
966 self.vapi.set_ip_flow_hash(0, src=1, dst=1, sport=0, dport=0)
968 self.send_and_expect_load_balancing(self.pg0, src_ip_pkts,
969 [self.pg1, self.pg2])
970 self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts,
971 [self.pg1, self.pg2])
973 self.send_and_expect_one_itf(self.pg0, port_ip_pkts, self.pg2)
976 # change the flow hash config back to defaults
978 self.vapi.set_ip_flow_hash(0, src=1, dst=1, sport=1, dport=1)
982 # - testing that 2 stages of load-balancing occurs and there is no
983 # polarisation (i.e. only 2 of 4 paths are used)
988 for ii in range(257):
989 port_pkts.append((Ether(src=self.pg0.remote_mac,
990 dst=self.pg0.local_mac) /
991 IP(dst="1.1.1.1", src="20.0.0.1") /
992 UDP(sport=1234, dport=1234 + ii) /
994 src_pkts.append((Ether(src=self.pg0.remote_mac,
995 dst=self.pg0.local_mac) /
996 IP(dst="1.1.1.1", src="20.0.0.%d" % ii) /
997 UDP(sport=1234, dport=1234) /
1000 route_10_0_0_2 = VppIpRoute(self, "10.0.0.2", 32,
1001 [VppRoutePath(self.pg3.remote_ip4,
1002 self.pg3.sw_if_index),
1003 VppRoutePath(self.pg4.remote_ip4,
1004 self.pg4.sw_if_index)])
1005 route_10_0_0_2.add_vpp_config()
1007 route_1_1_1_1 = VppIpRoute(self, "1.1.1.1", 32,
1008 [VppRoutePath("10.0.0.2", 0xffffffff),
1009 VppRoutePath("10.0.0.1", 0xffffffff)])
1010 route_1_1_1_1.add_vpp_config()
1013 # inject the packet on pg0 - expect load-balancing across all 4 paths
1015 self.vapi.cli("clear trace")
1016 self.send_and_expect_load_balancing(self.pg0, port_pkts,
1017 [self.pg1, self.pg2,
1018 self.pg3, self.pg4])
1019 self.send_and_expect_load_balancing(self.pg0, src_pkts,
1020 [self.pg1, self.pg2,
1021 self.pg3, self.pg4])
1024 # Recursive prefixes
1025 # - testing that 2 stages of load-balancing, no choices
1029 for ii in range(257):
1030 port_pkts.append((Ether(src=self.pg0.remote_mac,
1031 dst=self.pg0.local_mac) /
1032 IP(dst="1.1.1.2", src="20.0.0.2") /
1033 UDP(sport=1234, dport=1234 + ii) /
1036 route_10_0_0_3 = VppIpRoute(self, "10.0.0.3", 32,
1037 [VppRoutePath(self.pg3.remote_ip4,
1038 self.pg3.sw_if_index)])
1039 route_10_0_0_3.add_vpp_config()
1041 route_1_1_1_2 = VppIpRoute(self, "1.1.1.2", 32,
1042 [VppRoutePath("10.0.0.3", 0xffffffff)])
1043 route_1_1_1_2.add_vpp_config()
1046 # inject the packet on pg0 - expect load-balancing across all 4 paths
1048 self.vapi.cli("clear trace")
1049 self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg3)
1052 class TestIPVlan0(VppTestCase):
1056 super(TestIPVlan0, self).setUp()
1058 self.create_pg_interfaces(range(2))
1059 mpls_tbl = VppMplsTable(self, 0)
1060 mpls_tbl.add_vpp_config()
1062 for i in self.pg_interfaces:
1069 for i in self.pg_interfaces:
1073 super(TestIPVlan0, self).tearDown()
1075 def test_ip_vlan_0(self):
1078 pkts = (Ether(src=self.pg0.remote_mac,
1079 dst=self.pg0.local_mac) /
1081 IP(dst=self.pg1.remote_ip4,
1082 src=self.pg0.remote_ip4) /
1083 UDP(sport=1234, dport=1234) /
1084 Raw('\xa5' * 100)) * 65
1087 # Expect that packets sent on VLAN-0 are forwarded on the
1090 self.send_and_expect(self.pg0, pkts, self.pg1)
1093 class TestIPPunt(VppTestCase):
1094 """ IPv4 Punt Police/Redirect """
1097 super(TestIPPunt, self).setUp()
1099 self.create_pg_interfaces(range(4))
1101 for i in self.pg_interfaces:
1107 super(TestIPPunt, self).tearDown()
1108 for i in self.pg_interfaces:
1112 def test_ip_punt(self):
1113 """ IP punt police and redirect """
1115 p = (Ether(src=self.pg0.remote_mac,
1116 dst=self.pg0.local_mac) /
1117 IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
1118 TCP(sport=1234, dport=1234) /
1124 # Configure a punt redirect via pg1.
1126 nh_addr = VppIpAddress(self.pg1.remote_ip4).encode()
1127 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1128 self.pg1.sw_if_index,
1131 self.send_and_expect(self.pg0, pkts, self.pg1)
1136 policer = self.vapi.policer_add_del("ip4-punt", 400, 0, 10, 0,
1138 self.vapi.ip_punt_police(policer.policer_index)
1140 self.vapi.cli("clear trace")
1141 self.pg0.add_stream(pkts)
1142 self.pg_enable_capture(self.pg_interfaces)
1146 # the number of packet recieved should be greater than 0,
1147 # but not equal to the number sent, since some were policed
1149 rx = self.pg1._get_capture(1)
1150 self.assertGreater(len(rx), 0)
1151 self.assertLess(len(rx), len(pkts))
1154 # remove the poilcer. back to full rx
1156 self.vapi.ip_punt_police(policer.policer_index, is_add=0)
1157 self.vapi.policer_add_del("ip4-punt", 400, 0, 10, 0,
1158 rate_type=1, is_add=0)
1159 self.send_and_expect(self.pg0, pkts, self.pg1)
1162 # remove the redirect. expect full drop.
1164 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1165 self.pg1.sw_if_index,
1168 self.send_and_assert_no_replies(self.pg0, pkts,
1169 "IP no punt config")
1172 # Add a redirect that is not input port selective
1174 self.vapi.ip_punt_redirect(0xffffffff,
1175 self.pg1.sw_if_index,
1177 self.send_and_expect(self.pg0, pkts, self.pg1)
1179 self.vapi.ip_punt_redirect(0xffffffff,
1180 self.pg1.sw_if_index,
1184 def test_ip_punt_dump(self):
1185 """ IP4 punt redirect dump"""
1188 # Configure a punt redirects
1190 nh_address = VppIpAddress(self.pg3.remote_ip4).encode()
1191 self.vapi.ip_punt_redirect(self.pg0.sw_if_index,
1192 self.pg3.sw_if_index,
1194 self.vapi.ip_punt_redirect(self.pg1.sw_if_index,
1195 self.pg3.sw_if_index,
1197 self.vapi.ip_punt_redirect(self.pg2.sw_if_index,
1198 self.pg3.sw_if_index,
1199 VppIpAddress('0.0.0.0').encode())
1202 # Dump pg0 punt redirects
1204 punts = self.vapi.ip_punt_redirect_dump(self.pg0.sw_if_index)
1206 self.assertEqual(p.punt.rx_sw_if_index, self.pg0.sw_if_index)
1209 # Dump punt redirects for all interfaces
1211 punts = self.vapi.ip_punt_redirect_dump(0xffffffff)
1212 self.assertEqual(len(punts), 3)
1214 self.assertEqual(p.punt.tx_sw_if_index, self.pg3.sw_if_index)
1215 self.assertNotEqual(punts[1].punt.nh.un.ip4, self.pg3.remote_ip4)
1216 self.assertEqual(punts[2].punt.nh.un.ip4, '\x00'*4)
1219 class TestIPDeag(VppTestCase):
1220 """ IPv4 Deaggregate Routes """
1223 super(TestIPDeag, self).setUp()
1225 self.create_pg_interfaces(range(3))
1227 for i in self.pg_interfaces:
1233 super(TestIPDeag, self).tearDown()
1234 for i in self.pg_interfaces:
1238 def test_ip_deag(self):
1239 """ IP Deag Routes """
1242 # Create a table to be used for:
1243 # 1 - another destination address lookup
1244 # 2 - a source address lookup
1246 table_dst = VppIpTable(self, 1)
1247 table_src = VppIpTable(self, 2)
1248 table_dst.add_vpp_config()
1249 table_src.add_vpp_config()
1252 # Add a route in the default table to point to a deag/
1253 # second lookup in each of these tables
1255 route_to_dst = VppIpRoute(self, "1.1.1.1", 32,
1256 [VppRoutePath("0.0.0.0",
1259 route_to_src = VppIpRoute(self, "1.1.1.2", 32,
1260 [VppRoutePath("0.0.0.0",
1263 is_source_lookup=1)])
1264 route_to_dst.add_vpp_config()
1265 route_to_src.add_vpp_config()
1268 # packets to these destination are dropped, since they'll
1269 # hit the respective default routes in the second table
1271 p_dst = (Ether(src=self.pg0.remote_mac,
1272 dst=self.pg0.local_mac) /
1273 IP(src="5.5.5.5", dst="1.1.1.1") /
1274 TCP(sport=1234, dport=1234) /
1276 p_src = (Ether(src=self.pg0.remote_mac,
1277 dst=self.pg0.local_mac) /
1278 IP(src="2.2.2.2", dst="1.1.1.2") /
1279 TCP(sport=1234, dport=1234) /
1281 pkts_dst = p_dst * 257
1282 pkts_src = p_src * 257
1284 self.send_and_assert_no_replies(self.pg0, pkts_dst,
1286 self.send_and_assert_no_replies(self.pg0, pkts_src,
1290 # add a route in the dst table to forward via pg1
1292 route_in_dst = VppIpRoute(self, "1.1.1.1", 32,
1293 [VppRoutePath(self.pg1.remote_ip4,
1294 self.pg1.sw_if_index)],
1296 route_in_dst.add_vpp_config()
1297 self.send_and_expect(self.pg0, pkts_dst, self.pg1)
1300 # add a route in the src table to forward via pg2
1302 route_in_src = VppIpRoute(self, "2.2.2.2", 32,
1303 [VppRoutePath(self.pg2.remote_ip4,
1304 self.pg2.sw_if_index)],
1306 route_in_src.add_vpp_config()
1307 self.send_and_expect(self.pg0, pkts_src, self.pg2)
1310 # loop in the lookup DP
1312 route_loop = VppIpRoute(self, "2.2.2.3", 32,
1313 [VppRoutePath("0.0.0.0",
1316 route_loop.add_vpp_config()
1318 p_l = (Ether(src=self.pg0.remote_mac,
1319 dst=self.pg0.local_mac) /
1320 IP(src="2.2.2.4", dst="2.2.2.3") /
1321 TCP(sport=1234, dport=1234) /
1324 self.send_and_assert_no_replies(self.pg0, p_l * 257,
1328 class TestIPInput(VppTestCase):
1329 """ IPv4 Input Exceptions """
1332 super(TestIPInput, self).setUp()
1334 self.create_pg_interfaces(range(2))
1336 for i in self.pg_interfaces:
1342 super(TestIPInput, self).tearDown()
1343 for i in self.pg_interfaces:
1347 def test_ip_input(self):
1348 """ IP Input Exceptions """
1350 # i can't find a way in scapy to construct an IP packet
1351 # with a length less than the IP header length
1354 # Packet too short - this is forwarded
1356 p_short = (Ether(src=self.pg0.remote_mac,
1357 dst=self.pg0.local_mac) /
1358 IP(src=self.pg0.remote_ip4,
1359 dst=self.pg1.remote_ip4,
1361 UDP(sport=1234, dport=1234) /
1364 rx = self.send_and_expect(self.pg0, p_short * 65, self.pg1)
1367 # Packet too long - this is dropped
1369 p_long = (Ether(src=self.pg0.remote_mac,
1370 dst=self.pg0.local_mac) /
1371 IP(src=self.pg0.remote_ip4,
1372 dst=self.pg1.remote_ip4,
1374 UDP(sport=1234, dport=1234) /
1377 rx = self.send_and_assert_no_replies(self.pg0, p_long * 65,
1381 # bad chksum - this is dropped
1383 p_chksum = (Ether(src=self.pg0.remote_mac,
1384 dst=self.pg0.local_mac) /
1385 IP(src=self.pg0.remote_ip4,
1386 dst=self.pg1.remote_ip4,
1388 UDP(sport=1234, dport=1234) /
1391 rx = self.send_and_assert_no_replies(self.pg0, p_chksum * 65,
1395 # bad version - this is dropped
1397 p_ver = (Ether(src=self.pg0.remote_mac,
1398 dst=self.pg0.local_mac) /
1399 IP(src=self.pg0.remote_ip4,
1400 dst=self.pg1.remote_ip4,
1402 UDP(sport=1234, dport=1234) /
1405 rx = self.send_and_assert_no_replies(self.pg0, p_ver * 65,
1409 # fragment offset 1 - this is dropped
1411 p_frag = (Ether(src=self.pg0.remote_mac,
1412 dst=self.pg0.local_mac) /
1413 IP(src=self.pg0.remote_ip4,
1414 dst=self.pg1.remote_ip4,
1416 UDP(sport=1234, dport=1234) /
1419 rx = self.send_and_assert_no_replies(self.pg0, p_frag * 65,
1423 # TTL expired packet
1425 p_ttl = (Ether(src=self.pg0.remote_mac,
1426 dst=self.pg0.local_mac) /
1427 IP(src=self.pg0.remote_ip4,
1428 dst=self.pg1.remote_ip4,
1430 UDP(sport=1234, dport=1234) /
1433 rx = self.send_and_expect(self.pg0, p_ttl * 65, self.pg0)
1438 self.assertEqual(icmptypes[icmp.type], "time-exceeded")
1439 self.assertEqual(icmpcodes[icmp.type][icmp.code],
1440 "ttl-zero-during-transit")
1441 self.assertEqual(icmp.src, self.pg0.remote_ip4)
1442 self.assertEqual(icmp.dst, self.pg1.remote_ip4)
1447 p_mtu = (Ether(src=self.pg0.remote_mac,
1448 dst=self.pg0.local_mac) /
1449 IP(src=self.pg0.remote_ip4,
1450 dst=self.pg1.remote_ip4,
1451 ttl=10, flags='DF') /
1452 UDP(sport=1234, dport=1234) /
1455 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [1500, 0, 0, 0])
1457 rx = self.send_and_expect(self.pg0, p_mtu * 65, self.pg0)
1461 self.assertEqual(icmptypes[icmp.type], "dest-unreach")
1462 self.assertEqual(icmpcodes[icmp.type][icmp.code],
1463 "fragmentation-needed")
1464 self.assertEqual(icmp.src, self.pg0.remote_ip4)
1465 self.assertEqual(icmp.dst, self.pg1.remote_ip4)
1467 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [2500, 0, 0, 0])
1468 rx = self.send_and_expect(self.pg0, p_mtu * 65, self.pg1)
1470 # Reset MTU for subsequent tests
1471 self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [9000, 0, 0, 0])
1474 class TestIPDirectedBroadcast(VppTestCase):
1475 """ IPv4 Directed Broadcast """
1478 super(TestIPDirectedBroadcast, self).setUp()
1480 self.create_pg_interfaces(range(2))
1482 for i in self.pg_interfaces:
1486 super(TestIPDirectedBroadcast, self).tearDown()
1487 for i in self.pg_interfaces:
1490 def test_ip_input(self):
1491 """ IP Directed Broadcast """
1494 # set the directed broadcast on pg0 first, then config IP4 addresses
1495 # for pg1 directed broadcast is always disabled
1496 self.vapi.sw_interface_set_ip_directed_broadcast(
1497 self.pg0.sw_if_index, 1)
1499 p0 = (Ether(src=self.pg1.remote_mac,
1500 dst=self.pg1.local_mac) /
1502 dst=self.pg0._local_ip4_bcast) /
1503 UDP(sport=1234, dport=1234) /
1505 p1 = (Ether(src=self.pg0.remote_mac,
1506 dst=self.pg0.local_mac) /
1508 dst=self.pg1._local_ip4_bcast) /
1509 UDP(sport=1234, dport=1234) /
1512 self.pg0.config_ip4()
1513 self.pg0.resolve_arp()
1514 self.pg1.config_ip4()
1515 self.pg1.resolve_arp()
1518 # test packet is L2 broadcast
1520 rx = self.send_and_expect(self.pg1, p0 * 65, self.pg0)
1521 self.assertTrue(rx[0][Ether].dst, "ff:ff:ff:ff:ff:ff")
1523 self.send_and_assert_no_replies(self.pg0, p1 * 65,
1524 "directed broadcast disabled")
1527 # toggle directed broadcast on pg0
1529 self.vapi.sw_interface_set_ip_directed_broadcast(
1530 self.pg0.sw_if_index, 0)
1531 self.send_and_assert_no_replies(self.pg1, p0 * 65,
1532 "directed broadcast disabled")
1534 self.vapi.sw_interface_set_ip_directed_broadcast(
1535 self.pg0.sw_if_index, 1)
1536 rx = self.send_and_expect(self.pg1, p0 * 65, self.pg0)
1538 self.pg0.unconfig_ip4()
1539 self.pg1.unconfig_ip4()
1542 class TestIPLPM(VppTestCase):
1543 """ IPv4 longest Prefix Match """
1546 super(TestIPLPM, self).setUp()
1548 self.create_pg_interfaces(range(4))
1550 for i in self.pg_interfaces:
1556 super(TestIPLPM, self).tearDown()
1557 for i in self.pg_interfaces:
1561 def test_ip_lpm(self):
1562 """ IP longest Prefix Match """
1564 s_24 = VppIpRoute(self, "10.1.2.0", 24,
1565 [VppRoutePath(self.pg1.remote_ip4,
1566 self.pg1.sw_if_index)])
1567 s_24.add_vpp_config()
1568 s_8 = VppIpRoute(self, "10.0.0.0", 8,
1569 [VppRoutePath(self.pg2.remote_ip4,
1570 self.pg2.sw_if_index)])
1571 s_8.add_vpp_config()
1573 p_8 = (Ether(src=self.pg0.remote_mac,
1574 dst=self.pg0.local_mac) /
1577 UDP(sport=1234, dport=1234) /
1579 p_24 = (Ether(src=self.pg0.remote_mac,
1580 dst=self.pg0.local_mac) /
1583 UDP(sport=1234, dport=1234) /
1586 self.logger.info(self.vapi.cli("sh ip fib mtrie"))
1587 rx = self.send_and_expect(self.pg0, p_8 * 65, self.pg2)
1588 rx = self.send_and_expect(self.pg0, p_24 * 65, self.pg1)
1591 class TestIPv4Frag(VppTestCase):
1592 """ IPv4 fragmentation """
1595 def setUpClass(cls):
1596 super(TestIPv4Frag, cls).setUpClass()
1598 cls.create_pg_interfaces([0, 1])
1599 cls.src_if = cls.pg0
1600 cls.dst_if = cls.pg1
1602 # setup all interfaces
1603 for i in cls.pg_interfaces:
1608 def test_frag_large_packets(self):
1609 """ Fragmentation of large packets """
1611 p = (Ether(dst=self.src_if.local_mac, src=self.src_if.remote_mac) /
1612 IP(src=self.src_if.remote_ip4, dst=self.dst_if.remote_ip4) /
1613 UDP(sport=1234, dport=5678) / Raw())
1614 self.extend_packet(p, 6000, "abcde")
1615 saved_payload = p[Raw].load
1617 # Force fragmentation by setting MTU of output interface
1618 # lower than packet size
1619 self.vapi.sw_interface_set_mtu(self.dst_if.sw_if_index,
1622 self.pg_enable_capture()
1623 self.src_if.add_stream(p)
1626 # Expecting 3 fragments because size of created fragments currently
1627 # cannot be larger then VPP buffer size (which is 2048)
1628 packets = self.dst_if.get_capture(3)
1630 # Assume VPP sends the fragments in order
1633 payload_offset = p.frag * 8
1634 if payload_offset > 0:
1635 payload_offset -= 8 # UDP header is not in payload
1636 self.assert_equal(payload_offset, len(payload))
1637 payload += p[Raw].load
1638 self.assert_equal(payload, saved_payload, "payload")
1641 if __name__ == '__main__':
1642 unittest.main(testRunner=VppTestRunner)