mqx 4.1 udp cant recv broadcase frame

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

mqx 4.1 udp cant recv broadcase frame

1,902 次查看
胜利何
Contributor I

我现在用的MQX4.1版本中的网络通信使用中,无法接收网络的广播报文,我发送的广播报文对方能收到,请问在什么地方配置修改。
在rtcscfg.h中,定义如下
#ifndef RTCSCFG_IP_DISABLE_DIRECTED_BROADCAST
#define RTCSCFG_IP_DISABLE_DIRECTED_BROADCAST 0
#endif

#ifndef RTCSCFG_ENABLE_STATS
    #define RTCSCFG_ENABLE_STATS 1
#endif
K64广播发送,PC接收!没有问题。K64的IP设置100.100.100.100,pc地址为100.100.100.200,广播地址为100.100.100.255,用网络抓包工具,能看到K64发送出去的报文!但是K64接收不到PC的广播包内容,能接收到到PC发送给K64地址的数据包。使用的是UDP方式通信。
请问是什么原因?
标签 (1)
2 回复数

1,731 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi 胜利何 

To broadcast a UDP message with RTCS, simple set the destination IP to INADDR_BROADCAST;

raddr.sin_addr.s_addr =  INADDR_BROADCAST;

UDP should recieve broadcast packets without any special socket option.

If you are using directed broadcast, please enable RTCSCFG_IP_DISABLE_DIRECTED_BROADCAST in user_config.h


Have a great day,
Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button or helpful. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,731 次查看
胜利何
Contributor I

I have two netports,
I want to the two ports can receive boradcast frame.
such as net 1 IP is 192.168.1.2,I want to only receive IP data to 192.168.1.2 or 192.168.1.255 address .
net 2 IP is 192.168.2.2,I want to only receive IP data to 192.168.2.2 or 192.168.2.255 address .

but if I init the IP,
for(i=0;i<2;i++)
{
.....

addr.sin_family = AF_INET;
addr.sin_port = 8812;
addr.sin_addr.s_addr = INADDR_ANY;

sendsock[i] = socket(PF_INET, SOCK_DGRAM, 0);
error = bind(sendsock[i], &addr, sizeof(addr));
....
}

the second port retun error != RTCS_OK.

if addr.sin_addr.s_addr = IPADDR(192,168.1.2) or IPADDR(192,168.2.2),
I only receive data to 192.168.1.2 or 192.168.2.2 ,I cannot receive data to 192,168.1.255 or192,168.2.255,
what shall I do?

0 项奖励
回复