Class PduRecorder
java.lang.Object
edu.nps.moves.dis7.utilities.stream.PduRecorder
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:
-
- https://github.com/open-dis/open-dis7-java/blob/master/src/edu/nps/moves/dis7/utilities/stream/PduRecorderSelfTestLog.txt
- https://github.com/open-dis/open-dis7-java/blob/master/src/edu/nps/moves/dis7/utilities/stream/PduRecorderSelfTestENCODING_BASE64_PduCaptureLog.dislog
- https://github.com/open-dis/open-dis7-java/blob/master/src/edu/nps/moves/dis7/utilities/stream/PduRecorderSelfTestENCODING_BINARY_PduCaptureLog.dislog
- https://github.com/open-dis/open-dis7-java/blob/master/src/edu/nps/moves/dis7/utilities/stream/PduRecorderSelfTestENCODING_PLAINTEXT_PduCaptureLog.dislog
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Character sentinel indicating remainder of line is a commentstatic String
Default multicast group address239.1.2.3
for send and receive connections.static int
Default socket port3000
, matches Wireshark DIS capture defaultstatic final String
ENCODING_BASE64 uses simple Base64 (MIME type) compression on ENCODING_PLAINTEXTstatic final String
TODO ENCODING_BINARY is default DIS PDU format, not yet available within PduRecorderstatic final String
TODO ENCODING_CDIS is Compressed DIS formatstatic final String
TODO ENCODING_EXI is Efficient XML Interchange (EXI) format for compressed XMLstatic final String
TODO ENCODING_JSON is JavaScript Object Notation (JSON) formatstatic final String
TODO ENCODING_MAK_DATA_LOGGER is Mak data logger formatList of supported encodingsTODO list of planned encodingsstatic final String
ENCODING_PLAINTEXT uses a modified comma-separated values (CSV) format to show DIS values readablystatic final String
TODO ENCODING_WIRESHARK_DATA_LOGGER is likely going to be PCAPng formatstatic final String
TODO ENCODING_XML is default DIS PDU format using NPS DIS XML schema format -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor that uses default values for output directory, DIS address and port.PduRecorder
(String initialOutputDirectory) Constructor to let the use specify an output directory.PduRecorder
(String initialOutputDirectory, String initialAddress, int initialPort) Constructor to let the user specify all required parameters. -
Method Summary
Modifier and TypeMethodDescriptionGet current multicast (or unicast) network address for send and receive connections.Get simple descriptor (such as parent class name) for this network interface, used in trace statementsDeprecated.TODO change this to enumeration type for strictnessRetrieve the path to the log fileGet output directory for this PduRecorderGet output directory path for this PduRecorder.int
getPort()
Get network port used, multicast or unicast.boolean
Whether or not trace statements are provided when packets are sent or received.boolean
Whether or not trace statements include timestamp values.boolean
Whether or not trace statements are provided when packets are received.boolean
Whether or not trace statements are provided when packets are sent.boolean
static void
Entry point invocation to facilitate developmental testing, runs selfTest() method.void
pause()
Pause operation of this instancevoid
receivePdu
(byte[] newBuffer, int newLength) receivePdu from DIS data streamvoid
resume()
Resume instance operationvoid
This selfTest() method saves PDU output logs to assigned directory using all supported encodings.setAddress
(String newAddress) Network address for send and receive connections.setDescriptor
(String newDescriptor) Set new simple descriptor (such as parent class name) for this network interface, used in trace statementssetEncodingPduLog
(String newEncodingPduLog) setLogFileName
(String logFileName) setOutputDirectory
(String outputDirectory) Set output directory for this PduRecordersetPort
(int newPortValue) /** Set network port used, multicast or unicast.setVerbose
(boolean newValue) Set whether or not trace statements are provided when packets are sent or received.setVerboseIncludesTimestamp
(boolean verboseIncludesTimestamp) Set whether or not trace statements include timestamp values.setVerboseReceipt
(boolean newValue) Set whether or not trace statements are provided when packets are received.setVerboseSending
(boolean newValue) Set whether or not trace statements are provided when packets are sent.void
start()
Start instance operation, resetting network interface and file recordingstop()
End operation of this instance, removing interfaces
-
Field Details
-
DEFAULT_DIS_ADDRESS
Default multicast group address239.1.2.3
for send and receive connections. -
DEFAULT_DIS_PORT
public static int DEFAULT_DIS_PORTDefault socket port3000
, matches Wireshark DIS capture default -
COMMENT_MARKER
Character sentinel indicating remainder of line is a comment- See Also:
-
ENCODING_PLAINTEXT
ENCODING_PLAINTEXT uses a modified comma-separated values (CSV) format to show DIS values readably- See Also:
-
ENCODING_BASE64
ENCODING_BASE64 uses simple Base64 (MIME type) compression on ENCODING_PLAINTEXT- See Also:
-
ENCODING_BINARY
TODO ENCODING_BINARY is default DIS PDU format, not yet available within PduRecorder- See Also:
-
ENCODING_XML
TODO ENCODING_XML is default DIS PDU format using NPS DIS XML schema format- See Also:
-
ENCODING_EXI
TODO ENCODING_EXI is Efficient XML Interchange (EXI) format for compressed XML- See Also:
-
ENCODING_CDIS
TODO ENCODING_CDIS is Compressed DIS format- See Also:
-
ENCODING_JSON
TODO ENCODING_JSON is JavaScript Object Notation (JSON) format- See Also:
-
ENCODING_WIRESHARK_DATA_LOGGER
TODO ENCODING_WIRESHARK_DATA_LOGGER is likely going to be PCAPng format- See Also:
-
ENCODING_MAK_DATA_LOGGER
TODO ENCODING_MAK_DATA_LOGGER is Mak data logger format- See Also:
-
ENCODING_OPTIONS_LIST
List of supported encodings -
ENCODING_OPTIONS_TODO
TODO list of planned encodings
-
-
Constructor Details
-
PduRecorder
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
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
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 writteninitialAddress
- multicast group address to receive data from (TODO allow unicast UDP)initialPort
- UDP port to listen for data
-
-
Method Details
-
getEncodingPduLog
TODO change this to enumeration type for strictness- Returns:
- the pduLogEncoding
-
setEncodingPduLog
- Parameters:
newEncodingPduLog
- the pduLogEncoding to set- Returns:
- same object to permit progressive setters
-
resume
public void resume()Resume instance operation -
start
public void start()Start instance operation, resetting network interface and file recording -
pause
public void pause()Pause operation of this instance -
stop
End operation of this instance, removing interfaces -
receivePdu
public void receivePdu(byte[] newBuffer, int newLength) receivePdu from DIS data stream- Parameters:
newBuffer
- byte array for receiving datanewLength
- length of byte array
-
getLogFilePath
Retrieve the path to the log file- Returns:
- the path to the log file
-
getDisThreadedNetIF
Deprecated.Deprecated due to class rename, use getDisThreadedNetworkInterface() instead- Returns:
- an instance of this DisThreadedNetworkInterface
- See Also:
-
getDisThreadedNetworkInterface
- Returns:
- an instance of this DisThreadedNetworkInterface
-
isRunning
public boolean isRunning()- Returns:
- the pduRecorderRunning
-
main
Entry point invocation to facilitate developmental testing, runs selfTest() method.- Parameters:
args
- none supported, TODO offer path/filename
-
selfTest
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
Get current multicast (or unicast) network address for send and receive connections.- Returns:
- current multicast address value
- See Also:
-
setAddress
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
/** Set network port used, multicast or unicast.- Parameters:
newPortValue
- the disPort value to set- Returns:
- same object to permit progressive setters
- See Also:
-
getDescriptor
Get simple descriptor (such as parent class name) for this network interface, used in trace statements- Returns:
- simple descriptor name
-
setDescriptor
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
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
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
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
Set whether or not trace statements include timestamp values.- Parameters:
verboseIncludesTimestamp
- the value to set- Returns:
- same object to permit progressive setters
-
getLogFileName
- Returns:
- the logFileName
-
setLogFileName
- Parameters:
logFileName
- the logFileName to set- Returns:
- same object to permit progressive setters
-
getOutputDirectory
Get output directory for this PduRecorder- Returns:
- the outputDirectory
-
setOutputDirectory
Set output directory for this PduRecorder- Parameters:
outputDirectory
- the outputDirectory to set- Returns:
- same object to permit progressive setters
-
getOutputDirectoryPath
Get output directory path for this PduRecorder. To change outputDirectoryPath, invoke setOutputDirectory().- Returns:
- the outputDirectoryPath
- See Also:
-