* <p>This common shared class provides static code for timestamp configuration and conversion utilities,
* consistently supporting all active open-dis7-java simulations running together on a localhost.
* Multiple timestamp configurations are available, but dissimilar forms within a single simulation
* are considered counterproductive and impractical to manage coherently.</p>
*
* <p>DIS time units are a pain to work with. As specified by the IEEE DIS Protocol specification,
* <p>DIS time units are a pain to work with. As specified by the IEEE DIS Protocol specification,
* DIS time units are defined in a custom manner and set
* DIS time units are defined in a custom manner and set
* equal to 2^31 - 1 time units per hour. The DIS time is set to the number of time
* equal to 2^31 - 1 time units per hour. The DIS time is set to the number of time
* units since the start of the hour. Rollover problems can easily occur. The timestamp field in the PDU header is
* units since the start of the hour. Rollover problems can easily occur. The timestamp field in the PDU header is
* four bytes long and is specified to be an unsigned integer value.</p>
* four bytes long and is specified to be an unsigned integer value.</p>
*
*
* <p>Additionally, there are two types of official timestamps in the PDU header:
* <p>Multiple timestamp styles and settings are available.</p>
* <i>absolute time</i> and <i>relative time</i>. Absolute time is used when the host is synchronized to
*
* <a href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank">Coordinated Universal Time (UTC)</a>, i.e. the host
* <p><i>Absolute time</i> and <i>Relative time</i> are two variations for the
* is accurately synchronized with UTC via <a href="https://en.wikipedia.org/wiki/Network_Time_Protocol" target="_blank">Network Time Protocol (NTP)</a>.
* official timestamp value in the PDU header.
* Absolute time indicates that the localhost is synchronized to
* <a href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank">Coordinated Universal Time (UTC)</a>,
* typically meaning that the local computer system is accurately synchronized with UTC via
* <a href="https://en.wikipedia.org/wiki/Network_Time_Protocol" target="_blank">Network Time Protocol (NTP)</a>.
* Synchronization might also be achieved when a computer has a highly accurate reference clock (such as GPS).
* The packet timestamps originating from such hosts can be legitimately
* The packet timestamps originating from such hosts can be legitimately
* compared to the timestamp of packets received from other hosts, since they all are
* compared to the timestamp of packets received from other hosts, since they all are
* referenced to the same universal time.</p>
* referenced to the same universal time.
* Relative timestamps may require further processing in order to achieve synchronization</p>
*
*
* <p><b>Absolute timestamps</b> have their least significant bit (LSB) set to 1, and relative timestamps have their
* <p><b>Absolute timestamps</b> have their least significant bit (LSB) set to 1, and relative timestamps have their
* LSB set to 0. The idea in the DIS specification is to get the current time since the top of the hour,
* LSB set to 0. The idea in the DIS specification is to get the current time since the top of the hour,
* divide by 2^31-1, shift left one bit, then set the LSB to either 0 for relative
* divide by 2^31-1, shift left one bit, then set the LSB to either 0 for relative
* timestamps or 1 for absolute timestamps.</p>
* timestamps or 1 for absolute timestamps.</p>
*
*
* <p><b>Relative timestamps</b> are used when the host does NOT have access to NTP, and hence
* <p><b>Relative timestamps</b> are indicated when the host does NOT have access to NTP, and hence
* the system time might not be coordinated with that of other hosts. This means that
* the system time might not be coordinated with that of other hosts. This means that
* a host receiving DIS packets from several hosts might have to set up a per-host
* a host receiving DIS packets from several hosts might have to set up a per-host
* table to correlate baseline time references before ordering packets, and that
* table to correlate baseline time references before ordering packets, and that
* the PDU timestamp fields from one host is not
* the PDU timestamp fields from one host is not
* directly comparable to the PDU timestamp field from another host.</p>
* directly comparable to the PDU timestamp field from another host.
* (TODO: such support for correlating unsynchronized clocks is not yet implemented by this library.)</p>
*
*
* <p>The nature of shared DIS data is such that the timestamp values <i>roll over</i> once an
* <p>Another difficulty with the DIS standard has serious effects.
* The nature of shared DIS data is such that the timestamp values <i>roll over</i> once an
* hour, and simulations must be prepared for that eventuality. In other words, at the top of the hour
* hour, and simulations must be prepared for that eventuality. In other words, at the top of the hour
* outgoing PDUs will have a timestamp of 1, then just before the end of the hour the
* outgoing PDUs will have a timestamp of 1, then just before the end of the hour the
* PDUs will have a timestamp of 2^31 - 1, and then they will roll back over to a value of 1.
* PDUs will have a timestamp of 2^31 - 1, and then they will roll back over to a value of 1.
* Receiving applications should expect this behavior, and not simply expect a
* Receiving applications should expect this behavior, and not simply expect a
* monotonically increasing timestamp field.</p>
* monotonically increasing timestamp field.
* Two nonstandard timestamp alternatives follow.</p>
*
*
* <p><b>Unix time</b>. Note that many applications in the wild have been known to completely ignore
* <p><b>Unix time</b>. Note that many applications in the wild have been known to completely ignore
* the standard and to simply put commonly used <a href="https://en.wikipedia.org/wiki/Unix_time">Unix time</a> (seconds since 1 January 1970) into the
* the DIS standard and to simply put commonly used
* field. </p>
* <a href="https://en.wikipedia.org/wiki/Unix_time" target="_blank">Unix time</a> (seconds since 1 January 1970)
* into the timestamp field. </p>
*
*
* <p><b>Year time</b>. The rollover associated with official DIS timestamps don't work all that well in numerous applications,
* <p><b>Year time</b>. The rollover associated with official DIS timestamps don't work all that well in numerous applications,
* which often expect a monotonically increasing timestamp field. Such unpredictable rollover variations are also incompatible
* which often expect a monotonically increasing timestamp field. Such unpredictable rollover variations are also incompatible
* with archival recording or streaming playback of Live-Virtual-Constructive (LVC) behavior streams.
* with archival recording or streaming playback of
* @see <a href="https://docs.oracle.com/javase/tutorial/getStarted/application/index.html">Java Tutorials: A Closer Look at the "Hello World!" Application</a>
* @param args [unused] command-line arguments are an array of optional String parameters that are passed from execution environment during invocation
*/
publicstaticvoidmain(String[]args)
{
System.out.println("*** DisTime.main() self test started...");
DisTimedisTimeInstance=newDisTime();
disTimeInstance.selfTest();
System.out.println("*** DisTime.main() self test complete.");