Scapy

Scapy is a packet manipulation tool for computer networks, originally written in Python by Philippe Biondi. It can forge or decode packets, send them on the wire, capture them, and match requests and replies. It can also handle tasks like scanning, tracerouting, probing, unit tests, attacks, and network discovery.

Scapy provides a Python interface into libpcap or native raw sockets, in a similar way to that in which Wireshark provides a view and capture GUI. It differs by supporting packet injection, custom packet formats and scripting. While it is a command-line only tool, it can still interface with a number of other programs to provide visualisation including Wireshark, GnuPlot for providing graphs, graphviz or VPython for interactive displaying, etc.

Starting with 2.4.0, Scapy supports Python 2.7 and 3.4+. It must not be confused with "scapy3k" (now renamed Kamene), which is an outdated independent and unmaintained fork.