scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Fix ICMPEcho_am description

Open mbUSC opened this issue 2 years ago • 3 comments

From the ICMPEcho_am code:

    def make_reply(self, req):
        reply = IP(dst=req[IP].src) / ICMP()
        reply[ICMP].type = 0  # echo-reply
        reply[ICMP].seq = req[ICMP].seq
        reply[ICMP].id = req[ICMP].id
        # Force re-generation of the checksum
        reply[ICMP].chksum = None
        return reply

Nothing is actually swapped; the source IP address from the echo request is used as the destination for the echo reply. src in the echo reply is left unspecified, so it defaults to that of the outgoing interface

mbUSC avatar Jun 30 '23 16:06 mbUSC

Codecov Report

Merging #4051 (c1aaa2b) into master (cdbdb15) will decrease coverage by 0.01%. The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4051      +/-   ##
==========================================
- Coverage   81.91%   81.91%   -0.01%     
==========================================
  Files         328      328              
  Lines       75494    75494              
==========================================
- Hits        61841    61838       -3     
- Misses      13653    13656       +3     

see 9 files with indirect coverage changes

codecov[bot] avatar Jun 30 '23 16:06 codecov[bot]

Hi, did you find this confusing? I'm interested in why you bumped into this. Did you have a case where this was unexpected? Thanks !

gpotter2 avatar Jul 07 '23 20:07 gpotter2

Hi @gpotter2,

I was just reading the docs about using tun/tap (https://scapy.readthedocs.io/en/latest/layers/tuntap.html) when I ran into that.

Towards the bottom, it mentions "ICMPEcho_am swaps the source and destination fields of any Ether and IP headers...". Looking at the packets in Wireshark, I noticed that the behavior didn't quite match that description in the docs, so just thought of reporting it

mbUSC avatar Aug 21 '23 00:08 mbUSC