Which function sends a packet at Layer 3, grabs the first response, and returns it?

Study for the SANS560 GIAC Penetration Tester (GPEN) Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

Which function sends a packet at Layer 3, grabs the first response, and returns it?

Explanation:
In Scapy, when you want to send a packet at the network layer and immediately get the first reply, the function that does that is sr1(). It sends the crafted packet and waits for a response, returning only the first answer it receives (or None if there’s no reply). This is perfect for quick one-shot probes where you’re interested in the first interaction. If you just want to fire off a packet without waiting for any reply, send() is the right choice, but it won’t give you any response to inspect. If you expect multiple responses and want to collect them all, sr() is used, since it returns all matching replies. srp() operates at layer 2 (Ethernet), handling raw frame exchanges rather than IP-layer communication, so it’s not suitable for a simple Layer 3 first-response scenario.

In Scapy, when you want to send a packet at the network layer and immediately get the first reply, the function that does that is sr1(). It sends the crafted packet and waits for a response, returning only the first answer it receives (or None if there’s no reply). This is perfect for quick one-shot probes where you’re interested in the first interaction.

If you just want to fire off a packet without waiting for any reply, send() is the right choice, but it won’t give you any response to inspect. If you expect multiple responses and want to collect them all, sr() is used, since it returns all matching replies. srp() operates at layer 2 (Ethernet), handling raw frame exchanges rather than IP-layer communication, so it’s not suitable for a simple Layer 3 first-response scenario.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy