Network Variables

A network variable is a variable that you can use to share data between applications running on the same or different computers. Network variables use the NI Publish-Subscribe Protocol (NI-PSP) data transfer protocol to write and allow users to read live data. NI-PSP is a proprietary technology that provides fast and reliable data transmission for large and small applications.

Reference a network variable using its pathname. The pathname is similar to network file share names, such as \\machine\myprocess\item on Windows. In this example, machine is the computer name, IP address, or Fully Qualified Domain name of the server machine that is hosting the variable; myprocess contains network variable folders or variables and is referred to as a network variable process; and item is the name of the network variable. Following are additional examples:

  • \\localhost\my_process\my_variable
  • \\test_machine\my_process\my_folder1\my_folder2\my_variable
  • \\\my_process\my_variable
  • \\\my_process\my_variable
  • \\localhost\System\DAQmx\Server Polling Rate
  • \\localhost\system\my_variable

You must open TCP ports in addition to UDP ports to configure firewalls and Network Address Translating (NAT) routers to transmit network variables. Starting at TCP port 59110, open one TCP port for each application you run. By default, NI-PSP begins looking for available TCP ports at port 59110 and increments upward until it finds an available port for each running application. You manually can configure the range of TCP ports that NI-PSP uses by creating and editing a logosxt.ini file. For RT targets, you can configure the range of TCP ports in the ni-rt.ini configuration file.

Creating Network Variables

You can create network variables either explicitly or implicitly.

Explicitly Created Variables

You can create and configure network variables explicitly with the stand-alone NI Distributed System Manager or programmatically using Network Variable Library functions.

Using the NI Distributed System Manager

Select Start»All Programs»National Instruments»Distributed System Manager to access this application, which is included in the LabWindows/CVI installation. Use this application to create new processes and variables, delete existing processes and variables, start and stop processes, create variables with specific data types or the variant data type, allow multiple writers or restrict write access to a single client, configure server buffering, and so on. For more information, refer to the NI Distributed System Manager Help, which you can access from the Distributed System Manager.

Note Note
  • Although you cannot run the Distributed System Manager on an RT target, you can host network variables you create and configure with the Distributed System Manager on an RT target.
  • You cannot export network variables you create using the Distributed System Manager to other computers.

Using Network Variable Library Functions

Use the Configuration Functions in the Network Variable Library to programmatically create and configure network variables explicitly. You can create a single variable with the CNVNewVariable function or create a number of variables with the CNVNewVariableCollection function. You also can create, delete, start, and stop network variable processes using the Process Functions. Use the Folder Functions to create and delete folders programmatically. Explicit variables that you create programmatically do not have a concrete data type by default and can hold values of any type. If you want to specify the data type for a network variable, call the CNVSetVariableAttribute function and set the CNVVariablePrototypeAttribute attribute. Explicit variables continue to exist after the program terminates.

Although you can programmatically configure network variables, you must use the Distributed System Manager to configure security settings.

Note Note  When you create variables programmatically, you specify server buffer capacity as number of items. If you use the Distributed System Manager, you must specify server buffer capacity in bytes for certain data types. If you create a network variable programmatically and then want to configure the variable using the Distributed System Manager, the Distributed System Manager may change the buffer size to bytes.

Implicitly Created Variables

You can implicitly create network variables in the system process: a new variable is created automatically when you connect to it, if the process name is system and the variable name you specify does not already exist in the system process. For example, \\localhost\system\test would implicitly create a variable called test in the system process on your local computer. If the variable already exists, then your program connects to the existing variable and does not create a new variable. An implicitly created variable is automatically deleted by the server when all of its clients have disconnected. Implicit variables have no concrete data type and can hold values of any type. They always have the single-writer restriction and their values are not buffered on the server, but their values can be buffered on the client. Implicit variables are easier to deploy because they are automatically created and deleted.


Not Helpful