DataSocket Transfer Protocol (dstp) Overview


DataSocket Transfer Protocol (dstp) is a convenient mechanism to monitor the most recent values of measurement data distributed over the Internet. This document describes dstp, the components essential to this protocol, and why dstp is such an efficient data-sharing utility.



dstp is an application-layer protocol for transferring measurement data to and from a dstp server called a DataSocket server. dstp is implemented on top of TCP, and hence provides connection-oriented communication between the server and the client. In other words, clients maintain a session during communication with the server. During the session the server keeps track of client-connection information. Clients providing the measurement data to a DataSocket server are referred to as publishers or writers. Clients consuming the measurement data provided by the publishers are referred to as subscribers or readers.



A system participating in a dstp data exchange usually consists of three components – the DataSocket server, a publisher, and subscribers. A publisher acquires data from a local or remote data acquisition device and sends it to the server. The server may be located on the same machine (known as the localhost) or remotely on the Internet. Subscribers who have an interest in the published data can subscribe to receive the data from the server. Complex applications may require more than one publisher or more than one server.


Identifying the Measurement Data on the Server

A Uniform Resource Locator (URL) identifies the location of measurement data on a server. A dstp URL indicates the name of the DataSocket server and the access path for a particular measurement data item. Publishers and subscribers for the measurement data must refer to the data item by the same URL.


The Most-Recent Principle and Buffering Data

As it is implemented now, by default dstp transfers the most recent data on the server to the subscribers of the measurement data. In other words, subscribers are not guaranteed to receive every instance of data that gets published on the server. If the publisher is writing data to the server at a faster rate than the server is sending data to its subscribers, the subscribers might not get previously published data. This might seem to be a shortcoming of dstp; however, the most recent value of the measurement data is usually of the most interest for most measurement applications. The working principle is exactly the same as a digital voltmeter (DVM). The DVM displays the value of the voltage difference between two points at that instant. By transmitting the most recent data, you can use dstp in high-performance measurement applications. However, data loss can minimized or even eliminated by buffering data at the client and/or the server. dstp now offers both client-side and server-side data buffering. Client-side buffering can be configured through URL options, while server-side buffering can be configured through the DataSocket Server Diagnostic dialog box in the server.


Establishing a Session

Typically, users will interact with dstp only by using the DataSocket Application Programming Interface (API) within a National Instruments software application. To establish a connection to a DataSocket Server using the DataSocket API, the user only writes a value to a URL. Behind the scenes, the DataSocket client goes through several steps to establish a dstp connection. (1) To establish a session to the server, the client sends a "request to log on" message to the server. The request also includes the dstp version number for the session. (2) If the server accepts the connection, it sends back a log completion acknowledgement that confirms the dstp version number. (3) The client in turn sends a request to connect to a particular URL on the server. The URLs that represent particular measurement data on the DataSocket server are referred to as DataSocket items. The DataSocket server uses the same TCP connection for all DataSocket items that exist within the same process space.

Figure 1. A client establishes a session with a DataSocket server.

Transferring and Receiving Data


To transfer data to the server, a client sends a message whose header prompts the server to write the data encapsulated in the message as the new value for the data. The message also includes the URL identifying the data on the server. To request data from the server, a client sends a message that requests the most recent value of the data. The message also includes the URL of the requested data from the server. The clients can receive data from the server either via explicit value requests or via a programmatic automatic update connection. The server sends data updates to subscribers programmed to update automatically as soon as the server receives new values from the publisher. In other words, the server multicasts data updates for a particular URL to its subscribers.


Terminating the Session

To terminate a connection, a client sends a request for disconnect to the server.