diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverAtoTCP.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverAtoTCP.java index 95c27976eebb7696b8321575adaf6b4399e99dca..113dbe0c7ccc86e3f7a8ecb97713966a477fdefd 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverAtoTCP.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverAtoTCP.java @@ -6,8 +6,6 @@ import edu.nps.moves.disutil.*; import edu.nps.moves.dis.*; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.OutputStream; -import java.io.PrintStream; /** * Receives PDUs from the network creates a TCP connection, then @@ -74,21 +72,8 @@ public class AngelBlankEspduReceiverAtoTCP { DatagramPacket DpSend = new DatagramPacket(data, data.length, InetAddress.getByName(TCP_DESTINATION_IP), TCP_DESTINATION_PORT); dataGram.send(DpSend); - //Socket clientConnection = new Socket(TCP_DESTINATION_IP, TCP_DESTINATION_PORT); - //OutputStream os = clientConnection.getOutputStream(); - //PrintStream ps = new PrintStream(os); System.out.println("Alpha Bridging Complete to: " + TCP_DESTINATION_IP); //EntityType entityType = ((EntityStatePdu)aPdu).getEntityType(); - /**ps.println(eid.getSite()); - ps.println(eid.getApplication()); - ps.println(eid.getEntity()); - ps.println(entityType.getEntityKind()); // Platform (vs lifeform, munition, sensor, etc.) - ps.println(entityType.getCountry()); // USA - ps.println(entityType.getDomain()); // Land (vs air, surface, subsurface, space) - ps.println(entityType.getCategory()); // Tank - ps.println(entityType.getSubcategory()); // M1 Abrams - ps.println(entityType.getSpec()); // M1A2 Abrams**/ - } Vector3Double location = ((EntityStatePdu)aPdu).getEntityLocation(); System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverBtoTCP.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverBtoTCP.java index 1dee2574ed9c74968128cca3293ebbae4e86c25e..eddb89e2ff145359a7a397777881227351dee63b 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverBtoTCP.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduReceiverBtoTCP.java @@ -6,8 +6,7 @@ import edu.nps.moves.disutil.*; import edu.nps.moves.dis.*; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.OutputStream; -import java.io.PrintStream; + /** * Receives PDUs from the network in IEEE format and creates a TCP connection, @@ -63,23 +62,8 @@ public class AngelBlankEspduReceiverBtoTCP { DatagramPacket DpSend = new DatagramPacket(data, data.length, InetAddress.getByName(TCP_DESTINATION_IP), TCP_DESTINATION_PORT); dataGram.send(DpSend); // Create TCP Bridge - //Socket clientConnection = new Socket(TCP_DESTINATION_IP, TCP_DESTINATION_PORT); - // OutputStream os = clientConnection.getOutputStream(); - //PrintStream ps = new PrintStream(os); - System.out.println("Bravo briding complete to: "+ TCP_DESTINATION_IP); //EntityType entityType = ((EntityStatePdu)aPdu).getEntityType(); - /** ps.println(eid.getSite()); - ps.println(eid.getApplication()); - ps.println(eid.getEntity()); - ps.println(entityType.getEntityKind()); // Platform (vs lifeform, munition, sensor, etc.) - ps.println(entityType.getCountry()); // USA - ps.println(entityType.getDomain()); // Land (vs air, surface, subsurface, space) - ps.println(entityType.getCategory()); // Tank - ps.println(entityType.getSubcategory()); // M1 Abrams - ps.println(entityType.getSpec()); // M1A2 Abrams**/ - - } Vector3Double location = ((EntityStatePdu)aPdu).getEntityLocation(); System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverASenderB.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverASenderB.java index 834149b75ef1562f3941f35c22257ca2f79f2177..69fe8350023ff6eb72fc36306102235c1d52cc87 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverASenderB.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverASenderB.java @@ -104,7 +104,6 @@ public static void main(String args[]) { int connectionCount = 0; DatagramSocket ds = new DatagramSocket(TCP_DESTINATION_PORT); - //ServerSocket serverSocket = new ServerSocket(TCP_DESTINATION_PORT); while(true){ try @@ -112,7 +111,6 @@ public static void main(String args[]) byte buffer[] = new byte[MAX_PDU_SIZE]; DatagramPacket tcpPacket = new DatagramPacket(buffer, buffer.length); ds.receive(tcpPacket); - //Socket clientConnection = serverSocket.accept(); connectionCount++; System.out.println("Current PDUs transferred over TCP: "+ connectionCount); List<Pdu> pduBundle = pduFactory.getPdusFromBundle(tcpPacket.getData()); @@ -126,50 +124,14 @@ public static void main(String args[]) if(aPdu instanceof EntityStatePdu){ EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); System.out.println("Entity ID transferred: "+eid.getEntity()); - - //System.out.println(); - // end trop through PDU bundle - //System.out.println("RA SB received TCP connection."); - /**InputStream is = clientConnection.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - //System.out.println("RA SB waiting to readline."); - int entitySite = Integer.parseInt(br.readLine()); - int entityApplication = Integer.parseInt(br.readLine()); - int entityEntity = Integer.parseInt(br.readLine()); - short entityEntityKind = Short.parseShort(br.readLine()); - int entityCountry = Integer.parseInt(br.readLine()); - short entityDomain = Short.parseShort(br.readLine()); - short entityCategory = Short.parseShort(br.readLine()); - short entitySubcategory = Short.parseShort(br.readLine()); - short entitySpec = Short.parseShort(br.readLine()); - //System.out.println("RA SB reading complete."); - espdu.setExerciseID((short)1); - EntityID eid = espdu.getEntityID(); - eid.setSite(entitySite); // 0 is apparently not a valid site number, per the spec - eid.setApplication(entityApplication); - eid.setEntity(entityEntity); - EntityType entityType = espdu.getEntityType(); - entityType.setEntityKind(entityEntityKind); // Platform (vs lifeform, munition, sensor, etc.) - entityType.setCountry(entityCountry); // USA - entityType.setDomain(entityDomain); // AIR (vs air, surface, subsurface, space) - entityType.setCategory(entityCategory); // Tank - entityType.setSubcategory(entitySubcategory); // M1 Abrams - entityType.setSpec(entitySpec); // M1A2 Abrams **/ - //int ts = disTime.getDisAbsoluteTimestamp(); - //espdu.setTimestamp(ts); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(baos); - aPdu.marshal(dos); - // The byte array here is the packet in DIS format. We put that into a - // datagram and send it. - byte[] data = baos.toByteArray(); - DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT); - socket.send(udpPacket); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + aPdu.marshal(dos); + byte[] data = baos.toByteArray(); + DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT); + socket.send(udpPacket); } - //System.out.println(" EID=[" + eid.getSite() + "," + eid.getApplication() + "," + eid.getEntity() + "]"); - //clientConnection.close(); - } + } } catch(Exception e) { @@ -184,7 +146,7 @@ public static void main(String args[]) } - +/** public static Set<InetAddress> getBroadcastAddresses() { Set<InetAddress> bcastAddresses = new HashSet<InetAddress>(); @@ -224,5 +186,5 @@ public static void main(String args[]) return bcastAddresses; } - +**/ } diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverBSenderA.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverBSenderA.java index cf14cd688c3e6928ce303dde624d4fd153182723..582ea180c6ddac25791fe6c0eab0ac63e6aa5069 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverBSenderA.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduTCPReceiverBSenderA.java @@ -106,7 +106,6 @@ public static void main(String args[]) { int connectionCount = 0; DatagramSocket ds = new DatagramSocket(TCP_DESTINATION_PORT); - //ServerSocket serverSocket = new ServerSocket(TCP_DESTINATION_PORT); while(true){ try @@ -128,48 +127,13 @@ public static void main(String args[]) if(aPdu instanceof EntityStatePdu){ EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); System.out.println("Entity ID transferred: "+eid.getEntity()); - - /** - //System.out.println("RB SA received TCP connection."); - InputStream is = clientConnection.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - //System.out.println("RB SA waiting to readline."); - int entitySite = Integer.parseInt(br.readLine()); - int entityApplication = Integer.parseInt(br.readLine()); - int entityEntity = Integer.parseInt(br.readLine()); - short entityEntityKind = Short.parseShort(br.readLine()); - int entityCountry = Integer.parseInt(br.readLine()); - short entityDomain = Short.parseShort(br.readLine()); - short entityCategory = Short.parseShort(br.readLine()); - short entitySubcategory = Short.parseShort(br.readLine()); - short entitySpec = Short.parseShort(br.readLine()); - //System.out.println("RB SA reading complete."); - espdu.setExerciseID((short)1); - EntityID eid = espdu.getEntityID(); - eid.setSite(entitySite); // 0 is apparently not a valid site number, per the spec - eid.setApplication(entityApplication); - eid.setEntity(entityEntity); - EntityType entityType = espdu.getEntityType(); - entityType.setEntityKind(entityEntityKind); // Platform (vs lifeform, munition, sensor, etc.) - entityType.setCountry(entityCountry); // USA - entityType.setDomain(entityDomain); // AIR (vs air, surface, subsurface, space) - entityType.setCategory(entityCategory); // Tank - entityType.setSubcategory(entitySubcategory); // M1 Abrams - entityType.setSpec(entitySpec); // M1A2 Abrams - int ts = disTime.getDisAbsoluteTimestamp(); - espdu.setTimestamp(ts);**/ - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(baos); - aPdu.marshal(dos); - - // The byte array here is the packet in DIS format. We put that into a - // datagram and send it. - byte[] data = baos.toByteArray(); - DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT); - socket.send(udpPacket); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + aPdu.marshal(dos); + byte[] data = baos.toByteArray(); + DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT); + socket.send(udpPacket); } - //System.out.println(" EID=[" + eid.getSite() + "," + eid.getApplication() + "," + eid.getEntity() + "]"); } } catch(Exception e)