« Close

Datasheets and User Guides

Software & Driver

 

LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE

Summary

Requires LJM 1.2000 or later

Sets the TCP receive buffer size for LJM's stream data collection. This can reduce the frequency of auto-recovery. Behavior varies by platform.

For a background on the receive buffer, see LJM_GetStreamTCPReceiveBufferStatus.

Writing 0 to LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE will use the OS default receive buffer size, which probably includes auto-tuning. This is appropriate for most use cases. The default LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE is 0.

Writing a non-zero value to LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE will manually set the receive buffer size. Internally, setsockopt is called with SO_RCVBUF as the option parameter.

Since behavior for setting the receive buffer size varies by platform, you should try out different values of LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE until you find the maximum. For example, you should start with a small value like 65535 (which doesn't require window scaling) and exponentially increase it until an error occurs. Your test program should set LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE, then start stream and call LJM_GetStreamTCPReceiveBufferStatus, ensuring that the ReceiveBufferBytesSize is equivalent to your intended stream receive buffer size.

You may also wish to use Wireshark to capture packets to see what the maximum window size your host computer reports the window size to be. To do so, you can start a new capture with a filter like ip.addr == 192.168.1.207, where 192.168.1.207 is your LabJack's IP address, then find the first packet addressed to 192.168.1.207 with port 702. The window size and window scaling of that packet determines the window size as reported to the LabJack device.

Here are some known platform differences:

  • A Windows 10 computer was shown to be able to increase the receive buffer size until about 2147483647, which is the maximum number that Windows' recv function can take as the len parameter (due to the len parameter being a signed 32-bit integer). After this point, LJM will return LJME_NEGATIVE_RECEIVE_BUFFER_SIZE (errorcode 1321).
  • A macOS computer was shown to be able to increase the receive buffer size until about 7400000, when LJM_eStreamStart returns LJME_SOCKET_LEVEL_ERROR. If you need to increase the receive buffer size more, see Mac OS X TCP Performance Tuning.
  • Linux may accept any receive buffer size and silently reduce it to adhere to system configurations.

The constant LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE can be used interchangeably with the string "LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE".

Remarks

LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE does not affect currently running or already initialized streams.

Relevant Functions

To read LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE, use LJM_ReadLibraryConfigS.

To write LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE, use LJM_WriteLibraryConfigS orLJM_LoadConfigurationFile.

LJM_STREAM_TCP_RECEIVE_BUFFER_SIZE affects the behavior of LJM_eStreamStart.

For more LJM configurations, see Library Configuration Functions.