diff --git a/assignments/ReportingForDuty.md b/assignments/ReportingForDuty.md index a9e8f574de7d83ade8d5f824d007eb577d06a72a..63133c27db6f17dc1e3a2c83a9cece78f555c542 100644 --- a/assignments/ReportingForDuty.md +++ b/assignments/ReportingForDuty.md @@ -24,4 +24,4 @@ More information on your use of Git is in the parent directory [README.md](../.. - Bert Knobeloch -- Tobias Brennenstuhl +- Tobias Brennenstuhl aka Sir Tobi diff --git a/assignments/nbproject/genfiles.properties b/assignments/nbproject/genfiles.properties index 8db6e92d16272035af6f8a5e7dfdeadb03984180..81515a0c3dec1f6ab1d66241d0881f2f5426139c 100644 --- a/assignments/nbproject/genfiles.properties +++ b/assignments/nbproject/genfiles.properties @@ -1,5 +1,5 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=5eaf4250 -nbproject/build-impl.xml.script.CRC32=013963da -nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=5eaf4250 +nbproject/build-impl.xml.script.CRC32=013963da +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/assignments/pduLog/Pdusave.dislog b/assignments/pduLog/Pdusave.dislog new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/AllPduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/AllPduReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..c934694a7290d6ed6939c08eac634b4954339d26 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/AllPduReceiver.java @@ -0,0 +1,95 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import MV3500Cohort2019JulySeptember.homework4.Brennenstuhl.test.*; +import java.net.*; +import java.io.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import edu.nps.moves.dis7.util.*; +import java.util.ArrayList; + +public class AllPduReceiver +{ + public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS; + public static final boolean USE_FAST_ESPDU = false; + + public static void main(String args[]) + { + PduFactory factory; + MulticastSocket socket; + InetAddress address; + DatagramPacket packet; + + try { + System.out.println("DisExamplesOpenDis7.AllPduReceiver started..."); + if (args.length == 2) { + socket = new MulticastSocket(Integer.parseInt(args[0])); + address = InetAddress.getByName(args[1]); + } + else { + System.out.println("Usage: AllPduReceiver <port> <multicast group>"); + System.out.println("Default: AllPduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + } + socket.joinGroup(address); + + factory = new PduFactory(); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[1500]; // typical MTU size + + packet = new DatagramPacket(buffer, buffer.length); // reset + + socket.receive(packet); + + Pdu pdu = factory.createPdu(packet.getData()); + if (pdu != null) + { + DISPDUType currentPduType = pdu.getPduType(); //short currentPduType = pdu.getPduType(); + String currentPduTypeName = pdu.getClass().getName(); + DISProtocolFamily currentProtocolFamilyID = pdu.getProtocolFamily(); //short currentProtocolFamilyID = pdu.getProtocolFamily(); + String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU "); + if (currentPduType.getValue() < 10) + message.append(" "); // column spacing + message.append(currentPduType.getValue()); + String currentPduTypePadded = String.format("%-34s", currentPduType); // - indicates right padding of whitespace + message.append(" " ).append(currentPduTypePadded); + String currentPduTypeNamePadded = String.format("%-49s", currentPduTypeName); // - indicates right padding of whitespace + message.append(" of type ").append(currentPduTypeNamePadded); // package.class name + message.append(" (protocolFamily ").append(currentProtocolFamilyID); + // message.append(" ").append(currentPduFamilyName); // class name is also available + message.append(")"); + System.out.println(message.toString()); + + switch (currentPduType) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType + { + case COMMENT: + CommentPdu commentPdu = (CommentPdu)pdu; // cast to precise type + ArrayList<VariableDatum> payloadList = (ArrayList)commentPdu.getVariableDatums(); + for (VariableDatum variableDatum : payloadList) + { + String nextComment = new String(variableDatum.getVariableDatumValue()); // convert byte[] to String + System.out.println("\"" + nextComment + "\""); + } + } + } + else + System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + } + } + catch (IOException e) { + System.out.println("Problem with DisExamplesOpenDis7.AllPduReceiver, see exception trace:"); + System.out.println(e); + } + finally { + System.out.println("DisExamplesOpenDis7.AllPduReceiver complete."); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/AllPduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/AllPduSender.java new file mode 100755 index 0000000000000000000000000000000000000000..ad0d8ec0791a797e77162434260b9e5d9920cda2 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/AllPduSender.java @@ -0,0 +1,152 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import MV3500Cohort2019JulySeptember.homework4.Brennenstuhl.test.*; +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; + +/** + * This is an example that sends many/most types of PDUs. Useful for testing standards + * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. + * Adapted from OpenDIS library example package edu.nps.moves.examples + * + * @author DMcG + * @version $Id:$ + */ +public class AllPduSender +{ + /** Default multicast group address we send on. */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; + + /** Default multicast port used, matches Wireshark DIS capture default */ + public static final int DEFAULT_MULTICAST_PORT = 3000; + + private int port; + InetAddress multicastAddress; + + public AllPduSender(int port, String multicast) { + try + { + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + if (!multicastAddress.isMulticastAddress()) + { + System.out.println("Not a multicast address: " + multicast); + } + } + catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + public void run() + { + + try + { + System.out.println("Generate PDUs and note issues, if any..."); + List<Pdu> generatedPdusList = new ArrayList<>(); + + // Loop through all the enumerated PDU types, create a PDU for each type, + // add that PDU to generatedPdusList, and send each one + +// System.out.println("PDU " + pdu.getValue() + " " + pdu.name() + " " + pdu.getDescription()); // diagnostic + + Pdu aPdu = null; // edu.​nps.​moves7.​dis.PDU superclass for all PDUs, in preparation for custom assignment + + + + + + + //*************************************************************************** + CommentPdu newCommentPdu = new CommentPdu(); + ArrayList<VariableDatum> payloadList = new ArrayList<VariableDatum>(); + + ArrayList<String> commentsList = new ArrayList<>(); + commentsList.add("Hello CommentPDU"); + commentsList.add("Chuck Norris is comming to town from IP-Adress " + DEFAULT_MULTICAST_ADDRESS + " with Port " + DEFAULT_MULTICAST_PORT); + + if (!commentsList.isEmpty()) + System.out.println("Preparing CommentPDU:"); + + for (String comment : commentsList) + { + VariableDatum newVariableDatum = new VariableDatum(); + newVariableDatum.setVariableDatumValue (comment.getBytes()); // conversion + //newVariableDatum.setVariableDatumLength(comment.getBytes().length * 8); // bits, not bytes, see spec and javadoc + // alternatively, you do not need to set this and the marshaller will figure it out from the byte array + // (see javadoc for VariableDatum.setVariableDatumLength()) + payloadList.add(newVariableDatum); + System.out.println(" \"" + comment + "\""); + } + newCommentPdu.setVariableDatums(payloadList); + + aPdu = newCommentPdu; // hand off for sending + //***************************************************************************** + + generatedPdusList.add(aPdu); + + + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdusList.size(); idx++) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + aPdu = generatedPdusList.get(idx); + try + { + aPdu.marshal(dos); + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + try { + Thread.sleep(100L); + } catch (InterruptedException ex) { + } + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print ("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded ); + System.out.println(" of type " + aPdu.getClass().getName()); + } + catch (Exception ex) { + System.out.println("Marshaling error" + ex); + } + } + // write the PDUs out to an XML file. + //PduContainer container = new PduContainer(); + //container.setPdus(generatedPdus); + //container.marshallToXml("examplePdus.xml"); + } + catch (IOException e) + { + System.out.println(e); + } + } + + public static void main(String args[]) + { + if (args.length == 2) + { + AllPduSender sender = new AllPduSender(Integer.parseInt(args[0]), args[1]); + sender.run(); + } + else + { + System.out.println("Usage: AllPduSender <port> <multicast group>"); + System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + AllPduSender sender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(); + } + System.out.println("DisExamplesOpenDis7.AllPduSender complete."); + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC1_MCAST_PduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC1_MCAST_PduReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..a07ab479d855a9231c6f29a5da7afb4886477501 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC1_MCAST_PduReceiver.java @@ -0,0 +1,80 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.net.*; +import java.io.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import edu.nps.moves.dis7.util.*; + +public class BRE_KNO_MCC_PC1_MCAST_PduReceiver +{ + public static final int DEFAULT_MULTICAST_PORT = BRE_KNO_MCC_PC1_MCAST_PduSender.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = BRE_KNO_MCC_PC1_MCAST_PduSender.DEFAULT_MULTICAST_ADDRESS; + public static final boolean USE_FAST_ESPDU = false; + + public static void main(String args[]) + { + PduFactory factory; + MulticastSocket socket; + InetAddress address; + DatagramPacket packet; + + try { + System.out.println("Knobeloch_PduReceiver started..."); + if (args.length == 2) { + socket = new MulticastSocket(Integer.parseInt(args[0])); + address = InetAddress.getByName(args[1]); + } + else { + System.out.println("Usage: AllPduReceiver <port> <multicast group>"); + System.out.println("Default: AllPduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + } + socket.joinGroup(address); + + factory = new PduFactory(); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[1500]; // typical MTU size + + packet = new DatagramPacket(buffer, buffer.length); // reset + + socket.receive(packet); + + Pdu pdu = factory.createPdu(packet.getData()); + if (pdu != null) { + DISPDUType currentPduType = pdu.getPduType(); //short currentPduType = pdu.getPduType(); + String currentPduTypeName = pdu.getClass().getName(); + DISProtocolFamily currentProtocolFamilyID = pdu.getProtocolFamily(); //short currentProtocolFamilyID = pdu.getProtocolFamily(); + //String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU "); + if (currentPduType.getValue() < 10) + message.append(" "); + message.append(currentPduType.getValue()); + String currentPduTypePadded = String.format("%-34s", currentPduType); // - indicates right padding of whitespace + message.append(" " ).append(currentPduTypePadded); + String currentPduTypeNamePadded = String.format("%-49s", currentPduTypeName); // - indicates right padding of whitespace + message.append(" of type ").append(currentPduTypeNamePadded); // package.class name + message.append(" (protocolFamily ").append(currentProtocolFamilyID); +// message.append(" ").append(currentPduFamilyName); // class name is also available + message.append(")"); + System.out.println(message.toString()); + } + else + System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + } + } + catch (IOException e) { + System.out.println("Problem with BRE_KNO_MCC_PC1_MCAST_PduReceiver, see exception trace:"); + System.out.println(e); + } + finally { + System.out.println("BRE_KNO_MCC_PC1_MCAST_PduReceiver complete."); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC1_MCAST_PduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC1_MCAST_PduSender.java new file mode 100755 index 0000000000000000000000000000000000000000..8cb5ac2f80c54ee687461dfccc2181477ed887f1 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC1_MCAST_PduSender.java @@ -0,0 +1,178 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This is an example that sends many/most types of PDUs. Useful for testing standards + * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. + * Adapted from OpenDIS library example package edu.nps.moves.examples + * + * @author DMcG + * @version $Id:$ + */ +public class BRE_KNO_MCC_PC1_MCAST_PduSender +{ + /** Default multicast group address we send on. */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; + + /** Default multicast port used, matches Wireshark DIS capture default */ + public static final int DEFAULT_MULTICAST_PORT = 2342; + + private int port; + InetAddress multicastAddress; + + public BRE_KNO_MCC_PC1_MCAST_PduSender(int port, String multicast) { + try + { + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + if (!multicastAddress.isMulticastAddress()) + { + System.out.println("Not a multicast address: " + multicast); + } + } + catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + public void run(int numbOfPDUS) + { + System.out.println("BRE_KNO_MCC_PC1_MCAST_PduSender started..."); + System.out.println("Generate PDUs and note issues, if any..."); + + List<Pdu> generatedPdusList = createPDU(numbOfPDUS); + + // Send the PDUs we created + System.out.println("Send the " + generatedPdusList.size() + " PDUs we created..."); + + try + { + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdusList.size(); idx++) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + Pdu aPdu = generatedPdusList.get(idx); + try { + aPdu.marshal(dos); + } catch (Exception ex) { + Logger.getLogger(BRE_KNO_MCC_PC1_MCAST_PduSender.class.getName()).log(Level.SEVERE, null, ex); + } + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + try { + Thread.sleep(100L); + } catch (InterruptedException ex) { + } + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print ("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded ); + System.out.println(" of type " + aPdu.getClass().getName()); + } + } + catch (IOException e) + { + System.out.println(e); + } + } + + public static void main(String args[]) + { + if (args.length == 2) + { + BRE_KNO_MCC_PC1_MCAST_PduSender sender = new BRE_KNO_MCC_PC1_MCAST_PduSender(Integer.parseInt(args[0]), args[1]); + sender.run(5); + } + else + { + System.out.println("Usage: BRE_KNO_MCC_PC1_MCAST_PduSender <port> <multicast group>"); + System.out.println("Default: BRE_KNO_MCC_PC1_MCAST_PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + BRE_KNO_MCC_PC1_MCAST_PduSender sender = new BRE_KNO_MCC_PC1_MCAST_PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(5); + } + System.out.println("BRE_KNO_MCC_PC1_MCAST_PduSender complete."); + } + + private List<Pdu> createPDU(int numbOfPDUs) + { + List<Pdu> list = new ArrayList<>(); + List<Short> entityIDs = new ArrayList<>(); + Random r = new Random(); + + //generate Entity ID (no douplications) + for (int i = 0; i < numbOfPDUs; i++) + { + short temp = (short) r.nextInt(); + while (entityIDs.contains(temp)) + { + temp = (short) r.nextInt(); + } + entityIDs.add(temp); + } + + // + for (int i = 0; i < numbOfPDUs; i++){ + EntityStatePdu myPdu = new EntityStatePdu(); + + //ID + EntityID tempID = new EntityID(); + tempID.setEntityID(entityIDs.get(i)); + myPdu.setEntityID(tempID); + + //Enemy or Friend + myPdu.setForceId(ForceID.FRIENDLY); + + //location + Vector3Double tempLoc = new Vector3Double(); + tempLoc.setX(r.nextInt(1000) + r.nextDouble()); + tempLoc.setY(r.nextInt(1000) + r.nextDouble()); + tempLoc.setZ(r.nextInt(1000) + r.nextDouble()); + + myPdu.setEntityLocation(tempLoc); + + //orientation + EulerAngles tempOri = new EulerAngles(); + tempOri.setPhi(r.nextFloat()); + tempOri.setPsi(r.nextFloat()); + tempOri.setTheta(r.nextFloat()); + + myPdu.setEntityOrientation(tempOri); + + + //velocity + Vector3Double tempVel = new Vector3Double(); + tempVel.setX(r.nextDouble()); + tempVel.setY(r.nextDouble()); + tempVel.setZ(r.nextDouble()); + + myPdu.setEntityLocation(tempVel); + + +// Category? Country? Domain?... +// EntityType tempType = new EntityType(); +// tempType.set +// myPdu.setEntityType(tempType) + + list.add(myPdu); + } + + + return list; + } +} + diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_MessageList.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_MessageList.java new file mode 100644 index 0000000000000000000000000000000000000000..c323c0aaf28c923f18832b9502be631483978039 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_MessageList.java @@ -0,0 +1,18 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.util.HashSet; + + +public class BRE_KNO_MCC_PC2_MCAST_MessageList { + + HashSet<String> savedMCASTMessages = new HashSet(); + + public void addMassage(String str){ + savedMCASTMessages.add(str); + } + + public HashSet<String> getSavedMCASTMessages(){ + HashSet<String> temp = new HashSet(savedMCASTMessages); + return temp; + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_PduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_PduReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..e392871b1835bc928ae6fd407c8ecad0345a8e4a --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_PduReceiver.java @@ -0,0 +1,82 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.net.*; +import java.io.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import edu.nps.moves.dis7.util.*; + +public class BRE_KNO_MCC_PC2_MCAST_PduReceiver +{ + public static final int DEFAULT_MULTICAST_PORT = BRE_KNO_MCC_PC2_MCAST_PduSender.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = BRE_KNO_MCC_PC2_MCAST_PduSender.DEFAULT_MULTICAST_ADDRESS; + public static final boolean USE_FAST_ESPDU = false; + + + public static void main(String args[]) + { + PduFactory factory; + MulticastSocket socket; + InetAddress address; + DatagramPacket packet; + + try { + + System.out.println("BRE_KNO_MCC_PC2_MCAST_PduReceiver started..."); + if (args.length == 2) { + socket = new MulticastSocket(Integer.parseInt(args[0])); + address = InetAddress.getByName(args[1]); + } + else { + System.out.println("Usage: BRE_KNO_MCC_PC2_MCAST_PduReceiver <port> <multicast group>"); + System.out.println("Default: BRE_KNO_MCC_PC2_MCAST_PduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + } + socket.joinGroup(address); + + factory = new PduFactory(); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[1500]; // typical MTU size + + packet = new DatagramPacket(buffer, buffer.length); // reset + + socket.receive(packet); + + Pdu pdu = factory.createPdu(packet.getData()); + if (pdu != null) { + DISPDUType currentPduType = pdu.getPduType(); //short currentPduType = pdu.getPduType(); + String currentPduTypeName = pdu.getClass().getName(); + DISProtocolFamily currentProtocolFamilyID = pdu.getProtocolFamily(); //short currentProtocolFamilyID = pdu.getProtocolFamily(); + //String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU "); + if (currentPduType.getValue() < 10) + message.append(" "); + message.append(currentPduType.getValue()); + String currentPduTypePadded = String.format("%-34s", currentPduType); // - indicates right padding of whitespace + message.append(" " ).append(currentPduTypePadded); + String currentPduTypeNamePadded = String.format("%-49s", currentPduTypeName); // - indicates right padding of whitespace + message.append(" of type ").append(currentPduTypeNamePadded); // package.class name + message.append(" (protocolFamily ").append(currentProtocolFamilyID); +// message.append(" ").append(currentPduFamilyName); // class name is also available + message.append(")"); + System.out.println(message.toString()); + } + else + System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + } + } + catch (IOException e) { + System.out.println("Problem with BRE_KNO_MCC_PC2_MCAST_PduReceiver, see exception trace:"); + System.out.println(e); + } + finally { + System.out.println("BRE_KNO_MCC_PC2_MCAST_PduReceiver complete."); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_PduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_PduSender.java new file mode 100755 index 0000000000000000000000000000000000000000..e7b704fe6e2ed66dffae4c4a2c23570c23ab40aa --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_MCAST_PduSender.java @@ -0,0 +1,178 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This is an example that sends many/most types of PDUs. Useful for testing standards + * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. + * Adapted from OpenDIS library example package edu.nps.moves.examples + * + * @author DMcG + * @version $Id:$ + */ +public class BRE_KNO_MCC_PC2_MCAST_PduSender +{ + /** Default multicast group address we send on. */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; + + /** Default multicast port used, matches Wireshark DIS capture default */ + public static final int DEFAULT_MULTICAST_PORT = 2342; + + private int port; + InetAddress multicastAddress; + + public BRE_KNO_MCC_PC2_MCAST_PduSender(int port, String multicast) { + try + { + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + if (!multicastAddress.isMulticastAddress()) + { + System.out.println("Not a multicast address: " + multicast); + } + } + catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + public void run(int numbOfPDUS) + { + System.out.println("BRE_KNO_MCC_PC2_MCAST_PduSender started..."); + System.out.println("Generate PDUs and note issues, if any..."); + + List<Pdu> generatedPdusList = createPDU(numbOfPDUS); + + // Send the PDUs we created + System.out.println("Send the " + generatedPdusList.size() + " PDUs we created..."); + + try + { + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdusList.size(); idx++) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + Pdu aPdu = generatedPdusList.get(idx); + try { + aPdu.marshal(dos); + } catch (Exception ex) { + Logger.getLogger(BRE_KNO_MCC_PC2_MCAST_PduSender.class.getName()).log(Level.SEVERE, null, ex); + } + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + try { + Thread.sleep(100L); + } catch (InterruptedException ex) { + } + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print ("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded ); + System.out.println(" of type " + aPdu.getClass().getName()); + } + } + catch (IOException e) + { + System.out.println(e); + } + } + + public static void main(String args[]) + { + if (args.length == 2) + { + BRE_KNO_MCC_PC2_MCAST_PduSender sender = new BRE_KNO_MCC_PC2_MCAST_PduSender(Integer.parseInt(args[0]), args[1]); + sender.run(5); + } + else + { + System.out.println("Usage: BRE_KNO_MCC_PC2_MCAST_PduSender <port> <multicast group>"); + System.out.println("Default: BRE_KNO_MCC_PC2_MCAST_PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + BRE_KNO_MCC_PC2_MCAST_PduSender sender = new BRE_KNO_MCC_PC2_MCAST_PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(5); + } + System.out.println("BRE_KNO_MCC_PC2_MCAST_PduSender complete."); + } + + private List<Pdu> createPDU(int numbOfPDUs) + { + List<Pdu> list = new ArrayList<>(); + List<Short> entityIDs = new ArrayList<>(); + Random r = new Random(); + + //generate Entity ID (no douplications) + for (int i = 0; i < numbOfPDUs; i++) + { + short temp = (short) r.nextInt(); + while (entityIDs.contains(temp)) + { + temp = (short) r.nextInt(); + } + entityIDs.add(temp); + } + + // + for (int i = 0; i < numbOfPDUs; i++){ + EntityStatePdu myPdu = new EntityStatePdu(); + + //ID + EntityID tempID = new EntityID(); + tempID.setEntityID(entityIDs.get(i)); + myPdu.setEntityID(tempID); + + //Enemy or Friend + myPdu.setForceId(ForceID.FRIENDLY); + + //location + Vector3Double tempLoc = new Vector3Double(); + tempLoc.setX(r.nextInt(1000) + r.nextDouble()); + tempLoc.setY(r.nextInt(1000) + r.nextDouble()); + tempLoc.setZ(r.nextInt(1000) + r.nextDouble()); + + myPdu.setEntityLocation(tempLoc); + + //orientation + EulerAngles tempOri = new EulerAngles(); + tempOri.setPhi(r.nextFloat()); + tempOri.setPsi(r.nextFloat()); + tempOri.setTheta(r.nextFloat()); + + myPdu.setEntityOrientation(tempOri); + + + //velocity + Vector3Double tempVel = new Vector3Double(); + tempVel.setX(r.nextDouble()); + tempVel.setY(r.nextDouble()); + tempVel.setZ(r.nextDouble()); + + myPdu.setEntityLocation(tempVel); + + +// Category? Country? Domain?... +// EntityType tempType = new EntityType(); +// tempType.set +// myPdu.setEntityType(tempType) + + list.add(myPdu); + } + + + return list; + } +} + diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_MessageList.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_MessageList.java new file mode 100644 index 0000000000000000000000000000000000000000..7893cbe8c5ebc5aadc23d6fef8af45376be5ce88 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_MessageList.java @@ -0,0 +1,18 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.util.HashSet; + + +public class BRE_KNO_MCC_PC2_UNICAST_MessageList { + + HashSet<String> savedUNICASTMessages = new HashSet(); + + public void addMassage(String str){ + savedUNICASTMessages.add(str); + } + + public HashSet<String> getSavedUNICASTMessages(){ + HashSet<String> temp = new HashSet(savedUNICASTMessages); + return temp; + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_PduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_PduReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..ddd25ac2dd90351d8179037a53d0520abdf4342a --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_PduReceiver.java @@ -0,0 +1,81 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import MV3500Cohort2019JulySeptember.homework4.Knobeloch.*; +import java.net.*; +import java.io.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import edu.nps.moves.dis7.util.*; + +public class BRE_KNO_MCC_PC2_UNICAST_PduReceiver +{ + public static final int DEFAULT_MULTICAST_PORT = BRE_KNO_MCC_PC2_UNICAST_PduSender.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = BRE_KNO_MCC_PC2_UNICAST_PduSender.DEFAULT_MULTICAST_ADDRESS; + public static final boolean USE_FAST_ESPDU = false; + + public static void main(String args[]) + { + PduFactory factory; + MulticastSocket socket; + InetAddress address; + DatagramPacket packet; + + try { + System.out.println("BRE_KNO_MCC_PC2_UNICAST_PduReceiver started..."); + if (args.length == 2) { + socket = new MulticastSocket(Integer.parseInt(args[0])); + address = InetAddress.getByName(args[1]); + } + else { + System.out.println("Usage: BRE_KNO_MCC_PC2_UNICAST_PduReceiver <port> <multicast group>"); + System.out.println("Default: BRE_KNO_MCC_PC2_UNICAST_PduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + } + socket.joinGroup(address); + + factory = new PduFactory(); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[1500]; // typical MTU size + + packet = new DatagramPacket(buffer, buffer.length); // reset + + socket.receive(packet); + + Pdu pdu = factory.createPdu(packet.getData()); + if (pdu != null) { + DISPDUType currentPduType = pdu.getPduType(); //short currentPduType = pdu.getPduType(); + String currentPduTypeName = pdu.getClass().getName(); + DISProtocolFamily currentProtocolFamilyID = pdu.getProtocolFamily(); //short currentProtocolFamilyID = pdu.getProtocolFamily(); + //String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU "); + if (currentPduType.getValue() < 10) + message.append(" "); + message.append(currentPduType.getValue()); + String currentPduTypePadded = String.format("%-34s", currentPduType); // - indicates right padding of whitespace + message.append(" " ).append(currentPduTypePadded); + String currentPduTypeNamePadded = String.format("%-49s", currentPduTypeName); // - indicates right padding of whitespace + message.append(" of type ").append(currentPduTypeNamePadded); // package.class name + message.append(" (protocolFamily ").append(currentProtocolFamilyID); +// message.append(" ").append(currentPduFamilyName); // class name is also available + message.append(")"); + System.out.println(message.toString()); + } + else + System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + } + } + catch (IOException e) { + System.out.println("Problem with BRE_KNO_MCC_PC2_UNICAST_PduReceiver, see exception trace:"); + System.out.println(e); + } + finally { + System.out.println("BRE_KNO_MCC_PC2_UNICAST_PduReceiver complete."); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_PduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_PduSender.java new file mode 100755 index 0000000000000000000000000000000000000000..1b57b522bc168a47df788ef924048e8bdeda862b --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC2_UNICAST_PduSender.java @@ -0,0 +1,178 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This is an example that sends many/most types of PDUs. Useful for testing standards + * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. + * Adapted from OpenDIS library example package edu.nps.moves.examples + * + * @author DMcG + * @version $Id:$ + */ +public class BRE_KNO_MCC_PC2_UNICAST_PduSender +{ + /** Default multicast group address we send on. */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; + + /** Default multicast port used, matches Wireshark DIS capture default */ + public static final int DEFAULT_MULTICAST_PORT = 2343; + + private int port; + InetAddress multicastAddress; + + public BRE_KNO_MCC_PC2_UNICAST_PduSender(int port, String multicast) { + try + { + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + if (!multicastAddress.isMulticastAddress()) + { + System.out.println("Not a multicast address: " + multicast); + } + } + catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + public void run(int numbOfPDUS) + { + System.out.println("BRE_KNO_MCC_PC2_UNICAST_PduSender started..."); + System.out.println("Generate PDUs and note issues, if any..."); + + List<Pdu> generatedPdusList = createPDU(numbOfPDUS); + + // Send the PDUs we created + System.out.println("Send the " + generatedPdusList.size() + " PDUs we created..."); + + try + { + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdusList.size(); idx++) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + Pdu aPdu = generatedPdusList.get(idx); + try { + aPdu.marshal(dos); + } catch (Exception ex) { + Logger.getLogger(BRE_KNO_MCC_PC2_UNICAST_PduSender.class.getName()).log(Level.SEVERE, null, ex); + } + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + try { + Thread.sleep(100L); + } catch (InterruptedException ex) { + } + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print ("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded ); + System.out.println(" of type " + aPdu.getClass().getName()); + } + } + catch (IOException e) + { + System.out.println(e); + } + } + + public static void main(String args[]) + { + if (args.length == 2) + { + BRE_KNO_MCC_PC2_UNICAST_PduSender sender = new BRE_KNO_MCC_PC2_UNICAST_PduSender(Integer.parseInt(args[0]), args[1]); + sender.run(5); + } + else + { + System.out.println("Usage: BRE_KNO_MCC_PC2_UNICAST_PduSender <port> <multicast group>"); + System.out.println("Default: BRE_KNO_MCC_PC2_UNICAST_PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + BRE_KNO_MCC_PC2_UNICAST_PduSender sender = new BRE_KNO_MCC_PC2_UNICAST_PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(5); + } + System.out.println("BRE_KNO_MCC_PC2_UNICAST_PduSender complete."); + } + + private List<Pdu> createPDU(int numbOfPDUs) + { + List<Pdu> list = new ArrayList<>(); + List<Short> entityIDs = new ArrayList<>(); + Random r = new Random(); + + //generate Entity ID (no douplications) + for (int i = 0; i < numbOfPDUs; i++) + { + short temp = (short) r.nextInt(); + while (entityIDs.contains(temp)) + { + temp = (short) r.nextInt(); + } + entityIDs.add(temp); + } + + // + for (int i = 0; i < numbOfPDUs; i++){ + EntityStatePdu myPdu = new EntityStatePdu(); + + //ID + EntityID tempID = new EntityID(); + tempID.setEntityID(entityIDs.get(i)); + myPdu.setEntityID(tempID); + + //Enemy or Friend + myPdu.setForceId(ForceID.FRIENDLY); + + //location + Vector3Double tempLoc = new Vector3Double(); + tempLoc.setX(r.nextInt(1000) + r.nextDouble()); + tempLoc.setY(r.nextInt(1000) + r.nextDouble()); + tempLoc.setZ(r.nextInt(1000) + r.nextDouble()); + + myPdu.setEntityLocation(tempLoc); + + //orientation + EulerAngles tempOri = new EulerAngles(); + tempOri.setPhi(r.nextFloat()); + tempOri.setPsi(r.nextFloat()); + tempOri.setTheta(r.nextFloat()); + + myPdu.setEntityOrientation(tempOri); + + + //velocity + Vector3Double tempVel = new Vector3Double(); + tempVel.setX(r.nextDouble()); + tempVel.setY(r.nextDouble()); + tempVel.setZ(r.nextDouble()); + + myPdu.setEntityLocation(tempVel); + + +// Category? Country? Domain?... +// EntityType tempType = new EntityType(); +// tempType.set +// myPdu.setEntityType(tempType) + + list.add(myPdu); + } + + + return list; + } +} + diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC3_UNICAST_PduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC3_UNICAST_PduReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..21cdae780eab9582a7e979cda1f0193d1bd8be8e --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC3_UNICAST_PduReceiver.java @@ -0,0 +1,80 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.net.*; +import java.io.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import edu.nps.moves.dis7.util.*; + +public class BRE_KNO_MCC_PC3_UNICAST_PduReceiver +{ + public static final int DEFAULT_MULTICAST_PORT = BRE_KNO_MCC_PC3_UNICAST_PduSender.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = BRE_KNO_MCC_PC3_UNICAST_PduSender.DEFAULT_MULTICAST_ADDRESS; + public static final boolean USE_FAST_ESPDU = false; + + public static void main(String args[]) + { + PduFactory factory; + MulticastSocket socket; + InetAddress address; + DatagramPacket packet; + + try { + System.out.println("BRE_KNO_MCC_PC3_UNICAST_PduReceiver started..."); + if (args.length == 2) { + socket = new MulticastSocket(Integer.parseInt(args[0])); + address = InetAddress.getByName(args[1]); + } + else { + System.out.println("Usage: BRE_KNO_MCC_PC3_UNICAST_PduReceiver <port> <multicast group>"); + System.out.println("Default: BRE_KNO_MCC_PC3_UNICAST_PduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + } + socket.joinGroup(address); + + factory = new PduFactory(); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[1500]; // typical MTU size + + packet = new DatagramPacket(buffer, buffer.length); // reset + + socket.receive(packet); + + Pdu pdu = factory.createPdu(packet.getData()); + if (pdu != null) { + DISPDUType currentPduType = pdu.getPduType(); //short currentPduType = pdu.getPduType(); + String currentPduTypeName = pdu.getClass().getName(); + DISProtocolFamily currentProtocolFamilyID = pdu.getProtocolFamily(); //short currentProtocolFamilyID = pdu.getProtocolFamily(); + //String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU "); + if (currentPduType.getValue() < 10) + message.append(" "); + message.append(currentPduType.getValue()); + String currentPduTypePadded = String.format("%-34s", currentPduType); // - indicates right padding of whitespace + message.append(" " ).append(currentPduTypePadded); + String currentPduTypeNamePadded = String.format("%-49s", currentPduTypeName); // - indicates right padding of whitespace + message.append(" of type ").append(currentPduTypeNamePadded); // package.class name + message.append(" (protocolFamily ").append(currentProtocolFamilyID); +// message.append(" ").append(currentPduFamilyName); // class name is also available + message.append(")"); + System.out.println(message.toString()); + } + else + System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + } + } + catch (IOException e) { + System.out.println("Problem with BRE_KNO_MCC_PC3_UNICAST_PduReceiver, see exception trace:"); + System.out.println(e); + } + finally { + System.out.println("BRE_KNO_MCC_PC3_UNICAST_PduReceiver complete."); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC3_UNICAST_PduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC3_UNICAST_PduSender.java new file mode 100755 index 0000000000000000000000000000000000000000..34d19cefd81e7bec5a9d62c68cb80c12f9a0051b --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework2/Brennenstuhl/BRE_KNO_MCC/BRE_KNO_MCC_PC3_UNICAST_PduSender.java @@ -0,0 +1,178 @@ +package MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This is an example that sends many/most types of PDUs. Useful for testing standards + * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. + * Adapted from OpenDIS library example package edu.nps.moves.examples + * + * @author DMcG + * @version $Id:$ + */ +public class BRE_KNO_MCC_PC3_UNICAST_PduSender +{ + /** Default multicast group address we send on. */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; + + /** Default multicast port used, matches Wireshark DIS capture default */ + public static final int DEFAULT_MULTICAST_PORT = 2343; + + private int port; + InetAddress multicastAddress; + + public BRE_KNO_MCC_PC3_UNICAST_PduSender(int port, String multicast) { + try + { + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + if (!multicastAddress.isMulticastAddress()) + { + System.out.println("Not a multicast address: " + multicast); + } + } + catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + public void run(int numbOfPDUS) + { + System.out.println("BRE_KNO_MCC_PC3_UNICAST_PduSender started..."); + System.out.println("Generate PDUs and note issues, if any..."); + + List<Pdu> generatedPdusList = createPDU(numbOfPDUS); + + // Send the PDUs we created + System.out.println("Send the " + generatedPdusList.size() + " PDUs we created..."); + + try + { + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdusList.size(); idx++) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + Pdu aPdu = generatedPdusList.get(idx); + try { + aPdu.marshal(dos); + } catch (Exception ex) { + Logger.getLogger(BRE_KNO_MCC_PC3_UNICAST_PduSender.class.getName()).log(Level.SEVERE, null, ex); + } + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + try { + Thread.sleep(100L); + } catch (InterruptedException ex) { + } + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print ("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded ); + System.out.println(" of type " + aPdu.getClass().getName()); + } + } + catch (IOException e) + { + System.out.println(e); + } + } + + public static void main(String args[]) + { + if (args.length == 2) + { + BRE_KNO_MCC_PC3_UNICAST_PduSender sender = new BRE_KNO_MCC_PC3_UNICAST_PduSender(Integer.parseInt(args[0]), args[1]); + sender.run(5); + } + else + { + System.out.println("Usage: BRE_KNO_MCC_PC3_UNICAST_PduSender <port> <multicast group>"); + System.out.println("Default: BRE_KNO_MCC_PC3_UNICAST_PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + BRE_KNO_MCC_PC3_UNICAST_PduSender sender = new BRE_KNO_MCC_PC3_UNICAST_PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(5); + } + System.out.println("BRE_KNO_MCC_PC3_UNICAST_PduSender complete."); + } + + private List<Pdu> createPDU(int numbOfPDUs) + { + List<Pdu> list = new ArrayList<>(); + List<Short> entityIDs = new ArrayList<>(); + Random r = new Random(); + + //generate Entity ID (no douplications) + for (int i = 0; i < numbOfPDUs; i++) + { + short temp = (short) r.nextInt(); + while (entityIDs.contains(temp)) + { + temp = (short) r.nextInt(); + } + entityIDs.add(temp); + } + + // + for (int i = 0; i < numbOfPDUs; i++){ + EntityStatePdu myPdu = new EntityStatePdu(); + + //ID + EntityID tempID = new EntityID(); + tempID.setEntityID(entityIDs.get(i)); + myPdu.setEntityID(tempID); + + //Enemy or Friend + myPdu.setForceId(ForceID.FRIENDLY); + + //location + Vector3Double tempLoc = new Vector3Double(); + tempLoc.setX(r.nextInt(1000) + r.nextDouble()); + tempLoc.setY(r.nextInt(1000) + r.nextDouble()); + tempLoc.setZ(r.nextInt(1000) + r.nextDouble()); + + myPdu.setEntityLocation(tempLoc); + + //orientation + EulerAngles tempOri = new EulerAngles(); + tempOri.setPhi(r.nextFloat()); + tempOri.setPsi(r.nextFloat()); + tempOri.setTheta(r.nextFloat()); + + myPdu.setEntityOrientation(tempOri); + + + //velocity + Vector3Double tempVel = new Vector3Double(); + tempVel.setX(r.nextDouble()); + tempVel.setY(r.nextDouble()); + tempVel.setZ(r.nextDouble()); + + myPdu.setEntityLocation(tempVel); + + +// Category? Country? Domain?... +// EntityType tempType = new EntityType(); +// tempType.set +// myPdu.setEntityType(tempType) + + list.add(myPdu); + } + + + return list; + } +} + diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework3/MV3500 Group Excercise.pdf b/assignments/src/MV3500Cohort2019JulySeptember/homework3/MV3500 Group Excercise.pdf new file mode 100644 index 0000000000000000000000000000000000000000..bed3c7ad844ccf2bf375293a938ba6d3eebed77a Binary files /dev/null and b/assignments/src/MV3500Cohort2019JulySeptember/homework3/MV3500 Group Excercise.pdf differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlEspduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlEspduReceiver.java index 193a90192daf388746509ef0253b32f4f533ba70..1dd070ebf7e565f59ff86c0ce5d8a6ea2af71823 100755 --- a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlEspduReceiver.java +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlEspduReceiver.java @@ -22,16 +22,17 @@ public class BrennenstuhlEspduReceiver public static final int MAX_PDU_SIZE = 8192; /** Default multicast group address we send on. */ - public static final String DEFAULT_MULTICAST_ADDRESS = BrennenstuhllEspduSender.DEFAULT_MULTICAST_ADDRESS; + public static final String DEFAULT_MULTICAST_ADDRESS = BrennenstuhlEspduSender.DEFAULT_MULTICAST_ADDRESS; /** Default multicast port used, matches Wireshark DIS capture default */ - public static final int DEFAULT_MULTICAST_PORT = BrennenstuhllEspduSender.DEFAULT_MULTICAST_PORT; + public static final int DEFAULT_MULTICAST_PORT = BrennenstuhlEspduSender.DEFAULT_MULTICAST_PORT; public static void main(String args[]) { System.out.println("DisExamplesOpenDis7.EspduReceiver started..."); MulticastSocket socket; + DatagramPacket packet; InetAddress address; PduFactory pduFactory = new PduFactory(); diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhllEspduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlEspduSender.java similarity index 99% rename from assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhllEspduSender.java rename to assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlEspduSender.java index 34cdf054a3df839f460cbdd27ee712caf2dd0688..c219d3e7a866b0cec3ec2738224af6eda8a86766 100644 --- a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhllEspduSender.java +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlEspduSender.java @@ -17,9 +17,10 @@ import edu.nps.moves.dis7.enumerations.PlatformDomain; * @author Don McGregor * @author Don Brutzman */ -public class BrennenstuhllEspduSender +public class BrennenstuhlEspduSender { public static final int NUMBER_TO_SEND = 5; // 5000 + /** * Default multicast group address we send on. diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlSave5.dislog b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlSave5.dislog new file mode 100644 index 0000000000000000000000000000000000000000..3a77f83e66fd2f8517d611c8b2a414bea0e3a20b --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/BrennenstuhlSave5.dislog @@ -0,0 +1,9 @@ +!Begin!Beginning of DIS capture file, Pdusave5.dislog. +AAAAAAAAAAA=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFEqBAvE0/7wVCboK8OPnFBTNmlKP7JIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAFpF86g=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFEqBJ2pXaEwVCbn/mZDlxBTNmlKP7JIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAH6chEw=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFEqBJ2pXaEwVCbn/mZDlxBTNmlKP7JIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAALPTqOg=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFEqBAvE0/7wVCboK8OPnFBTNmlKP7JIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAQ+HHuA=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFEqBJ2pXaEwVCbn/mZDlxBTNmlKP7JIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAATPChgA=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFEqBJ2pXaEwVCbn/mZDlxBTNmlKP7JIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAWfrQ/Q=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFEqBAvE0/7wVCboK8OPnFBTNmlKP7JIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +!End!End of DIS capture file, Pdusave5.dislog. diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Log.PNG b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Log.PNG new file mode 100644 index 0000000000000000000000000000000000000000..4bdfdc98bc4e2455b40a8d10b1984ae1a5992e14 Binary files /dev/null and b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Log.PNG differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/AllPduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/AllPduReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..b8e71805e324ff2e6d4fb65a52d290712dfff9ba --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/AllPduReceiver.java @@ -0,0 +1,94 @@ +package MV3500Cohort2019JulySeptember.homework4.Brennenstuhl.test; + +import java.net.*; +import java.io.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import edu.nps.moves.dis7.util.*; +import java.util.ArrayList; + +public class AllPduReceiver +{ + public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS; + public static final boolean USE_FAST_ESPDU = false; + + public static void main(String args[]) + { + PduFactory factory; + MulticastSocket socket; + InetAddress address; + DatagramPacket packet; + + try { + + if (args.length == 2) { + socket = new MulticastSocket(Integer.parseInt(args[0])); + address = InetAddress.getByName(args[1]); + } + else { + System.out.println("Usage: AllPduReceiver <port> <multicast group>"); + System.out.println("Default: AllPduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + } + socket.joinGroup(address); + + factory = new PduFactory(); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[1500]; // typical MTU size + + packet = new DatagramPacket(buffer, buffer.length); // reset + + socket.receive(packet); + + Pdu pdu = factory.createPdu(packet.getData()); + if (pdu != null) + { + DISPDUType currentPduType = pdu.getPduType(); //short currentPduType = pdu.getPduType(); + String currentPduTypeName = pdu.getClass().getName(); + DISProtocolFamily currentProtocolFamilyID = pdu.getProtocolFamily(); //short currentProtocolFamilyID = pdu.getProtocolFamily(); + String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU "); + if (currentPduType.getValue() < 10) + message.append(" "); // column spacing + message.append(currentPduType.getValue()); + String currentPduTypePadded = String.format("%-34s", currentPduType); // - indicates right padding of whitespace + message.append(" " ).append(currentPduTypePadded); + String currentPduTypeNamePadded = String.format("%-49s", currentPduTypeName); // - indicates right padding of whitespace + message.append(" of type ").append(currentPduTypeNamePadded); // package.class name + message.append(" (protocolFamily ").append(currentProtocolFamilyID); + // message.append(" ").append(currentPduFamilyName); // class name is also available + message.append(")"); + System.out.println(message.toString()); + + switch (currentPduType) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType + { + case COMMENT: + CommentPdu commentPdu = (CommentPdu)pdu; // cast to precise type + ArrayList<VariableDatum> payloadList = (ArrayList)commentPdu.getVariableDatums(); + for (VariableDatum variableDatum : payloadList) + { + String nextComment = new String(variableDatum.getVariableDatumValue()); // convert byte[] to String + System.out.println("\"" + nextComment + "\""); + } + } + } + else + System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + } + } + catch (IOException e) { + System.out.println("Problem with DisExamplesOpenDis7.AllPduReceiver, see exception trace:"); + System.out.println(e); + } + finally { + //System.out.println("DisExamplesOpenDis7.AllPduReceiver complete."); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/AllPduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/AllPduSender.java new file mode 100755 index 0000000000000000000000000000000000000000..a1607920c29d1843ec83854ee99368a7e301e8e9 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/AllPduSender.java @@ -0,0 +1,141 @@ +package MV3500Cohort2019JulySeptember.homework4.Brennenstuhl.test; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; + +/** + * This is an example that sends many/most types of PDUs. Useful for testing standards + * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. + * Adapted from OpenDIS library example package edu.nps.moves.examples + * + * @author DMcG + * @version $Id:$ + */ +public class AllPduSender +{ + /** Default multicast group address we send on. */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; + + /** Default multicast port used, matches Wireshark DIS capture default */ + public static final int DEFAULT_MULTICAST_PORT = 3000; + + private int port; + InetAddress multicastAddress; + + public AllPduSender(int port, String multicast) { + try + { + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + if (!multicastAddress.isMulticastAddress()) + { + System.out.println("Not a multicast address: " + multicast); + } + } + catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + public void run() + { + + try + { + System.out.println("Generate PDUs and note issues, if any..."); + List<Pdu> generatedPdusList = new ArrayList<>(); + + // Loop through all the enumerated PDU types, create a PDU for each type, + // add that PDU to generatedPdusList, and send each one + +// System.out.println("PDU " + pdu.getValue() + " " + pdu.name() + " " + pdu.getDescription()); // diagnostic + + Pdu aPdu = null; // edu.​nps.​moves7.​dis.PDU superclass for all PDUs, in preparation for custom assignment + + + //*************************************************************************** + CommentPdu newCommentPdu = new CommentPdu(); + ArrayList<VariableDatum> payloadList = new ArrayList<VariableDatum>(); + + ArrayList<String> commentsList = new ArrayList<>(); + commentsList.add("Hello CommentPDU"); + commentsList.add("Chuck Norris is comming to town from IP-Adress " + DEFAULT_MULTICAST_ADDRESS + " with Port " + DEFAULT_MULTICAST_PORT); + + for (String comment : commentsList) + { + VariableDatum newVariableDatum = new VariableDatum(); + newVariableDatum.setVariableDatumValue (comment.getBytes()); + payloadList.add(newVariableDatum); + System.out.println(" \"" + comment + "\""); + } + newCommentPdu.setVariableDatums(payloadList); + + aPdu = newCommentPdu; // hand off for sending + //***************************************************************************** + + generatedPdusList.add(aPdu); + + + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdusList.size(); idx++) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + aPdu = generatedPdusList.get(idx); + try + { + aPdu.marshal(dos); + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + try { + Thread.sleep(100L); + } catch (InterruptedException ex) { + } + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print ("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded ); + System.out.println(" of type " + aPdu.getClass().getName()); + } + catch (Exception ex) { + System.out.println("Marshaling error" + ex); + } + } + // write the PDUs out to an XML file. + //PduContainer container = new PduContainer(); + //container.setPdus(generatedPdus); + //container.marshallToXml("examplePdus.xml"); + } + catch (IOException e) + { + System.out.println(e); + } + } + + public static void main(String args[]) + { + if (args.length == 2) + { + AllPduSender sender = new AllPduSender(Integer.parseInt(args[0]), args[1]); + sender.run(); + } + else + { + System.out.println("Usage: AllPduSender <port> <multicast group>"); + System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + AllPduSender sender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(); + } + System.out.println("DisExamplesOpenDis7.AllPduSender complete."); + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/Brennenstuhl Chuck Norris.dislog b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/Brennenstuhl Chuck Norris.dislog new file mode 100644 index 0000000000000000000000000000000000000000..ec63e64137f7d90b933a3301db9f898ba926b3c9 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Brennenstuhl/Version2/Brennenstuhl Chuck Norris.dislog @@ -0,0 +1,3 @@ +!Begin!Beginning of DIS capture file, Pdusave2.dislog. +AAAAAAAAAAA=,BwAWBQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAPpAAAAgEhlbGxvIENvbW1lbnRQRFUAAAPpAAACOENodWNrIE5vcnJpcyBpcyBjb21taW5nIHRvIHRvd24gZnJvbSBJUC1BZHJlc3MgMjM5LjEuMi4zIHdpdGggUG9ydCAzMDAwAA== +!End!End of DIS capture file, Pdusave2.dislog. diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduListenerSaver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduListenerSaver.java new file mode 100644 index 0000000000000000000000000000000000000000..817f479fc1b8aacb9ce7e9bc8940f353b4ddb927 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduListenerSaver.java @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2008-2019, MOVES Institute, Naval Postgraduate School. All rights reserved. + * This work is licensed under the BSD open source license, available at https://www.movesinstitute.org/licenses/bsd.html + */ +package MV3500Cohort2019JulySeptember.homework4.Fetterolf; + +import edu.nps.moves.dis7.util.playerrecorder.Recorder; +import java.io.IOException; +import java.util.Scanner; + +/** + * PduSaver.java created on Aug 21, 2019 MOVES Institute Naval Postgraduate + * School, Monterey, CA, USA www.nps.edu + * + * @author Mike Bailey, jmbailey@nps.edu + * @version $Id$ + */ +public class FetterolfPduListenerSaver { + + private final static String DEFAULT_OUTPUTDIR = "pduLog"; + private final static String MCAST_ADDR = "239.1.2.3"; + private final static int DIS_PORT = 3000; + + private enum mystate { + RUNNING, + PAUSED; + } + + public static void main(String[] args) { + String outDir = DEFAULT_OUTPUTDIR; + String mcast = MCAST_ADDR; + int port = DIS_PORT; + + System.out.println("DisExamplesOpenDis7.PduListenerSaver started..."); + + switch (args.length) { + case 0: + break; + case 1: + outDir = args[0]; + break; + case 3: + outDir = args[0]; + mcast = args[1]; + port = Integer.parseInt(args[2]); + break; + default: + System.err.println("Usage: PduListener() or PduListener(\"outputdir\") or PduListener(\"outputdir\",\"multicast address\", ipPort"); + System.exit(1); + } + + System.out.println("Beginning pdu save to directory " + outDir); + try { + Recorder recorder = new Recorder(outDir, mcast, port); + + recorder.startResume(); + mystate state = mystate.RUNNING; + System.out.println("* recorder.startResume(), state=RUNNING, recording in progress..."); + Scanner scan = new Scanner(System.in); + + while (true) { + System.out.println("Warning: you must quit when complete, otherwise recorded PDUs are lost!"); + System.out.println("Type p/enter to pause, r/enter to resume, q/enter to stop recording, save and quit"); + String line = scan.nextLine(); + if (line.equalsIgnoreCase("p") && state == mystate.RUNNING) { + recorder.stopPause(); + state = mystate.PAUSED; + System.out.println("* recorder.stopPause(), state=PAUSED, recording paused..."); + } else if (line.equalsIgnoreCase("r") && state == mystate.PAUSED) { + recorder.startResume(); + state = mystate.RUNNING; + System.out.println("* recorder.startResume(), state=RUNNING, recording in progress..."); + } else if (line.equalsIgnoreCase("q")) { + recorder.end(); + System.out.println("* recorder.end(), recording complete."); + break; + } + } + System.out.println("Ending pdu save to " + recorder.getLogFile()); + } catch (IOException ex) { + System.err.println("*** Exception: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage()); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..9140a5699b972fddcf834fb69716da689be60f47 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduReceiver.java @@ -0,0 +1,89 @@ +package MV3500Cohort2019JulySeptember.homework4.Fetterolf; + +import java.net.*; +import java.io.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; +import edu.nps.moves.dis7.util.*; +import java.util.ArrayList; + +public class FetterolfPduReceiver { + + public static final int DEFAULT_MULTICAST_PORT = FetterolfPduReceiver.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = FetterolfPduReceiver.DEFAULT_MULTICAST_ADDRESS; + public static final boolean USE_FAST_ESPDU = false; + + public static void main(String args[]) { + PduFactory factory; + MulticastSocket socket; + InetAddress address; + DatagramPacket packet; + + try { + System.out.println("DisExamplesOpenDis7.AllPduReceiver started..."); + if (args.length == 2) { + socket = new MulticastSocket(Integer.parseInt(args[0])); + address = InetAddress.getByName(args[1]); + } else { + System.out.println("Usage: AllPduReceiver <port> <multicast group>"); + System.out.println("Default: AllPduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + } + socket.joinGroup(address); + + factory = new PduFactory(); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[1500]; // typical MTU size + + packet = new DatagramPacket(buffer, buffer.length); // reset + + socket.receive(packet); + + Pdu pdu = factory.createPdu(packet.getData()); + if (pdu != null) { + DISPDUType currentPduType = pdu.getPduType(); //short currentPduType = pdu.getPduType(); + String currentPduTypeName = pdu.getClass().getName(); + DISProtocolFamily currentProtocolFamilyID = pdu.getProtocolFamily(); //short currentProtocolFamilyID = pdu.getProtocolFamily(); + String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU "); + if (currentPduType.getValue() < 10) { + message.append(" "); // column spacing + } + message.append(currentPduType.getValue()); + String currentPduTypePadded = String.format("%-34s", currentPduType); // - indicates right padding of whitespace + message.append(" ").append(currentPduTypePadded); + String currentPduTypeNamePadded = String.format("%-49s", currentPduTypeName); // - indicates right padding of whitespace + message.append(" of type ").append(currentPduTypeNamePadded); // package.class name + message.append(" (protocolFamily ").append(currentProtocolFamilyID); + // message.append(" ").append(currentPduFamilyName); // class name is also available + message.append(")"); + System.out.println(message.toString()); + + switch (currentPduType) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType + { + case COMMENT: + CommentPdu commentPdu = (CommentPdu) pdu; // cast to precise type + ArrayList<VariableDatum> payloadList = (ArrayList) commentPdu.getVariableDatums(); + for (VariableDatum variableDatum : payloadList) { + String nextComment = new String(variableDatum.getVariableDatumValue()); // convert byte[] to String + System.out.println("\"" + nextComment + "\""); + } + } + } else { + System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + } + } + } catch (IOException e) { + System.out.println("Problem with DisExamplesOpenDis7.AllPduReceiver, see exception trace:"); + System.out.println(e); + } finally { + System.out.println("DisExamplesOpenDis7.AllPduReceiver complete."); + } + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduSender.java new file mode 100755 index 0000000000000000000000000000000000000000..af97291ed05ce19edf6172e52853261111f64bd2 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPduSender.java @@ -0,0 +1,202 @@ +package MV3500Cohort2019JulySeptember.homework4.Fetterolf; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.*; +import edu.nps.moves.dis7.enumerations.*; + +/** + * This is an example that sends many/most types of PDUs. Useful for testing + * standards compliance or getting a full set of PDUs. It also writes the + * generated PDUs to an XML file. Adapted from OpenDIS library example package + * edu.nps.moves.examples + * + * @author DMcG + * @version $Id:$ + */ +public class FetterolfPduSender { + + /** + * Default multicast group address we send on. + */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; + + /** + * Default multicast port used, matches Wireshark DIS capture default + */ + public static final int DEFAULT_MULTICAST_PORT = 3000; + + private int port; + InetAddress multicastAddress; + + public FetterolfPduSender(int port, String multicast) { + try { + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + if (!multicastAddress.isMulticastAddress()) { + System.out.println("Not a multicast address: " + multicast); + } + } catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + public void run() { + System.out.println("DisExamplesOpenDis7.AllPduSender started..."); + try { + System.out.println("Generate PDUs and note issues, if any..."); + List<Pdu> generatedPdusList = new ArrayList<>(); + + // Loop through all the enumerated PDU types, create a PDU for each type, + // add that PDU to generatedPdusList, and send each one + for (DISPDUType pdu : DISPDUType.values()) { +// System.out.println("PDU " + pdu.getValue() + " " + pdu.name() + " " + pdu.getDescription()); // diagnostic + + Pdu aPdu = null; // edu.​nps.​moves7.​dis.PDU superclass for all PDUs, in preparation for custom assignment + + try { + switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType + { + case OTHER: // 0 + System.out.println("*** Note: DISPDUType." + pdu.name() + " not supported"); // TODO why was this received? + // nothing to send + break; + + case ENTITY_STATE: // 1 + aPdu = new EntityStatePdu(); + + EntityStatePdu espdu = (EntityStatePdu) aPdu; + EntityMarking entityMarking = new EntityMarking(); + entityMarking.setCharacters("AllPduSender".getBytes()); //entityMarking.setCharacters(Byte.valueOf("0")); // 11 characters max? + + espdu.setMarking(entityMarking); + Vector3Double espduLocation = new Vector3Double(); + espduLocation.setX(1.0); + espduLocation.setY(2.0); + espduLocation.setZ(3.0); + espdu.setEntityLocation(espduLocation); + // it is important to identify questions as you think of them + // TODO how to set azimuth, i.e. course direction over ground? + break; + + //added in different PDUs from the jar file. + case COLLISION: + aPdu = new CollisionPdu(); + break; + + case TRANSMITTER: + aPdu = new TransmitterPdu(); + break; + + case ACKNOWLEDGE: + aPdu = new AcknowledgePdu(); + break; + + case RECEIVER: + aPdu = new ReceiverPdu(); + break; + + case COMMENT: + // aPdu = new CommentPdu(); // default for this switch logic + + // see Garrett Loffelman and Pete Severson's code for OpenDis version 4 example + // https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/assignments/src/MV3500Cohort2018JulySeptember/projects/LoeffelmanSeverson + CommentPdu newCommentPdu = new CommentPdu(); + ArrayList<VariableDatum> payloadList = new ArrayList<VariableDatum>(); + + ArrayList<String> commentsList = new ArrayList<>(); + commentsList.add("Hello CommentPDU"); + commentsList.add("Here is a new message"); + + if (!commentsList.isEmpty()) { + System.out.println("Preparing CommentPDU:"); + } + + for (String comment : commentsList) { + VariableDatum newVariableDatum = new VariableDatum(); + newVariableDatum.setVariableDatumValue(comment.getBytes()); // conversion + newVariableDatum.setVariableDatumLength(comment.getBytes().length * 8); // bits, not bytes, see spec and javadoc + // alternatively, you do not need to set this and the marshaller will figure it out from the byte array + // (see javadoc for VariableDatum.setVariableDatumLength()) + payloadList.add(newVariableDatum); + System.out.println(" \"" + comment + "\""); + } + newCommentPdu.setVariableDatums(payloadList); + + aPdu = newCommentPdu; // hand off for sending + break; +//commented out this warning message +// default: +// System.out.println("*** Warning: PDU " + pdu.getValue() + " " + pdu + " not supported, created or sent "); + + // code generation block for this class follows: +// System.out.println(" case " + pdu + ": // " + pdu.getValue()); +// System.out.println(" aPdu = new " + pdu.getDescription().replace(" ","").replace("-","").replace("/","") + +// "Pdu();"); +// System.out.println(" break;"); +// System.out.println(); + } + if (aPdu != null) { + generatedPdusList.add(aPdu); + } + } catch (Exception e) { + System.out.print("Exception thrown for PDU " + pdu.getValue() + " " + pdu); + System.out.print(Arrays.toString(e.getStackTrace())); + // continue looping + } + } + // Send the PDUs we created + System.out.println("Send the " + generatedPdusList.size() + " PDUs we created..."); + + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdusList.size(); idx++) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + Pdu aPdu = generatedPdusList.get(idx); + try { + aPdu.marshal(dos); + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + try { + Thread.sleep(100L); + } catch (InterruptedException ex) { + } + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded); + System.out.println(" of type " + aPdu.getClass().getName()); + } catch (Exception ex) { + System.out.println("Marshaling error" + ex); + } + } + // write the PDUs out to an XML file. + //PduContainer container = new PduContainer(); + //container.setPdus(generatedPdus); + //container.marshallToXml("examplePdus.xml"); + } catch (IOException e) { + System.out.println(e); + } + } + + public static void main(String args[]) { + if (args.length == 2) { + FetterolfPduSender sender = new FetterolfPduSender(Integer.parseInt(args[0]), args[1]); + sender.run(); + } else { + System.out.println("Usage: AllPduSender <port> <multicast group>"); + System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + FetterolfPduSender sender = new FetterolfPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(); + } + System.out.println("DisExamplesOpenDis7.AllPduSender complete."); + } +} diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPdusave1.dislog b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPdusave1.dislog new file mode 100644 index 0000000000000000000000000000000000000000..aaa92796faa23675276790dc09bfc050587bc146 --- /dev/null +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Fetterolf/FetterolfPdusave1.dislog @@ -0,0 +1,4 @@ +!Begin!Beginning of DIS capture file, Pdusave1.dislog. +AAAAAAAAAAA=,BwABAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/AAAAAAAABAAAAAAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQWxsUGR1U2VuZGUAAAAA +AAAAACQr8hg=,BwAbBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +!End!End of DIS capture file, Pdusave1.dislog. diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduReceiver.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduReceiver.java index d23bef63de7d55beaca0e06896cfbb937025ba40..8dafea51049ef7360d17fecdd8d2dbd49a6f9d48 100644 --- a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduReceiver.java +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduReceiver.java @@ -1,5 +1,6 @@ package MV3500Cohort2019JulySeptember.homework4.Knobeloch; +import MV3500Cohort2019JulySeptember.homework2.Brennenstuhl.BRE_KNO_MCC.*; import java.net.*; import java.io.*; diff --git a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduSender.java b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduSender.java index 7294c95f1cce104089c272deb54e0cf0efc9d468..ad0139b5dec0f91c10c5a012aa629e03794a9ff1 100755 --- a/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduSender.java +++ b/assignments/src/MV3500Cohort2019JulySeptember/homework4/Knobeloch/Knobeloch_PduSender.java @@ -6,6 +6,8 @@ import java.util.*; import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.enumerations.*; +import java.util.logging.Level; +import java.util.logging.Logger; /** * This is an example that sends many/most types of PDUs. Useful for testing standards @@ -21,7 +23,7 @@ public class Knobeloch_PduSender public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; /** Default multicast port used, matches Wireshark DIS capture default */ - public static final int DEFAULT_MULTICAST_PORT = 3000; + public static final int DEFAULT_MULTICAST_PORT = 1718; private int port; InetAddress multicastAddress; @@ -64,7 +66,11 @@ public class Knobeloch_PduSender byte[] buffer; Pdu aPdu = generatedPdusList.get(idx); - aPdu.marshal(dos); + try { + aPdu.marshal(dos); + } catch (Exception ex) { + Logger.getLogger(Knobeloch_PduSender.class.getName()).log(Level.SEVERE, null, ex); + } buffer = baos.toByteArray(); DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); diff --git a/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/FinalProject_YurkBoron.pptx b/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/FinalProject_YurkBoron.pptx index f586fb8130952a871bf1c4c9270b6b189c076727..2d785e8eff3196cc1d41de2ccda535d61d196c18 100644 Binary files a/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/FinalProject_YurkBoron.pptx and b/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/FinalProject_YurkBoron.pptx differ diff --git a/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/README.txt b/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/README.txt index 348e101a5a9d3da4d466f35ab9bdcc7340f91eed..0eb6605e46a19dddd943e26ff2848a3b8c7caac8 100644 --- a/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/README.txt +++ b/assignments/src/MV3500Cohort2019JulySeptember/projects/Boron_Yurkovich - UDPs for MAJ Furr/README.txt @@ -1,65 +1,65 @@ -1. Purpose - The purpose of this project was to incorporate Distributive -Interactive Simulation (DIS) protocol data units (PDU) into MAJ John Furr's -thesis work. His project models a specific aspect of ground combat communications, -producing data that may influence and change how ground units conduct tactical -communications while in close contact with the enemy. As such, there is great -benefit to adding a networking capability to his simulation that will allow it to -interact with other combat models. - -2. Background - MAJ Furr programmed a discrete event simulation (DES) of the -call-for-fire process from the forward observation positions through battalion -level fires using java and SimKit. His simulation covers multiple forms of radio -frequencies and means of communication. Consequently, his results show how an -enemy capable of monitoring the electromagnetic spectrum can intercept conventional -omni-directional frequency modulation waveforms and exploit this information to -disrupt our kill chain. What was lacking from his program was the ability to -integrate his simulation with other combat models. - -3. Process - Capt Jonathan Boron and Maj Daniel Yurkovich utilized an incremental -model process to incorporate the DIS PDUs into MAJ Furr's simulation. The approach -began with understanding MAJ Furr's code and how java classes interacted with each -other and populated events onto the event list. With this understanding, a PDU -Constructor class was developed to provide a blueprint that supports the creation -of all required PDUs. At this point, the following PDUs deemed necessary for proof -of concept were: CreateEntity, EntityState, Fire, Detonation, Transmitter, Receiver, -and Signal PDUs. A major breakthrough that enabled quick, seamless implementation of -PDU construction into the simulation was found in MAJ Furr's creation of the -SimpleMover3D class. All moving elements, both enemy and friendly, were subclassed -from this SimpleMover3D class. Within the SimpleMover3D class we placed the primary -PDUConstructor object, as well as methods that allowed Transmitter, Signal, and -Receiver PDUs to be sent. Moreover, with further refinement of the program, the -CreateEntity and EntityState PDUs were completely integrated into the SimpleMover3D -class. Since a large focus of MAJ Furr's work was how different radio procedures -influenced the battlefield, a struggle for Capt Boron and Maj Yurkovich was to -identify where radio messages were executed and broadcasted in the DES portion of -the program. - -4. How to use - DIS was implemented in the simulation such that no other additional -files need to be explicitly run for PDUs to be constructed and sent. A PduReceiver -class was programmed, as well, in order to assist in monitoring the state of the -program and debugging. Thus, to observe and track the PDUs being sent, simply run -this file prior to executing MAJ Furr's main program. - -5. Future work - The intricacies subordinate to the main 72 PDUs identified in -the MOVES Institute's open-dis7-source.jar need improvement if a more effective -and thorough implementation is desired. A better understanding of how the -Institute of Electrical and Electronics Engineers Standard for DIS - Application -Protocols (IEEE Std 1278.1-2012) and Simulation Interoperability Standards -Organization Reference for Enumerations for Simulation Interoperability (SISO- -REF-010-2019) work together would make future work easier to complete. Moreover, -the simulation itself, while an effective model of the call-for-fire process, -lacked certain, minute details to fully populate all parameters of the PDUs. This -included specific information pertaining to the type of fuse and warhead in -artillery rounds and the frequency and model of radios employed. Subsequently, this -data requires refinement in each PDU. Lastly, this project showed that DIS can -seamlessly interoperate with SimKit programs. Although outside of the scope of -this project, it would be beneficial for a more thorough integration of the -PDUConstructor and PDUSender classes into the SimKit package. - -6. Conclusion - The modular structure of SimKit and DES allowed for the seamless -implementation of DIS PDUs into MAJ Furr's call-for-fire combat simulation. The -classes taught in the first year of the MOVES curriculum, specifically Java and -DES, establish a strong foundation for any second year MOVES student to continue -to improve MAJ Furr's simulation and broaden its impact with DIS implementation in -MV3500. - +1. Purpose - The purpose of this project was to incorporate Distributive +Interactive Simulation (DIS) protocol data units (PDU) into MAJ John Furr's +thesis work. His project models a specific aspect of ground combat communications, +producing data that may influence and change how ground units conduct tactical +communications while in close contact with the enemy. As such, there is great +benefit to the warfighter by adding a networking capability to his simulation +that will allow it to interact with other combat models. + +2. Background - MAJ Furr programmed a discrete event simulation (DES) of the +call-for-fire process from the forward observation positions through battalion +level fires using java and SimKit. His simulation covers multiple forms of radio +frequencies and means of communication. Consequently, his results show how an +enemy capable of monitoring the electromagnetic spectrum can intercept conventional +omni-directional frequency modulation waveforms and exploit this information to +disrupt our kill chain. What was lacking from his program was the ability to +integrate his simulation with other combat models. + +3. Process - Capt Jonathan Boron and Maj Daniel Yurkovich utilized an incremental +model process to incorporate the DIS PDUs into MAJ Furr's simulation. The approach +began with understanding MAJ Furr's code and how java classes interacted with each +other and populated events onto the event list. With this understanding, a PDU +Constructor class was developed to provide a blueprint that supports the creation +of all required PDUs. At this point, the following PDUs deemed necessary for proof +of concept were: CreateEntity, EntityState, Fire, Detonation, Transmitter, Receiver, +and Signal PDUs. A major breakthrough that enabled quick, seamless implementation of +PDU construction into the simulation was found in MAJ Furr's creation of the +SimpleMover3D class. All moving elements, both enemy and friendly, were subclassed +from this SimpleMover3D class. Within the SimpleMover3D class we placed the primary +PDUConstructor object, as well as methods that allowed Transmitter, Signal, and +Receiver PDUs to be sent. Moreover, with further refinement of the program, the +CreateEntity and EntityState PDUs were completely integrated into the SimpleMover3D +class. Since a large focus of MAJ Furr's work was how different radio procedures +influenced the battlefield, a struggle for Capt Boron and Maj Yurkovich was to +identify where radio messages were executed and broadcasted in the DES portion of +the program. + +4. How to use - DIS was implemented in the simulation such that no other additional +files need to be explicitly run for PDUs to be constructed and sent. A PduReceiver +class was programmed, as well, in order to assist in monitoring the state of the +program and debugging. Thus, to observe and track the PDUs being sent, simply run +this file prior to executing MAJ Furr's main program. + +5. Future work - The intricacies subordinate to the main 72 PDUs identified in +the MOVES Institute's open-dis7-source.jar need improvement if a more effective +and thorough implementation is desired. A better understanding of how the +Institute of Electrical and Electronics Engineers Standard for DIS - Application +Protocols (IEEE Std 1278.1-2012) and Simulation Interoperability Standards +Organization Reference for Enumerations for Simulation Interoperability (SISO- +REF-010-2019) work together would make future work easier to complete. Moreover, +the simulation itself, while an effective model of the call-for-fire process, +lacked certain, minute details to fully populate all parameters of the PDUs. This +included specific information, such as the type and number of transmission +tower arrays and the frequency and model of radios employed. Subsequently, some +data requires refinement in each PDU. Lastly, this project showed that DIS can +seamlessly interoperate with SimKit programs. Although outside of the scope of +this project, it would be beneficial for a more thorough integration of the +PDUConstructor and PDUSender classes into the SimKit package. + +6. Conclusion - The modular structure of SimKit and DES allowed for the seamless +implementation of DIS PDUs into MAJ Furr's call-for-fire combat simulation. The +classes taught in the first year of the MOVES curriculum, specifically Java and +DES, establish a strong foundation for any second year MOVES student to continue +to improve MAJ Furr's simulation and broaden its impact with DIS implementation in +MV3500. + diff --git a/examples/pduLog/Pdusave1.dislog b/examples/pduLog/Pdusave1.dislog new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/examples/pduLog/Pdusave8.dislog b/examples/pduLog/Pdusave8.dislog new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/lib/open-dis7-java.jar b/lib/open-dis7-java.jar index 4c8a6dbbb8bb3f4022d98a1ca27fd10637c82883..144d0acaac30a8f0bf4b686fba61c53ecdbe96f5 100644 Binary files a/lib/open-dis7-java.jar and b/lib/open-dis7-java.jar differ diff --git a/lib/open-dis7-javadoc.jar b/lib/open-dis7-javadoc.jar index 69ebf09d0b1d1377b369ab1e6e22c1cfdcfc546b..cb14cc1d676aa0d385a492bc58169c2a162e6830 100644 Binary files a/lib/open-dis7-javadoc.jar and b/lib/open-dis7-javadoc.jar differ diff --git a/lib/open-dis7-source.jar b/lib/open-dis7-source.jar index 22c5fde380a80dc1414474b2d667a380aacff268..1174d68715c53ac1e81beb3e361bdd591c20a433 100644 Binary files a/lib/open-dis7-source.jar and b/lib/open-dis7-source.jar differ