diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverA.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverA.java index 94a4176ac08a3f63062ef72aeb68bde362093d59..41d15fadb455c9e2befb829f77072208f992e62e 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverA.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverA.java @@ -21,7 +21,7 @@ public class ABEspduReceiverA { * somewhat outdated--PDUs can be larger--but this is a reasonable starting point */ public static final int MAX_PDU_SIZE = 8192; - public static final String GROUP = "239.1.2.4"; + public static final String GROUP = "239.1.2.3"; public static void main(String args[]) { MulticastSocket socket; DatagramPacket packet; @@ -32,10 +32,10 @@ public class ABEspduReceiverA { try { // Create TCP Bridge - System.out.println("Creating Bridge."); + System.out.println("Opening Bridge."); ServerSocket serverSocket = new ServerSocket(2999); - Socket clientConnection = serverSocket.accept(); + OutputStream os = clientConnection.getOutputStream(); PrintStream ps = new PrintStream(os); @@ -44,20 +44,21 @@ public class ABEspduReceiverA { System.out.println("Bridging Complete."); // Specify the socket to receive data - socket = new MulticastSocket(3100); + socket = new MulticastSocket(3000); socket.setBroadcast(true); address = InetAddress.getByName(GROUP); socket.joinGroup(address); - + + System.out.println("Joined Group"); // Loop infinitely, receiving datagrams while (true) { byte buffer[] = new byte[MAX_PDU_SIZE]; packet = new DatagramPacket(buffer, buffer.length); socket.receive(packet); - - ps.println(packet); + System.out.println("Packet Received"); + //ps.println(packet); List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData()); System.out.println("Bundle size is " + pduBundle.size()); diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderA.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderA.java index 7789921a31983794530fd377dd12454e7595eee5..79dbfbbb8b13552c6bb8fbea6dcfa5c4c5787f23 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderA.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderA.java @@ -21,10 +21,10 @@ public class ABEspduSenderA public enum NetworkMode{UNICAST, MULTICAST, BROADCAST}; /** default multicast group we send on */ - public static final String DEFAULT_MULTICAST_GROUP="239.1.2.4"; + public static final String DEFAULT_MULTICAST_GROUP="239.1.2.3"; /** Port we send on */ - public static final int DIS_DESTINATION_PORT = 3100; + public static final int DIS_DESTINATION_PORT = 3000; /** Possible system properties, passed in via -Dattr=val * networkMode: unicast, broadcast, multicast @@ -152,6 +152,14 @@ public static void main(String args[]) // Loop through sending N ESPDUs try { + int connectionCount = 0; + //Socket socketTcp = new Socket("localhost", 2998); + ServerSocket serverSocket = new ServerSocket(2999); + + + //InputStream is = socketTcp.getInputStream(); + //InputStreamReader isr = new InputStreamReader(is); + //BufferedReader br = new BufferedReader(isr); System.out.println("Sending " + NUMBER_TO_SEND + " ESPDU packets to " + destinationIp.toString()); for(int idx = 0; idx < NUMBER_TO_SEND; idx++) { @@ -233,6 +241,33 @@ public static void main(String args[]) FirePdu fire = new FirePdu(); byte[] fireArray = fire.marshal(); + /**String serverMessage = br.readLine(); + System.out.println("The message the client sent was " + serverMessage); + + // Print some information locally about the Socket + // connection. This includes the port and IP numbers + // on both sides (the socket pair.) + + InetAddress localAddress = socketTcp.getLocalAddress(); + InetAddress remoteAddress = socketTcp.getInetAddress(); + + int localPort = socketTcp.getLocalPort(); + int remotePort = socketTcp.getPort(); + + // My socket pair connection looks like this, to localhost: + // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 )) + // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54881 )) + // + // Why is the first IP/port the same, while the second set has + // different ports? + + + System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " + + remoteAddress.toString() + ", " + remotePort + " ))"); + + System.out.println("Connection count is: " + connectionCount);**/ + + // The byte array here is the packet in DIS format. We put that into a // datagram and send it. byte[] data = baos.toByteArray();