Clearing of DW Socket Buffer

Please provide the following info (check/uncheck the boxes after creating this topic):
Software Version
DRIVE OS Linux 5.2.6
DRIVE OS Linux 5.2.0
DRIVE OS Linux 5.2.0 and DriveWorks 3.5
NVIDIA DRIVE™ Software 10.0 (Linux)
NVIDIA DRIVE™ Software 9.0 (Linux)
other DRIVE OS version
other

Target Operating System
Linux
QNX
other

Hardware Platform
NVIDIA DRIVE™ AGX Xavier DevKit (E3550)
NVIDIA DRIVE™ AGX Pegasus DevKit (E3550)
other

SDK Manager Version
1.6.1.8175
1.6.0.8170
other

Host Machine Version
native Ubuntu 18.04
other

I am currently working on an application in which a stream of data (image data ~ 740kB each) is being transmitted from one SoC to another (Xavier A to Xavier B) using DriveWorks Socket APIs. The dw_SocketConnection_read and dw_SocketConnection_write calls have been given a specific timeout value (100ms). The client process on receiving the data does some further processing of the data. The server will publish an image at a constant rate (1 image per 80 ms).

On running this application it is observed that the data received by the client is corrupted, i.e the data received is sometimes a combination of 2-3 frames. Also the server while transmitting, after a certain point does not uniformly transmit ~740kB.

Snippet of Server side:
.
.
Bytes written : 737280 -----> expected data size to be transmitted
loop count = 55
Bytes written : 48516
Socket Write:0 Bytes written : 48516
loop count = 56
Bytes written : 720313
Socket Write:0 Bytes written : 720313
loop count = 57
Bytes written : 654830
Socket Write:0 Bytes written : 654830
loop count = 58
Bytes written : 392898
Socket Write:0 Bytes written : 392898
loop count = 59
Bytes written : 0
Socket Write:20 Bytes written : 0
loop count = 60
Bytes written : 737280
loop count = 61
Success count 27
.
.

Snippet of Client side:
.
.
Bytes received : 737280 -----------> expected data size to be received
read_image_status = 0
loop_count = 55
Bytes received : 737280
Socket Write = 0
loop_count = 56
Bytes received : 737280
Socket Write = 0
loop_count = 57
Bytes received : 737280
Socket Write = 0
loop_count = 58
Bytes received : 737280
Socket Write = 0
loop_count = 59
Bytes received : 737280
Socket Write = 0
loop_count = 60
Bytes received : 737280
Socket Write = 0
success
Success image_count = 61
loop_count = 61
Bytes received : 737280
Socket Write = 0
.
.

It seems that the server and client get out of sync. The client always receives expected data size (737280) even if server sends less than that. There is a corruption of data in the “socket buffer”. Is there anyway we can access/modify/clear/dump this “socket buffer” data?
Dropping of certain frames is acceptable as long as the data being transmitted and received is accurate and not corrupted.
Also once the server and client get out of sync, they never get back in sync.
Data corruption is observed only when the rate of transmission by the server is 80ms. When increasing this to 100ms, everything works as expected.

Dear @dhruva.ungrupulithaya,
So, if the used timeout value is greater than 100ms, You don’t see any issue. Could you share reproducible code?

Hi Siva. No increasing the timeout value (for read or write) does not help. By increasing the time duration between 2 successive write calls (any value >= 100ms) only helps.

Hi @dhruva.ungrupulithaya,

Does this issue also with localhost communication? Does calling with DW_TIMEOUT_INFINITE help?

Yes the issue is present for localhost comm also. But yes by keeping Read() call timeout as DW_TIMEOUT_INFINITE, sender always sends the right data size and no data is corrupted.
However, we would not like to keep it as infinite as then the Read() call will become a blocking call. We don’t want a condition where the application is kept in a hold state waiting for Read() to finish. Rather we would prefer if the read is unsuccessful, to just drop that data and ensure the socket buffer is free for the next image (should not promote corruption of data).

In order to this we need to understand the condition of the socket buffer and try to clean/modify it.

Does nonblocking mode help?

The observation is that in the DW internal socket buffer, newly transmitted data gets appended instead of overwriting the internal socket buffer. Because of this we are getting data which is a mixture of 2 transmitted frames. Is there any API that would do this overwriting of this socket buffer or clear the buffer before a new transmit call?

Also by non-blocking mode do you mean by setting a finite TIME_OUT value? Or is there a specific API for non-blocking mode?

Dear @dhruva.ungrupulithaya,
Thank you for update. I will check internally and update you on this. It would be great if you can share a simple reproducible code as I asked earlier to get more insights on the issue

Dear @dhruva.ungrupulithaya,
non-blocking mode means using time_out = 0. I don’t see any issue with APIs. Could you share the reproducible code to investigate the issue further.