Hi,
I cannot send UDP multicast message in ARM to 1900 port. It is SSDP. netUDP_Send failed with unspecified error.
Any idea?
I will need full SSDP working in keil/ARM.
int32_t udp_sock;
udp_sock = netUDP_GetSocket (udp_cb_func);
netStatus net_status;
if (udp_sock > 0) { // Open UDP port 1000 for communication. net_status = netUDP_Open (udp_sock, 1900); // Let UDP Multicast datagrams cross a router. net_status = netUDP_SetOption (udp_sock, netUDP_OptionTTL, 2); NET_ADDR addr = { NET_ADDR_IP4, 1900, 255, 255, 255, 255 }; uint8_t *sendbuf;
const char* buf = "NOTIFY * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nCACHE-CONTROL: max-age=100\r\n" "NT: upnp:rootdevice\r\nNTS: ssdp:alive\r\nSERVER: device/14.0.0, ProBuf, UPnP/1.1\r\nX-User-Agent: fkuehne-upnpx\r\n\r\n";
u32 size = strlen(buf);
sendbuf = netUDP_GetBuffer (size); strncpy((char*)sendbuf, buf, size);
const uint8_t sgroup[NET_ADDR_IP4_LEN] = { 239,255,255,250 }; char ip_ascii[16]; if (netIGMP_Join (0, sgroup) == netOK) { netIP_ntoa (NET_ADDR_IP4, &sgroup[0], ip_ascii, sizeof(ip_ascii)); } else { return ES_NoError; }
net_status = netUDP_Send (udp_sock, &addr, sendbuf, size); }
Thanks, Naeem
I am entering the reply of our expert: " ...receiving multicast frames must be enabled in Network stack. Actually, a host must join a multicast group (IGMP). The IP layer dumps all multicast packets, destined to a non-member host group. And of course “IGMP Group Management” must be enabled in the system configuration for Ethernet interface.
In the code this is missing actually:
Network V7: uint8_t group_ssdp[NET_ADDR_IP4_LEN] = { 239, 255, 255, 250 }; .. netIGMP_Join (0, group_ssdp);
Network V6: uint8_t group_ssdp[IP4_ADDR_LEN] = { 239, 255, 255, 250 }; .. igmp_join (0, group_ssdp);
TCPnet V4 U8 group_ssdp[IP_ADRLEN] = { 239, 255, 255, 250 }; .. igmp_join (group_ssdp); "
Hello,
I am joining IGMP group in my code before sending UDP message. See this code segment.
I will check If “IGMP Group Management” must be enabled in the system configuration for Ethernet interface.
It should be. I will double check.
netUDP_Send is failing.
netStatus s = netInitialize ();
udp_sock = netUDP_GetSocket (udp_cb_func); if (udp_sock >= 0) { // Open UDP port 1000 for communication. s= netUDP_Open (udp_sock, 2000);
// Let UDP Multicast datagrams cross a router. s = netUDP_SetOption (udp_sock, netUDP_OptionTTL, 2);
// IPv4 address: 192.168.0.1 NET_ADDR4 addr = { NET_ADDR_IP4, 2000, 192, 168, 0, 1 }; uint8_t *sendbuf;
sendbuf = netUDP_GetBuffer (2); sendbuf[0] = 0x01; sendbuf[1] = 0xAA;
s = netUDP_Send (udp_sock, (NET_ADDR *)&addr, sendbuf, 2);
// This UDP connection is no longer needed s = netUDP_Close (udp_sock); s = netUDP_ReleaseSocket (udp_sock);
}