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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
2,411 次查看
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 

 

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,137 次查看
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 项奖励
回复
7 回复数
1,137 次查看
DiegoSpinola
Contributor I

@TomR

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

0 项奖励
回复
1,138 次查看
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 项奖励
回复
1,137 次查看
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 项奖励
回复
1,137 次查看
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 项奖励
回复
1,137 次查看
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 项奖励
回复
1,137 次查看
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 项奖励
回复
1,137 次查看
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 项奖励
回复