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.util.*;
import edu.nps.moves.disutil.*;
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.
......@@ -18,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.3";
public static final String GROUP = "239.1.2.4";
public static void main(String args[]) {
MulticastSocket socket;
DatagramPacket packet;
......@@ -29,12 +32,19 @@ public class ABEspduReceiverA {
try {
// 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
socket = new MulticastSocket(3000);
socket = new MulticastSocket(3100);
socket.setBroadcast(true);
address = InetAddress.getByName(GROUP);
......@@ -46,6 +56,8 @@ public class ABEspduReceiverA {
packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
ps.println(packet);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData());
System.out.println("Bundle size is " + pduBundle.size());
......
......@@ -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.3";
public static final String DEFAULT_MULTICAST_GROUP="239.1.2.4";
/** 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
* 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