Sending packets with scapy

To send a package in scapy, we have two methods:

  • send(): Sends layer-3 packets

  • sendp(): Sends layer-2 packets

We will use send() if we do it from layer 3 or IP and trust the routes of the operating system itself to send it. We will use sendp() if we need control at layer 2 (for example, Ethernet).

The main arguments for the send commands are:

  • iface: The interface to send packets.

  • Inter: The time, in seconds, that we want to pass between package and package sent.

  • loop: To keep sending packets endlessly, set this to 1. If it is different from 0, send the packet, or list of packages, in an infinite loop until we stop it by pressing Ctrl + C.

  • packet: Packet or a list of packets.

  • verbose: It allows us ...

Get Mastering Python for Networking and Security now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.