I’m running into a bit of an issue porting some code from Linux to QNX. I need to send a broadcast UDP packet to 255.255.255.255, but for some reason QNX (6.3.2) change the IP of the packet recipient to 192.168.255.255 … which is the broadcast @ of the adapter … I have googled around and it seems that several people have encountered that issue, but I haven’t found any link to a solution … yet.
Thanks in advance for any tips/advice or solution(s).
Stevens: Unix Network Programming Volume 1, 2nd ed. (1998)
"… the subnet-directed broadcast address is the most common today. But some older systems still send datagrams destined to 255.255.255.255 "
‘subnet-directed’ being what you’re seeing (netmask applied to the broadcast address)
BSD seems to have an IOCTL which will allow you to force the 255.255.255.255 address but it’s not
supported in QNX.
You may be stuck with this behavior or have to go to raw sockets - and there’s no guaruntee it’ll
work there either.
“… A special type of IP address is the limited broadcast address 255.255.255.255. A broadcast involves delivering a message from one sender to many recipients. This broadcast is ‘limited’ in that it does not reach every node on the Internet, only nodes on the LAN.”
We use this broadcast address (RFC1122) to discover devices (cameras) on the local network, this is what the standard (GigE Vision) request. QNX is the only OS to not allow it AFAIK. Assigning a broadcast address of 255.255.255.255 with ifconfig to the adapter “solve” the issue … but I’m not sure this is an acceptable solution
While I agree that you should be able to send to the general boradcast address, this does bring up an obvious question. If your subnet covers the local lan, why would a local broadcast address not be sufficient for your needs? I’m just trying to be practical here.
Well, broadcasting to 255.255.255.255 garantee that we can “reach” any devices on the local network, inlcuding the ones that are not configured properly (unreachable otherwise as they won’t answer a subnet broadcast as they don’t know, or have an incorrect, netmask.