Any built-in function for dump switch traffic as .pcap file?

The bmv2 + mininet setup in p4lang/tutorials repo can preserve the.pcap files of ingress/egress traffic on each port of the switch and host. How can I achieve the same within this repo?

One workaround seems to be manually run the tcpdump for capturing traffic on the veth.

Thanks!