Package edu.nps.moves.dis7.utilities
Class DisThreadedNetworkInterface
java.lang.Object
edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface
This is a thread-safe, multicast DIS network interface class.
- Since:
- Jul 29, 2019
- Author:
- Mike Bailey, jmbailey@nps.edu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Stores data for further processingstatic interface
Pdu listener class and interfacestatic interface
Raw pdu listener class and interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
Default socket port3000
, matches Wireshark DIS capture defaultstatic String
Default multicast group address229.1.2.3
for send and receive connections.static int
MTU 8192: TODO this has actually been superseded by a larger buffer size, but good enough for nowstatic int
MTU 1500: size of an Ethernet frame, common value to avoid packet segmentation -
Constructor Summary
ConstructorsConstructorDescriptionObject constructor using default multicast address and portDisThreadedNetworkInterface(String multicastGroup, int port)
Object constructor using specified multicast address and port -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener(DisThreadedNetworkInterface.PduListener newListener)
Add a listener to accept all pdu typesvoid
addListener(DisThreadedNetworkInterface.PduListener newListener, DisPduType disPduType)
Add a listener to accept only pdus of a given typevoid
Add a listener to accept pdus of all types in the form of a byte arrayvoid
close()
Terminate the instance after completion of pending send/receive activity.static NetworkInterface
Find proper IPV4 interfaceGet current multicast (or unicast) address valueint
Deprecated.Deprecated.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.void
kill()
Deprecated.void
removeListener(DisThreadedNetworkInterface.PduListener priorListener)
Remove previously added listenervoid
Remove previously added raw listenervoid
Send the given pdu to the network using the IP address and port given to the constructorvoid
setPort(int newPortValue)
/** Set network port used, multicast or unicast.void
setVerbose(boolean newValue)
Set whether or not trace statements are provided when packets are sent or received.void
setVerboseIncludesTimestamp(boolean verboseIncludesTimestamp)
Set whether or not trace statements include timestamp values.void
setVerboseReceipt(boolean newValue)
Set whether or not trace statements are provided when packets are received.void
setVerboseSending(boolean newValue)
Set whether or not trace statements are provided when packets are sent.
-
Field Details
-
DEFAULT_MULTICAST_ADDRESS
Default multicast group address229.1.2.3
for send and receive connections. -
DEFAULT_DIS_PORT
public static int DEFAULT_DIS_PORTDefault socket port3000
, matches Wireshark DIS capture default -
MAX_DIS_PDU_SIZE
public static final int MAX_DIS_PDU_SIZEMTU 8192: TODO this has actually been superseded by a larger buffer size, but good enough for now- See Also:
- Constant Field Values
-
MAX_TRANSMISSION_UNIT_SIZE
public static final int MAX_TRANSMISSION_UNIT_SIZEMTU 1500: size of an Ethernet frame, common value to avoid packet segmentation- See Also:
- Constant Field Values
-
-
Constructor Details
-
DisThreadedNetworkInterface
public DisThreadedNetworkInterface()Object constructor using default multicast address and port -
DisThreadedNetworkInterface
Object constructor using specified multicast address and port- Parameters:
multicastGroup
- the multicast group address to utilizeport
- the multicast port to utilize
-
-
Method Details
-
addListener
public void addListener(DisThreadedNetworkInterface.PduListener newListener, DisPduType disPduType)Add a listener to accept only pdus of a given type- Parameters:
newListener
- listener instance implementing the RawPduListener interfacedisPduType
- Pdu type
-
addListener
Add a listener to accept all pdu types- Parameters:
newListener
- listener instance implementing the RawPduListener interface
-
removeListener
Remove previously added listener- Parameters:
priorListener
- listener instance implementing the RawPduListener interface
-
addRawListener
Add a listener to accept pdus of all types in the form of a byte array- Parameters:
lis
- listener instance implementing the RawPduListener interface
-
removeRawListener
Remove previously added raw listener- Parameters:
lis
- listener instance implementing the RawPduListener interface
-
getDisPort
Deprecated.Deprecated, replaced by getPort()- Returns:
- current port value
-
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)
-
getMulticastGroup
Deprecated.Deprecated, replaced by getAddress()- Returns:
- current multicast address value
-
getAddress
Get current multicast (or unicast) address value- Returns:
- current multicast address value
-
send
Send the given pdu to the network using the IP address and port given to the constructor- Parameters:
pdu
- the pdu to send
-
kill
Deprecated.Method renamed asclose()
. -
close
public void close()Terminate the instance after completion of pending send/receive activity. -
findIpv4Interface
Find proper IPV4 interface- Returns:
- a network interface to use to join a multicast group
-
setVerbose
public void 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.- 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 void setVerboseReceipt(boolean newValue)Set whether or not trace statements are provided when packets are received.- Parameters:
newValue
- the verboseReceipt status to set- 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 void setVerboseSending(boolean newValue)Set whether or not trace statements are provided when packets are sent.- Parameters:
newValue
- the verboseSending status to set- 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 void setVerboseIncludesTimestamp(boolean verboseIncludesTimestamp)Set whether or not trace statements include timestamp values.- Parameters:
verboseIncludesTimestamp
- the value to set
-
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)
-