Class DisThreadedNetworkInterface

java.lang.Object
edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface

public class DisThreadedNetworkInterface extends Object
This is a thread-safe, multicast DIS network interface class.
Since:
Jul 29, 2019
Author:
Mike Bailey, jmbailey@nps.edu
  • Field Details

    • DEFAULT_MULTICAST_ADDRESS

      public static String DEFAULT_MULTICAST_ADDRESS
      Default value
    • DEFAULT_DIS_PORT

      public static int DEFAULT_DIS_PORT
      Default value
    • MAX_DIS_PDU_SIZE

      public static final int MAX_DIS_PDU_SIZE
      MTU 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_SIZE
      MTU 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

      public DisThreadedNetworkInterface(String multicastGroup, int port)
      Constructor
      Parameters:
      multicastGroup - the multicast group address to utilize
      port - 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 interface
      disPduType - Pdu type
    • addListener

      public void addListener(DisThreadedNetworkInterface.PduListener newListener)
      Add a listener to accept all pdu types
      Parameters:
      newListener - listener instance implementing the RawPduListener interface
    • removeListener

      public void removeListener(DisThreadedNetworkInterface.PduListener priorListener)
      Remove previously added listener
      Parameters:
      priorListener - listener instance implementing the RawPduListener interface
    • addRawListener

      public void addRawListener(DisThreadedNetworkInterface.RawPduListener lis)
      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

      public void removeRawListener(DisThreadedNetworkInterface.RawPduListener lis)
      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

      public String getMulticastGroup()
      Get current multicast address value
      Returns:
      current multicast address value
    • send

      public void send(Pdu pdu)
      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

      public static NetworkInterface 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