// Path: srcJava/com/rti/perftest/IMessaging.java
// public interface IMessaging {
//     public boolean initialize(int argc, String[] argv);
// 
//     public void printCmdLineHelp();
// 
//     String printConfiguration();
// 
//     public void shutdown();
// 
//     /**
//      * If the implementation supports batching and the test scenario is
//      * using batching, this function should return the size of the batch
//      * in bytes.
//      */
//     public int getBatchSize();
// 
//     /**
//      * Get an estimation of the minimum number of samples that need to be send
//      * before starting the test to ensure that most memory allocations will be
//      * done in the subscriber side (when sending a burst of that data).
//      */
//     public int getInitializationSampleCount();
// 
//     public IMessagingWriter createWriter(String topicName);
// 
//     /**
//      * Pass null for callback if using IMessagingReader.ReceiveMessage()
//      * to get data
//      */
//     public IMessagingReader createReader(
//             String topicName, IMessagingCB callback);
// 
//     public void dispose();
// 
// }
// 
// Path: srcJava/com/rti/perftest/IMessagingReader.java
// public interface IMessagingReader {
//     /**
//      * Only used for non-callback test.
//      */
//     public TestMessage receiveMessage();
// 
//     public void waitForWriters(int numWriters);
// 
//     /**
//      * Only used for non-callback test to cleanup the thread.
//      */
//     public void shutdown();
// 
// }
// 
// Path: srcJava/com/rti/perftest/IMessagingWriter.java
// public interface IMessagingWriter {
//     public void waitForReaders(int numReaders);
// 
//     public boolean send(TestMessage message, boolean isCftWildCardKey);
//     public boolean waitForPingResponse();
//     public boolean waitForPingResponse(long timeout, TimeUnit unit);
//     public boolean notifyPingResponse();
//     public long getPulledSampleCount();
//     public void waitForAck(int sec, int nsec);
//     public void flush();
// 
// }
// 
// Path: srcJava/com/rti/perftest/TestMessage.java
// public class TestMessage {
//     
//     public byte[] data;
//     public int    size;
//     public byte[] key = new byte[4];
//     public int    entity_id;
//     public int    seq_num;
//     public int    timestamp_sec;
//     public int    timestamp_usec;
//     public int    latency_ping;
// }
// 
// Path: srcJava/com/rti/perftest/harness/PerftestTimerTask.java
// public class PerftestTimerTask extends TimerTask {
// 
//   private PerfTest perftest;
//   private Timer timer;
//   private boolean _isScan;
//   
//   public PerftestTimerTask(PerfTest _perftest) {
//       // this way we can modify testCompleted in perftest
//       perftest = _perftest;
//       // running timer task as daemon thread (true)
//       timer = new Timer(true);
//       _isScan = false;
//   }
//   
//   @Override
//   public void run() {
//       if (!_isScan) {
//           perftest.finishTest();
//       } else {
//           perftest.finishTestScan();
//       }
//   }
// 
//   public void setTimeout(long executionTime, boolean isScan) {
//       timer.schedule(this, executionTime * 1000);
//       _isScan = isScan;
//       if (!_isScan) {
//           System.err.println("Setting timeout to "
//                 + executionTime + " seconds.");
//       }
//   }
//   
//   public void cancelTimer() {
//       timer.cancel();
//   }
// 
// }
// 
// Path: srcJava/com/rti/perftest/ddsimpl/PerftestVersion.java
// public final class PerftestVersion {
// 
//     private static final PerftestVersion _singleton = new PerftestVersion();
// 
//     private final ProductVersion_t _productVersion;
// 
//     private PerftestVersion() {
//         _productVersion = new ProductVersion_t(new int[] { 9, 9, 9, 9 });
//     }
// 
//     public static PerftestVersion getInstance() {
//         return _singleton;
//     }
// 
//     public ProductVersion_t getProductVersion() {
//         return _productVersion;
//     }
// }


