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.

Doubt regarding the Ping callback function during router down and coming back up scenarios

Other Parts Discussed in Thread: CC3200

Hi Folks,

I have some doubts on how the ping callback function works and when is it called during certain scenario.  Assume the ping timeout interval is set to 300 ms and time for ping to complete is 200 ms for the following scenarios:

Scenario: Currently my router is up and pings are working well with the callback function being called regularly, after each ping completes. Now, consider, if the ping has started and is in progress and 100ms has passed, and suddenly the router goes down in the middle of the progress.

Questions: For the above scenario

1. What will happen to the callback function?, will it be called when the router is down?

2. Since the router went down in the middle and did not allow the ping to complete, will the ping timeout after 300 ms and after the time out, will the ping callback function be called?

3. Now after the router comes up again, will the cc3200 automatically connect back to the router or we have to again call the function "wlanconnect" to reconnect to the router?

I noticed that, if my router goes down, the ping succeeds returning 0 for the API lRetVal = sl_NetAppPingStart((SlPingStartCommand_t*)&pingParams_ds, SL_AF_INET,(SlPingReport_t*)&pingReport_ds, PingCallBack);, but the ping callback function is not called and it gets stuck there. I believe that in this case the ping should time out and the ping call back function is called?.

Please, any support and advises regarding working of ping call backs with respect to router up and down scenarios as described above, would be greatly appreciated.

               

  • Hi Vinay,

    What contents do you see in the ping report when you see the application get stuck?

    I'm going to have another person on the team clarify when you can expect the ping callback function to be called. However, with regards to (3), the CC3200 could reconnect to the router if the profile is saved, the device itself is restarted, and if the auto connect policy is set.

    Best Regards,
    Ben
  • Hi,

    1. What will happen to the callback function?, will it be called when the router is down?

    Yes, it would be invoked, most likely after all (attempts * interval timeouts) are consumed

    2. Since the router went down in the middle and did not allow the ping to complete, will the ping timeout after 300 ms and after the time out, will the ping callback function be called?

    The ping callback is invoked after (attempts * interval timeouts) is consumed

    3. Now after the router comes up again, will the cc3200 automatically connect back to the router or we have to again call the function "wlanconnect" to reconnect to the router?

    If you work with wlanconnect() API, you would need to call it again.

    Shlomi

  • When I switch off the router while the ping is in progress to several IP addresses with in the subnet. The ping call back isn't being called after the timeout occurs. I generally use the ping report to see the number of packets received and sent after each ping, and this report is displayed within the ping call back function which isn't being called at all when router is switched off. 

    I believe that once the pinging is over, the  status bit in the ping callback function is set using SET_STATUS_BIT(Hooter_ulStatus, STATUS_BIT_PING_DONE);. However, when I turn off the router, this bit is never set for some reason, even after the time out may have occuured.

  • Hi,

    Let me just understand the setup.

    Are you using flags=1 on the ping start API? in normal condition when the AP is up, are you getting ping report for every packet?

    Shlomi

  • Hi,

    I am using flags = 0 in the ping start API.

    Yes. When the AP is up, I get ping report for every packet. Below is the ping call back function I am using and in which the status bit is set after the ping has completed. But when the AP goes down, the status bit is never set until we reconnect back to AP when it is up and restart the ping process.

    Below is the ping callback function and ping to IP function.

    //  Variables Solely used by PingCallBack
    static volatile unsigned long  	Hooter_ulStatus;
    static unsigned long  			Hooter_ulPingPacketsRecv;
    
    static SlPingStartCommand_t pingParams_ds = {0};
    static SlPingReport_t pingReport_ds = {0};
    
    
    void PingCallBack(SlPingReport_t *pPingReport)
    {
    	SET_STATUS_BIT(Hooter_ulStatus, STATUS_BIT_PING_DONE);
    	Hooter_ulPingPacketsRecv = pPingReport->PacketsReceived;
    	UART_PRINT("ping (rcv:%d / send: %d) *********\r\n", pPingReport->PacketsReceived, pPingReport->PacketsSent);
    }
    
    
    long PingToIP(unsigned long PingIP, unsigned long pingInterval, unsigned short pingPacketSize, unsigned short pingTimeout, unsigned long pingAttempts)
    {
    	/*  Clear the global variables used in the call to ping. Note that ping is
    	 *  used in NON-BLOCKING mode. Hence the variables passed to ping should have
    	 *  a global scope, as compared to the example ping programs which are BLOCKING.
    	 */
    
    	long lRetVal = -1;
    
    	CLR_STATUS_BIT(Hooter_ulStatus, STATUS_BIT_PING_DONE);
    	Hooter_ulPingPacketsRecv = 0;
    
    	// Set the ping parameters
    	pingParams_ds.PingIntervalTime 			= pingInterval; //100ms
    	pingParams_ds.PingSize 					= pingPacketSize; //32
    	pingParams_ds.PingRequestTimeout 		= pingTimeout; //300ms
    	pingParams_ds.TotalNumberOfAttempts 	= pingAttempts; //2
    	pingParams_ds.Flags 					= 0;
    	pingParams_ds.Ip 						= PingIP;
    
    	// Try to ping HOST_NAME
    	lRetVal = sl_NetAppPingStart((SlPingStartCommand_t*)&pingParams_ds, SL_AF_INET,(SlPingReport_t*)&pingReport_ds, PingCallBack);
    	return lRetVal;
    
    	// No Wait. Calling function will use the callback-set global variables to detect complewtion.
    }
    

    
    
  • Hi,

    I am checking it internally but from what I see till now, in case the interface is down and flags equal 1, report message would not get trigerred back to host. However, I do expect that a final report message at the end of the period would get triggered.

    Shlomi

  • Hi,

    I have just tested it locally and the callback should be called after all retries are exhausted.

    I am working with latest SP 2.7.0.0.

    Shlomi

  • Also please ensure that if you use infinite ping (0 in number of packets), you should stop the ping from application (upon getting disconnect command for example).

    Shlomi

  • Hi,

    Did the above post answer your query? Any update on the post?
    please verify the answer.

    Shlomi

  • Hi Folks,

    I will have to try once with the latest service pack as advised, as currently I am using the old one. However, I have handled the issue logically such that, the call to ping functions is never invoked when the router goes down. The moment the router is power back on, the periodic ping process is continued as per the logic. I had to make a release, therefore, for now this has fixed it. Currently I am working on something else, however, in a couple of days, I will have to further investigate why this is happening. I will post a new thread with the results then. So, for now I'd like to close this thread. 

    Regards

    Vinay

  • Hi,

    As mentioned above, I have tested it locally and the callback should be called after all retries are exhausted.

    What is your case again? Do you claim that the callback is not triggered at the end?

    Also, are you using infinite ping (0 in number of packets)? If so, you should stop the ping from application (upon getting disconnect command for example).

    Your workaround is good for now but it is better to get to the root cause and understand.

    Regards,

    Shlomi