0

I have an arduino on LAN emitting UDP packets with some data.

From my laptop using an ssh session with a Pi, both my laptop and Pi are also on the LAN, when I run:

sudo tcpdump -n udp port 8888

Terminal registers the UDP packets

18:14:44.868050 IP 192.168.1.27.8888 > 255.255.255.255.67: BOOTP/DHCP, unknown (0x1a), length 4

I'm a little unsure why it seems that the packet arrives at 255.255.255.255 on port 67 since my arduino is programmed to send to port 8888. The Pi is running the following script:

const dgram = require('dgram');
const catcher = dgram.createSocket('udp4');

catcher.on('listening', () => {
  const address = catcher.address();
  console.log(`server listening ${address.address}:${address.port}`);
});

catcher.on('message', (msg, rinfo) => {
  console.log('Received a Message from: ' + rinfo.address + " Message Code: " + msg.readUInt8(0));
});

catcher.on('error', (err) => {
  console.log(`server error:\n${err.stack}`);
});

catcher.bind({
  address: "255.255.255.255",
  port: 8888,
  exclusive: true
});

Which is pretty much identical to the dgram basic documentation but I don't actually see anything show up in the terminal for the packets. I've tried cycling through binding to localhost, define it's local IP manually, when it's just left at catcher.bind(8888) it's bound to 0.0.0.0, and lastly I've tried 255.255.255.255 but no luck. Even tried port 67 just be sure.

Obviously the packets are reaching the Pi as I can see them through tcpdump but I'm unclear as to why they're not getting picked up.

Would any of you know? Cheers!

Sam Mason
  • 15,216
  • 1
  • 41
  • 60
AustinFoss
  • 385
  • 5
  • 13
  • seeing the relevant part of the arduino code might help. also what host is 192.168.1.27? your JS code probably wants to bind to `0.0.0.0`, i.e. don't do any filtering by destination IP address – Sam Mason Mar 13 '20 at 11:58
  • It was actually a change in the arduino code. Was very strange cause it worked on another nodejs socket previously.... Oh well – AustinFoss Mar 13 '20 at 16:52
  • Seems like you're sending multicast. 255.255.255.255 is the broadcast address, so when you send a packet here, it will get broadcast to all other nodes who care on the network. If you want to send to a specific address, an alternative is unicast. – vincent Mar 14 '20 at 05:52
  • @AustinFoss Can you post your solution? I am having a similar issue and perhaps your solution would be helpful. – Soenhay Mar 17 '21 at 13:54

0 Answers0