LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Subnet mask erroneously stopping UDP packets (http://www.linuxquestions.org/questions/programming-9/subnet-mask-erroneously-stopping-udp-packets-535017/)

estratos 03-06-2007 05:48 AM

Subnet mask erroneously stopping UDP packets
 
Hi all,

I'm developing an application that sends/receives broadcasted UDP packets to/from other machines on my LAN. This application runs on an uClinux ARM7 processor - I've tried to find the solution in the uClinux mail list with no luck. Now I post here my experiences just to see if this rings someone's bells.

The receiving side of my application is very similar to this example:
http://beej.us/guide/bgnet/examples/listener.c

In fact, this code gives the same results than my app.

And here I list my experiences...

----------------- SCENARIO 1 --------------------
Embedded box settings
IP address: 192.168.1.33
Def gateway: 192.168.1.1
Subnet mask: 255.255.255.0
(UDP packets broadcasted to 255.255.255.255)

Second machine (Win XP) settings
IP address: 192.168.1.16
Def gateway: 192.168.1.1
Subnet mask: 255.255.255.0
(UDP packets broadcasted to 192.168.1.255)

Packets are correctly sent and received by both applications (verified from Ethereal)
-------------------------------------------------
----------------- SCENARIO 2 --------------------
Embedded box settings (LESS EXCLUSIVE NETMASK !!)
IP address: 192.168.1.33
Def gateway: 192.168.1.1
Subnet mask: 255.0.0.0
(UDP packets broadcasted to 255.255.255.255)

Second machine settings (unchanged)
IP address: 192.168.1.16
Def gateway: 192.168.1.1
Subnet mask: 255.255.255.0
(UDP packets broadcasted to 192.168.1.255)

Packets are correctly sent by both applications (verified from Ethereal)
The second machine does receive the packets sent by the embedded box.

THE EMBEDDED BOX DOENS'T RECEIVE ANY PACKET FROM THE SECOND MACHINE !!

-------------------------------------------------

Please, any idea is welcome !

Thanks a lot,

Daniel.

Mara 03-06-2007 03:18 PM

Are you sure the embedded machine does not receive the packets? You probably have a some kind of a LED. Check if it's blinking.

The problem seems to be quite simple. For netmask 255.0.0.0 and net 192. your address 192.168.1.255 is not a broadcast one. I think that the network stack realizes it's not the destination and silently drops your packets.

estratos 03-07-2007 02:54 AM

Quote:

Originally Posted by Mara
The problem seems to be quite simple. For netmask 255.0.0.0 and net 192. your address 192.168.1.255 is not a broadcast one. I think that the network stack realizes it's not the destination and silently drops your packets.

Thanks Mara!

This seems to be the problem. Manually setting the broadcast address to 192.168.1.255 (ifconfig eth0 broadcast 192.168.1.255) does make my application receive the udp packets, even with netmask=255.0.0.0. I get similar results on my Ubuntu machine, so, this behaviour seems to be linux-platform independant. Thus, the origin of this issue is how linux calculates the broadcast address from the subnet mask.

I'm going to post a message on the "Networking" board regarding this issue. I'm still concerned about this issue as many applications that are intended to communicate with my own app do send packets to different broadcast addresses (192.168.1.255, 192.255.255.255, 255.255.255.255).

On the other hand, Windows doesn't have this limitation...

Thanks again,

Daniel.


All times are GMT -5. The time now is 08:05 PM.