With the wrpcap() function, we can store the captured packets in a pcap file. Also, it is possible to write the packets to a pcap file with Scapy. To write the packets to a pcap file, we can use the wrpcap() method. In the following example, we are capturing tcp packets for FTP transmissions and saving this packets in a pcap file:
scapy > packets = sniff(filter='tcp port 21') scapy> file=wrpcap('<path_file.pcap>',packets)