Skip to content
Snippets Groups Projects
Commit f42dcc7b authored by brutzman's avatar brutzman
Browse files

consistent address, port ordering and output on console

parent 29cf8d5f
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,8 @@ import java.util.ArrayList; ...@@ -10,8 +10,8 @@ import java.util.ArrayList;
public class AllPduReceiver 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 String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS;
public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT;
public static final boolean USE_FAST_ESPDU = false; public static final boolean USE_FAST_ESPDU = false;
public static void main(String args[]) public static void main(String args[])
...@@ -24,12 +24,12 @@ public class AllPduReceiver ...@@ -24,12 +24,12 @@ public class AllPduReceiver
try { try {
System.out.println("OpenDis7Examples.AllPduReceiver started..."); System.out.println("OpenDis7Examples.AllPduReceiver started...");
if (args.length == 2) { if (args.length == 2) {
socket = new MulticastSocket(Integer.parseInt(args[0])); address = InetAddress.getByName(args[0]);
address = InetAddress.getByName(args[1]); socket = new MulticastSocket(Integer.parseInt(args[1]));
} }
else { else {
System.out.println("Usage: AllPduReceiver <port> <multicast group>"); System.out.println("Usage: AllPduReceiver <multicast group> <port>");
System.out.println("Default: AllPduReceiver " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); System.out.println("Default: AllPduReceiver " + DEFAULT_MULTICAST_ADDRESS + " " + DEFAULT_MULTICAST_PORT);
socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
} }
......
...@@ -18,7 +18,7 @@ import edu.nps.moves.dis7.enumerations.*; ...@@ -18,7 +18,7 @@ import edu.nps.moves.dis7.enumerations.*;
public class AllPduSender public class AllPduSender
{ {
/** Default multicast group address we send on. */ /** Default multicast group address we send on. */
public static final String DEFAULT_MULTICAST_ADDRESS = "225.4.5.6"; // "239.1.2.3"; // PduRecorder "225.4.5.6"; // public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; // PduRecorder "225.4.5.6"; //
/** Default multicast port used, matches Wireshark DIS capture default */ /** 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;
...@@ -29,19 +29,19 @@ public class AllPduSender ...@@ -29,19 +29,19 @@ public class AllPduSender
/** Number of complete loops to perform */ /** Number of complete loops to perform */
private int SEND_LOOPS_TO_PERFORM = 10; private int SEND_LOOPS_TO_PERFORM = 10;
private int port; private static InetAddress multicastAddress;
private InetAddress multicastAddress; private static int port;
public AllPduSender(int port, String multicast) { public AllPduSender(String newMulticastAddress, int newMulticastPort) {
this.port = DEFAULT_MULTICAST_PORT; this.port = DEFAULT_MULTICAST_PORT;
try try
{ {
this.port = port; multicastAddress = InetAddress.getByName(newMulticastAddress);
multicastAddress = InetAddress.getByName(multicast);
if (!multicastAddress.isMulticastAddress()) if (!multicastAddress.isMulticastAddress())
{ {
System.out.println("Not a multicast address: " + multicast); System.out.println("Not a multicast address: " + newMulticastAddress);
} }
this.port = newMulticastPort;
} }
catch (UnknownHostException e) { catch (UnknownHostException e) {
System.out.println("Unable to open socket: " + e); System.out.println("Unable to open socket: " + e);
...@@ -500,14 +500,16 @@ public class AllPduSender ...@@ -500,14 +500,16 @@ public class AllPduSender
if (args.length == 2) if (args.length == 2)
{ {
allPduSender = new AllPduSender(Integer.parseInt(args[0]), args[1]); allPduSender = new AllPduSender(args[0], Integer.parseInt(args[1]));
System.out.println("Usage: AllPduSender <multicast group> <port>");
System.out.println("Actual: AllPduSender " + multicastAddress.getHostAddress() + " " + port);
totalSentPdus = allPduSender.run(); totalSentPdus = allPduSender.run();
} }
else else
{ {
System.out.println("Usage: AllPduSender <port> <multicast group>"); System.out.println("Usage: AllPduSender <multicast group> <port>");
System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_ADDRESS + " " + DEFAULT_MULTICAST_PORT);
allPduSender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); allPduSender = new AllPduSender(DEFAULT_MULTICAST_ADDRESS, DEFAULT_MULTICAST_PORT);
totalSentPdus = allPduSender.run(); totalSentPdus = allPduSender.run();
} }
System.out.println("OpenDis7Examples.AllPduSender complete, sent " + totalSentPdus + " PDUs total."); System.out.println("OpenDis7Examples.AllPduSender complete, sent " + totalSentPdus + " PDUs total.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment