Uni-Directional Network Watchdog Reference Example

Publish Date: May 06, 2010 | 7 Ratings | 3.43 out of 5 | Print | 2 Customer Reviews | Submit your review


This example presents a very simple uni-directional network watchdog, also known as a network heartbeat.

Table of Contents

  1. Overview
  2. References


  1. Download the reference example.
  2. Unzip the file to a working directory.
  3. Open the Network Watchdog Listener.vi and copy the contents in parallel with the system that needs notification of a network failure.
  4. Open the Network Watchdog Sender.vi and copy the contents in parallel with the system communicating with the listener.
  5. Refer to this document and comments in the code for additional or optional changes.

1. Overview

Many systems require a reliable network connection to perform correctly.  In some cases, particularly for control systems, the system must respond to a lost network connection by stopping operation or entering a safe state.  This code provides a simple light-weight mechanism for quickly identifying a lost network connection.

A network watchdog, also known as a network heartbeat, periodically sends a message across the network to verify that the network is available and that both sides are still functioning.  A uni-directional watchdog has one system which waits for the heartbeat messages and responds in the event of a lost network connection, hereafter referred to as the Listener. The Listener is typically a control system, such as a Real-Time CompactRIO, FieldPoint or PXI system.  A second system sends the heartbeat messages, hereafter referred to as the Sender.  The Sender is often a user-interface or SCADA system, often implemented on a PC or industrial display.  Only the Listener is notified when the network connection is lost.


This network watchdog is implemented using UDP communication.  In comparison to TCP, UDP is simple, lightweight, and does not require connection management or reestablishment.  This example provides two VIs, each containing a loop which can be placed in parallel with other code.  


The Sender transmits a UDP message to the address specified by IP Address, at the port specified by Listener Port and at an interval specified by the Heartbeat Period.  You can use the Net Address to select a network for systems which have multiple network connections.


The Listener receives the messages, and increments a counter if a message is not received within a time period specified by Heartbeat Period.  If the counter exceeds a value specified by Heartbeat Timeout, or if it detects an error in communication, the Listener loop indicates a lost network connection which other elements of the Listener system can respond to.


The following are suggestions for incorporating the network watchdog into your system.

Communicating a Lost Connection

When the Listener identifies a lost network connection, the example code merely toggles a front-panel LED.  This is most likely an insufficient response, especially for Real-Time systems which do not typically expose the front-panel to the user.  You should respond to the Dead Connection data item either by directly modifying the listener loop, or by transmitting the information to another loop for response.  The transmission may be performed using any cross-loop communication mechanism such as a variable, queue, or RT FIFO.

Common responses to a lost connection include buffering streamed data, placing a user controlled task on "autopilot" via control algorithms, and/or placing control outputs in a safe-state.


Both the Sender and Listener use a stop button to signify program completion.  Your system most likely already has a shutdown mechanism either triggered by a different button, or in response to system conditions.  Replace the stop buttons with a communication mechanism to notify the network watchdog loops of a system shutdown.  Functional Global Variables or Queue messages are popular implementations for a shutdown mechanism.

The following example shows what the Listener loop might look like when implemented in a system that communicates using Global Variables.

Back to Top

2. References

This architecture is most effective when used in conjunction with a safe-state design on the listener.  CompactRIO users should consider utilizing the following design:

Fail-Safe Control Reference Design for CompactRIO

Back to Top

Customer Reviews
2 Reviews | Submit your review

  - Mar 25, 2013

Currently have 8.2 version. Cannot process.

  - Apr 2, 2010

could you please post this example for Labview 8.5

Bookmark & Share






Rate this document

Answered Your Question?
Yes No