This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hello everyone,
I’m working on a Linux application using libcoap3 4.3.0 to send CoAP messages over a Wi-SUN network through a border router. The border router is running SimpleLink SDK 7.40 from Texas Instruments, and the network interface is set up using wfantund.
When I send a unicast CoAP message to a specific node, it reaches the node without any issues. However, when I try to send a multicast message to the address ff02::1
, none of the nodes receive it. I can see the multicast message leaving my application using Wireshark, but the nodes do not seem to respond to it.
Interestingly, if a node sends a multicast message, it reaches all the nodes and the border router without problems.
Has anyone encountered this issue or have any insights on why the multicast message might not be reaching the nodes when sent from the application?
this is the program i`m using to test:
#include <coap3/coap.h> #include <stdio.h> #include <ctype.h> #include <signal.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/select.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <net/if.h> // Para if_nametoindex int main(void) { coap_context_t *ctx = NULL; coap_session_t *session = NULL; coap_address_t dst; coap_uri_t uri; coap_pdu_t *pdu; unsigned int if_index; // Índice de la interfaz de red // Inicializa el URI manualmente con dirección completa de IPv6 memset(&uri, 0, sizeof(coap_uri_t)); // Limpia la estructura uri.port = COAP_DEFAULT_PORT; // Puerto por defecto de CoAP uri.path.s = (uint8_t *)"ok"; // El recurso "ok" uri.path.length = strlen("ok"); // Longitud del recurso "ok" uri.host.s = (uint8_t *)"ff02::1"; // Dirección multicast IPv6 completa uri.host.length = strlen("ff02::1"); // Inicializa CoAP coap_startup(); // Crea el contexto de CoAP ctx = coap_new_context(NULL); if (!ctx) { fprintf(stderr, "Error al crear el contexto de CoAP\n"); return -1; // Configura la dirección de destino (grupo multicast con IPv6 completo) coap_address_init(&dst); dst.addr.sin6.sin6_family = AF_INET6; dst.addr.sin6.sin6_port = htons(uri.port); if (inet_pton(AF_INET6, "ff02::1", &dst.addr.sin6.sin6_addr) != 1) { fprintf(stderr, "Error al establecer la dirección multicast\n"); coap_free_context(ctx); return -1; } // Obtiene el índice de la interfaz de red (por ejemplo, eth0) if_index = if_nametoindex("wfan0"); // Cambia "eth0" por el nombre de tu interfaz de red if (if_index == 0) { perror("if_nametoindex"); coap_free_context(ctx); return -1; } // Especifica la interfaz de red a través del campo sin6_scope_id dst.addr.sin6.sin6_scope_id = if_index; // Crea una sesión CoAP (multicast) session = coap_new_client_session(ctx, NULL, &dst, COAP_PROTO_UDP); if (!session) { fprintf(stderr, "Error al crear la sesión de CoAP\n"); coap_free_context(ctx); return -1; } // Crea una nueva solicitud PUT pdu = coap_pdu_init(COAP_MESSAGE_NON, COAP_REQUEST_PUT, coap_new_message_id(session), coap_session_max_pdu_size(session)); if (!pdu) { fprintf(stderr, "Error al crear el PDU\n"); coap_session_release(session); coap_free_context(ctx); return -1; } // Configura la URI con la dirección IPv6 completa para "ok" coap_add_option(pdu, COAP_OPTION_URI_PATH, uri.path.length, uri.path.s); // Envía el PDU (el payload está vacío, por lo que no se agregan datos) if (coap_send(session, pdu) == COAP_INVALID_TID) { fprintf(stderr, "Error al enviar el mensaje CoAP\n"); coap_session_release(session); coap_free_context(ctx); return -1; } printf("Solicitud PUT multicast enviada a ff02::01\n"); // Limpieza coap_session_release(session); coap_free_context(ctx); coap_cleanup(); return 0; }
This happens when I send the multicast message through the application.
This occurs when I send the multicast message from the node
Please note that the response to the multicast I'm expecting causes the nodes to send a message to the border router.
Any suggestions on how to troubleshoot this or ideas on what might be causing this issue would be greatly appreciated!
Thanks in advance!
Hi nicolas,
I have encountered the same not long ago, and have filed a bug report.
My "workaround" is the following:
Workaround is in quotes because we are missing the sequence number increase when just copying the payload from pyspinel, so I think the nodes are ignoring it sometimes.
Regards,
Arthur