Creating our first packet
So, let's go ahead and look at our first packet. I'm going to go ahead and create one with a payload with a message MyFirstPacket
embeded inside an ICMP packet. Then I will use Wireshark to show you the packet breakdown and details of how I did it.
The breakdown is as follows:
p
: This is the name of the packetIP()
: This is the type of packet you want to create, in this case an IP packet(dst="192.168.0.6")
: This is the destination to send the packet to (in this case my router)/ICMP()
: If you want to create an ICMP packet with the default values provided by scapy/"MyFirstPacket")
: The payload to include which you don't have to provide in order for it to work
Sending and receiving
Scapy provides us with three functions for sending and receiving packets. The first two functions require that it's constructed for the network layer packets only such as IP, ICMP, and ARP packets. You may use sr()
for sending and receiving packets whether they are answered or unanswered responses...