Class PduRecorder

java.lang.Object
edu.nps.moves.dis7.utilities.stream.PduRecorder

public class PduRecorder extends Object
Utility to save PDUs received over the network to disk, greatly simplifying the capture of DIS streams by applications. Example main() self-test response shown in log file, example results also included.
Author:
Don Brutzman, brutzman@nps.edu, Mike Bailey, jmbailey@nps.edu
See Also:
  • Field Details

    • DEFAULT_DIS_ADDRESS

      public static String DEFAULT_DIS_ADDRESS
      Default multicast group address 239.1.2.3 for send and receive connections.
      See Also:
    • DEFAULT_DIS_PORT

      public static int DEFAULT_DIS_PORT
      Default socket port 3000, matches Wireshark DIS capture default
      See Also:
    • COMMENT_MARKER

      public static final String COMMENT_MARKER
      Character sentinel indicating remainder of line is a comment
      See Also:
    • ENCODING_PLAINTEXT

      public static final String ENCODING_PLAINTEXT
      ENCODING_PLAINTEXT uses a modified comma-separated values (CSV) format to show DIS values readably
      See Also:
    • ENCODING_BASE64

      public static final String ENCODING_BASE64
      ENCODING_BASE64 uses simple Base64 (MIME type) compression on ENCODING_PLAINTEXT
      See Also:
    • ENCODING_BINARY

      public static final String ENCODING_BINARY
      TODO ENCODING_BINARY is default DIS PDU format, not yet available within PduRecorder
      See Also:
    • ENCODING_XML

      public static final String ENCODING_XML
      TODO ENCODING_XML is default DIS PDU format using NPS DIS XML schema format
      See Also:
    • ENCODING_EXI

      public static final String ENCODING_EXI
      TODO ENCODING_EXI is Efficient XML Interchange (EXI) format for compressed XML
      See Also:
    • ENCODING_CDIS

      public static final String ENCODING_CDIS
      TODO ENCODING_CDIS is Compressed DIS format
      See Also:
    • ENCODING_JSON

      public static final String ENCODING_JSON
      TODO ENCODING_JSON is JavaScript Object Notation (JSON) format
      See Also:
    • ENCODING_WIRESHARK_DATA_LOGGER

      public static final String ENCODING_WIRESHARK_DATA_LOGGER
      TODO ENCODING_WIRESHARK_DATA_LOGGER is likely going to be PCAPng format
      See Also:
    • ENCODING_MAK_DATA_LOGGER

      public static final String ENCODING_MAK_DATA_LOGGER
      TODO ENCODING_MAK_DATA_LOGGER is Mak data logger format
      See Also:
    • ENCODING_OPTIONS_LIST

      public static final List<String> ENCODING_OPTIONS_LIST
      List of supported encodings
    • ENCODING_OPTIONS_TODO

      public static final List<String> ENCODING_OPTIONS_TODO
      TODO list of planned encodings
  • Constructor Details

    • PduRecorder

      public PduRecorder() throws IOException
      Default constructor that uses default values for output directory, DIS address and port. Each instance must invoke start() to begin operations, pause() to suspend operations, resume() to continue operations, and stop() to terminate operations.
      Throws:
      IOException - if something goes wrong during instantiation
    • PduRecorder

      public PduRecorder(String initialOutputDirectory) throws IOException
      Constructor to let the use specify an output directory. Uses default values for multicast address and port. Each instance must invoke start() to begin operations, pause() to suspend operations, resume() to continue operations, and stop() to terminate operations.
      Parameters:
      initialOutputDirectory - the directory to write log files to
      Throws:
      IOException - if something goes wrong during instantiation
    • PduRecorder

      public PduRecorder(String initialOutputDirectory, String initialAddress, int initialPort)
      Constructor to let the user specify all required parameters. Each instance must invoke start() to begin operations, pause() to suspend operations, resume() to continue operations, and stop() to terminate operations..
      Parameters:
      initialOutputDirectory - local path for directory where the log files are written
      initialAddress - multicast group address to receive data from (TODO allow unicast UDP)
      initialPort - UDP port to listen for data
  • Method Details

    • getEncodingPduLog

      public String getEncodingPduLog()
      TODO change this to enumeration type for strictness
      Returns:
      the pduLogEncoding
    • setEncodingPduLog

      public PduRecorder setEncodingPduLog(String newEncodingPduLog)
      Parameters:
      newEncodingPduLog - the pduLogEncoding to set
      Returns:
      same object to permit progressive setters
    • resume

      public void resume()
      Resume instance operation
      See Also:
    • start

      public void start()
      Start instance operation, resetting network interface and file recording
      See Also:
    • pause

      public void pause()
      Pause operation of this instance
      See Also:
    • stop

      public File stop()
      End operation of this instance, removing interfaces
      Returns:
      recorder logFile
      See Also:
    • receivePdu

      public void receivePdu(byte[] newBuffer, int newLength)
      receivePdu from DIS data stream
      Parameters:
      newBuffer - byte array for receiving data
      newLength - length of byte array
    • getLogFilePath

      public String getLogFilePath()
      Retrieve the path to the log file
      Returns:
      the path to the log file
    • getDisThreadedNetIF

      @Deprecated public DisThreadedNetworkInterface getDisThreadedNetIF()
      Deprecated.
      Deprecated due to class rename, use getDisThreadedNetworkInterface() instead
      Returns:
      an instance of this DisThreadedNetworkInterface
      See Also:
    • getDisThreadedNetworkInterface

      public DisThreadedNetworkInterface getDisThreadedNetworkInterface()
      Returns:
      an instance of this DisThreadedNetworkInterface
    • isRunning

      public boolean isRunning()
      Returns:
      the pduRecorderRunning
    • main

      public static void main(String[] args)
      Entry point invocation to facilitate developmental testing, runs selfTest() method.
      Parameters:
      args - none supported, TODO offer path/filename
    • selfTest

      public void selfTest(String[] args)
      This selfTest() method saves PDU output logs to assigned directory using all supported encodings. Further checking can be accomplished by separately Invoking the edu.nps.moves.dis7.examples.PduReaderPlayer which will playback all logs written to that log directory.
      Parameters:
      args - none supported, TODO offer path/filename
    • getAddress

      public String getAddress()
      Get current multicast (or unicast) network address for send and receive connections.
      Returns:
      current multicast address value
      See Also:
    • setAddress

      public PduRecorder setAddress(String newAddress)
      Network address for send and receive connections.
      Parameters:
      newAddress - the new network address to set
      Returns:
      same object to permit progressive setters
      See Also:
    • getPort

      public int getPort()
      Get network port used, multicast or unicast.
      Returns:
      current port value
      See Also:
    • setPort

      public PduRecorder setPort(int newPortValue)
      /** Set network port used, multicast or unicast.
      Parameters:
      newPortValue - the disPort value to set
      Returns:
      same object to permit progressive setters
      See Also:
    • getDescriptor

      public String getDescriptor()
      Get simple descriptor (such as parent class name) for this network interface, used in trace statements
      Returns:
      simple descriptor name
    • setDescriptor

      public PduRecorder setDescriptor(String newDescriptor)
      Set new simple descriptor (such as parent class name) for this network interface, used in trace statements
      Parameters:
      newDescriptor - simple descriptor name
      Returns:
      same object to permit progressive setters
    • setVerbose

      public PduRecorder setVerbose(boolean newValue)
      Set whether or not trace statements are provided when packets are sent or received.
      Parameters:
      newValue - the verbose status to set, also resets verboseReceipt and verboseSending to match.
      Returns:
      same object to permit progressive setters
      See Also:
      • verboseReceipt
      • verboseSending
    • hasVerboseOutput

      public boolean hasVerboseOutput()
      Whether or not trace statements are provided when packets are sent or received.
      Returns:
      the verbose status
      See Also:
      • verboseReceipt
      • verboseSending
    • setVerboseReceipt

      public PduRecorder setVerboseReceipt(boolean newValue)
      Set whether or not trace statements are provided when packets are received.
      Parameters:
      newValue - the verboseReceipt status to set
      Returns:
      same object to permit progressive setters
      See Also:
      • verbose
      • verboseSending
    • hasVerboseReceipt

      public boolean hasVerboseReceipt()
      Whether or not trace statements are provided when packets are received.
      Returns:
      the verboseReceipt status
    • setVerboseSending

      public PduRecorder setVerboseSending(boolean newValue)
      Set whether or not trace statements are provided when packets are sent.
      Parameters:
      newValue - the verboseSending status to set
      Returns:
      same object to permit progressive setters
      See Also:
      • verbose
      • verboseReceipt
    • hasVerboseSending

      public boolean hasVerboseSending()
      Whether or not trace statements are provided when packets are sent.
      Returns:
      the verboseSending status
    • hasVerboseOutputIncludesTimestamp

      public boolean hasVerboseOutputIncludesTimestamp()
      Whether or not trace statements include timestamp values.
      Returns:
      the verboseIncludesTimestamp value
    • setVerboseIncludesTimestamp

      public PduRecorder setVerboseIncludesTimestamp(boolean verboseIncludesTimestamp)
      Set whether or not trace statements include timestamp values.
      Parameters:
      verboseIncludesTimestamp - the value to set
      Returns:
      same object to permit progressive setters
    • getLogFileName

      public String getLogFileName()
      Returns:
      the logFileName
    • setLogFileName

      public PduRecorder setLogFileName(String logFileName)
      Parameters:
      logFileName - the logFileName to set
      Returns:
      same object to permit progressive setters
    • getOutputDirectory

      public String getOutputDirectory()
      Get output directory for this PduRecorder
      Returns:
      the outputDirectory
    • setOutputDirectory

      public PduRecorder setOutputDirectory(String outputDirectory)
      Set output directory for this PduRecorder
      Parameters:
      outputDirectory - the outputDirectory to set
      Returns:
      same object to permit progressive setters
    • getOutputDirectoryPath

      public Path getOutputDirectoryPath()
      Get output directory path for this PduRecorder. To change outputDirectoryPath, invoke setOutputDirectory().
      Returns:
      the outputDirectoryPath
      See Also: