NI Peer-to-Peer Streaming

Content Type
Programming Language
Current manual

Peer-to-Peer Stream State Model

Peer-to-Peer Stream State Model

The state model for peer-to-peer streams defines the conditions under which the stream can move from one state to another and coordinates the writer, reader, and host.

The peer-to-peer stream has the following states:

  • Unlinked—The writer and reader have no connection to the stream, the host, or each other. You must use an application on the host to transition the stream out of the Unlinked state.
  • Disabled—The writer has the hardware address of the reader and vice versa, but the stream is not prepared to accept data. When the stream is in the Disabled state, no data can flow through the stream.
  • Enabled—The stream is capable of transmitting data from the writer to the reader. While the stream is in the Enabled state, data can flow from the writer to the reader. The host, reader, and writer can enable the stream when the stream is in a Disabled state.
  • Flushing—The writer stops accepting new data and sends all existing data to the reader.

Use the Property Node configured for niP2P Stream to determine the state of the stream during run time.

Blocking and Non-Blocking State Transitions

Transitions between two states can be non-blocking or blocking. Non-blocking transitions, such as the transition from Enabled to Flushing, occur immediately. Blocking transitions, such as from Unlinked to Disabled, halt the application until the reader or writer completes the necessary tasks. For example, when a stream transitions from Unlinked to Disabled, it must wait on the writer or reader to initialize. Non-blocking transitions for the writer and reader occur before the next clock cycle. Blocking transitions might not finish for several clock cycles.

The following table lists the types of transitions, the blocking characteristics of the transition, and the host application VIs that can perform the transition.

TransitionTypeVI
Unlinked to DisabledBlockingniP2P Create Peer to Peer Stream
Disabled to EnabledBlockingniP2P Enable Peer to Peer Stream
Enabled to FlushingNon-BlockingniP2P Flush And Disable Peer to Peer Stream
Flushing to DisabledBlockingniP2P Flush And Disable Peer to Peer Stream
Enabled to DisabledBlockingniP2P Disable Peer to Peer Stream
Disabled to UnlinkedNon-BlockingniP2P Unlink Peer to Peer Stream

States of the Host

The state of the host matches the state of the stream. The host application can monitor all states of the stream and control the transitions between the stream states. When the host application begins, the stream is in an Unlinked state. The host application then transitions the stream into other states using the Peer To Peer Streaming VIs. The following illustration shows the stream states and the transitions that the host can control.

States of the Writer

The state of the writer matches the state of the stream, but the writer cannot control all the transitions between the stream states. When the host links the writer and reader, the writer transitions from the Unlinked state to the Disabled state. When the host disables the stream, the writer transitions to the Disabled state immediately. When the writer or host initiates a flush and disable command, the writer transitions to the Flushing state and then to the Disabled state when the transfer of data in the queue is complete or the command times out, whichever happens first.

You can use the following VIs to disable the stream from the host application:

The following illustration shows the possible states of the writer and the transitions that the writer can control.

States of the Reader

The state of the reader matches the state of the stream, except for the Flushing state. Also, the reader cannot control all the transitions between the stream states. When the host links the writer and reader, the reader transitions from the Unlinked state to the Disabled state. The following illustration shows the possible states of the reader and the transitions that the reader can control.

Was this information helpful?