diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduRequestingUnit.java b/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduRequestingUnit.java index d75c71d30cf532a208ed0fed9b9a54fa93226917..b4d9ae887771a9d2dc3ee667f0e363790cd48039 100644 --- a/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduRequestingUnit.java +++ b/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduRequestingUnit.java @@ -46,7 +46,6 @@ public class C_T_EspduRequestingUnit { //Receiving DatagramPacket receivingPacket; - InetAddress receivingAddress; PduFactory pduFactory = new PduFactory(); //Use a try/catch to ensure the you can connect to the Destination IP @@ -125,25 +124,52 @@ public class C_T_EspduRequestingUnit { // Lat and Long Coordinates that will be used for the location of the Requesting Unit double lat = 36.595517; double lon = -121.877000; - //Boolean for the initial connection - boolean connectionMade = false; + //Convert the lat and long coordinates to cartisian coordinates required by DIS + double disCoordinates[] = CoordinateConversions.getXYZfromLatLonDegrees(lat, lon, 1.0); + requestingUnitEsPdu.getEntityLocation().setX(disCoordinates[0]); + requestingUnitEsPdu.getEntityLocation().setY(disCoordinates[1]); + requestingUnitEsPdu.getEntityLocation().setZ(disCoordinates[2]); + + //Create a Resupply Service Request + ServiceRequestPdu serviceRequest = new ServiceRequestPdu(); + serviceRequest.setRequestingEntityID(entityID); + serviceRequest.setServiceTypeRequested((short) 1); //Resupply + List<SupplyQuantity> pSupplies = new ArrayList<SupplyQuantity>(); + pSupplies.add(new SupplyQuantity()); + serviceRequest.setSupplies(pSupplies); + + //Create a Resupply Offer + ResupplyOfferPdu resupplyOffer = new ResupplyOfferPdu(); + + //Create a Resupply Received + AcknowledgePdu acknowledge = new AcknowledgePdu(); + + //Booleans for dialogue + boolean connectionMade = false; + boolean serviceRequestAcknowledged = false; + boolean serviceRequestComplete = false; Set<InetAddress> broadcastAddresses; try { - while (true) { + while (true) + { System.out.println("\nREQUESTING UNIT:\n\tListening\n"); int timestamp = disTime.getDisAbsoluteTimestamp(); - // Marshal out the espdu object to a byte array, then send a datagram - // packet with that data in it. + // Marshal out the espdu object to a byte array ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); requestingUnitEsPdu.marshal(dos); + // Marshal out the Service Request PDU object to a byte array + ByteArrayOutputStream baosServiceRequest = new ByteArrayOutputStream(); + DataOutputStream dosServiceRequest = new DataOutputStream(baosServiceRequest); + serviceRequest.marshal(dosServiceRequest); //While we have not recieved an acknowledgement from the receiving unit keep sending the entity state information - while(!connectionMade) { + while(!connectionMade) + { //DIS Time must be used for this because DIS requires it. timestamp = disTime.getDisAbsoluteTimestamp(); requestingUnitEsPdu.setTimestamp(timestamp); @@ -157,7 +183,6 @@ public class C_T_EspduRequestingUnit { while (broadcastIterator.hasNext()) { InetAddress broadcast = (InetAddress) broadcastIterator.next(); - System.out.println("Sending broadcast datagram packet to " + broadcast); DatagramPacket packet = new DatagramPacket(data, data.length, broadcast, port); socket.send(packet); } @@ -166,20 +191,20 @@ public class C_T_EspduRequestingUnit { System.out.println("SENDING ENTITY STATE INFORMATION"); System.out.println("\tEID=[" + entityID.getSite() + "," + entityID.getApplication() + "," + entityID.getEntity() + "]"); - + System.out.println("\tEntity Location: [" + requestingUnitEsPdu.getEntityLocation().getX() + ", " + requestingUnitEsPdu.getEntityLocation().getY() + ", " + requestingUnitEsPdu.getEntityLocation().getZ() + "]"); + System.out.println("\tEntity Type: " + requestingUnitEsPdu.getEntityType().getEntityKind() + "\n"); + //Prepare to receive a package byte buffer[] = new byte[MAX_PDU_SIZE]; receivingPacket = new DatagramPacket(buffer, buffer.length); socket.receive(receivingPacket); List<Pdu> pduBundle = pduFactory.getPdusFromBundle(receivingPacket.getData()); - System.out.println("Bundle size is " + pduBundle.size()); //Iterate through the bundle Iterator iterator = pduBundle.iterator(); while (iterator.hasNext()) { Pdu aPdu = (Pdu) iterator.next(); - System.out.println("got PDU of type: " + aPdu.getClass().getName()); if (aPdu instanceof EntityStatePdu) { EntityID eid = ((EntityStatePdu) aPdu).getEntityID(); @@ -189,6 +214,7 @@ public class C_T_EspduRequestingUnit { if(eType.getEntityKind() != requestingUnitEsPdu.getEntityType().getEntityKind()) { connectionMade = true; System.out.println("RECEIVED PACKET"); + System.out.println("\tPacket Type: " + aPdu.getClass().getName()); System.out.println("\tEID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); System.out.println("\tEntity Location: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); System.out.println("\tEntity Type: " + eType.getEntityKind() + "\n"); @@ -196,25 +222,129 @@ public class C_T_EspduRequestingUnit { } } } + while(!serviceRequestAcknowledged && connectionMade) { + //DIS Time must be used for this because DIS requires it. + timestamp = disTime.getDisAbsoluteTimestamp(); + serviceRequest.setTimestamp(timestamp); + + //The byte array here is the packet in DIS format. We put that into a + // datagram and send it. + byte[] dataServiceRquest = baosServiceRequest.toByteArray(); + + broadcastAddresses = getBroadcastAddresses(); + Iterator broadcastIterator = broadcastAddresses.iterator(); + + while (broadcastIterator.hasNext()) { + InetAddress broadcast = (InetAddress) broadcastIterator.next(); + DatagramPacket packet = new DatagramPacket(dataServiceRquest, dataServiceRquest.length, broadcast, port); + socket.send(packet); + } + // Send every 1 sec. Otherwise all this will be all over in a fraction of a second. + Thread.sleep(1000); // msec + + //Print out the details on the service reuqest being sent + System.out.println("SENDING SERVICE REQUEST"); + EntityID eid = serviceRequest.getRequestingEntityID(); + short serviceType = serviceRequest.getServiceTypeRequested(); + String serviceReqestTypeString = "null"; + if (serviceType == 0) { + serviceReqestTypeString = "Other"; + } + if (serviceType == 1) { + serviceReqestTypeString = "Resupply"; + } + if (serviceType == 2) { + serviceReqestTypeString = "Repair"; + } + System.out.println("\tEntity Requesting:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); + System.out.println("\tService Type Requested: [" + serviceType + ", " + serviceReqestTypeString + "]\n"); + + //Prepare to receive a package + byte buffer[] = new byte[MAX_PDU_SIZE]; + receivingPacket = new DatagramPacket(buffer, buffer.length); + socket.receive(receivingPacket); + List<Pdu> pduBundle = pduFactory.getPdusFromBundle(receivingPacket.getData()); + + //Iterate through the bundle + Iterator iterator = pduBundle.iterator(); + while (iterator.hasNext()) { + + Pdu aPdu = (Pdu) iterator.next(); + + if (aPdu instanceof ResupplyOfferPdu) { + resupplyOffer = (ResupplyOfferPdu) aPdu; + EntityID supplyingUnitEntityId = ((ResupplyOfferPdu) aPdu).getSupplyingEntityID(); + EntityID receivingUnitEntityId = ((ResupplyOfferPdu) aPdu).getReceivingEntityID(); + + System.out.println("RECEIVED PACKET"); + System.out.println("\tPacket Type: " + aPdu.getClass().getName()); + System.out.println("\tSupplying Unit:\t[" + supplyingUnitEntityId.getSite() + ", " + supplyingUnitEntityId.getApplication() + ", " + supplyingUnitEntityId.getEntity() + "]"); + System.out.println("\tRequesting Unit: [" + receivingUnitEntityId.getSite() + ", " + receivingUnitEntityId.getApplication() + ", " + receivingUnitEntityId.getEntity() + "]\n"); + + serviceRequestAcknowledged = true; + } + } + } + while(!serviceRequestComplete && serviceRequestAcknowledged) { + //DIS Time must be used for this because DIS requires it. + timestamp = disTime.getDisAbsoluteTimestamp(); + acknowledge.setTimestamp(timestamp); + // Marshal out the Service Request PDU object to a byte array + ByteArrayOutputStream baosAcknowledge = new ByteArrayOutputStream(); + DataOutputStream dosAcknowledge = new DataOutputStream(baosAcknowledge); + acknowledge.marshal(dosAcknowledge); + + //The byte array here is the packet in DIS format. We put that into a + // datagram and send it. + byte[] dataAcknowledge = baosAcknowledge.toByteArray(); + + broadcastAddresses = getBroadcastAddresses(); + Iterator broadcastIterator = broadcastAddresses.iterator(); + + while (broadcastIterator.hasNext()) { + InetAddress broadcast = (InetAddress) broadcastIterator.next(); + DatagramPacket packet = new DatagramPacket(dataAcknowledge, dataAcknowledge.length, broadcast, port); + socket.send(packet); + } + // Send every 1 sec. Otherwise all this will be all over in a fraction of a second. + Thread.sleep(1000); // msec + + //Print out the details on the service reuqest being sent + System.out.println("SENDING ACKNOWLEDGE\n"); + + //Prepare to receive a package + byte buffer[] = new byte[MAX_PDU_SIZE]; + receivingPacket = new DatagramPacket(buffer, buffer.length); + socket.receive(receivingPacket); + List<Pdu> pduBundle = pduFactory.getPdusFromBundle(receivingPacket.getData()); + + //Iterate through the bundle + Iterator iterator = pduBundle.iterator(); + while (iterator.hasNext()) { + + Pdu aPdu = (Pdu) iterator.next(); + + if (aPdu instanceof AcknowledgePdu) { + System.out.println("RECEIVED PACKET"); + System.out.println("\tPacket Type: " + aPdu.getClass().getName()); + + serviceRequestComplete = true; + } + } + } + if (serviceRequestComplete) + { + socket.close(); + System.out.println("\nREQUEST COMPLETED - SOCKET IS NOW CLOSED"); + break; + } } - } catch (IOException | InterruptedException e) { + } catch (IOException | InterruptedException e) { System.out.println("Problem with DisExamples.EspduSender, see exception trace:"); System.out.println(e); } } - /** - * A number of sites get all snippy about using 255.255.255.255 for a - * broadcast address; it trips their security software and they kick you off - * their network. (Comcast, NPS.) This determines the broadcast address for - * all connected interfaces, based on the IP and subnet mask. If you have a - * dual-homed host it will return a broadcast address for both. If you have - * some VMs running on your host this will pick up the addresses for those - * as well--e.g. running VMWare on your laptop with a local IP this will - * also pick up a 192.168 address assigned to the VM by the host OS. - * - * @return set of all broadcast addresses - */ public static Set<InetAddress> getBroadcastAddresses() { Set<InetAddress> broadcastAddresses = new HashSet<>(); Enumeration interfaces; diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduSupplyerUnit.java b/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduSupplyerUnit.java index 2597251fb70d7d21223a01d48560518eeb4f7c01..8e8a5e82d1c2003873d518865ff1c3598aa865a9 100644 --- a/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduSupplyerUnit.java +++ b/deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/CainThomersonFinal/C_T_EspduSupplyerUnit.java @@ -32,7 +32,7 @@ public class C_T_EspduSupplyerUnit { public static final int DEFAULT_MULTICAST_PORT = 3000; public static void main(String args[]) { - + System.out.println("\nSUPPLYER UNIT:\n\tProgram started\n"); //Initialize the MulticastSocket to null @@ -40,15 +40,14 @@ public class C_T_EspduSupplyerUnit { //Initialize the DIS time (this will be used later in the code DisTime disTime = DisTime.getInstance(); - + // Initialize the Port, Mode, and Destination IP int port = DEFAULT_MULTICAST_PORT; NetworkMode mode = NetworkMode.BROADCAST; InetAddress destinationIp = null; - + //Receiving DatagramPacket receivingPacket; - InetAddress receivingAddress; PduFactory pduFactory = new PduFactory(); //Use a try/catch to ensure the you can connect to the Destination IP @@ -58,7 +57,7 @@ public class C_T_EspduSupplyerUnit { System.out.println(e + " Cannot create multicast address"); System.exit(0); } - + // All system properties, passed in on the command line via -Dattribute=value Properties systemProperties = System.getProperties(); // IP address we send to @@ -68,7 +67,6 @@ public class C_T_EspduSupplyerUnit { // Network mode: unicast, multicast, broadcast String networkModeString = systemProperties.getProperty("networkMode"); // unicast or multicast or broadcast - try { // Port we send to if (portString != null) { @@ -101,18 +99,18 @@ public class C_T_EspduSupplyerUnit { System.out.println(e); System.exit(-1); } - + //Establish the Requesting Unit EnityState PDU EntityStatePdu supplyerUnitEsPdu = new EntityStatePdu(); - + // Initialize values in the Entity State PDU object. //The exercise ID is a way to differentiate between different virtual worlds on one network. supplyerUnitEsPdu.setExerciseID((short) 1); // The EID is the unique identifier for objects in the world. EntityID entityID = supplyerUnitEsPdu.getEntityID(); - entityID.setSite(1); // 0 is apparently not a valid site number, per the spec - entityID.setApplication(1); + entityID.setSite(2); // 0 is apparently not a valid site number, per the spec + entityID.setApplication(2); entityID.setEntity(2); // Set the entity type. (Check SISO for a list of enumerations) @@ -121,47 +119,71 @@ public class C_T_EspduSupplyerUnit { entityType.setCountry(225); // USA entityType.setDomain((short) 1); // Land (vs air, surface, subsurface, space) entityType.setCategory((short) 34); // Command Facility - + // Lat and Long Coordinates that will be used for the location of the Requesting Unit double lat = 75.123456; double lon = -200.877000; - + + //Convert the lat and long coordinates to cartisian coordinates required by DIS + double disCoordinates[] = CoordinateConversions.getXYZfromLatLonDegrees(lat, lon, 1.0); + supplyerUnitEsPdu.getEntityLocation().setX(disCoordinates[0]); + supplyerUnitEsPdu.getEntityLocation().setY(disCoordinates[1]); + supplyerUnitEsPdu.getEntityLocation().setZ(disCoordinates[2]); + + //Resupply Offer + ResupplyOfferPdu resupplyOffer = new ResupplyOfferPdu(); + + //Acknowledge + AcknowledgePdu acknowledge = new AcknowledgePdu(); + + //Booleans for dialogue + boolean someoneWantsToTalk = false; + boolean serviceRequestReceived = false; + boolean serviceRequestComplete = false; + Set<InetAddress> broadcastAddresses; - Set<Pdu> receivedMessages = new HashSet<>(); - try{ + try { while (true) // Loop infinitely, receiving datagrams { System.out.println("\nSUPPYER UNIT:\n\tListening\n"); - + int timestamp = disTime.getDisAbsoluteTimestamp(); - - // Marshal out the espdu object to a byte array, then send a datagram - // packet with that data in it. + + // Marshal out the espdu object to a byte array ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); supplyerUnitEsPdu.marshal(dos); - byte[] data = baos.toByteArray(); - broadcastAddresses = getBroadcastAddresses(); - Iterator broadcastIterator = broadcastAddresses.iterator(); - - //Receiving Set Up - byte buffer[] = new byte[MAX_PDU_SIZE]; - receivingPacket = new DatagramPacket(buffer, buffer.length); - socket.receive(receivingPacket); - List<Pdu> pduBundle = pduFactory.getPdusFromBundle(receivingPacket.getData()); - System.out.println("Bundle size is " + pduBundle.size()); - - Iterator receivingIterator = pduBundle.iterator(); - - while (receivingIterator.hasNext()) { - Pdu aPdu = (Pdu) receivingIterator.next(); - if (!receivedMessages.contains(aPdu)) { - System.out.println("got PDU of type: " + aPdu.getClass().getName()); + + while (!someoneWantsToTalk) { + //DIS Time must be used for this because DIS requires it. + timestamp = disTime.getDisAbsoluteTimestamp(); + supplyerUnitEsPdu.setTimestamp(timestamp); + + //The byte array here is the packet in DIS format. We put that into a + // datagram and send it. + byte[] data = baos.toByteArray(); + + broadcastAddresses = getBroadcastAddresses(); + Iterator broadcastIterator = broadcastAddresses.iterator(); + + //Receiving Set Up + byte buffer[] = new byte[MAX_PDU_SIZE]; + receivingPacket = new DatagramPacket(buffer, buffer.length); + socket.receive(receivingPacket); + List<Pdu> pduBundle = pduFactory.getPdusFromBundle(receivingPacket.getData()); + + Iterator receivingIterator = pduBundle.iterator(); + + while (receivingIterator.hasNext()) { + Pdu aPdu = (Pdu) receivingIterator.next(); + + //System.out.println("got PDU of type: " + aPdu.getClass().getName()); if (aPdu instanceof EntityStatePdu) { EntityID eid = ((EntityStatePdu) aPdu).getEntityID(); EntityType eType = ((EntityStatePdu) aPdu).getEntityType(); Vector3Double position = ((EntityStatePdu) aPdu).getEntityLocation(); System.out.println("RECEIVED PACKET"); + System.out.println("\tPacket Type: " + aPdu.getClass().getName()); System.out.println("\tEID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); System.out.println("\tEntity Location: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); System.out.println("\tEntity Type: " + eType.getEntityKind() + "\n"); @@ -169,15 +191,129 @@ public class C_T_EspduSupplyerUnit { if (eType.getEntityKind() != supplyerUnitEsPdu.getEntityType().getEntityKind()) { while (broadcastIterator.hasNext()) { InetAddress broadcast = (InetAddress) broadcastIterator.next(); - System.out.println("Sending broadcast datagram packet to " + broadcast); DatagramPacket packet = new DatagramPacket(data, data.length, broadcast, port); socket.send(packet); } + System.out.println("SENDING ENTITY STATE PACKET"); + System.out.println("\tEID=[" + entityID.getSite() + "," + entityID.getApplication() + "," + entityID.getEntity() + "]"); + System.out.println("\tEntity Location: [" + supplyerUnitEsPdu.getEntityLocation().getX() + ", " + supplyerUnitEsPdu.getEntityLocation().getY() + ", " + supplyerUnitEsPdu.getEntityLocation().getZ() + "]"); + System.out.println("\tEntity Type: " + supplyerUnitEsPdu.getEntityType().getEntityKind() + "\n"); + someoneWantsToTalk = true; } } - receivedMessages.add(aPdu); + } } + while (!serviceRequestReceived && someoneWantsToTalk) { + //DIS Time must be used for this because DIS requires it. + timestamp = disTime.getDisAbsoluteTimestamp(); + resupplyOffer.setTimestamp(timestamp); + + //The byte array here is the packet in DIS format. We put that into a + // datagram and send it. + byte[] data = baos.toByteArray(); + + broadcastAddresses = getBroadcastAddresses(); + Iterator broadcastIterator = broadcastAddresses.iterator(); + + //Receiving Set Up + byte buffer[] = new byte[MAX_PDU_SIZE]; + receivingPacket = new DatagramPacket(buffer, buffer.length); + socket.receive(receivingPacket); + List<Pdu> pduBundle = pduFactory.getPdusFromBundle(receivingPacket.getData()); + + Iterator receivingIterator = pduBundle.iterator(); + + while (receivingIterator.hasNext()) { + Pdu aPdu = (Pdu) receivingIterator.next(); + + //System.out.println("got PDU of type: " + aPdu.getClass().getName()); + if (aPdu instanceof ServiceRequestPdu) { + EntityID serviceRequestId = ((ServiceRequestPdu) aPdu).getRequestingEntityID(); + short serviceRequestType = ((ServiceRequestPdu) aPdu).getServiceTypeRequested(); + + if (serviceRequestType == 1) { + System.out.println("RECEIVED PACKET"); + System.out.println("\tPacket Type: " + aPdu.getClass().getName()); + System.out.println("\tRequesting Entity ID:[" + serviceRequestId.getSite() + ", " + serviceRequestId.getApplication() + ", " + serviceRequestId.getEntity() + "] "); + System.out.println("\tService Type Requested: [" + serviceRequestType + ", Resupply]\n"); + List<SupplyQuantity> pSupplies = ((ServiceRequestPdu) aPdu).getSupplies(); + + resupplyOffer.setReceivingEntityID(serviceRequestId); + resupplyOffer.setSupplyingEntityID(supplyerUnitEsPdu.getEntityID()); + resupplyOffer.setSupplies(pSupplies); + + // Marshal out the Service Request PDU object to a byte array + ByteArrayOutputStream baosResupplyOffer = new ByteArrayOutputStream(); + DataOutputStream dosResupplyOffer = new DataOutputStream(baosResupplyOffer); + resupplyOffer.marshal(dosResupplyOffer); + + byte[] dataResupplyOffer = baosResupplyOffer.toByteArray(); + + while (broadcastIterator.hasNext()) { + InetAddress broadcast = (InetAddress) broadcastIterator.next(); + DatagramPacket packet = new DatagramPacket(dataResupplyOffer, dataResupplyOffer.length, broadcast, port); + socket.send(packet); + } + System.out.println("SENDING PACKET"); + System.out.println("\tPacket Type: Resupply Offer"); + System.out.println("\tReceiving Entity ID: [" + resupplyOffer.getReceivingEntityID().getSite() + ", " + resupplyOffer.getReceivingEntityID().getApplication() + ", " + resupplyOffer.getReceivingEntityID().getEntity() + "]"); + System.out.println("\tSupplying Entity ID: [" + resupplyOffer.getSupplyingEntityID().getSite() + ", " + resupplyOffer.getSupplyingEntityID().getApplication() + ", " + resupplyOffer.getSupplyingEntityID().getEntity() + "]\n"); + + serviceRequestReceived = true; + } + } + } + } + while (!serviceRequestComplete && serviceRequestReceived ) { + //DIS Time must be used for this because DIS requires it. + timestamp = disTime.getDisAbsoluteTimestamp(); + acknowledge.setTimestamp(timestamp); + + //The byte array here is the packet in DIS format. We put that into a + // datagram and send it. + //byte[] data = baos.toByteArray(); + + broadcastAddresses = getBroadcastAddresses(); + Iterator broadcastIterator = broadcastAddresses.iterator(); + + //Receiving Set Up + byte buffer[] = new byte[MAX_PDU_SIZE]; + receivingPacket = new DatagramPacket(buffer, buffer.length); + socket.receive(receivingPacket); + List<Pdu> pduBundle = pduFactory.getPdusFromBundle(receivingPacket.getData()); + + Iterator receivingIterator = pduBundle.iterator(); + + while (receivingIterator.hasNext()) { + Pdu aPdu = (Pdu) receivingIterator.next(); + + if (aPdu instanceof AcknowledgePdu) { + + System.out.println("RECEIVED PACKET"); + System.out.println("\tPacket Type: " + aPdu.getClass().getName()); + + + // Marshal out the Service Request PDU object to a byte array + ByteArrayOutputStream baosAcknowledge = new ByteArrayOutputStream(); + DataOutputStream dosAcknowledge = new DataOutputStream(baosAcknowledge); + acknowledge.marshal(dosAcknowledge); + + byte[] dataAcknowledge = baosAcknowledge.toByteArray(); + + while (broadcastIterator.hasNext()) { + InetAddress broadcast = (InetAddress) broadcastIterator.next(); + DatagramPacket packet = new DatagramPacket(dataAcknowledge, dataAcknowledge.length, broadcast, port); + socket.send(packet); + } + System.out.println("SENDING PACKET"); + System.out.println("\tPacket Type: Acknowledge"); + + serviceRequestComplete = true; + } + } + } + } // end while } // End try catch (IOException e) { @@ -185,7 +321,7 @@ public class C_T_EspduSupplyerUnit { System.out.println(e); } } // end main - + public static Set<InetAddress> getBroadcastAddresses() { Set<InetAddress> broadcastAddresses = new HashSet<>(); Enumeration interfaces; diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/FinalProjects/README.md b/deliverables/src/MV3500Cohort2018JulySeptember/FinalProjects/README.md new file mode 100644 index 0000000000000000000000000000000000000000..90da34a44cd5f0ee4352ccc596923d2d561809ca --- /dev/null +++ b/deliverables/src/MV3500Cohort2018JulySeptember/FinalProjects/README.md @@ -0,0 +1,7 @@ +## Final Course Projects 2018September + +Create a dedicated subdirectory for each individual or team project. + +Example: `SmithJones` + +See the [course syllabus](../../../../MV3500NetworkedGraphicsSyllabus2018JulySeptember.pdf) for details on how to document your project.