EXAMPLES

Throughput

1) Description

The Throughput example allows the measurement of data throughput when receiving samples from a publisher.

2) Design

It consists of 2 units :

3) Scenario

The publisher sends samples and allows you to specify a payload size in bytes as well as allowing you to specify whether to send data in bursts. The publisher will continue to send data forever unless a time out is specified.

Configurable:

The subscriber will receive data and output the total amount received and the data rate in bytes per second. It will also indicate if any samples were received out of order. A maximum number of cycles can be specified and once this has been reached the subscriber will terminate and output totals and averages.

The subscriber executable measures:

Configurable:

Running of examples in Standalone Mode

Running the examples in a Posix environment

Environment Setup

Let's call OpenSplice_install_dir the OpenSplice installation directory.

The OpenSpliceDDS environment variables must be set in order for the examples to build/run correctly. To do this, open a terminal and source the "OpenSplice_install_dir/release.com" script supplied with the distribution.

C, C++ and ISO C++ Executables

Building the examples is described on the Summary page

Two executables and a two libraries are generated in the example directory when the example is built:

For ISO C++

For C++

For C

Running the example

Ensure that the environment for OpenSpliceDDS is set up correctly as described above for each new terminal used. If running the C, C++ or ISO C++ examples, ensure that . is added to the LD_LIBRARY_PATH.

It is recommended that you run the subscriber and publisher in separate terminals to avoid mixing the output

Running in single process (heap memory) configuration : the application starts OpenSpliceDDS middleware

Running in multiple process shared memory configuration

To enable deployment in this mode, an OpenSpliceDDS configuration file must be selected that has shared memory support e.g. one of the ospl_shmem xml configuration files found in the OpenSplice_install_dir/etc/config directory.

Starting the publisher and subscriber

In the first terminal start the publisher by running the publisher.exe executable

    publisher usage (parameters must be supplied in order):
      ./publisher [payloadSize (bytes)] [burstInterval (ms)] [burstSize (samples)] [timeOut (seconds)] [partitionName]
    defaults:
      ./publisher 8192 0 1 0 "Throughput example"
    

In the second terminal start the subscriber by the subscriber.exe executable

    subscriber usage:
      ./subscriber [maxCycles (0 = infinite)] [pollingDelay (ms, 0 = event based)] [partitionName]
    defaults:
      ./subscriber 0 0 "Throughput example"
    

To achieve optimal performance it is recommended to set the CPU affinity so that the publisher and subscriber run on separate CPU cores. You must have su privileges to run the following commands.

    publisher usage:
      taskset -c 0 chrt -f 80 ./publisher [payloadSize (bytes)] [burstInterval (ms)] [burstSize (samples)] [timeOut (seconds)] [partitionName]
    subscriber usage:
      taskset -c 1 chrt -f 80 ./subscriber [maxCycles (0 = infinite)] [pollingDelay (ms, 0 = event based)] [partitionName]
    

Running C/C++/ISO C++ on Windows

Environment Setup

Let's call OpenSplice_install_dir the OpenSplice installation directory.

The OpenSpliceDDS environment variables must be set in order for the examples to run correctly. To do this open an OpenSpliceDDS Command Prompt which will set up the environment variables for OpenSpliceDDS automatically. The OpenSpliceDDS Command Prompt can be selected from the start menu. Alternatively, open a windows Command Prompt and execute the "OpenSplice_install_dir\release.bat" batch script supplied with the distribution.

C/C++/ISO C++

Building the examples is described on the Summary page

Two executables are generated in the example directory when the example is built:

For C, C++ and C#

Running the C/C++/ISO C++ Examples

Ensure that the environment for OpenSpliceDDS is set up correctly as described above for each new command prompt used.

The following steps describe how to run the examples:

Running in single process (heap memory) configuration : the application starts OpenSpliceDDS middleware

Running in multiple process shared memory configuration

To enable deployment in this mode, an OpenSpliceDDS configuration file must be selected that has shared memory support e.g. one of the ospl_shmem xml configuration files found in the OpenSplice_install_dir\etc\config directory.

Starting the publisher and subscriber

In the first terminal start the publisher by running the publisher.exe executable

    publisher usage (parameters must be supplied in order):
      ./publisher [payloadSize (bytes)] [burstInterval (ms)] [burstSize (samples)] [timeOut (seconds)] [partitionName]
    defaults:
      ./publisher 8192 0 1 0 "Throughput example"
    

In the second terminal start the subscriber by the subscriber.exe executable

    subscriber usage:
      ./subscriber [maxCycles (0 = infinite)] [pollingDelay (ms, 0 = event based)] [partitionName]
    defaults:
      ./subscriber 0 0 "Throughput example"
    

To achieve optimal performance it is recommended to set the CPU affinity so that the publisher and subscriber run on separate CPU cores

    publisher usage:
      START /affinity 1 /high cmd /k "publisher.exe" [payloadSize (bytes)] [burstInterval (ms)] [burstSize (samples)] [timeOut (seconds)] [partitionName]
    subscriber usage:
      START /affinity 2 /high cmd /k "subscriber.exe" [maxCycles (0 = infinite)] [pollingDelay (ms, 0 = event based)] [partitionName]