Putting the Packet Together

Learn to combine IP and TCP headers within a single packet using Scapy.

Examining IP and TCP headers

We’ve defined the individual layers of a packet used in a SYN scanner. This includes defining the IP and TCP headers for the final packet. However, we can only send the packet over the network if we put the layers together into a single packet.

Technically, our SYN scanning packet requires three layers, including a base layer (such as Ethernet) as well as IP and TCP. However, if we define a packet containing the IP and TCP headers for a packet, Scapy can wrap them in an Ethernet packet and define the necessary headers for us.

To start, let’s take a look at the IP and TCP layers that we defined previously.

Get hands-on with 1200+ tech skills courses.