nospaceships / node-raw-socket

Raw sockets for Node.js.
207 stars 69 forks source link

NONE Protocol throwing error on a vanilla Raspberry Pi 3. #48

Closed sourcevault closed 6 years ago

sourcevault commented 6 years ago

Hi !

I am trying to use node-raw-socket, for now I can work around the issue but I still think its important to find out what went wrong :

SOFTWARE : armv7l Raspbian GNU/Linux 9 (stretch) 4.14.50-v7+ HARDWARE : Raspberry Pi 3 - Model B

On the Pi 3 TCP and ICMP works flawlessly but for some reason NONE is throwing error.

write(2, "/home/pi/code/raw-socket/node_mo"..., 707/home/pi/code/raw-socket/node_modules/raw-socket/index.js:47
        this.wrap = new raw.SocketWrap (
                    ^

Error: Protocol not supported
    at new Socket (/home/pi/code/raw-socket/node_modules/raw-socket/index.js:47:14)

I ran strace to find out exactly which system call is to blame:

read(12, "var _arity = /*#__PURE__*/requir"..., 1155) = 1155
close(12)                               = 0
socket(AF_INET, SOCK_RAW, IPPROTO_IP)   = -1 EPROTONOSUPPORT (Protocol not supported)
cacheflush(0x23887680, 0x238877a0, 0, 0x1, 0x7ec5ef28) = 0

Do you think is a issue with the Pi or some config I need to fix in node-raw-socket ?

Cheers !


var raw, options, socket;                                                          
raw = require("raw-socket");                                                             
options = {                                                                              
  addressFamily: raw.AddressFamily.IPv4,                                                 
  protocol: raw.Protocol.None,                                                           
  bufferSize: 4096,                                                                      
  generateChecksums: false,                                                              
  checksumOffset: 0                                                                      
};                                                                                       
socket = raw.createSocket(options);                                                      
socket.on("message", function(buffer, source){                                           
  return console.log("received " + buffer.length + " bytes from " + source);             
});
stephenwvickers commented 6 years ago

Hi @sourcevault

I am really sorry but I'm not sure what to suggest here :(

You can see that the error obviously indicates raw sockets are not supported on your platform. I have zero experience with Raspberry Pi so I don't know if what you see is correct and expected behavior or not.

Does your platform documentation indicate raw sockets are supported, and if so does the raw-socket module open the socket in the correct way?

Steve

sourcevault commented 6 years ago

HI steve !

Thanks for the reply, but I think it has something to do with raspbian (debian) - I tried to find documentation on raw sockets on raspbian.

It's okay I am not experienced enough to use raw sockets to create any meaningful application anyway.

cheers !