Open Talbot3 opened 5 years ago
@orangebook can you please give more detail. I don't understand what the problem is from your description.
there is all description. just check the 3th and 4th bytes is not right from node-raw-socket. packet's 3th and 4th bytes is length of packet right ?
@orangebook so the length in the data
printed above would be 40, i.e. 0x28. That's the length of the sent packet, perhaps you are printing the sent packet?
Can you share the program you are using to display this data so I can look further?
@orangebook so the length in the
data
printed above would be 40, i.e. 0x28. That's the length of the sent packet, perhaps you are printing the sent packet?
should not so, maybe mixed return and send packet
Can you share the program you are using to display this data so I can look further?
@stephenwvickers , just run demo on node-raw-socket/example/ping.js
@Talbot3 The example program works for me.
yea, but my mean is the 2800
data wrong.but i didn't know how to fix it on this repo
I just created https://stackoverflow.com/questions/74448657/why-might-wireshark-and-nodejs-disagree-about-a-packets-contents and was pointed to this issue.
I also see this on macOS (so, perhaps this is macOS related).
I've run the ping example in the following ways:
SOCK_DGRAM
disabledIn every instance, the ICMP reply comes back with the length set to 0x2800 instead of 0x0040.
Even setting aside the Wireshark evidence, the reply packet is wrong for a few reasons:
I've created a SSCCE here: https://github.com/dancrumb/sscce-raw-socket-ping
Hmmm - this seems pertinent :/
https://cseweb.ucsd.edu//~braghava/notes/freebsd-sockets.txt
Specifically:
Reading from RAW sockets
------------------------
- ip_len does not include the IP header's length. recvfrom() however
returns the packet's true length. To get the true ip_len field do:
iphdr->ip_len += iphdr->ip_hl << 2;
- You may only read from RAW sockets bound with a protocol other than
IPPROTO_RAW
- ip_len is in host byte order
- You may only read packets for protocols or subprotocols that the kernel
does not process. This includes things such as ICMP_ECHOREPLY and
ICMP_TIMESTAMP as well as nonstandard protocol numbers.
ENV: Node 12.4.0 OS: macos mojave 10.14.5