Do LabVIEW TCP Functions Use the Nagle Algorithm?

Updated Nov 4, 2021

Reported In

Software

  • LabVIEW

Issue Details

I am using TCP communication to send many small packets between pieces of hardware on my system, but I am seeing some latency in communication. I am aware Windows and many other operating systems use the Nagle algorithm to increase the efficiency of network traffic. Do the LabVIEW TCP functions use the Nagle algorithm?

Solution

Yes. By default, LabVIEW uses the Nagle algorithm when doing TCP communication. See the Additional Information section below for how to turn off the Nagle algorithm.

Additional Information

The Nagle algorithm is one of the basic algorithms of TCP that helps reduce Internet traffic by combining several small packets into a single large one. While this increases the efficiency of sending large messages such as those commonly sent in normal Internet traffic, the algorithm can introduce some latency for situations where small amounts of information are being sent back and forth, such as in instrument handshaking.

Attached is an example that contains the following VIs in LabVIEW 2012 format that turn off the Nagle algorithm for different targets:
  • TCP_NoDelay.vi: Allows you to turn the Nagle algorithm off for a specific TCP connection.
  • NagleDemo-MessageSender.vi: Sends two quick, 4-byte messages to NagleDemo-MessageReflector.vi. These two VIs in combinations can demonstrate the timing differences between using the Nagle algorithm and not using it.
  • NagleDemo-MessageReflector.vi: Reads 8-bytes from NagleDemo-MessageSender.vi and replies back. These two VIs in combinations can demonstrate the timing differences between using the Nagle algorithm and not using it.
  • TCP Get Raw Net Object.vi: Gets the raw socket used for TCP communications from the operating system so that properties can be set on it.

NOTE: These VIs were built specifically for Windows, Phar Lap ETS, VxWorks, and Linux RT. With a little modification, they can also be used on other operating systems. Refer to the block diagrams for more information.

Attachments