diff --git a/examples/src/OpenDis7Examples/EspduSender.java b/examples/src/OpenDis7Examples/EspduSender.java index cdb5d1fb89f4526f6d3c3eaffc08596b48e667c5..0caa559814ac790d919dcad0263eb2c755a4f7b6 100644 --- a/examples/src/OpenDis7Examples/EspduSender.java +++ b/examples/src/OpenDis7Examples/EspduSender.java @@ -19,7 +19,10 @@ import edu.nps.moves.dis7.enumerations.PlatformDomain; */ public class EspduSender { - public static final int NUMBER_TO_SEND = 5; // 5000 + /** + * Putting any upper limit on # packets sent avoids possibility of non-terminating infinite loops that continue sending packets. + */ + public static final int NUMBER_PDUS_TO_SEND = 5; // 5000 /** * Default multicast group address we send on. @@ -29,7 +32,7 @@ public class EspduSender /** * Default multicast port used, matches Wireshark DIS capture default */ - public static final int DEFAULT_MULTICAST_PORT = 3000; + public static final int DEFAULT_MULTICAST_PORT = 3000; public enum NetworkMode { UNICAST, MULTICAST, BROADCAST @@ -46,6 +49,7 @@ public class EspduSender * * @param args */ + @SuppressWarnings("SleepWhileInLoop") // allows Thread.sleep(value) without warning in code public static void main(String args[]) { System.out.println("DisExamplesOpenDis7.EspduSender started..."); @@ -157,21 +161,22 @@ public class EspduSender // Manual way: /* - EntityType entityType = espdu.getEntityType(); - entityType.setEntityKind(EntityKind.PLATFORM); //(short) 1); // Platform (vs lifeform, munition, sensor, etc.) - entityType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); //225); // USA - entityType.setDomain(Domain.inst(PlatformDomain.LAND)); // Land (vs air, surface, subsurface, space) - entityType.setCategory((byte) 1); // Tank - entityType.setSubCategory((byte) 1); // M1 Abrams - entityType.setSpecific((byte) 3); // M1A2 Abrams */ + EntityType entityType = espdu.getEntityType(); + entityType.setEntityKind(EntityKind.PLATFORM); //(short) 1); // Platform (vs lifeform, munition, sensor, etc.) + entityType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); // 225 USA + entityType.setDomain(Domain.inst(PlatformDomain.LAND)); // Land (vs air, surface, subsurface, space) + entityType.setCategory ((byte) 1); // Tank + entityType.setSubCategory((byte) 1); // M1 Abrams + entityType.setSpecific ((byte) 3); // M1A2 Abrams + Set<InetAddress> broadcastAddresses; try // Loop through sending N ESPDUs { - System.out.println("Sending " + NUMBER_TO_SEND + " sets of packets:"); // + address.toString() + System.out.println("Sending " + NUMBER_PDUS_TO_SEND + " sets of packets:"); // + address.toString() - for (int index = 0; index < NUMBER_TO_SEND; index++) { + for (int index = 0; index < NUMBER_PDUS_TO_SEND; index++) { // DIS time is a pain in the uh, neck. DIS time units are 2^31-1 units per // hour, and time is set to DIS time units from the top of the hour. // This means that if you start sending just before the top of the hour