UDP Communication in LabVIEW

Publish Date: Nov 20, 2018 | 33 Ratings | 3.39 out of 5 | Print | Submit your review

User Datagram Protocol, or UDP, provides a means for communicating short packets of data to one or more recipients. Unlike TCP, UDP does not guarantee the safe arrival of data to the destination. Furthermore, data sent in multiple packets may not arrive at the destination in the order they were sent. Therefore UDP should be used to send short, non-critical messages to one or more destinations. The size limit of each packet is approximately 65K. For esoteric information of UDP, see RFC768. For practical, LabVIEW related information, read on....

Because UDP does not have much in the way of communication control, no explicit connection to the other side of communcation is necessary in order to send or receive data. A client must simply listen on a specified UDP port, and any data broadcast to that port of that client is received. In the example below, any data received is printed on a string indicator, along with the source address and port. If the UDP read timesout (after 250 ms) the error is ignored, nothing is printed to the indicator, and the loop returns to the beginning and listens for data on the UDP port again. Note that the UDP connection must be opened and closed with the corresponding UDP functions.

The server is even simpler, as no waiting is required. The server simply opens the desired UDP port, sends the data, and then closes it. (The person using the program then hopes that the data actually gets to its destination!)

Most routers recognize an IP address with all bits in a byte set to 1 (the bytes value would therefore be 255) as a "send to all" address for that range. Therefore, sending a datagram to would send a datagram to all addresses on the net 36 (all addresses of the form 36.<anything>. The address will send the packet to all addresses of the form 36.122.32.<anything> Theoretically, would send the datagram to all addresses on the internet, however in practice, all subnets prevent datagrams from being broadcast to address outside of their own, so that would send the data to all addresses on the subnet. This can be used to the advantage of the programmer if one desires to send data to anyone who's listening.

Related Links:
RFC768 -- User Datagram Protocol (UDP)

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No