NI-XNET API for LabVIEW and C

XNET Write (Frame Ethernet).vi

  • Updated2023-11-11
  • 5 minute(s) read
 XNET Write (Frame Ethernet).vi

XNET Write (Frame Ethernet).vi

Purpose

Writes data to a session as an array of Ethernet frames. The session must use an Ethernet interface and a mode of Frame Output Stream.

Format

Inputs

session in is the session to write. This session is selected from the LabVIEW project or returned from the XNET Create Session VI. The session mode must be Frame Output Stream.
data provides an array of LabVIEW clusters.

Each array element corresponds to a frame value to transmit. The elements of each cluster are specific to the Ethernet protocol.

The data you write is queued up for transmit on the network. Using the default queue configuration for this mode, you can safely write 64 frames if you have a sufficiently long timeout. To write more data, refer to the XNET Session Number of Values Unused property to determine the actual amount of queue space available for write.

type is the type of Ethernet frame. It is a ring (enumerated list) with the following values:
EnumerationValueDescription
Ethernet Data0Ethernet frame received or transmitted.
Delay Frame225Hardware delays for the specified time. Special frame type described in Special Frames.
Future Time Wait226Hardware waits until the absolute time associated with this frame occurs before processing subsequent frames. Special frame type described in Special Frames.
local timestamp is a timestamp using XNET local time. The timestamp uses the LabVIEW absolute timestamp type.
network timestamp is a timestamp using network time (clock of the network's time synchronization protocol, such as IEEE Std 802.1AS). The timestamp uses the LabVIEW absolute timestamp type.
network synced? is not used for XNET Write (Frame Ethernet). Refer to XNET Read (Frame Ethernet).
receive? is not used for XNET Write (Frame Ethernet). Refer to XNET Read (Frame Ethernet).
transmit? is not used for XNET Write (Frame Ethernet). Refer to XNET Read (Frame Ethernet).
error? is not used for XNET Write (Frame Ethernet). Refer to XNET Read (Frame Ethernet).
frame data is an array of bytes that provides the data of the Ethernet frame.

Using the terminology from IEEE Std 802.3, the frame data begins with the first byte of the destination MAC address, and ends with the last byte of the mac_service_data_unit (MSDU). For examples of two commonly used formats for frame data, refer to the Raw Frame Format.

In order to obtain the payload data that is contained in the frame, your code must decode the layered headers in frame data. For example, for an IPv4 UDP packet, you decode the Ethernet header, including the EtherType, to determine that the remaining data is an IPv4 packet; then you decode the IPv4 header, including the Protocol, to determine that the remaining data is a UDP packet; and then you decode the UDP header and its payload data.

The Source MAC Address Auto property specifies automatic handling of the source MAC address in frame data (i.e., offset 6 through 11). If Source Address MAC Auto is true (default), XNET automatically replaces the source MAC address bytes with its own MAC Address. If Source Address MAC Auto is false, XNET does not alter the source MAC address, so that you can specify this address in frame data.

The maximum length of this array is provided in the Payload Length Maximum property.

fcs is not used for XNET Write (Frame Ethernet). Refer to XNET Read (Frame Ethernet).
timeout is the time to wait for the Ethernet frame data to be queued up for transmit.

The timeout is a LabVIEW relative time, represented as 64-bit floating-point in units of seconds.

If timeout is positive, the XNET Write (Frame Ethernet) VI waits up to that timeout for space to become available in queues. If the space is not available prior to the timeout, a timeout error is returned.

If timeout is negative, the XNET Write (Frame Ethernet) VI waits indefinitely for space to become available in queues.

If timeout is 0, the XNET Write (Frame Ethernet) VI does not wait and immediately returns with a timeout error if all data cannot be queued. Regardless of the timeout used, if a timeout error occurs, none of the data is queued, so you can attempt to call the XNET Write (Frame Ethernet) VI again at a later time with the same data.

This input is optional. The default value is 10.0 (10 seconds).

error in is the error cluster input (refer to Error Handling).

Outputs

session out is the same as session in, provided for use with subsequent VIs.
error out is the error cluster output (refer to Error Handling).

Description

The data represents an array of Ethernet frames. Each Ethernet frame uses a LabVIEW cluster with Ethernet-specific elements.

NoteNote  When the Frame Output Stream session is in in Replay Exclusive or Replay Inclusive mode (see Interface:Output Stream Timing), hardware will evaluate the timestamp for each frame and output the frame at the right time, in accordance with the policy described in Handling Timestamps. The Interface:Ethernet:Output Stream Timescale property configures which timestamp parameter is used.

Log in to get a better experience