Generating NI-XNET IP Stack JSON Configuration
- Updated2025-04-14
- 3 minute(s) read
Programming TCP or UDP communication with the NI-XNET IP stack first requires you to generate a JSON configuration string. This JSON configuration defines the IP stack that you create with the NI-XNET IP stack API and is how you implement, for example, the type of addressing you use in your application (static or DHCP).
The JSON that NI-XNET requires is governed by a schema that installs with the driver. The default installation location for this schema is %Public\Documents\National Instruments\NI-XNET\Documentation\xnetIpStackSchema-n.json, where n is a version number. Refer to this schema to understand the following:
- The information that your program needs to provide
- The name the information should have to create a valid JSON string
This procedure describes how to implement addressing in the configuration file: either static addressing, using IPv4 or IPv6 addresses, or DHCP using IPv4 addresses.
Complete the following steps to create a JSON configuration for the NI-XNET IP stack:
-
Form an array of VLAN configurations:
- name: Use an empty string "" for IP stacks that have a single VLAN.
- isTagged: Identify whether the VLAN has a tag.
- id: Include the VLAN ID only if the VLAN has a tag.
-
IPv4.mode: Set depending on your addressing
scheme.
- Static addressing: If a user specifies an address, set to enabled; if a user does not specify an address, set to disabled.
- DHCP: For the server, set to static; for clients, set to dhcp.
-
IPv4.staticAddresses: Set depending on your addressing
scheme.
- Static addressing: Allow a user to input IPv4 addresses.
- DHCP: For the server, form this field from a static IPv4 address for the server, an IPv4 subnetMask, and a dhcpServer configuration; for clients, accept the IPv4 addresses that the server generates.
-
IPv6.mode: Set depending on your addressing
scheme.
- Static addressing: If a user specifies an address, set to enabled; if a user does not specify an address, set to disabled.
- DHCP: Set to disabled.
- (Static addressing only) IPv6.staticAddresses: Allow a user to input IPv6 addresses.
- (Static addressing only) staticArpTable: Allow a user to input a static ARP/NDP table.
-
Form an array of MAC configuration clusters/structs:
- address: Set a value of generated to have NI-XNET generate local MAC addresses.
- VLANs: Pass in the array of VLAN configurations you created in step 1.
-
Form an array of XNET interface (physical interface) clusters/structs:
- name: Pass in the name of the interface, for example, ENET1.
- MACs: Pass in the array of MAC configurations you created in step 2.
-
Form a stack configuration cluster/struct:
- schema: Pass in the latest version of the schema installed on your system.
- xnetInterfaces: Pass in the array of XNET interfaces you created in step 3.
- Create a single string out of the configuration with Flatten to JSON; set enable LabVIEW extensions? to False so the configuration can support non-LabVIEW code.
LabVIEW Programming Examples for Configuring the NI-XNET IP Stack
For an example of creating this configuration for TCP or UDP communication with basic static addressing, refer to the XNET Example IP Stack Config - Single Interface.vi in the NI-XNET IP Stack Simple TCP.lvproj or NI-XNET IP Stack Simple UDP.lvproj examples.
For an example of creating this configuration to implement DHCP, refer to XNET Example IP Stack Config - DHCP Config.vi in the NI-XNET IP Stack Simple DHCP.lvproj example.
Now that you have generated the JSON configuration string for the IP stack, continue with establishing communication using either TCP or UDP.
Related Information
- Setting up TCP Communication with the NI-XNET IP Stack
You can use the NI-XNET IP stack to establish connection-oriented communication with TCP.
- Setting up UDP Communication with the NI-XNET IP Stack
You can use the NI-XNET IP stack to establish message-oriented communication with UDP.
- Automotive Ethernet Socket API
The automotive Ethernet socket API enables you to create BSD-like network sockets for TCP communication and UDP communication. This implementation is independent of the limitations of the IP stack native to your operating system.
- NI-XNET IP Stack Supported Protocols
Understand the versions of the Internet protocol and which communication protocols you can use with the NI-XNET IP stack.
- Choosing Between TCP and UDP for the NI-XNET IP Stack
The NI-XNET IP stack supports communication with TCP (Transmission Control Protocol) and UDP (Universal Datagram Protocol). Each protocol is best suited for different situations, though TCP is suitable for most applications.