Example Code

Reassembling Out-of-Sequence UDP Packets in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This code allows the user to Reassemble UDP Packets that could arrive our of sequence in scenarios with long distance.

 

Description

In some network transmission scenarios packets sent across a long distance may arrive out of sequence at the receiver. This example provides one solution for reassembling such packets and returning them to the application in sequence.

 

For this example packets are sent over UDP. To be able to reassemble packets each packets contains a running counter value and the packets contents. The packet contents is a scalar double value which when reassembled represents a sine wave.

 

The core of the example is a Buffer and Reassemble subVI. This VI receives all incoming packets, buffers them in a circular data buffer and checks for contiguous blocks of data, which when available, are returned to the calling application.

 

In parallel to the data buffer, a Boolean buffer is used to mark and track valid data in the data buffer. Valid data are any elements received and buffered, but not yet returned to the application. Using this Boolean array the subVI can detect when a contiguous block of data is available for processing.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run UDP Receiver.vi
  2. Run UDP Sender.vi
    *This VI is a UDP Sender.vi subVI

Additional Information or References

11512.png

**This document has been updated to meet the current required format for the NI Code Exchange.** 

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.