RTCS doesn't receive broadcast datagrams on subnet, bug?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RTCS doesn't receive broadcast datagrams on subnet, bug?

Jump to solution
2,063 Views
TomR
Contributor I

 

I am trying to send UDP frames to an MQX system using broadcast messages.
The MQX system has a DHCP assigned IP address of 192.168.0.5 and a netmask of 255.255.255.0.
  • UDP frames sent to 192.168.0.5 are rx ok
  • UDP frames sent to 255.255.255.255 are rx ok
  • UDP frames sent to 192.168.0.255 are not rx
Sniffing the wire, both the 255.255.255.255 and 192.168.0.255 frames are sent with a destination MAC address of ff:ff:ff:ff:ff:ff as expected.
RTCS IP statistics show the UDP frames sent to 192.168.0.255 are being discarded.
This seems broken. I have a different platform (non-MQX) where is works.
Is there a setting that I'm overlooking?
My code looks like this:
 struct sockaddr_in any;
 udp_ethernet = socket(PF_INET, SOCK_DGRAM, 0);
 any.sin_family      = AF_INET;
 any.sin_port        = MY_PORT;
 any.sin_addr.s_addr = INADDR_ANY;
 bind(udp_ethernet, &any, sizeof(any));
 rlen = sizeof(raddr);
 memset(&raddr, 0, rlen);
 len = recvfrom(udp_ethernet, data, DATA_LEN, 0, &raddr, &rlen);
Thanks
Tom 

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
789 Views
DiegoSpinola
Contributor I

Solved!

 

Recompile your Libs with the RTCSCFG_IP_DISABLE_DIRECTED_BROADCAST defined to 0 at user_config.h

 

 

#define RTCSCFG_IP_DISABLE_DIRECTED_BROADCAST 0

 

 

View solution in original post

0 Kudos
7 Replies
789 Views
DiegoSpinola
Contributor I

@TomR

 I'm having the exact same issue , have you been able to solve it ?

0 Kudos
790 Views
DiegoSpinola
Contributor I

Solved!

 

Recompile your Libs with the RTCSCFG_IP_DISABLE_DIRECTED_BROADCAST defined to 0 at user_config.h

 

 

#define RTCSCFG_IP_DISABLE_DIRECTED_BROADCAST 0

 

 

0 Kudos
789 Views
dank60
Contributor III

I tried to do this and it works if I build my libs in debug configuration. If I build them in release configuration I can't receive broadcast frames... I don't know what I have to do...

0 Kudos
789 Views
dank60
Contributor III

I tried building rtcs library  with different compiler's optimization levels : with level 1 no problem, with level 2 or superior broadcast udp reception doesn't work.

0 Kudos
789 Views
TomR
Contributor I

Additional debugging info:

The datagram sent to 192.168.0.255 is being dropped in the function IP_route_local(). It discards the packet and increments the rx discarded count and the rx addr errors count.

0 Kudos
789 Views
boogy
Contributor III

You have gotten farther than me. I can't recieve a broadcast (255,255,255,255) datagram.

I am currently using a stream socket and wanted to add a datagram socket to recieve broadcast datagrams.

What settings allow the reception of UDP broadcasts ?

0 Kudos
789 Views
TomR
Contributor I

The code fragment above will do the trick. Nothing more is needed on the receive side.

 

Typically the problem to send a broadcast datagram is on the sending end. Make sure that you've done a setsockopt(SO_BROADCAST) on the sending socket.

 

Have you sniffed the wire and observed that the packet is being sent on the wire?

0 Kudos