| 646 | return capture |
| 647 | |
| 648 | def send_and_expect( |
| 649 | self, |
| 650 | intf: VppPGInterface, |
| 651 | pkts, |
| 652 | output: VppPGInterface, |
| 653 | n_rx: int | None = None, |
| 654 | worker: int | None = None, |
| 655 | trace: bool = True, |
| 656 | log_packets: bool = True, |
| 657 | msg: str | None = None, |
| 658 | stats_diff: StatsDiff | None = None, |
| 659 | filter_out_fn=is_ipv6_misc, |
| 660 | assert_nothing_captured=[], |
| 661 | ) -> PacketList | None: |
| 662 | send = Send(interface=intf, packets=pkts, worker=worker) |
| 663 | if n_rx is None: |
| 664 | n_rx = 1 if isinstance(pkts, Packet) else len(pkts) |
| 665 | expect = Expect( |
| 666 | interface=output, expected_count=n_rx, filter_out_fn=filter_out_fn |
| 667 | ) |
| 668 | |
| 669 | if stats_diff: |
| 670 | stats_snapshot = self.snapshot_stats(stats_diff) |
| 671 | |
| 672 | capture = self.send_and_expect_multi( |
| 673 | [send], |
| 674 | [expect], |
| 675 | trace=trace, |
| 676 | log_packets=log_packets, |
| 677 | msg=msg, |
| 678 | stats_diff=stats_diff, |
| 679 | assert_nothing_captured=assert_nothing_captured, |
| 680 | ) |
| 681 | |
| 682 | if stats_diff: |
| 683 | self.compare_stats_with_snapshot(stats_diff, stats_snapshot) |
| 684 | |
| 685 | self.assert_equal(len(capture), 1, "number of capture contexts") |
| 686 | return capture[0].packets |
| 687 | |
| 688 | def send_and_expect_load_balancing( |
| 689 | self, input, pkts, outputs, worker=None, trace=True |