import com.rti.perftest.gen.THROUGHPUT_TOPIC_NAME;
import com.rti.perftest.gen.LATENCY_TOPIC_NAME;
import com.rti.perftest.gen.ANNOUNCEMENT_TOPIC_NAME;
import com.rti.perftest.IMessaging;
import com.rti.perftest.IMessagingReader;
import com.rti.perftest.IMessagingWriter;
import com.rti.perftest.TestMessage;
import com.rti.perftest.harness.PerftestTimerTask;
import com.rti.perftest.gen.MAX_BOUNDED_SEQ_SIZE;
import com.rti.perftest.gen.MAX_PERFTEST_SAMPLE_SIZE;
import com.rti.perftest.gen.THROUGHPUT_TOPIC_NAME;
import com.rti.perftest.gen.LATENCY_TOPIC_NAME;
import com.rti.perftest.gen.ANNOUNCEMENT_TOPIC_NAME;
import com.rti.perftest.ddsimpl.PerftestVersion;
import com.rti.ndds.Utility;
import com.rti.dds.infrastructure.ProductVersion_t;
import com.rti.ndds.config.Version;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
                    System.err.println("Sleep NanoSec does not work.");
                    return;
                }
            }


            pingID = -1;

            // only send latency pings if is publisher with ID 0
            // In batch mode, latency pings are sent once every LatencyCount batches
            if ( (pubID == 0) && (((loop/samplesPerBatch) %_latencyCount) == 0) )
            {

                /* In batch mode only send a single ping in a batch.
                 *
                 * However, the ping is sent in a round robin position within
                 * the batch.  So keep track of which position(index) the
                 * current sample is within the batch, and which position
                 * within the batch should contain the ping. Only send the ping
                 * when both are equal.
                 *
                 * Note when not in batch mode, current_index_in_batch = ping_index_in_batch
                 * always.  And the if() is always true.
                 */
                if ( current_index_in_batch == ping_index_in_batch && !sentPing )
                {
                    // If running in scan mode, dataLen under test is changed
                    // after _executionTime
                    if (_isScan && testCompletedScan) {
                        testCompletedScan = false;
// Path: srcJava/com/rti/perftest/IMessaging.java
// public interface IMessaging {
//     public boolean initialize(int argc, String[] argv);
// 
//     public void printCmdLineHelp();
// 
//     String printConfiguration();
// 
//     public void shutdown();
// 
//     /**
//      * If the implementation supports batching and the test scenario is
//      * using batching, this function should return the size of the batch
//      * in bytes.
//      */
//     public int getBatchSize();
// 
//     /**
//      * Get an estimation of the minimum number of samples that need to be send
//      * before starting the test to ensure that most memory allocations will be
//      * done in the subscriber side (when sending a burst of that data).
//      */
//     public int getInitializationSampleCount();
// 
//     public IMessagingWriter createWriter(String topicName);
// 
//     /**
//      * Pass null for callback if using IMessagingReader.ReceiveMessage()
//      * to get data
//      */
//     public IMessagingReader createReader(
//             String topicName, IMessagingCB callback);
// 
//     public void dispose();
// 
// }
// 
// Path: srcJava/com/rti/perftest/IMessagingReader.java
// public interface IMessagingReader {
//     /**
//      * Only used for non-callback test.
//      */
//     public TestMessage receiveMessage();
// 
//     public void waitForWriters(int numWriters);
// 
//     /**
//      * Only used for non-callback test to cleanup the thread.
//      */
//     public void shutdown();
// 
// }
// 
// Path: srcJava/com/rti/perftest/IMessagingWriter.java
// public interface IMessagingWriter {
//     public void waitForReaders(int numReaders);
// 
//     public boolean send(TestMessage message, boolean isCftWildCardKey);
//     public boolean waitForPingResponse();
//     public boolean waitForPingResponse(long timeout, TimeUnit unit);
//     public boolean notifyPingResponse();
//     public long getPulledSampleCount();
//     public void waitForAck(int sec, int nsec);
//     public void flush();
// 
// }
// 
// Path: srcJava/com/rti/perftest/TestMessage.java
// public class TestMessage {
//     
//     public byte[] data;
//     public int    size;
//     public byte[] key = new byte[4];
//     public int    entity_id;
//     public int    seq_num;
//     public int    timestamp_sec;
//     public int    timestamp_usec;
//     public int    latency_ping;
// }
// 
// Path: srcJava/com/rti/perftest/harness/PerftestTimerTask.java
// public class PerftestTimerTask extends TimerTask {
// 
//   private PerfTest perftest;
//   private Timer timer;
//   private boolean _isScan;
//   
//   public PerftestTimerTask(PerfTest _perftest) {
//       // this way we can modify testCompleted in perftest
//       perftest = _perftest;
//       // running timer task as daemon thread (true)
//       timer = new Timer(true);
//       _isScan = false;
//   }
//   
//   @Override
//   public void run() {
//       if (!_isScan) {
//           perftest.finishTest();
//       } else {
//           perftest.finishTestScan();
//       }
//   }
// 
//   public void setTimeout(long executionTime, boolean isScan) {
//       timer.schedule(this, executionTime * 1000);
//       _isScan = isScan;
//       if (!_isScan) {
//           System.err.println("Setting timeout to "
//                 + executionTime + " seconds.");
//       }
//   }
//   
//   public void cancelTimer() {
//       timer.cancel();
//   }
// 
// }
// 
// Path: srcJava/com/rti/perftest/ddsimpl/PerftestVersion.java
// public final class PerftestVersion {
// 
//     private static final PerftestVersion _singleton = new PerftestVersion();
// 
//     private final ProductVersion_t _productVersion;
// 
//     private PerftestVersion() {
//         _productVersion = new ProductVersion_t(new int[] { 9, 9, 9, 9 });
//     }
// 
//     public static PerftestVersion getInstance() {
//         return _singleton;
//     }
// 
//     public ProductVersion_t getProductVersion() {
//         return _productVersion;
//     }
// }


// Path: srcJava/com/rti/perftest/harness/PerfTest.java
import com.rti.perftest.gen.THROUGHPUT_TOPIC_NAME;
import com.rti.perftest.gen.LATENCY_TOPIC_NAME;
import com.rti.perftest.gen.ANNOUNCEMENT_TOPIC_NAME;
import com.rti.perftest.IMessaging;
import com.rti.perftest.IMessagingReader;
import com.rti.perftest.IMessagingWriter;
import com.rti.perftest.TestMessage;
import com.rti.perftest.harness.PerftestTimerTask;
import com.rti.perftest.gen.MAX_BOUNDED_SEQ_SIZE;
import com.rti.perftest.gen.MAX_PERFTEST_SAMPLE_SIZE;
import com.rti.perftest.gen.THROUGHPUT_TOPIC_NAME;
import com.rti.perftest.gen.LATENCY_TOPIC_NAME;
import com.rti.perftest.gen.ANNOUNCEMENT_TOPIC_NAME;
import com.rti.perftest.ddsimpl.PerftestVersion;
import com.rti.ndds.Utility;
import com.rti.dds.infrastructure.ProductVersion_t;
import com.rti.ndds.config.Version;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.TimeUnit;

                    System.err.println("Sleep NanoSec does not work.");
                    return;
                }
            }


            pingID = -1;

            // only send latency pings if is publisher with ID 0
            // In batch mode, latency pings are sent once every LatencyCount batches
            if ( (pubID == 0) && (((loop/samplesPerBatch) %_latencyCount) == 0) )
            {

                /* In batch mode only send a single ping in a batch.
                 *
                 * However, the ping is sent in a round robin position within
                 * the batch.  So keep track of which position(index) the
                 * current sample is within the batch, and which position
                 * within the batch should contain the ping. Only send the ping
                 * when both are equal.
                 *
                 * Note when not in batch mode, current_index_in_batch = ping_index_in_batch
                 * always.  And the if() is always true.
                 */
                if ( current_index_in_batch == ping_index_in_batch && !sentPing )
                {
                    // If running in scan mode, dataLen under test is changed
                    // after _executionTime
                    if (_isScan && testCompletedScan) {
                        testCompletedScan = false;
                        timertask = new PerftestTimerTask(this);