Class PduRecorder
java.lang.Object
edu.nps.moves.dis7.utilities.stream.PduRecorder
- All Implemented Interfaces:
PduReceiver
Utility to save PDUs received over the network to disk
- Author:
- Mike Bailey, jmbailey@nps.edu
-
Field Summary
Fields -
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 statementsRetrieve the path to the log filestatic String
TODO change this to enumeration type for strictnessint
getPort()
Get network port used, multicast or unicast.boolean
static void
Entry point invocation.void
pause()
Pause operation of this instancevoid
receivePdu(byte[] newBuffer, int newLength)
receivePdu from DIS data streamvoid
resume()
Resume instance operationvoid
setAddress(String newAddress)
Network address for send and receive connections.void
setDescriptor(String newDescriptor)
Set new simple descriptor (such as parent class name) for this network interface, used in trace statementsstatic void
setPduLogEncoding(String newPduLogEncoding)
void
setPort(int newPortValue)
/** Set network port used, multicast or unicast.void
start()
Start instance operationstop()
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:
- Constant Field Values
-
-
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
-
getPduLogEncoding
TODO change this to enumeration type for strictness- Returns:
- the pduLogEncoding
-
setPduLogEncoding
- Parameters:
newPduLogEncoding
- the pduLogEncoding to set
-
resume
public void resume()Resume instance operation -
start
public void start()Start instance operation -
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- Specified by:
receivePdu
in interfacePduReceiver
- 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
-
getDisThreadedNetworkInterface
- Returns:
- an instance of this DisThreadedNetworkInterface
-
isRunning
public boolean isRunning()- Returns:
- the pduRecorderRunning
-
main
Entry point invocation. Saves a PDU output log to ./pduLog. Invoking the edu.nps.moves.dis7.examples.PduReaderPlayer will playback all logs written to the 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:
- https://en.wikipedia.org/wiki/Multicast_address
-
setAddress
Network address for send and receive connections.- Parameters:
newAddress
- the new network address to set- See Also:
- https://en.wikipedia.org/wiki/Multicast_address
-
getPort
public int getPort()Get network port used, multicast or unicast.- Returns:
- current port value
- See Also:
- https://en.wikipedia.org/wiki/Port_(computer_networking)
-
setPort
public void setPort(int newPortValue)/** Set network port used, multicast or unicast.- Parameters:
newPortValue
- the disPort value to set- See Also:
- https://en.wikipedia.org/wiki/Port_(computer_networking)
-
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
-