I'm sending a simple ARP request using Scapy. I noticed that it will send multiple packets out though, even when I've only given it a single packet:
from scapy.sendrecv import sr1
from scapy.layers.l2 import ARP
from typing import Optional
def request_mac(target_ip: str, **kwargs) -> Optional[str]:
req = ARP(pdst=target_ip)
reply = sr1(req, **kwargs)
return reply and reply[ARP].hwsrc
request_mac("192.168.123.118", timeout=5)
In Wireshark, I can see that it sends out two ARPs instead of one:
Even though the output only shows one being sent:
Begin emission:
Finished sending 1 packets.
................................................................................................................
Received 112 packets, got 0 answers, remaining 1 packets
If I set the retry
parameter to sr1
, I get two packets sent for every one I explicitly send.
Is this expected behavior? Is there a way to have it only send one? When I made a port scanner, I didn't see duplicate sends of TCP segments, so it seems like it may be specific to ARPs?