A simple packet sniffer in Python can be created with the help socket module. We can use the raw socket type to get the packets. A raw socket provides access to the underlying protocols, which support socket abstractions. Since raw sockets are part of the internet socket API, they can only be used to generate and receive IP packets.
![](https://static.packt-cdn.com/products/9781784399771/graphics/assets/3dc0a79f-9baf-4fad-a3e4-edd7c6043d77.png)