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.

CC3135MOD: MDNS - multiple devices advertising

Part Number: CC3135MOD
Other Parts Discussed in Thread: CC3135

Hi all,

I am using a CC3135 module to connect to a WiFi network. My devices are advertising on the network using a service name composed by a device-specific ID and a common service name:

int simplelink_configure_mdns(int mode, char *name, char* txt, int port)
{
    static char mds_service[64];
    int retval;

    retval = simplelink_start_stop_mdns(1);  // Start mdns service <-- Registration of a new service should be performed only if the mDNS service is enabled  
    ASSERT_ON_ERROR(retval, NETAPP_ERROR);
    // unregister mdns services
    retval = sl_NetAppMDNSUnRegisterService(0, 0, 0);            
    ASSERT_ON_ERROR(retval, NETAPP_ERROR);

    if (!mode)
    {
        return retval;
    }
    
    //name = device ID
    //MDNS_STRING = "_smartcam._tcp.local"
    sprintf(mds_service, "%s.%s", name, MDNS_STRING);
    
    /* Stop continuous query */
    retval = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,0 , 0);

    /* Register mDNS services */
    // Advertise (Mdns host) broadcasts its own IP address, port number and message to 224.0.0.251 + 5353 

    uint32_t opt = /*SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT |*/ SL_NETAPP_MDNS_IPV4_ONLY_SERVICE | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT;
    retval = sl_NetAppMDNSRegisterService((const signed char*)mds_service, strlen(mds_service), 
                                          (const signed char*)txt, strlen(txt), port, TTL_VALUE, opt);
    ASSERT_ON_ERROR(retval, NETAPP_ERROR);
    LOG_SERIAL_INFO("[mDNS advertise] : service name %s registered successfully", mds_service);


    /* The below parameters are used to configure the advertise times and interval
       For example:
        If:
        Period is set to T
        Repetitions are set to P
        Telescopic factor is K=2
        The transmission shall be:
        advertise P times
        wait T
        advertise P times
        wait 4 * T
        advertise P time
        wait 16 * T  ... (till max time reached / configuration changed / query issued)
     */
    SlNetAppServiceAdvertiseTimingParameters_t Timing;
    
    Timing.t = 100; // 1 seconds Default is 100 ticks for 1 second
    Timing.p = 2; // 2 repetitions
    Timing.k = 2; // Telescopic factor 1
    Timing.RetransInterval = 500;
    Timing.Maxinterval = 1000;
    Timing.max_time = 0xFF;    // in seconds FOREVER
    retval = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_TIMING_PARAMS_OPT, sizeof(Timing), (const unsigned char*)&Timing);
    if (retval < 0)
    {
        LOG_SERIAL_ERROR("[mDNS advertise] : mDNS set timing params %d", retval);
    }

    return retval;
}

When I have only one device advertising, I see a 'Standard query response' after a 'Standard query' from the software looking for devices:

When I have 2 devices instead, I see also the two devices sending queries as reply to a software query (see the highlighted message)

It seems that the device is sending a query to the PC instead of a query response.

Can someone explain me why? Can I avoid it in some way? It seems that this behaviour is slowing down the devices detection by the PC.

Thank you

regards

Arianna

  • Hi Arianna,

    This looks like an advertisement notification (of the internal HTTP server).

    I'm not sure how this slows down the detection.

    br,

    Kobi  

  • Hi Kobi,

    thank you for your reply!

    So is this a normal behavior? And is it normal that the behavior is different when there is one or there are more devices?

    I'm not sure how this slows down the detection.

    Our software looks for a 'query response' message; when there is only one device it arrives quickly, while when there are two devices we see a lot of queries arriving but we have to wait much more to get a 'query response'.

    We can try to intercept and parse also the advertising messages but we would like to be sure that this is the right way to detect the devices.

    Thank you again

    Arianna

  • what do you mean that you need to wait much more for a response?

    How much more?

    When having more than one device, there can be conjunctions over the air (2 devices try to respond at the same time) which can introduce some delays, but it should be too much.

    I don't think the advertisement contains the info you are looking for (it is for the http server).

  • Look at this example:

    The software query starts at t=5.37 s, the first devices replies immediately, while the response of the second one arrives only at t=28,79 s, that is near half minute of waiting.

    The time to wait is random, but it is at least 10 seconds with the 2 devices on.
    Maybe some adjustment on the timing parameters can help?

    Thank you for the reply,

    Arianna

  • looks like the devices miss some of the queries.

    Are the devices going to low power (maybe LSI) so they can miss broadcasts?

    It doesn't explain the difference from the single device use-case.

    According to the latest log, you may try sending couple of retransmissions of the query (i.e. reduce the 7-8 sec interval).

    br,

    Kobi

  • Hi Kobi,

    yes, you are right, the LSI was enabled with a max sleep time of 500 ms.
    I tried to set the power policy to normal and now the discovery seems to be much faster (max 2 queries to get response from both the devices!).

    As you said, it is not totally clear why with 2 devices the difference was so high, maybe it is the sum of LSI latency and conjunctions over the air.

    Thank you for your support,

    best regards,

    Arianna