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 TypeClassDescriptionclassStores data for further processingstatic interfacePdu listener class and interfacestatic interfaceRaw pdu listener class and interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intDefault valuestatic StringDefault valuestatic intMTU 8192: TODO this has actually been superseded by a larger buffer size, but good enough for nowstatic intMTU 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 TypeMethodDescriptionvoidaddListener(DisThreadedNetworkInterface.PduListener newListener)Add a listener to accept all pdu typesvoidaddListener(DisThreadedNetworkInterface.PduListener newListener, DisPduType disPduType)Add a listener to accept only pdus of a given typevoidAdd a listener to accept pdus of all types in the form of a byte arraystatic NetworkInterfaceFind proper IPV4 interfaceintGet current port valueGet current multicast address valuebooleanbooleanvoidkill()Terminate the instancevoidremoveListener(DisThreadedNetworkInterface.PduListener priorListener)Remove previously added listenervoidRemove previously added raw listenervoidSend the given pdu to the network using the IP address and port given to the constructorvoidsetDisPort(int disPort)voidsetVerbose(boolean verbose)voidsetVerboseIncludesTimestamp(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
-