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.

Problem receiving multicast



Hello

I'm using the cc3000 and trying to send and receiving multicast over udp according to http://processors.wiki.ti.com/index.php/CC3000_Multicast

But regardless of which multicast adress I bind to the socket, I receive all messages sent on multicast adresses as long as they have the same port as I have used when binding the socket. Since recvfrom only gives the address of the sender, not the address received on I have no way to filter out if the multicast message was for me. I want to have groups of units where each group listen to a different multicast addresse but all groups should use the same port. 

Is this a problem with the module or am I missing something when setting up the socket for receving on a multicast ip address?
(I'm using the latest release 1.11 and reading out patch version 1.19 with  nvmem_read_sp_version)

BR
/Benneth 

  • Hi Benneth,

    You simply have to recall which port you bind to...Is this what you are trying to accomplish?

     

    Thanks,

    Aaron

     

     

  • Hi

    The problem isn't the port.
    If i bind my socket to multicast address 239.1.0.41 and port 50632, then it will receive all messages sent on different multicast addresses as long as it is on the same port.
    For example the socket will receive message sent to 224.1.1.22 if is sent to port 50632 even though the socket was bind to another address.

    So how can I do to only receive for the address I bind? Or is it a way to determine which address that was received on after the recvfrom function has been called?

    BR
    /Benneth

  • Hi,

    I'm still having this problem.

    Is there someone that know if this is a known problem? (If so are there any plan for fixing the problem?)

    Or are there any more information available on how tu use multicast for CC3000 since it doesn't work when using the example (see original post).

    BR
    /Benneth 

  • Hi Benneth,

    I'm checking to see if this is a known issue. In the meanwhile, can you post the code you are using to set up the socket?

     

    Thanks,

    Aaron

  • Hi,

    After the wlan module has started and we have a connection, the following is used to set up the socket.
    (Only included the parts related to the socket. It is used in a bigger switch/case statemachine, hence the breaks)

    #define DISCOVER_PORT 50632

    long wifiUdpClient;
    sockaddr udpaddr;
    sockaddr udpClientAddr;
    socklen_t addrlen;
    fd_set readsds;
    long maxFD;
    timeval timeout; 

    //-----------

    if (socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) == -1) {

        break;
    }

    //-----------

    udpaddr.sa_family = AF_INET;
    udpaddr.sa_data[0] = (DISCOVER_PORT & 0xFF00)>> 8;
    udpaddr.sa_data[1] = (DISCOVER_PORT & 0x00FF);
    udpaddr.sa_data[2] = 239;
    udpaddr.sa_data[3] = 63;
    udpaddr.sa_data[4] = 253;
    udpaddr.sa_data[5] = 57; 

    if (bind(wifiUdpClient, &udpaddr, sizeof(sockaddr))== -1) {
        break;
    }

    //-----------

    FD_ZERO(&readsds);
    FD_SET(wifiUdpClient, &readsds);
    maxFD = wifiUdpClient + 1;
    timeout.tv_sec = 0;
    timeout.tv_usec = 5000;

    if(select(maxFD, &readsds, NULL, NULL, &timeout) < 0) {
        break;
    }
    if(!FD_ISSET(wifiUdpClient,&readsds)) {
        break;
    }

    // Look for a request/command packet
    addrlen = sizeof(sockaddr);
    i = recvfrom(wifiUdpClient, &pktData[0], sizeof(pktData), 0, &udpClientAddr, &addrlen);

    //Parse received message 

    //-----------

    With this, the checks with select and FD_ISSET will give ok for all receptions on the port that was set up and not only for thoose on the set up multicast address.
    I've also tried the code from the example linked in the first post without any success. 

    BR
    /Benneth 

  • Hi Benneth,

    I have not heard of this being a known issue... so I will try to reproduce. I do think this is an important issue. Please stand by.

     

    Regards,

    Aaron

  • Hi Benneth,

    Where are you setting wifiUdpClient?

    I see socket() is called without retrieving the file descriptor.

     

    Regards,
    Aaron

  • Hi Aaron,

    looks like I managed to do some kind of copy paste error.
    The code used is the following:

    #define DISCOVER_PORT 50632

    long wifiUdpClient;
    sockaddr udpaddr;
    sockaddr udpClientAddr;
    socklen_t addrlen;
    fd_set readsds;
    long maxFD;
    timeval timeout; 

    //-----------

    wifiUdpClient = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if (wifiUdpClient == -1) {
        break;
    }

    //-----------

    udpaddr.sa_family = AF_INET;
    udpaddr.sa_data[0] = (DISCOVER_PORT & 0xFF00)>> 8;
    udpaddr.sa_data[1] = (DISCOVER_PORT & 0x00FF);
    udpaddr.sa_data[2] = 239;
    udpaddr.sa_data[3] = 63;
    udpaddr.sa_data[4] = 253;
    udpaddr.sa_data[5] = 57; 

    if (bind(wifiUdpClient, &udpaddr, sizeof(sockaddr))== -1) {
        break;
    }

    //-----------

    FD_ZERO(&readsds);
    FD_SET(wifiUdpClient, &readsds);
    maxFD = wifiUdpClient + 1;
    timeout.tv_sec = 0;
    timeout.tv_usec = 5000;

    if(select(maxFD, &readsds, NULL, NULL, &timeout) < 0) {
        break;
    }
    if(!FD_ISSET(wifiUdpClient,&readsds)) {
        break;
    }

    // Look for a request/command packet
    addrlen = sizeof(sockaddr);
    i = recvfrom(wifiUdpClient, &pktData[0], sizeof(pktData), 0, &udpClientAddr, &addrlen);

    //Parse received message 

    //-----------

    BR
    /Benneth

  • Hi Benneth,

    I have reproduced your issue, and this does seem strange to me. I'll keep you updated with any workarounds or conclusions.

     

    Regards,

    Aaron

  • Hi Aaron,

    Any update regarding the multicast issue?

    Also, for multicast to fully work on all networks it might be necessary to implement IGMP protocol since some networks don't forward multicast traffic. What I understand there are no support for IGMP for the CC3000 today. Is there any way to implement the IGMP protocol with the current api of the CC3000

    BR
    /Benneth 

  • Hi Benneth,

    We have had an internal discussion about this and have concluded there is no way for the CC3000 to recieve only multicast messages designated for a specific group. Also, with CC3000's API, IGMP is not implementable. The only possible workaround is to perhaps include group information in the payload, and simply ignore packets not in that group at the application level.

     

    Regards,

    Aaron