Skip to content
Snippets Groups Projects
Commit 693884e8 authored by cs2017's avatar cs2017
Browse files

AngelBlank update of Receiver and Sender A

parent e3555b70
No related branches found
No related tags found
No related merge requests found
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import edu.nps.moves.disutil.*; import edu.nps.moves.disutil.*;
import edu.nps.moves.dis.*; 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. * Receives PDUs from the network in IEEE format.
...@@ -18,7 +21,7 @@ public class ABEspduReceiverA { ...@@ -18,7 +21,7 @@ public class ABEspduReceiverA {
* somewhat outdated--PDUs can be larger--but this is a reasonable starting point * somewhat outdated--PDUs can be larger--but this is a reasonable starting point
*/ */
public static final int MAX_PDU_SIZE = 8192; public static final int MAX_PDU_SIZE = 8192;
public static final String GROUP = "239.1.2.3"; public static final String GROUP = "239.1.2.4";
public static void main(String args[]) { public static void main(String args[]) {
MulticastSocket socket; MulticastSocket socket;
DatagramPacket packet; DatagramPacket packet;
...@@ -29,12 +32,19 @@ public class ABEspduReceiverA { ...@@ -29,12 +32,19 @@ public class ABEspduReceiverA {
try { try {
// Create TCP Bridge // Create TCP Bridge
ServerSocket serverSocket = new ServerSocket(2999); System.out.println("Creating Bridge.");
ServerSocket serverSocket = new ServerSocket(2999);
Socket clientConnection = serverSocket.accept();
OutputStream os = clientConnection.getOutputStream();
PrintStream ps = new PrintStream(os);
//ByteArrayOutputStream baos = new ByteArrayOutputStream();
//DataOutputStream dos = new DataOutputStream(baos);
System.out.println("Bridging Complete.");
// Specify the socket to receive data // Specify the socket to receive data
socket = new MulticastSocket(3000); socket = new MulticastSocket(3100);
socket.setBroadcast(true); socket.setBroadcast(true);
address = InetAddress.getByName(GROUP); address = InetAddress.getByName(GROUP);
...@@ -46,6 +56,8 @@ public class ABEspduReceiverA { ...@@ -46,6 +56,8 @@ public class ABEspduReceiverA {
packet = new DatagramPacket(buffer, buffer.length); packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet); socket.receive(packet);
ps.println(packet);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData()); List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData());
System.out.println("Bundle size is " + pduBundle.size()); System.out.println("Bundle size is " + pduBundle.size());
......
...@@ -21,10 +21,10 @@ public class ABEspduSenderA ...@@ -21,10 +21,10 @@ public class ABEspduSenderA
public enum NetworkMode{UNICAST, MULTICAST, BROADCAST}; public enum NetworkMode{UNICAST, MULTICAST, BROADCAST};
/** default multicast group we send on */ /** default multicast group we send on */
public static final String DEFAULT_MULTICAST_GROUP="239.1.2.3"; public static final String DEFAULT_MULTICAST_GROUP="239.1.2.4";
/** Port we send on */ /** Port we send on */
public static final int DIS_DESTINATION_PORT = 3000; public static final int DIS_DESTINATION_PORT = 3100;
/** Possible system properties, passed in via -Dattr=val /** Possible system properties, passed in via -Dattr=val
* networkMode: unicast, broadcast, multicast * networkMode: unicast, broadcast, multicast
......
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