OpenSplice examples - PingPong

# EXAMPLES

- Summary
- PingPong
- Tutorial
- HelloWorld
- WaitSet
- Listener
- ContentFilteredTopic
- QueryCondition
- Lifecycle
- Ownership
- BuiltInTopics
- NetworkPartitions
- RoundTrip
- Throughput

## PingPong

- Running of examples in Standalone Mode
- Running of examples in CORBA Cohabitation Mode

### 1) Description

The PingPong example allows the measurement of roundtrip duration when sending and receiving back a single message.

### 2) Design

It consists of 2 units :

- pong : Waits for messages from ping and sends the same message back
- ping : Sends a message to pong and waits for it's return

### 3) Scenario

A message is sent by the ping executable on the "PING" partition, which the pong executable is waiting for. The pong executable sends the same message back on the "PONG" partition, which the ping executable is waiting for. This sequence is repeated a configurable number of times.

The ping executable measures:

- write_access-time: time the write() method took.
- read_access-time: time the take() method took.
- round_trip-time: time between the call to the write() method and the return of the take() method.
- ping also calculates min/max/average statistics on these values over configurable data blocks.

Configurable:

- blocks: number of roundtrips in each statistics calculation
- nof_cycles: how many times such a statistics calculation is run
- topic_id: for the topic, there's a choice between several preconfigured topics.
- write_partition: the partition for writing.
- read_partition: the partition that all samples are read from.

topic_id allows selection of topic used for the test, among those defined by pragma keylist in pinpong.idl, and may be one of :

- 'm' (PP_min_msg)
- 'q' (PP_seq_msg)
- 's' (PP_string_msg)
- 'f' (PP_fixed_msg)
- 'a' (PP_array_msg)
- 't' (PP_quit_msg)
- 'b' (PP_bounded_seq_msg) is also available when running the C++ version of PingPong on posix platforms

PING and PONG partition: this enables to use several PING-PONG pairs simultaneous with them interfering with each other. It also enables creating larger loops, by chaining several PONG tests to one PING test.

## Running of examples in Standalone Mode

- Running examples in Posix
- Running examples in Visual Studio

### Running the examples in a Posix environment

#### Environment Setup

Let's call OpenSplice_install_dir the OpenSplice installation directory.

The OpenSplice 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++ Examples
- Java examples

#### C and C++ Executables

Building the examples is described on the Summary page

Two executables and a library are generated in the standalone directory when the example is built:

For C++

- ping
- pong
- libsacpp_pingpong_types.so

For C

- ping
- pong
- libsac_pingpong_types.so

#### Java executables

Building the examples is described on the Summary page

Three jars are generated in the java/standalone directory when the example is built:

For Java

- saj_pingpong_ping.jar
- saj_pingpong_pong.jar
- saj_pingpong_types.jar

For Java5

- saj5_pingpong_ping.jar
- saj5_pingpong_pong.jar
- saj5_pingpong_types.jar

#### Running the example

Ensure that the environment for OpenSplice is set up correctly as described above for each new terminal used.

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 OpenSplice middleware

- OpenSplice is deployed in this mode by default.
- The OpenSplice daemon should not be started manually. Instead the OpenSplice middleware and optional services are implicitly started by the single process applications as required
- Open 2 terminals. Set up the environment and go to the example directory as described above

Running in multiple process shared memory configuration

To enable deployment in this mode, an OpenSplice 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.

- Open 2 terminals. In each terminal:
- Setup the environment and go to the example directory as described above
- Set the required configuraton file e.g. OSPL_URI=file://$OSPL_HOME/etc/config/ospl_shmem_ddsi.xml
- Start the OpenSplice daemon. You can do this by typing ospl start

Starting ping and pong

- In the first terminal start pong by running either
  - pong PongRead PongWrite for C/C++
  - java -jar saj_pingpong_pong.jar PongRead PongWrite for Java
  - java -jar saj5_pingpong_pong.jar PongRead PongWrite for Java5

        pong usage:  pong [write_partition] [read_partition]

