Answered by:
Wince 6 socket latency

Question
-
Hello,
Data streaming over Wi-Fi and Ethernet socket has latency under WinCE 6 R3 and needs help to resolve this issue.
In one of our real-time medical applicaiton, we are required to transmit 25 to 200 bytes at every 100ms on a TCP/IP socket. It was also found that even if the data is transferred at 100ms from the device end (TI AM37/Wince 6 R3) to the PC, the data is received in every 200ms at the PC end. The code runs fine in TI OM35 with Windows embedded compact 7 platform.
Based on the artilce http://www.stuartcheshire.org/papers/NagleDelayedAck/, we learned that the issue could be due to the Delayed ACK and even disabled the Nagle’s Algorithm through the code fragment given below.
iTcpNoDelay = setsockopt(m_socWinSocket,IPPROTO_TCP, TCP_NODELAY,(char *) &iOptVal, iOptLen);
This code works fine under WEC 7, but does not work under Wince 6 R3 :-(
Thanks in advance for any help.
Thanks & regards,
Kumar
Monday, May 21, 2012 6:41 AM
Answers
-
This issue is resolved when Nagle Algorithm is disabled on client connected socket. Disabling Nagle algorithm on listener socket is not required.
Thanks,
Kumar
Kumar
- Marked as answer by SaravanakumarS Wednesday, July 11, 2012 5:50 AM
Wednesday, July 11, 2012 5:50 AM
All replies
-
The Nagle algorithm is not disabled or the call to setsockopt() returns an error? You need to give us enough information to duplicate your problem and potentially suggest a solution. The probability of finding someone who just happens to have exactly the same requirement as you is pretty low.
In general, if you have packet timing requirements, looking at just the two WinSock ends of the connection is useless. Socket programming's entire goal is to abstract the low-level operations and provide an abstract "pipe" concept. You need to connect a network sniffer, potentially one at each end of the connection, and evaluate the timing of packet send/receive/acknowledge. That will direct your further efforts to optimize the timing.
Paul T.
Tuesday, May 29, 2012 3:14 PM -
Dear Paul,
Thanks for your kind reply. As suggested by you we are collecting additional information to support the issue and get back to you.
Thanks again,
Kumar
Kumar
Monday, June 4, 2012 7:11 AM -
Dear Paul,
With reference to your suggestion, we have added the following code to verify the status of the return and found it return '0' indicating sucess. Therefore it confirms that the nagale algorithm is disabled.
int iTcpNoDelay = 0;<o:p></o:p>
int cOptVal = 1;<o:p></o:p>
int iOptLen = sizeof(int);<o:p></o:p>
iTcpNoDelay = setsockopt(m_socWinSocket,IPPROTO_TCP, TCP_NODELAY,(char*) &cOptVal, iOptLen);<o:p></o:p>
if(!iTcpNoDelay)<o:p></o:p>
{<o:p></o:p>
PMS_LOG(CNS_MODULE_INFO, (L"\nNAGALE ALGORITHM DISABLED\n"));<o:p></o:p>
}<o:p></o:p>
else<o:p></o:p>
{<o:p></o:p>
PMS_LOG(CNS_MODULE_ERROR, (L"\nNAGALE ALGORITHM DISABLING FAILED\n"));<o:p></o:p>
}<o:p></o:p>
Please let us know if we need to do any more to resolve this issue.
Looking forward, thanks,
Kumar
Tuesday, June 5, 2012 10:43 AM -
Kumar,
I'm mystified. Can you confirm that the Nagle algorithm is actually still in operation (by sending bytes) in a pattern that should result in different packets depending on its existence? Your next step is Microsoft, I'm afraid.
Paul T.
Tuesday, July 10, 2012 2:49 AM -
SOCKET clientSocket; clientSocket = accept(serverSocket, NULL, NULL); //by default Nagle algorithm is enabled in newly created socket in WinCE6. //To disable the Nagle algorithm setsockopt(clientSocket,IPPROTO_TCP, TCP_NODELAY,(char*) &cOptVal, iOptLen);
I think Nagle alogrithm is disabled in Listener socket (ie. i think m_socWinSocket is server socket.) or server socket. So try to disable Nagle alogrithm on the client socket which is created by accept function.
Tuesday, July 10, 2012 6:52 AM -
Nagle affects both ends of the connection. It describes how, rather than a large number of small packets, data can be aggregated into a smaller number of larger packets, improving TCP efficiency. If you want both ends of a connection to use or not use Nagle, sockets on both ends have to change.
Paul T.
Tuesday, July 10, 2012 3:38 PM -
This issue is resolved when Nagle Algorithm is disabled on client connected socket. Disabling Nagle algorithm on listener socket is not required.
Thanks,
Kumar
Kumar
- Marked as answer by SaravanakumarS Wednesday, July 11, 2012 5:50 AM
Wednesday, July 11, 2012 5:50 AM -
Another post has the same problem with WinCE 6 and not being able to disable the Nagle algorithm. The OP here was able to turn off the algo on the client side and that was enough. This other post has the problem where two-way communications are needed, and WinCE 6 is not honoring the disable. WinCE 7 does honor it.
WINCE 6 not honoring setsockopt to disable Nagle algorithm (TCP_NODELAY)
Wednesday, October 2, 2019 7:49 PM