There are other ways to push out packets with send() for layer 3 and sendp() for layer 2 that'll be represented by a series of periods, each of which represents 1 packet sent when executed. Sending multiple packtes can be done by manipulating the time to live function in the IP, providing a loop function, or sending a whole pcap file out. Let's look at how we can build a packet and stack protocols or change details to customize our packet for other purposes. As mentioned earlier, to view the most recent result then use the underscore character (_) .
A very important feature you need to know about is layering between upper and lower layer data is done using the the key/to bridge the two sets of data together. If you do construct a packet or sets of it going through multiple layers, the details in the upper layer may override one or more of what is provided by default:
Here's a simplified view of several various examples of layer packets. The first line was just an IP packet. The next line we layered a UDP protocol which could be a TCP. Remember UDP is connectionless and TCP is connection oriented requiring a 3-handshake at the initiation of a connection. The third packet we created is now a frame when it becomes encapsulated with the Ethernet header which operated down in layer 2. For the fourth one, we are back at layer 3 and the GET / HTTP... would reference to the inputted dns that's being requested by a host ( so basically anytime someone is try to reach a or clicks on a link would commonly be sending get request). The Last statement defines what IP protocol to use which we input the value 58, which is IPv6 ICMP. These are just a few common examples to help you understand how easy it is to create a multi-layered protocol with scapy that's very customizable to test for vulnerability, network issues, and packet inspection.