- In the second terminal start ping by running either
  - ping 100 100 f PongRead PongWrite for C/C++
  - java -jar saj_pingpong_ping.jar 100 100 f PongRead PongWrite for Java
  - java -jar saj5_pingpong_ping.jar 100 100 f PongRead PongWrite for Java5

    ping usage:
          ping [blocks][nof_cycles] [topic_id] [write_partition] [read_partition]
          topic_id is from 'm', 'q', 's', 'f', 'a' or 't' where 't' is to quit

### Running C/C++/C#/Java examples on Windows

#### Environment Setup

Let's call OpenSplice_install_dir the OpenSplice installation directory.

The OpenSplice environment variables must be set in order for the examples to run correctly. To do this open an OpenSplice Command Prompt which will set up the environment variables for OpenSplice automatically. The OpenSplice 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++/C# Examples
- Java examples

#### C/C++/C# Executables

Building the examples is described on the Summary page

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

For C and C++

- ping
- pong

For C#

- sacs_pingpong_ping
- sacs_pingpong_pong

#### Java Executables

Building the examples is described on the Summary page

Three jars are generated in the java/standalone directory when the example is built:

For Java

- saj_pingpong_ping.jar
- saj_pingpong_pong.jar
- saj_pingpong_types.jar

For Java5

- saj5_pingpong_ping.jar
- saj5_pingpong_pong.jar
- saj5_pingpong_types.jar

#### Running the C/C++/C#/Java Examples

Ensure that the environment for OpenSplice 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 OpenSplice middleware

- OpenSplice is deployed in this mode by default.
- The OpenSplice daemon should not be started manually. Instead the OpenSplice middleware and optional services are implicitly started by the single process applications as required
- Open 2 OpenSplice Command Prompts and go to the example directory as described above

Running in multiple process shared memory configuration

To enable deployment in this mode, an OpenSplice 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.

- Open 2 OpenSplice Command Prompts. In each window:
- Go to the example directory as described above
- Set the required configuration file e.g. set OSPL_URI=file://%OSPL_HOME%\etc\config\ospl_shmem_ddsi.xml
- Start the OpenSplice daemon. You can do this by typing ospl start

- In the first terminal start pong by running either
  - pong PongRead PongWrite for C/C++
  - sacs_pingpong_pong PongRead PongWrite for C#
  - java -jar saj_pingpong_pong.jar PongRead PongWrite for Java
  - java -jar saj5_pingpong_pong.jar PongRead PongWrite for Java5

    pong usage: pong [write partition] [read partition]

- In the second terminal start ping by running either
  - ping 100 100 f PongRead PongWrite for C/C++
  - sacs_pingpong_ping 100 100 f PongRead PongWrite for C#
  - java -jar saj_pingpong_ping.jar 100 100 f PongRead PongWrite for Java
  - java -jar saj5_pingpong_ping.jar 100 100 f PongRead PongWrite for Java5

      ping usage:
              ping [blocks][number of cycles] [topic_id] [write partition] [read partition]
              topic_id is from 'm', 'q', 's', 'f', 'a' or 't' where 't' is to quit

  ## Running in CORBA Cohabitation Mode

  Doing the substitution and additional set up described below, everything previously said for Standalone Mode can be applied to CORBA Cohabitation Mode.

  #### Environment Setup

  Besides OpenSplice environment variables, we need to set

  - C/C++
  - The TAO environment variable TAO_ROOT to point to the Tao installation directory.
  - Java
  - The JacORB environment variable JACORB_HOME to point to the JacORB installation directory.

  #### Substitution

  - standalone is replaced by corba
  - the java command is java -Djava.endorsed.dirs=$JACORB_HOME/lib/endorsed -classpath $OSPL_HOME/jar/dcpssaj.jar:classes