diff --git a/src/edu/nps/moves/dis7/examples/AlphabeticalPduSender.java b/src/edu/nps/moves/dis7/examples/AlphabeticalPduSender.java index afe72bc98ea2291e8ad7c0143d2246abe9020374..3f4f84e84a313c764385e03a9b20aed7e04a2ac2 100644 --- a/src/edu/nps/moves/dis7/examples/AlphabeticalPduSender.java +++ b/src/edu/nps/moves/dis7/examples/AlphabeticalPduSender.java @@ -2,7 +2,7 @@ package edu.nps.moves.dis7.examples; import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.enumerations.DISPDUType; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -292,7 +292,7 @@ public class AlphabeticalPduSender DatagramPacket packet; MulticastSocket socket = new MulticastSocket(); InetSocketAddress group = new InetSocketAddress(multicastAddress, port); - socket.joinGroup(group, DisThreadedNetIF.findIpv4Interface()); + socket.joinGroup(group, DisThreadedNetworkInterface.findIpv4Interface()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); @@ -331,8 +331,8 @@ public class AlphabeticalPduSender } else { System.out.println("Usage: AlphabeticalPduSender <port> <multicast group>"); - System.out.println("Default: AlphabeticalPduSender " + DisThreadedNetIF.DEFAULT_DIS_PORT + " " + DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS); - sender = new AlphabeticalPduSender(DisThreadedNetIF.DEFAULT_DIS_PORT, DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS); + System.out.println("Default: AlphabeticalPduSender " + DisThreadedNetworkInterface.DEFAULT_DIS_PORT + " " + DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS); + sender = new AlphabeticalPduSender(DisThreadedNetworkInterface.DEFAULT_DIS_PORT, DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS); } sender.run(); } diff --git a/src/edu/nps/moves/dis7/examples/EntityStateEntityIdExampleUse.java b/src/edu/nps/moves/dis7/examples/EntityStateEntityIdExampleUse.java index 1a568b9fea400e93bf59de729772d82c0f8a91ec..4639774c072e2a3f4e25174042611796b821ca4c 100644 --- a/src/edu/nps/moves/dis7/examples/EntityStateEntityIdExampleUse.java +++ b/src/edu/nps/moves/dis7/examples/EntityStateEntityIdExampleUse.java @@ -9,7 +9,7 @@ import edu.nps.moves.dis7.EntityStatePdu; import edu.nps.moves.dis7.Pdu; import edu.nps.moves.dis7.utilities.PduFactory; import edu.nps.moves.dis7.enumerations.DISPDUType; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import java.io.IOException; import edu.nps.moves.dis7.entities.usa.platform.surface.*; @@ -76,7 +76,7 @@ public class EntityStateEntityIdExampleUse */ public static void exampleUse() throws Exception { - DisThreadedNetIF disNetworkInterface = new DisThreadedNetIF(); // uses defaults + DisThreadedNetworkInterface disNetworkInterface = new DisThreadedNetworkInterface(); // uses defaults // We want to listen also, so add a listener, using JDK8+ lambda grammar disNetworkInterface.addListener(pdu->handleReceivedPdu(pdu)); diff --git a/src/edu/nps/moves/dis7/examples/EspduReceiver.java b/src/edu/nps/moves/dis7/examples/EspduReceiver.java index 47d451d653a91fcffa871e7ade4b45ed36513a4e..e2c03448697e3a1c5029772c231f627fac2e4983 100644 --- a/src/edu/nps/moves/dis7/examples/EspduReceiver.java +++ b/src/edu/nps/moves/dis7/examples/EspduReceiver.java @@ -8,7 +8,7 @@ import edu.nps.moves.dis7.EntityID; import edu.nps.moves.dis7.EntityStatePdu; import edu.nps.moves.dis7.Pdu; import edu.nps.moves.dis7.Vector3Double; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import java.io.IOException; import java.net.DatagramPacket; @@ -31,7 +31,7 @@ public class EspduReceiver public static void main(String args[]) { MulticastSocket socket; - byte buffer[] = new byte[DisThreadedNetIF.MAX_DIS_PDU_SIZE]; + byte buffer[] = new byte[DisThreadedNetworkInterface.MAX_DIS_PDU_SIZE]; DatagramPacket packet = new DatagramPacket(buffer, buffer.length); PduFactory pduFactory = new PduFactory(); List<Pdu> pduBundle; @@ -39,12 +39,12 @@ public class EspduReceiver try { // Specify the socket to receive data - socket = new MulticastSocket(DisThreadedNetIF.DEFAULT_DIS_PORT); + socket = new MulticastSocket(DisThreadedNetworkInterface.DEFAULT_DIS_PORT); - InetAddress maddr = InetAddress.getByName(DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS); - InetSocketAddress group = new InetSocketAddress(maddr, DisThreadedNetIF.DEFAULT_DIS_PORT); + InetAddress maddr = InetAddress.getByName(DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS); + InetSocketAddress group = new InetSocketAddress(maddr, DisThreadedNetworkInterface.DEFAULT_DIS_PORT); - socket.joinGroup(group, DisThreadedNetIF.findIpv4Interface()); + socket.joinGroup(group, DisThreadedNetworkInterface.findIpv4Interface()); // Loop infinitely, receiving datagrams EntityID eid; @@ -75,7 +75,7 @@ public class EspduReceiver System.out.println(); } // end trop through PDU bundle } // end while - } // End try + } // End try // End try catch (IOException e) { System.err.println(e); } diff --git a/src/edu/nps/moves/dis7/examples/EspduReceiverNIO.java b/src/edu/nps/moves/dis7/examples/EspduReceiverNIO.java index 10c76c7902edcb34a951bacda5b963beca61d463..5bcd202a70d278730ff259746071d427792cc8d2 100644 --- a/src/edu/nps/moves/dis7/examples/EspduReceiverNIO.java +++ b/src/edu/nps/moves/dis7/examples/EspduReceiverNIO.java @@ -5,7 +5,7 @@ package edu.nps.moves.dis7.examples; import edu.nps.moves.dis7.Pdu; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import java.io.IOException; import java.net.DatagramPacket; @@ -27,7 +27,7 @@ public class EspduReceiverNIO InetAddress maddr; InetSocketAddress group; PduFactory pduFactory = new PduFactory(); - byte buffer[] = new byte[DisThreadedNetIF.MAX_DIS_PDU_SIZE]; + byte buffer[] = new byte[DisThreadedNetworkInterface.MAX_DIS_PDU_SIZE]; DatagramPacket packet = new DatagramPacket(buffer, buffer.length); Pdu pdu; int pduCounter = 0; @@ -35,10 +35,10 @@ public class EspduReceiverNIO try { // Specify the socket to receive data - socket = new MulticastSocket(DisThreadedNetIF.DEFAULT_DIS_PORT); - maddr = InetAddress.getByName(DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS); - group = new InetSocketAddress(maddr, DisThreadedNetIF.DEFAULT_DIS_PORT); - socket.joinGroup(group, DisThreadedNetIF.findIpv4Interface()); + socket = new MulticastSocket(DisThreadedNetworkInterface.DEFAULT_DIS_PORT); + maddr = InetAddress.getByName(DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS); + group = new InetSocketAddress(maddr, DisThreadedNetworkInterface.DEFAULT_DIS_PORT); + socket.joinGroup(group, DisThreadedNetworkInterface.findIpv4Interface()); // Loop infinitely, receiving datagrams while (true) { @@ -52,7 +52,7 @@ public class EspduReceiverNIO System.out.println(pduCounter + ". got PDU of type: " + pdu.getClass().getSimpleName()); } // end while - } // End try + } // End try // End try catch (IOException e) { System.err.println(e); } diff --git a/src/edu/nps/moves/dis7/examples/EspduSender.java b/src/edu/nps/moves/dis7/examples/EspduSender.java index 232b938ccb227a9a1fc31aa72d3f4c3a6e4c6413..1faa4615b52b8f2cc0f080d23e8cfecd4ed99ea2 100644 --- a/src/edu/nps/moves/dis7/examples/EspduSender.java +++ b/src/edu/nps/moves/dis7/examples/EspduSender.java @@ -7,7 +7,7 @@ package edu.nps.moves.dis7.examples; import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.utilities.CoordinateConversions; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import java.io.*; import java.net.*; import java.util.*; @@ -46,12 +46,12 @@ public class EspduSender // Default settings. These are used if no system properties are set. // If system properties are passed in, these are over ridden. - int port = DisThreadedNetIF.DEFAULT_DIS_PORT; + int port = DisThreadedNetworkInterface.DEFAULT_DIS_PORT; NetworkMode mode; InetAddress destinationIp = null; // must be initialized, even if null try { - destinationIp = InetAddress.getByName(DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS); + destinationIp = InetAddress.getByName(DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS); } catch (UnknownHostException e) { System.err.println(e + " Cannot create multicast address"); @@ -98,7 +98,7 @@ public class EspduSender } group = new InetSocketAddress(destinationIp, port); - socket.joinGroup(group, DisThreadedNetIF.findIpv4Interface()); + socket.joinGroup(group, DisThreadedNetworkInterface.findIpv4Interface()); } } // end networkModeString } diff --git a/src/edu/nps/moves/dis7/examples/EspduSenderNIO.java b/src/edu/nps/moves/dis7/examples/EspduSenderNIO.java index a4bf76c67bc0c8868ce5a42e5b3899e92d8618dc..6acef73e8ac1e31a7983b8a4f7628b7e400359b2 100644 --- a/src/edu/nps/moves/dis7/examples/EspduSenderNIO.java +++ b/src/edu/nps/moves/dis7/examples/EspduSenderNIO.java @@ -8,7 +8,7 @@ import edu.nps.moves.dis7.EntityID; import edu.nps.moves.dis7.EntityStatePdu; import edu.nps.moves.dis7.EulerAngles; import edu.nps.moves.dis7.Vector3Double; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import java.net.DatagramPacket; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -43,9 +43,9 @@ public class EspduSenderNIO try { socket = new MulticastSocket(); - maddr = InetAddress.getByName(DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS); - group = new InetSocketAddress(maddr, DisThreadedNetIF.DEFAULT_DIS_PORT); - socket.joinGroup(group, DisThreadedNetIF.findIpv4Interface()); + maddr = InetAddress.getByName(DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS); + group = new InetSocketAddress(maddr, DisThreadedNetworkInterface.DEFAULT_DIS_PORT); + socket.joinGroup(group, DisThreadedNetworkInterface.findIpv4Interface()); Vector3Double location; EulerAngles orientation; diff --git a/src/edu/nps/moves/dis7/examples/PduListenerSaver.java b/src/edu/nps/moves/dis7/examples/PduListenerSaver.java index d874dd81dd34149ec2aacf700b80d27d8ca367be..38dc5134d963d1c7e38444a96840737abf51bb14 100644 --- a/src/edu/nps/moves/dis7/examples/PduListenerSaver.java +++ b/src/edu/nps/moves/dis7/examples/PduListenerSaver.java @@ -4,7 +4,7 @@ */ package edu.nps.moves.dis7.examples; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.stream.PduRecorder; import java.io.IOException; import java.util.Scanner; @@ -31,8 +31,8 @@ public class PduListenerSaver public static void main(String[] args) { String outputDirectoryPath = DEFAULT_OUTPUT_DIRECTORY; - String multicastAddress = DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS; - int port = DisThreadedNetIF.DEFAULT_DIS_PORT; + String multicastAddress = DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS; + int port = DisThreadedNetworkInterface.DEFAULT_DIS_PORT; switch (args.length) { case 0: diff --git a/src/edu/nps/moves/dis7/examples/PduReaderPlayer.java b/src/edu/nps/moves/dis7/examples/PduReaderPlayer.java index 0da9f5bdf0dcf7f1cdde24bcb69385068f15068e..e785998b8a3abb5e9af6bfe87b95caed6c157014 100644 --- a/src/edu/nps/moves/dis7/examples/PduReaderPlayer.java +++ b/src/edu/nps/moves/dis7/examples/PduReaderPlayer.java @@ -4,7 +4,7 @@ */ package edu.nps.moves.dis7.examples; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.stream.PduPlayer; import java.io.IOException; import java.nio.file.Path; @@ -32,8 +32,8 @@ public class PduReaderPlayer public static void main(String[] args) { String outDir = DEFAULT_OUTPUTDIR; - String mcast = DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS; - int port = DisThreadedNetIF.DEFAULT_DIS_PORT; + String mcast = DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS; + int port = DisThreadedNetworkInterface.DEFAULT_DIS_PORT; boolean sendToNet = false; switch (args.length) { diff --git a/src/edu/nps/moves/dis7/examples/ThreadedNetExample.java b/src/edu/nps/moves/dis7/examples/ThreadedNetExample.java index 8d656957cb50099b4e61988e89037ae712083d5d..4b5d9c1df6161dfad7bd42ec57b93ce437b47caa 100644 --- a/src/edu/nps/moves/dis7/examples/ThreadedNetExample.java +++ b/src/edu/nps/moves/dis7/examples/ThreadedNetExample.java @@ -6,14 +6,14 @@ package edu.nps.moves.dis7.examples; import edu.nps.moves.dis7.Pdu; import edu.nps.moves.dis7.enumerations.Country; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; /** * ThreadedNetExample.java created on Sep 9, 2019 - * MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu - * - * Shows how to use DisThreadedNetIF from an application class + MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu + + Shows how to use DisThreadedNetworkInterface from an application class * * @author Mike Bailey, jmbailey@nps.edu * @version $Id$ @@ -22,8 +22,8 @@ public class ThreadedNetExample { public static void main(String[] args) { - // Create an instance of DisThreadedNetIF using default port 3000, mcast 225.4.5.6, use other constructor to specific port and ip - DisThreadedNetIF netif = new DisThreadedNetIF(); + // Create an instance of DisThreadedNetworkInterface using default port 3000, mcast 225.4.5.6, use other constructor to specific port and ip + DisThreadedNetworkInterface netif = new DisThreadedNetworkInterface(); // Internally, the DisThreadeNetIF class has constructed whatever threads it needs to operated diff --git a/src/edu/nps/moves/dis7/utilities/DisThreadedNetIF.java b/src/edu/nps/moves/dis7/utilities/DisThreadedNetworkInterface.java similarity index 95% rename from src/edu/nps/moves/dis7/utilities/DisThreadedNetIF.java rename to src/edu/nps/moves/dis7/utilities/DisThreadedNetworkInterface.java index 07230cafec53a9e92b19edd15d30c06e195450e8..dc9fc9ae423fe2523de4aa9c697bc807f1c64931 100644 --- a/src/edu/nps/moves/dis7/utilities/DisThreadedNetIF.java +++ b/src/edu/nps/moves/dis7/utilities/DisThreadedNetworkInterface.java @@ -24,9 +24,9 @@ import java.util.logging.Logger; * @author Mike Bailey, jmbailey@nps.edu * @since Jul 29, 2019 */ -public class DisThreadedNetIF +public class DisThreadedNetworkInterface { - private static final String TRACE_PREFIX = "[" + DisThreadedNetIF.class.getName() + "] "; + private static final String TRACE_PREFIX = "[" + DisThreadedNetworkInterface.class.getName() + "] "; private boolean verbose = true; /** Pdu listener interface */ @@ -84,7 +84,7 @@ public class DisThreadedNetIF /** * Default constructor using default port 3000 and multicast address 225.4.5.6 */ - public DisThreadedNetIF() + public DisThreadedNetworkInterface() { this(DEFAULT_DIS_PORT, DEFAULT_MULTICAST_ADDRESS); } @@ -94,14 +94,14 @@ public class DisThreadedNetIF * @param port the multicast port to utilize * @param mcastgroup the multicast group address to utilize */ - public DisThreadedNetIF(int port, String mcastgroup) + public DisThreadedNetworkInterface(int port, String mcastgroup) { disPort = port; mcastGroup = mcastgroup; try { maddr = InetAddress.getByName(mcastGroup); } catch (UnknownHostException ex) { - Logger.getLogger(DisThreadedNetIF.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(DisThreadedNetworkInterface.class.getName()).log(Level.SEVERE, null, ex); } group = new InetSocketAddress(maddr, disPort); ni = findIpv4Interface(); @@ -265,7 +265,7 @@ public class DisThreadedNetIF try { ((MulticastSocket)socket).leaveGroup(group, ni); } catch (IOException ex) { - Logger.getLogger(DisThreadedNetIF.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(DisThreadedNetworkInterface.class.getName()).log(Level.SEVERE, null, ex); } socket.close(); socket = null; @@ -375,7 +375,7 @@ public class DisThreadedNetIF } } } catch (SocketException ex) { - Logger.getLogger(DisThreadedNetIF.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(DisThreadedNetworkInterface.class.getName()).log(Level.SEVERE, null, ex); } return null; } diff --git a/src/edu/nps/moves/dis7/utilities/TrialDisMulticastNetworkingDeprecated.java b/src/edu/nps/moves/dis7/utilities/TrialDisMulticastNetworkingDeprecated.java index e7e6aadf2413b522c89c030742774025623f18b9..c0206f174d8c22708a7739dca8d28653dc7edef3 100644 --- a/src/edu/nps/moves/dis7/utilities/TrialDisMulticastNetworkingDeprecated.java +++ b/src/edu/nps/moves/dis7/utilities/TrialDisMulticastNetworkingDeprecated.java @@ -19,7 +19,7 @@ import java.util.logging.Logger; * </pre> * * @since Jul 29, 2019. - * @deprecated Use {@link edu.nps.moves.dis7.utilities.DisThreadedNetIF} instead + * @deprecated Use {@link edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface} instead */ @Deprecated(since="dis7") public class TrialDisMulticastNetworkingDeprecated @@ -48,7 +48,7 @@ public class TrialDisMulticastNetworkingDeprecated public TrialDisMulticastNetworkingDeprecated() { - this(DisThreadedNetIF.DEFAULT_DIS_PORT, DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS); + this(DisThreadedNetworkInterface.DEFAULT_DIS_PORT, DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS); } public TrialDisMulticastNetworkingDeprecated(int port, String mcastgroup) @@ -61,7 +61,7 @@ public class TrialDisMulticastNetworkingDeprecated Logger.getLogger(TrialDisMulticastNetworkingDeprecated.class.getName()).log(Level.SEVERE, null, ex); } group = new InetSocketAddress(maddr, DIS_PORT); - ni = DisThreadedNetIF.findIpv4Interface(); + ni = DisThreadedNetworkInterface.findIpv4Interface(); baos = new ByteArrayOutputStream(); dos = new DataOutputStream(baos); } @@ -103,7 +103,7 @@ public class TrialDisMulticastNetworkingDeprecated { rsocket = new MulticastSocket(DIS_PORT); rsocket.joinGroup(group, ni); - buffer = new byte[DisThreadedNetIF.MAX_DIS_PDU_SIZE]; + buffer = new byte[DisThreadedNetworkInterface.MAX_DIS_PDU_SIZE]; packet = new DatagramPacket(buffer, buffer.length); //System.out.println("Listening on " + MCAST_GROUP + ":" + DIS_PORT + " if:" + socket.getNetworkInterface().getDisplayName()); diff --git a/src/edu/nps/moves/dis7/utilities/stream/PduRecorder.java b/src/edu/nps/moves/dis7/utilities/stream/PduRecorder.java index 511ef1de9edfe28edb899bb242c928216ea7d418..a208d25d0b611799e02289415b66e87dde39f0c3 100644 --- a/src/edu/nps/moves/dis7/utilities/stream/PduRecorder.java +++ b/src/edu/nps/moves/dis7/utilities/stream/PduRecorder.java @@ -3,7 +3,7 @@ package edu.nps.moves.dis7.utilities.stream; import com.google.common.primitives.Longs; import edu.nps.moves.dis7.enumerations.DISPDUType; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import java.io.BufferedWriter; @@ -50,13 +50,13 @@ public class PduRecorder implements PduReceiver private Writer logFileWriter; private File logFile; - private DisThreadedNetIF disThreadedNetIF; - private DisThreadedNetIF.RawPduListener disRawPduListener; + private DisThreadedNetworkInterface disThreadedNetIF; + private DisThreadedNetworkInterface.RawPduListener disRawPduListener; private Long startNanoTime = null; private final StringBuilder sb = new StringBuilder(); private final Base64.Encoder base64Encoder = Base64.getEncoder(); - private static int port = DisThreadedNetIF.DEFAULT_DIS_PORT; // self-test via port 1 when main() invoked + private static int port = DisThreadedNetworkInterface.DEFAULT_DIS_PORT; // self-test via port 1 when main() invoked private final int pduCount = 0; // debug private boolean headerWritten = false; private boolean running = true; // starts recording by default @@ -68,7 +68,7 @@ public class PduRecorder implements PduReceiver */ public PduRecorder() throws IOException { - this(outputDirectoryPath, DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS, port); + this(outputDirectoryPath, DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS, port); } /** @@ -80,7 +80,7 @@ public class PduRecorder implements PduReceiver */ public PduRecorder(String directoryPath) throws IOException { - this(directoryPath, DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS, DisThreadedNetIF.DEFAULT_DIS_PORT); + this(directoryPath, DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS, DisThreadedNetworkInterface.DEFAULT_DIS_PORT); } /** Constructor to let the user specify all required parameters @@ -97,11 +97,11 @@ public class PduRecorder implements PduReceiver logFile = createUniquePduLogFile(new File(outputPath).toPath(), DEFAULT_FILE_PREFIX + DISLOG_FILE_EXTENSION ); logFileWriter = new PrintWriter(new BufferedWriter(new FileWriter(logFile))); - disThreadedNetIF = new DisThreadedNetIF(port, multicastAddress); + disThreadedNetIF = new DisThreadedNetworkInterface(port, multicastAddress); - disRawPduListener = new DisThreadedNetIF.RawPduListener() { + disRawPduListener = new DisThreadedNetworkInterface.RawPduListener() { @Override - public void incomingPdu(DisThreadedNetIF.BuffAndLength bAndL) { + public void incomingPdu(DisThreadedNetworkInterface.BuffAndLength bAndL) { receivePdu(bAndL.buff, bAndL.length); } }; @@ -222,9 +222,9 @@ public class PduRecorder implements PduReceiver } /** - * @return an instance of this DisThreadedNetIF + * @return an instance of this DisThreadedNetworkInterface */ - public DisThreadedNetIF getDisThreadedNetIF() { + public DisThreadedNetworkInterface getDisThreadedNetIF() { return disThreadedNetIF; } diff --git a/test/edu/nps/moves/dis7/AllPduRoundTripTest.java b/test/edu/nps/moves/dis7/AllPduRoundTripTest.java index 610734435c0fcf2a5a0317039e18852094079861..72ae4f59e0c65ca486b8be5824cd03088c70f107 100644 --- a/test/edu/nps/moves/dis7/AllPduRoundTripTest.java +++ b/test/edu/nps/moves/dis7/AllPduRoundTripTest.java @@ -17,7 +17,7 @@ package edu.nps.moves.dis7; * @version $Id$ */ import edu.nps.moves.dis7.enumerations.Country; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import edu.nps.moves.dis7.utilities.stream.PduPlayer; import edu.nps.moves.dis7.utilities.stream.PduRecorder; @@ -32,8 +32,8 @@ import static org.junit.jupiter.api.Assertions.*; @DisplayName("All Pdu Round Trip Test") public class AllPduRoundTripTest { - DisThreadedNetIF disnetworking; - DisThreadedNetIF.PduListener lis; + DisThreadedNetworkInterface disNetworkInterface; + DisThreadedNetworkInterface.PduListener pduListener; List<Pdu> pdusSent = new ArrayList<>(); List<Pdu> pdusReceived = new ArrayList<>(); List<Pdu> pdusRead = new ArrayList<>(); @@ -148,7 +148,7 @@ public class AllPduRoundTripTest pdusSent.add(pduFactory.makeUnderwaterAcousticPdu()); pdusSent.forEach(p -> { - disnetworking.send(p); + disNetworkInterface.send(p); sleep(5l); // give receiver time to process }); @@ -176,12 +176,12 @@ public class AllPduRoundTripTest private void setupSenderRecorder() throws Exception { recorder = new PduRecorder(); // default mcaddr, port, logfile dir - disnetworking = recorder.getDisThreadedNetIF(); + disNetworkInterface = recorder.getDisThreadedNetIF(); - // When the DisThreadedNetIF receives a pdu, a call is made to the + // When the DisThreadedNetworkInterface receives a pdu, a call is made to the // everyTypeListeners which makes a lamba call back here to capture received // pdus - lis = new DisThreadedNetIF.PduListener() { + pduListener = new DisThreadedNetworkInterface.PduListener() { @Override public void incomingPdu(Pdu pdu) { if (!pdusReceived.contains(pdu)) { @@ -189,14 +189,14 @@ public class AllPduRoundTripTest } } }; - disnetworking.addListener(lis); + disNetworkInterface.addListener(pduListener); System.out.println("Recorder log at " + recorder.getLogFilePath()); } /** Will shutdown the common send/receive network interface */ private void shutDownSenderRecorder() throws Exception { - disnetworking.removeListener(lis); + disNetworkInterface.removeListener(pduListener); recorder.end(); } @@ -212,7 +212,7 @@ public class AllPduRoundTripTest { sem.acquire(); Path path = Path.of(recorder.getLogFilePath()).getParent(); - PduPlayer player = new PduPlayer(disnetworking.getMcastGroup(), disnetworking.getDisPort(), path, false); + PduPlayer player = new PduPlayer(disNetworkInterface.getMcastGroup(), disNetworkInterface.getDisPort(), path, false); player.addRawListener(ba -> { if (ba != null) { Pdu pdu = pduFactory.createPdu(ba); diff --git a/test/edu/nps/moves/dis7/BitFieldRoundTripTest.java b/test/edu/nps/moves/dis7/BitFieldRoundTripTest.java index 14208ca45406fbbb69e8f6ed12cb199364d7add0..7049dc40a7d281ff1f943efbcb283cb9ea945e21 100644 --- a/test/edu/nps/moves/dis7/BitFieldRoundTripTest.java +++ b/test/edu/nps/moves/dis7/BitFieldRoundTripTest.java @@ -7,7 +7,7 @@ package edu.nps.moves.dis7; import edu.nps.moves.dis7.enumerations.AppearanceCamouflageType; import edu.nps.moves.dis7.enumerations.ForceID; import edu.nps.moves.dis7.enumerations.LandPlatformAppearance; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -16,8 +16,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class BitFieldRoundTripTest { Pdu receivedPdu; - DisThreadedNetIF netif; - DisThreadedNetIF.PduListener lis; + DisThreadedNetworkInterface disNetworkInterface; + DisThreadedNetworkInterface.PduListener pduListener; @BeforeAll public static void setUpClass() @@ -33,22 +33,22 @@ public class BitFieldRoundTripTest @BeforeEach public void setUp() { - netif = new DisThreadedNetIF(); - lis = new DisThreadedNetIF.PduListener() { + disNetworkInterface = new DisThreadedNetworkInterface(); + pduListener = new DisThreadedNetworkInterface.PduListener() { @Override public void incomingPdu(Pdu pdu) { setUpReceiver(pdu); } }; - netif.addListener(lis); + disNetworkInterface.addListener(pduListener); } @AfterEach public void tearDown() { - netif.removeListener(lis); - netif.kill(); - netif = null; + disNetworkInterface.removeListener(pduListener); + disNetworkInterface.kill(); + disNetworkInterface = null; } @Test @@ -77,7 +77,7 @@ public class BitFieldRoundTripTest .set(LandPlatformAppearance.IS_FROZEN,1); try { - netif.send(espdu); + disNetworkInterface.send(espdu); Thread.sleep(100l); } catch (InterruptedException ex) { diff --git a/test/edu/nps/moves/dis7/CommentPdusTest.java b/test/edu/nps/moves/dis7/CommentPdusTest.java index 67e7fcabe5e180cf658bd0a3265ef95b37578415..3cb7083bde673088ea830849b03796c1ad8bc82d 100644 --- a/test/edu/nps/moves/dis7/CommentPdusTest.java +++ b/test/edu/nps/moves/dis7/CommentPdusTest.java @@ -5,7 +5,7 @@ package edu.nps.moves.dis7; import edu.nps.moves.dis7.enumerations.VariableRecordType; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; @@ -13,9 +13,9 @@ import static org.junit.jupiter.api.Assertions.*; @DisplayName("Comment Pdus Test") public class CommentPdusTest { - DisThreadedNetIF disThreadedNetworkInterface; - Pdu receivedPdu; - DisThreadedNetIF.PduListener pduListener; + DisThreadedNetworkInterface disNetworkInterface; + Pdu receivedPdu; + DisThreadedNetworkInterface.PduListener pduListener; @BeforeAll public static void setUpClass() @@ -31,22 +31,22 @@ public class CommentPdusTest @BeforeEach public void setUp() { - disThreadedNetworkInterface = new DisThreadedNetIF(); - pduListener = new DisThreadedNetIF.PduListener() { + disNetworkInterface = new DisThreadedNetworkInterface(); + pduListener = new DisThreadedNetworkInterface.PduListener() { @Override public void incomingPdu(Pdu newPdu) { setUpReceiver(newPdu); } }; - disThreadedNetworkInterface.addListener(pduListener); + disNetworkInterface.addListener(pduListener); } @AfterEach public void tearDown() { - disThreadedNetworkInterface.removeListener(pduListener); - disThreadedNetworkInterface.kill(); - disThreadedNetworkInterface = null; + disNetworkInterface.removeListener(pduListener); + disNetworkInterface.kill(); + disNetworkInterface = null; } @Test @@ -82,7 +82,7 @@ public class CommentPdusTest private void sendPdu(Pdu pdu) { try { - disThreadedNetworkInterface.send(pdu); + disNetworkInterface.send(pdu); Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally } catch (InterruptedException ex) { diff --git a/test/edu/nps/moves/dis7/DataQueryPduRoundTripTest.java b/test/edu/nps/moves/dis7/DataQueryPduRoundTripTest.java index d1e281f5d93614671b3865e91ca26ec5650e6098..76fa487530ead29444721b32c87de49f9d63f671 100644 --- a/test/edu/nps/moves/dis7/DataQueryPduRoundTripTest.java +++ b/test/edu/nps/moves/dis7/DataQueryPduRoundTripTest.java @@ -5,7 +5,7 @@ package edu.nps.moves.dis7; import edu.nps.moves.dis7.enumerations.VariableRecordType; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -15,8 +15,8 @@ public class DataQueryPduRoundTripTest { Pdu receivedPdu; - DisThreadedNetIF netif; - DisThreadedNetIF.PduListener lis; + DisThreadedNetworkInterface disNetworkInterface; + DisThreadedNetworkInterface.PduListener pduListener; @BeforeAll public static void setUpClass() @@ -32,22 +32,22 @@ public class DataQueryPduRoundTripTest @BeforeEach public void setUp() { - netif = new DisThreadedNetIF(); - lis = new DisThreadedNetIF.PduListener() { + disNetworkInterface = new DisThreadedNetworkInterface(); + pduListener = new DisThreadedNetworkInterface.PduListener() { @Override public void incomingPdu(Pdu pdu) { setUpReceiver(pdu); } }; - netif.addListener(lis); + disNetworkInterface.addListener(pduListener); } @AfterEach public void tearDown() { - netif.removeListener(lis); - netif.kill(); - netif = null; + disNetworkInterface.removeListener(pduListener); + disNetworkInterface.kill(); + disNetworkInterface = null; } private static int REQUEST_ID = 0x00112233; @@ -107,7 +107,7 @@ public class DataQueryPduRoundTripTest sendingPdu.getVariableDatums().add(variableDatum2); try { - netif.send(sendingPdu); + disNetworkInterface.send(sendingPdu); Thread.sleep(100l); } catch (InterruptedException ex) { diff --git a/test/edu/nps/moves/dis7/EntityStatePduTest.java b/test/edu/nps/moves/dis7/EntityStatePduTest.java index 9f8433857e3156df599a0fc20660a6e2cd6d771c..065f305d6c1e4e0cdd4377f783420b8f20b17f99 100644 --- a/test/edu/nps/moves/dis7/EntityStatePduTest.java +++ b/test/edu/nps/moves/dis7/EntityStatePduTest.java @@ -8,7 +8,7 @@ import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.entities.usa.munition.other.M1A2; import edu.nps.moves.dis7.enumerations.Country; import edu.nps.moves.dis7.enumerations.EntityKind; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import edu.nps.moves.dis7.enumerations.PlatformDomain; import org.junit.jupiter.api.*; @@ -17,9 +17,9 @@ import static org.junit.jupiter.api.Assertions.*; @DisplayName("Entity State Pdu Test") public class EntityStatePduTest { - DisThreadedNetIF disThreadedNetworkInterface; - Pdu receivedPdu; - DisThreadedNetIF.PduListener pduListener; + DisThreadedNetworkInterface disNetworkInterface; + Pdu receivedPdu; + DisThreadedNetworkInterface.PduListener pduListener; @BeforeAll public static void setUpClass() @@ -35,22 +35,22 @@ public class EntityStatePduTest @BeforeEach public void setUp() { - disThreadedNetworkInterface = new DisThreadedNetIF(); - pduListener = new DisThreadedNetIF.PduListener() { + disNetworkInterface = new DisThreadedNetworkInterface(); + pduListener = new DisThreadedNetworkInterface.PduListener() { @Override public void incomingPdu(Pdu newPdu) { setUpReceiver(newPdu); } }; - disThreadedNetworkInterface.addListener(pduListener); + disNetworkInterface.addListener(pduListener); } @AfterEach public void tearDown() { - disThreadedNetworkInterface.removeListener(pduListener); - disThreadedNetworkInterface.kill(); - disThreadedNetworkInterface = null; + disNetworkInterface.removeListener(pduListener); + disNetworkInterface.kill(); + disNetworkInterface = null; } @Test @@ -137,7 +137,7 @@ public class EntityStatePduTest private void sendPdu(Pdu pdu) { try { - disThreadedNetworkInterface.send(pdu); + disNetworkInterface.send(pdu); Thread.sleep(100); } catch (InterruptedException ex) { diff --git a/test/edu/nps/moves/dis7/FixedAndVariableDatumRoundTripTest.java b/test/edu/nps/moves/dis7/FixedAndVariableDatumRoundTripTest.java index 04d331d215ae9f482efee5c659573d5c47a51c97..e9f223b0c92a651abd458bdc1d7c07643119a6d0 100644 --- a/test/edu/nps/moves/dis7/FixedAndVariableDatumRoundTripTest.java +++ b/test/edu/nps/moves/dis7/FixedAndVariableDatumRoundTripTest.java @@ -5,7 +5,7 @@ package edu.nps.moves.dis7; import edu.nps.moves.dis7.enumerations.VariableRecordType; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -14,8 +14,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class FixedAndVariableDatumRoundTripTest { Pdu receivedPdu; - DisThreadedNetIF netif; - DisThreadedNetIF.PduListener lis; + DisThreadedNetworkInterface disNetworkInterface; + DisThreadedNetworkInterface.PduListener pduListener; @BeforeAll public static void setUpClass() @@ -31,22 +31,22 @@ public class FixedAndVariableDatumRoundTripTest @BeforeEach public void setUp() { - netif = new DisThreadedNetIF(); - lis = new DisThreadedNetIF.PduListener() { + disNetworkInterface = new DisThreadedNetworkInterface(); + pduListener = new DisThreadedNetworkInterface.PduListener() { @Override public void incomingPdu(Pdu pdu) { setUpReceiver(pdu); } }; - netif.addListener(lis); + disNetworkInterface.addListener(pduListener); } @AfterEach public void tearDown() { - netif.removeListener(lis); - netif.kill(); - netif = null; + disNetworkInterface.removeListener(pduListener); + disNetworkInterface.kill(); + disNetworkInterface = null; } private static FixedDatum fixedDatum1 = new FixedDatum(); @@ -99,7 +99,7 @@ public class FixedAndVariableDatumRoundTripTest sentPdu.getVariableDatums().add(variableDatum2); try { - netif.send(sentPdu); + disNetworkInterface.send(sentPdu); Thread.sleep(100l); } catch (InterruptedException ex) { diff --git a/test/edu/nps/moves/dis7/SignalPdusTest.java b/test/edu/nps/moves/dis7/SignalPdusTest.java index 93b61fbf3c802cc9d5b21f7324180b6fa4875b83..68088e21b1d28b81ac72a89e5ba8e7d341401cb2 100644 --- a/test/edu/nps/moves/dis7/SignalPdusTest.java +++ b/test/edu/nps/moves/dis7/SignalPdusTest.java @@ -4,7 +4,7 @@ */ package edu.nps.moves.dis7; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import edu.nps.moves.dis7.utilities.stream.PduPlayer; import edu.nps.moves.dis7.utilities.stream.PduRecorder; @@ -30,8 +30,8 @@ import static org.junit.jupiter.api.Assertions.*; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class SignalPdusTest { - static DisThreadedNetIF netif; - static DisThreadedNetIF.PduListener lis; + static DisThreadedNetworkInterface disNetworkInterface; + static DisThreadedNetworkInterface.PduListener pduListener; static List<Pdu> receivedPdus; static PduRecorder recorder; @@ -46,14 +46,14 @@ public class SignalPdusTest { System.out.println("SignalPdusTest"); recorder = new PduRecorder(); // default dir - netif = recorder.getDisThreadedNetIF(); - lis = new DisThreadedNetIF.PduListener() { + disNetworkInterface = recorder.getDisThreadedNetIF(); + pduListener = new DisThreadedNetworkInterface.PduListener() { @Override public void incomingPdu(Pdu pdu) { handleReceivedPdu(pdu); } }; - netif.addListener(lis); + disNetworkInterface.addListener(pduListener); mutex = new Semaphore(1); @@ -82,7 +82,7 @@ public class SignalPdusTest { sentPdus.add(pdu); sentPdus.forEach(p -> { - netif.send(p); + disNetworkInterface.send(p); sleep(5l); // give receiver time to process }); } @@ -98,8 +98,8 @@ public class SignalPdusTest { @AfterEach public void tearDown() throws IOException { - netif.removeListener(lis); - recorder.end(); // kills the netif as well + disNetworkInterface.removeListener(pduListener); + recorder.end(); // kills the disNetworkInterface as well } @Test @@ -135,7 +135,7 @@ public class SignalPdusTest { Path path = Path.of("./pduLog"); // Note: the player will playback all log files in the given path - PduPlayer player = new PduPlayer(DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS, DisThreadedNetIF.DEFAULT_DIS_PORT, path, false); + PduPlayer player = new PduPlayer(DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS, DisThreadedNetworkInterface.DEFAULT_DIS_PORT, path, false); player.addRawListener(ba -> { if (ba != null) assertNotNull(pduFac.createPdu(ba), "PDU creation failure"); diff --git a/test/edu/nps/moves/dis7/X3dInterpolatorsTest.java b/test/edu/nps/moves/dis7/X3dInterpolatorsTest.java index 90627816663d69faeac520455295de114937dc88..41132200af0bae0b1dfbfa63e0fc17893975d6ff 100644 --- a/test/edu/nps/moves/dis7/X3dInterpolatorsTest.java +++ b/test/edu/nps/moves/dis7/X3dInterpolatorsTest.java @@ -4,7 +4,7 @@ */ package edu.nps.moves.dis7; -import edu.nps.moves.dis7.utilities.DisThreadedNetIF; +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import edu.nps.moves.dis7.utilities.stream.PduPlayer; import java.io.File; @@ -62,10 +62,10 @@ public class X3dInterpolatorsTest { Path path = Path.of("./pduLog"); // Note: the player will playback all log files in the given path - PduPlayer player = new PduPlayer(DisThreadedNetIF.DEFAULT_MULTICAST_ADDRESS, DisThreadedNetIF.DEFAULT_DIS_PORT, path, true); - player.addRawListener(ba -> { + PduPlayer pduPlayer = new PduPlayer(DisThreadedNetworkInterface.DEFAULT_MULTICAST_ADDRESS, DisThreadedNetworkInterface.DEFAULT_DIS_PORT, path, true); + pduPlayer.addRawListener(ba -> { if (ba == null) { - player.end(); + pduPlayer.end(); mutex.release(); } });