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 valuestatic String
Default valuestatic 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
ConstructorsConstructorDescriptionDefault constructor using default port and multicast addressDisThreadedNetworkInterface(String multicastGroup, int port)
Constructor -
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 arraystatic NetworkInterface
Find proper IPV4 interfaceint
Get current port valueGet current multicast address valueboolean
boolean
void
kill()
Terminate the instancevoid
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
setDisPort(int disPort)
void
setVerbose(boolean verbose)
void
setVerboseIncludesTimestamp(boolean verboseIncludesTimestamp)
-
Field Details
-
DEFAULT_MULTICAST_ADDRESS
Default value -
DEFAULT_DIS_PORT
public static int DEFAULT_DIS_PORTDefault value -
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()Default constructor using default port and multicast address -
DisThreadedNetworkInterface
Constructor- 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
public int getDisPort()Get current port value- Returns:
- current port value
-
getMulticastGroup
Get current multicast 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
public void kill()Terminate the instance -
findIpv4Interface
Find proper IPV4 interface- Returns:
- a network interface to use to join a multicast group
-
isVerbose
public boolean isVerbose()- Returns:
- the verbose
-
setVerbose
public void setVerbose(boolean verbose)- Parameters:
verbose
- the verbose to set
-
isVerboseIncludesTimestamp
public boolean isVerboseIncludesTimestamp()- Returns:
- the verboseIncludesTimestamp value
-
setVerboseIncludesTimestamp
public void setVerboseIncludesTimestamp(boolean verboseIncludesTimestamp)- Parameters:
verboseIncludesTimestamp
- the value to set
-
setDisPort
public void setDisPort(int disPort)- Parameters:
disPort
- the disPort value to set
-