Boris Veselov
Boris Veselov

Reputation: 75

Differences between scapy.sr and scapy.srp

I'm using Scapy to scan my network and I can't see a differences between functions : scapy.sr() and scapy.srp(). Documentation says that scapy.sr() returns packets from layer 3 and scapy.srp() returns packets from layer 2. What are these layers? Sorry for my question, I'm a beginner in networks.

Upvotes: 5

Views: 5643

Answers (1)

Cukic0d
Cukic0d

Reputation: 5411

Here’s a cool image that sums it up pretty well:

Layers 2 & 3

When you use srp, srp1 or sendp, you are expected to provide a packet that starts at layer 2, such as:

srp1(Ether()/IP(dst="www.google.com")/ICMP())

Without the p, it’s layer 3:

sr1(IP(dst="www.google.com")/ICMP())

(Behind the scenes, Scapy takes care of it)

Layer 2 allows you to spoof the data link (Ethernet, 802.11...) frames, but it requires you to know which one to use.

Upvotes: 5

Related Questions