Scapy has the ability to listen to the network interface and capture all incoming packets on it. It can write it on a pcap file in the same way that tcpdump works, but Scapy provides additional functions that can read and replay a pcap file, in the network again.
Starting with a simple packet replay, we will instruct Scapy to read a normal pcap file captured from the network (either using tcpdump or Scapy itself) and send it again to the network. This is very useful if we need to test the behavior of the network if a specific traffic pattern travels through it. For example, we may have a network firewall configured to block FTP communication. We can test the functionality of the firewall by hitting it with FTP data replayed from Scapy.
In this example, we have the FTP captured pcap file and we need to replay it to the network:
from scapy.layers...