cyclonedds/examples/throughput
Erik Boasson c1f3ad8a22 Eliminate domain-specific global variables
This commit moves all but a handful of the global variables into the
domain object, in particular including the DDSI configuration, globals
and all transport internal state.

The goal of this commit is not to produce the nicest code possible, but
to get a working version that can support multiple simultaneous domains.
Various choices are driven by this desire and it is expected that some
of the changes will have to be undone.  (E.g., passing the DDSI globals
into address set operations and locator printing because there is no
other way to figure out what transport to use for a given locator;
storing the transport pointer inside the locator would solve that.)

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-08-21 14:16:51 +02:00
..
CMakeLists.export Generate documentation using the FindSphinx.cmake module 2019-07-31 20:12:11 +02:00
CMakeLists.txt Generate documentation using the FindSphinx.cmake module 2019-07-31 20:12:11 +02:00
publisher.c Eliminate domain-specific global variables 2019-08-21 14:16:51 +02:00
readme.rst Reorganize repository 2019-07-30 10:52:44 +02:00
subscriber.c Reorganize repository 2019-07-30 10:52:44 +02:00
Throughput.idl Reorganize repository 2019-07-30 10:52:44 +02:00

..
   Copyright(c) 2006 to 2018 ADLINK Technology Limited and others

   This program and the accompanying materials are made available under the
   terms of the Eclipse Public License v. 2.0 which is available at
   http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
   v. 1.0 which is available at
   http://www.eclipse.org/org/documents/edl-v10.php.

   SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

Throughput
==========

Description
***********

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


Design
******

It consists of 2 units:

- Publisher: sends samples at a specified size and rate.
- Subscriber: Receives samples and outputs statistics about throughput

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:

- payloadSize: the size of the payload in bytes
- burstInterval: the time interval between each burst in ms
- burstSize: the number of samples to send each burst
- timeOut: the number of seconds the publisher should run for (0=infinite)
- partitionName: the name of the partition

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:

- transferred: the total amount of data transferred in bytes.
- outOfOrder: the number of samples that were received out of order.
- transfer rate: the data transfer rate in bytes per second.
- subscriber also calculates statistics on these values over a configurable number of cycles.

Configurable:

- maxCycles: the number of times to output statistics before terminating
- pollingDelay
- partitionName: the name of the partition


Running the example
*******************

It is recommended that you run ping and pong in separate terminals to avoid mixing the output.

- Open 2 terminals.
- In the first terminal start Publisher by running publisher

  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 Ping by running subscriber

  subscriber usage (parameters must be supplied in order):
    ``./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 ping and pong run on separate CPU cores,
  and use real-time scheduling. In a Linux environment this can be achieved as follows:

  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]``

  On Windows the CPU affinity and prioritized scheduling class can be set as follows:

  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]``