Skip to content
Snippets Groups Projects
Commit 46fff065 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

Merge origin/master

parents 613cfd9e 60927a08
No related branches found
No related tags found
No related merge requests found
Showing
with 1139 additions and 140 deletions
package MV3500Cohort2024JulySeptember.homework2.Yu;
import java.io.*;
import java.net.*;
/**
* @author Jin Hong Yu
*/
public class YuHW2HandlerThread extends Thread
{
/** The socket connection to a client */
Socket socket;
/**
* The thread constructor creates the socket from a ServerSocket, waiting for the client to connect,
* and passes that socket when constructing the thread responsible for handling the connection.
*
* @param socket The socket connection handled by this thread
*/
YuHW2HandlerThread(Socket socket)
{
this.socket = socket;
}
/**
* Program invocation and execution starts here - but is illegal and unwanted, so warn the unsuspecting user!
* @param args command-line arguments
*/
public static void main(String[] args)
{
System.out.println ("*** YuHW2HandlerThread is not a standalone executable progam.");
System.out.println ("*** Please run TcpExample4DispatchServer instead... now exiting.");
}
/** Handles one connection. We add an artificial slowness
* to handling the connection with a sleep(). This means
* the client won't see a server connection response for ten seconds (default).
*/
// @overriding run() method in Java Thread class is deliberate
@Override
public void run()
{
try {
System.out.println(YuHW2HandlerThread.class.getName() + " starting to handle a thread...");
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintStream ps = new PrintStream(socket.getOutputStream());
// Sequence of the Knock Knock joke
String clientMessage = in.readLine();
System.out.println("Client: " + clientMessage);
if ("Knock Knock".equals(clientMessage)) {
ps.println("Who's there?");
ps.flush();
}
clientMessage = in.readLine();
System.out.println("Client: " + clientMessage);
if ("Hatch".equals(clientMessage)) {
ps.println("Hatch who?");
ps.flush();
}
clientMessage = in.readLine();
System.out.println("Client: " + clientMessage);
if ("God Bless You!".equals(clientMessage)) {
System.out.println("Joke sequence complete.");
}
socket.close(); // all clear, no longer need socket
System.out.println(YuHW2HandlerThread.class.getName() + " finished handling a thread, now exit.");
} catch(IOException e) {
System.out.println("Problem with " + YuHW2HandlerThread.class.getName() + " networking:");
System.out.println("Error: " + e);
if (e instanceof java.net.BindException) {
System.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
}
}
package MV3500Cohort2024JulySeptember.homework2.Yu;
import java.io.IOException;
import java.net.*;
/**
* @author Jin Hong Yu
*/
public class YuHW2Server
{
/** Default constructor */
public YuHW2Server()
{
// default constructor
}
/**
* Program invocation, execution starts here
* @param args command-line arguments
*/
public static void main(String[] args)
{
try {
ServerSocket serverSocket = new ServerSocket(2317);
Socket clientConnectionSocket;
YuHW2HandlerThread handlerThread;
int connectionCount = 0; // state variable
//System.out.println(TcpExample4DispatchServer.class.getName() + " ready to accept socket connections...");
while (true) // infinite loop
{
clientConnectionSocket = serverSocket.accept(); // block! until connected
connectionCount++; // unblocked, got another connection
System.out.println("=============================================================");
//System.out.println(TcpExample4DispatchServer.class.getName() + ".handlerThread created for connection #" + connectionCount + "...");
// hand off this aready-created and connected socket to constructor
handlerThread = new YuHW2HandlerThread(clientConnectionSocket);
handlerThread.start();// invokes the run() method in that object
//System.out.println(TcpExample4DispatchServer.class.getName() + ".handlerThread is now dispatched and running, using most recent connection...");
// while(true) continue looping, serverSocket is still waiting for another customer client
}
}
catch (IOException e) {
//System.out.println("Problem with " + TcpExample4DispatchServer.class.getName() + " networking:"); // describe what is happening
System.out.println("Error: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) {
System.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
System.out.println("============================================================="); // execution complete
}
}
File added
File added
package HttpServletExamples;
import java.io.*;
import java.net.*;
/**
* A very simple http web-page reading example that won't work in some circumstances.
* But it will in some others.
*
* @author mcgredo
* @author brutzman@nps.edu
*/
public class HttpWebPageSource
{
/** Default constructor */
public HttpWebPageSource()
{
// default constructor
}
/**
* Program invocation, execution starts here
* @param args command-line arguments
*/
public static void main(String[] args)
{
try
{
System.out.println("HttpWebPageSource: create http connection and retrieve default page");
System.out.println("Reference: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol");
System.out.println("Reference: https://tools.ietf.org/html/rfc7230");
System.out.println("Reference: https://en.wikipedia.org/wiki/CURL");
System.out.println();
// We request an IP to connect to a web server running on default http port 80.
String WEB_SERVER_ADDRESS = "www.nps.edu";
int WEB_SERVER_PORT_HTTP = 80;
int WEB_SERVER_PORT_HTTPS = 443; // does this work too?
System.out.println("New socket WEB_ADDRESS=" + WEB_SERVER_ADDRESS);
// this Java construct will work for HTTP but not HTTPS
Socket socket = new Socket(WEB_SERVER_ADDRESS, WEB_SERVER_PORT_HTTPS); // compare alternative: https on port 443
// we send a command to the web server, asking for what
// we want. Note that the format for the command is very
// specific and documented.
OutputStream os = socket.getOutputStream();
PrintStream ps = new PrintStream(os);
String message = "GET /index.html HTTP/1.0";
ps.print(message); // to socket
System.out.println(message);
System.out.println();
// Commands have to terminate with "carriage return/line feed"
// twice to end the request. Those are the special characters
// to have the control characters printed. Part of the http protocol!
ps.print("\r\n\r\n");
ps.flush();
// Up until now we have been reading one line only.
// But a web server will write an unknown number of lines.
// So now we read until the transmisson ends.
InputStream is = socket.getInputStream();
Reader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
int count = 0;
while((line = br.readLine()) != null) // read from BufferedReader br one line at a time
{
count++;
System.out.println(count + ": " + line);
}
System.out.println("HttpWebPageSource: response finished");
}
catch(IOException e)
{
System.err.println("HttpWebPageSource: problem with client");
System.err.println(e);
}
}
}
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=HttpServletExamples/HttpWebPageSource.java -Drun.class=HttpServletExamples.HttpWebPageSource run-single
init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
compile-single:
run-single:
HttpWebPageSource: create http connection and retrieve default page
Reference: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
Reference: https://tools.ietf.org/html/rfc7230
Reference: https://en.wikipedia.org/wiki/CURL
New socket WEB_ADDRESS=www.nps.edu
GET /index.html HTTP/1.0
1: HTTP/1.1 301 Moved Permanently
2: Date: Wed, 12 Aug 2020 01:19:20 GMT
3: Server: Apache
4: Location: https://instituteforsecuritygovernance.org/index.html
5: Content-Length: 261
6: Connection: close
7: Content-Type: text/html; charset=iso-8859-1
8:
9: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
10: <html><head>
11: <title>301 Moved Permanently</title>
12: </head><body>
13: <h1>Moved Permanently</h1>
14: <p>The document has moved <a href="https://instituteforsecuritygovernance.org/index.html">here</a>.</p>
15: </body></html>
HttpWebPageSource: response finished
BUILD SUCCESSFUL (total time: 2 seconds)
now using https to port 443:
run-single:
HttpWebPageSource: create http connection and retrieve default page
Reference: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
Reference: https://tools.ietf.org/html/rfc7230
Reference: https://en.wikipedia.org/wiki/CURL
New socket WEB_ADDRESS=www.nps.edu
GET /index.html HTTP/1.0
1: HTTP/1.1 400 Bad Request
2: Date: Mon, 17 Aug 2020 18:25:20 GMT
3: Server: Apache
4: Content-Length: 362
5: Connection: close
6: Content-Type: text/html; charset=iso-8859-1
7:
8: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
9: <html><head>
10: <title>400 Bad Request</title>
11: </head><body>
12: <h1>Bad Request</h1>
13: <p>Your browser sent a request that this server could not understand.<br />
14: Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
15: Instead use the HTTPS scheme to access this URL, please.<br />
16: </p>
17: </body></html>
HttpWebPageSource: response finished
BUILD SUCCESSFUL (total time: 2 seconds)
File added
assignments/src/src/HttpServletExamples/JavaServletArchitecture.png

192 KiB

File added
/**
* opendis7 Http Servlet Java examples supporting the NPS MOVES MV3500 Networked Graphics course.
*
* @see <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/examples/src/HttpServletExamples" target="blank">NetworkedGraphicsMV3500 examples: HttpServletExamples</a>
* @see java.lang.Package
* @see <a href="https://stackoverflow.com/questions/22095487/why-is-package-info-java-useful" target="blank">StackOverflow: why-is-package-info-java-useful</a>
* @see <a href="https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java" target="blank">StackOverflow: how-do-i-document-packages-in-java</a>
*/
package HttpServletExamples;
package OpenDis4Examples;
import java.net.*;
import java.util.*;
import edu.nps.moves.disutil.*;
import edu.nps.moves.dis.*;
import java.io.IOException;
/**
* Receives PDUs from the network in IEEE DIS format.
* Adapted from OpenDIS library example package edu.nps.moves.examples
*
* @author DMcG
* @version $Id:$
*/
public class EspduReceiver
{
/** Default constructor */
public EspduReceiver()
{
// default constructor
}
/** Max size of a PDU in binary format that we can receive. This is actually
* somewhat outdated--PDUs can be larger--but this is a reasonable starting point.
*/
private static final int MAX_PDU_SIZE = 8192;
/** Default multicast group address we send on.
* @see <a href="https://en.wikipedia.org/wiki/Multicast_address" target="_blank">https://en.wikipedia.org/wiki/Multicast_address</a> */
private static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
/** Default multicast port used, matches Wireshark DIS capture default
* @see <a href="https://en.wikipedia.org/wiki/Port_(computer_networking)" target="_blank">https://en.wikipedia.org/wiki/Port_(computer_networking)</a> */
private static final int DEFAULT_MULTICAST_PORT = 3000;
/**
* Program invocation, execution starts here
* @param args command-line arguments
*/
public static void main(String args[])
{
System.out.println("OpenDis4Examples.EspduReceiver started...");
MulticastSocket socket;
DatagramPacket packet;
InetAddress address;
PduFactory pduFactory = new PduFactory();
try {
// Specify the socket to receive data
socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
socket.setBroadcast(true);
// address = InetAddress.getByName(EspduSender.DEFAULT_MULTICAST_GROUP);
// socket.joinGroup(address);
while (true) // Loop infinitely, receiving datagrams
{
byte buffer[] = new byte[MAX_PDU_SIZE];
packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData());
System.out.println("Bundle size is " + pduBundle.size());
Iterator iterator = pduBundle.iterator();
while(iterator.hasNext())
{
Pdu aPdu = (Pdu)iterator.next();
System.out.print("got PDU of type: " + aPdu.getClass().getSimpleName());
if(aPdu instanceof EntityStatePdu)
{
EntityID eid = ((EntityStatePdu)aPdu).getEntityID();
Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation();
System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] ");
System.out.print(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]");
}
System.out.println();
} // end trop through PDU bundle
} // end while
} // End try
catch (IOException e)
{
System.out.println("Problem with OpenDis4Examples.EspduReceiver, see exception trace:");
System.out.println(e);
}
} // end main
} // end class
package OpenDis4Examples;
import java.io.*;
import java.net.*;
import java.util.*;
import edu.nps.moves.dis.*;
import edu.nps.moves.disutil.CoordinateConversions;
import edu.nps.moves.disutil.DisTime;
/**
* Creates and sends ESPDUs in IEEE binary format. Adapted from OpenDIS library
* example package edu.nps.moves.examples
*
* @author DMcG
*/
public class EspduSender
{
/** Default constructor */
public EspduSender()
{
// default constructor
}
/** Defining number of packets to send is superior to infinite loops
* which have possible hazard of unstoppably sending packets as a zombie process */
public static final int NUMBER_TO_SEND = 5; // 5000;
/** Type of network connection */
public enum NetworkMode {
/** Unicast network mode
* @see <a href="https://en.wikipedia.org/wiki/Unicast" target="_blank">https://en.wikipedia.org/wiki/Unicast</a> */
UNICAST,
/** Multicast network mode
* @see <a href="https://en.wikipedia.org/wiki/Multicast" target="_blank">https://en.wikipedia.org/wiki/Multicast</a> */
MULTICAST,
/** Broadcast network mode
* @see <a href="https://en.wikipedia.org/wiki/Broadcasting_(networking)" target="_blank">https://en.wikipedia.org/wiki/Broadcasting_(networking)</a> */
BROADCAST
};
/**
* Default multicast group address we send on.
*/
public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
/**
* Default multicast port used, matches Wireshark DIS capture default
* @see <a href="https://en.wikipedia.org/wiki/Port_(computer_networking)" target="_blank">https://en.wikipedia.org/wiki/Port_(computer_networking)</a>
*/
public static final int DEFAULT_MULTICAST_PORT = 3000;
/**
* Possible system properties, passed in via -Dattr=val networkMode:
* unicast, broadcast, multicast destinationIp: where to send the packet. If
* in multicast mode, this can be multicast. To determine broadcast
* destination IP, use an online broadcast address calculator, for example
* http://www.remotemonitoringsystems.ca/broadcast.php If in multicast mode,
* a join() will be done on the multicast address. port: port used for both
* source and destination.
*
* @param args command-line arguments
*/
public static void main(String args[])
{
System.out.println("OpenDis4Examples.EspduSender started... send " + NUMBER_TO_SEND + " ESPDUs, initial index=0");
/**
* an entity state pdu
*/
EntityStatePdu espdu = new EntityStatePdu();
MulticastSocket socket = null; // must be initialized, even if null
DisTime disTime = DisTime.getInstance(); // TODO explain
int alternator = -1;
// ICBM coordinates for my office
double lat = 36.595517;
double lon = -121.877000;
// Default settings. These are used if no system properties are set.
// If system properties are passed in, these are over ridden.
int port = DEFAULT_MULTICAST_PORT;
NetworkMode mode = NetworkMode.BROADCAST;
InetAddress destinationIp = null; // must be initialized, even if null
try {
destinationIp = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
} catch (UnknownHostException e) {
System.out.println(e + " Cannot create multicast address");
System.exit(0);
}
// All system properties, passed in on the command line via -Dattribute=value
Properties systemProperties = System.getProperties();
// IP address we send to
String destinationIpString = systemProperties.getProperty("destinationIp");
// Port we send to, and local port we open the socket on
String portString = systemProperties.getProperty("port");
// Network mode: unicast, multicast, broadcast
String networkModeString = systemProperties.getProperty("networkMode"); // unicast or multicast or broadcast
// Set up a socket to send information
try {
// Port we send to
if (portString != null)
{
System.out.println("Using systemProperties port=" + portString);
port = Integer.parseInt(portString);
}
socket = new MulticastSocket(port);
// Where we send packets to, the destination IP address
if (destinationIpString != null)
{
destinationIp = InetAddress.getByName(destinationIpString);
}
// Type of transport: unicast, broadcast, or multicast
// TODO convert to String constants
if (networkModeString != null) {
if (networkModeString.equalsIgnoreCase("unicast"))
{
mode = NetworkMode.UNICAST;
}
else if (networkModeString.equalsIgnoreCase("broadcast")) {
mode = NetworkMode.BROADCAST;
}
else if (networkModeString.equalsIgnoreCase("multicast")) {
mode = NetworkMode.MULTICAST;
if (!destinationIp.isMulticastAddress())
{
throw new RuntimeException("Sending to multicast address, but destination address " + destinationIp.toString() + "is not multicast");
}
// socket.joinGroup(destinationIp); // deprecated, TODO select correct NetworkInterface
// =======================================================================
// updated approach using NetworkInterface
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(destinationIp);
if (networkInterface != null)
System.out.println("networkInterface=" + networkInterface.getDisplayName()); // typically null if loopback
SocketAddress localMulticastSocketAddress = new InetSocketAddress(destinationIp, DEFAULT_MULTICAST_PORT);
MulticastSocket multicastSocket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
multicastSocket.joinGroup(localMulticastSocketAddress, networkInterface);
// =======================================================================
}
} // end networkModeString
}
catch (IOException | RuntimeException e)
{
System.out.println("Unable to initialize networking. Exiting.");
System.out.println(e);
System.exit(-1);
}
// Initialize values in the Entity State PDU object. The exercise ID is
// a way to differentiate between different virtual worlds on one network.
// Note that some values (such as the PDU type and PDU family) are set
// automatically when you create the ESPDU.
espdu.setExerciseID((short) 1);
// The EID is the unique identifier for objects in the world. This
// EID should match up with the ID for the object specified in the
// VMRL/x3d/virtual world.
EntityID entityID = espdu.getEntityID();
entityID.setSite(1); // 0 is apparently not a valid site number, per the spec
entityID.setApplication(1);
entityID.setEntity(2);
// Set the entity type. SISO has a big list of enumerations, so that by
// specifying various numbers we can say this is an M1A2 American tank,
// the USS Enterprise, and so on. We'll make this a tank. There is a
// separate project elsehwhere in this project that implements DIS
// enumerations in C++ and Java, but to keep things simple we just use
// numbers here.
EntityType entityType = espdu.getEntityType();
entityType.setEntityKind((short) 1); // Platform (vs lifeform, munition, sensor, etc.)
entityType.setCountry(225); // USA
entityType.setDomain((short) 1); // Land (vs air, surface, subsurface, space)
entityType.setCategory((short) 1); // Tank
entityType.setSubcategory((short) 1); // M1 Abrams
entityType.setSpec((short) 3); // M1A2 Abrams
Set<InetAddress> broadcastAddresses;
// Loop through sending N ESPDUs
try
{
System.out.println("Sending " + NUMBER_TO_SEND + " ESPDU packets to " + destinationIp.toString());
for (int index = 0; index < NUMBER_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
// the time units can roll over to zero as you are sending. The receivers
// (escpecially homegrown ones) are often not able to detect rollover
// and may start discarding packets as dupes or out of order. We use
// an NPS timestamp here, hundredths of a second since the start of the
// year. The DIS standard for time is often ignored in the wild; I've seen
// people use Unix time (seconds since 1970) and more. Or you can
// just stuff idx into the timestamp field to get something that is monotonically
// increasing.
// Note that timestamp is used to detect duplicate and out of order packets.
// That means if you DON'T change the timestamp, many implementations will simply
// discard subsequent packets that have an identical timestamp. Also, if they
// receive a PDU with an timestamp lower than the last one they received, they
// may discard it as an earlier, out-of-order PDU. So it is a good idea to
// update the timestamp on ALL packets sent.
// An alterative approach: actually follow the standard. It's a crazy concept,
// but it might just work.
int timestamp = disTime.getDisAbsoluteTimestamp();
espdu.setTimestamp(timestamp);
// Set the position of the entity in the world. DIS uses a cartesian
// coordinate system with the origin at the center of the earth, the x
// axis out at the equator and prime meridian, y out at the equator and
// 90 deg east, and z up and out the north pole. To place an object on
// the earth's surface you also need a model for the shape of the earth
// (it's not a sphere.) All the fancy math necessary to do this is in
// the SEDRIS SRM package. There are also some one-off formulas for
// doing conversions from, for example, lat/lon/altitude to DIS coordinates.
// Here we use those one-off formulas.
// Modify the position of the object. This will send the object a little
// due east by adding some to the longitude every iteration. Since we
// are on the Pacific coast, this sends the object east. Assume we are
// at zero altitude. In other worlds you'd use DTED to determine the
// local ground altitude at that lat/lon, or you'd just use ground clamping.
// The x and y values will change, but the z value should not.
//lon = lon + (double)((double)idx / 100000.0);
//System.out.println("lla=" + lat + "," + lon + ", 0.0");
double direction = Math.pow((double) (-1.0), (double) (index));
lon = lon + (direction * 0.00006);
System.out.println(lon);
double disCoordinates[] = CoordinateConversions.getXYZfromLatLonDegrees(lat, lon, 1.0);
Vector3Double location = espdu.getEntityLocation();
location.setX(disCoordinates[0]);
location.setY(disCoordinates[1]);
location.setZ(disCoordinates[2]);
System.out.println("lat, lon:" + lat + ", " + lon);
System.out.println("DIS coord:" + disCoordinates[0] + ", " + disCoordinates[1] + ", " + disCoordinates[2]);
// Optionally, we can do some rotation of the entity
/*
Orientation orientation = espdu.getEntityOrientation();
float psi = orientation.getPsi();
psi = psi + idx;
orientation.setPsi(psi);
orientation.setTheta((float)(orientation.getTheta() + idx /2.0));
*/
// You can set other ESPDU values here, such as the velocity, acceleration,
// and so on.
// Marshal out the espdu object to a byte array, then send a datagram
// packet with that data in it.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
espdu.marshal(dos);
FirePdu fire = new FirePdu();
byte[] fireArray = fire.marshal();
// The byte array here is the packet in DIS format. We put that into a
// datagram and send it.
byte[] data = baos.toByteArray();
broadcastAddresses = getBroadcastAddresses();
Iterator iterator = broadcastAddresses.iterator();
while (iterator.hasNext())
{
InetAddress broadcast = (InetAddress) iterator.next();
System.out.println("Sending broadcast datagram packet to " + broadcast);
DatagramPacket packet = new DatagramPacket(data, data.length, broadcast, port);
socket.send(packet);
// TODO experiment with these! 8)
packet = new DatagramPacket(fireArray, fireArray.length, broadcast, port); // alternate
socket.send(packet);
}
// Send every 1 sec. Otherwise all this will be all over in a fraction of a second.
Thread.sleep(1000); // msec
location = espdu.getEntityLocation();
System.out.println("Espdu #" + index + " EID=[" + entityID.getSite() + "," + entityID.getApplication() + "," + entityID.getEntity() + "]");
System.out.println(" DIS coordinates location=[" + location.getX() + "," + location.getY() + "," + location.getZ() + "]");
double c[] = {location.getX(), location.getY(), location.getZ()};
double lla[] = CoordinateConversions.xyzToLatLonDegrees(c);
// debug: System.out.println(" Location (lat/lon/alt): [" + lla[0] + ", " + lla[1] + ", " + lla[2] + "]");
}
}
catch (IOException | InterruptedException e)
{
System.out.println("Problem with OpenDis4Examples.EspduSender, see exception trace:");
System.out.println(e);
}
}
/**
* A number of sites get all snippy about using 255.255.255.255 for a
* broadcast address; it trips their security software and they kick you off
* their network. (Comcast, NPS.) This determines the broadcast address for
* all connected interfaces, based on the IP and subnet mask. If you have a
* dual-homed host it will return a broadcast address for both. If you have
* some VMs running on your host this will pick up the addresses for those
* as well--e.g. running VMWare on your laptop with a local IP this will also
* pick up a 192.168 address assigned to the VM by the host OS.
*
* @return set of all broadcast addresses
*/
public static Set<InetAddress> getBroadcastAddresses()
{
Set<InetAddress> broadcastAddresses = new HashSet<>();
Enumeration interfaces;
try {
interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements())
{
NetworkInterface anInterface = (NetworkInterface) interfaces.nextElement();
if (anInterface.isUp())
{
Iterator iterator = anInterface.getInterfaceAddresses().iterator();
while (iterator.hasNext())
{
InterfaceAddress anAddress = (InterfaceAddress) iterator.next();
if ((anAddress == null || anAddress.getAddress().isLinkLocalAddress()))
{
continue;
}
//System.out.println("Getting broadcast address for " + anAddress);
InetAddress broadcastAddress = anAddress.getBroadcast();
if (broadcastAddress != null)
{
broadcastAddresses.add(broadcastAddress);
}
}
}
}
}
catch (SocketException e)
{
System.out.println("Problem with OpenDis4Examples.EspduSender.getBroadcastAddresses(), see exception trace:");
System.out.println(e);
}
return broadcastAddresses;
}
}
assignments/src/src/OpenDis4Examples/EspduSenderWireshark.png

120 KiB

Invocation instructions:
1. run/debug EspduReceiver.java (since sender does not block, must first be ready to listen)
2. run/debug EspduSender.java
Program responses for sender and receiver:
===================================================
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=OpenDis4Examples/EspduSender.java -Drun.class=OpenDis4Examples.EspduSender run-single
init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
compile-single:
run-single:
OpenDis4Examples.EspduSender started... send 5 ESPDUs, initial index=0
Sending 5 ESPDU packets to /239.1.2.3
-121.87693999999999
lat, lon:36.595517, -121.87693999999999
DIS coord:-2707488.3677768684, -4353666.735244378, 3781450.3202754413
Sending broadcast datagram packet to /127.255.255.255
Sending broadcast datagram packet to /172.23.143.255
Sending broadcast datagram packet to /172.16.0.255
Sending broadcast datagram packet to /172.20.209.219
Espdu #0 EID=[1,1,2]
DIS coordinates location=[-2707488.3677768684,-4353666.735244378,3781450.3202754413]
-121.877
lat, lon:36.595517, -121.877
DIS coord:-2707492.9269245286, -4353663.899966802, 3781450.3202754413
Sending broadcast datagram packet to /127.255.255.255
Sending broadcast datagram packet to /172.23.143.255
Sending broadcast datagram packet to /172.16.0.255
Sending broadcast datagram packet to /172.20.209.219
Espdu #1 EID=[1,1,2]
DIS coordinates location=[-2707492.9269245286,-4353663.899966802,3781450.3202754413]
-121.87693999999999
lat, lon:36.595517, -121.87693999999999
DIS coord:-2707488.3677768684, -4353666.735244378, 3781450.3202754413
Sending broadcast datagram packet to /127.255.255.255
Sending broadcast datagram packet to /172.23.143.255
Sending broadcast datagram packet to /172.16.0.255
Sending broadcast datagram packet to /172.20.209.219
Espdu #2 EID=[1,1,2]
DIS coordinates location=[-2707488.3677768684,-4353666.735244378,3781450.3202754413]
-121.877
lat, lon:36.595517, -121.877
DIS coord:-2707492.9269245286, -4353663.899966802, 3781450.3202754413
Sending broadcast datagram packet to /127.255.255.255
Sending broadcast datagram packet to /172.23.143.255
Sending broadcast datagram packet to /172.16.0.255
Sending broadcast datagram packet to /172.20.209.219
Espdu #3 EID=[1,1,2]
DIS coordinates location=[-2707492.9269245286,-4353663.899966802,3781450.3202754413]
-121.87693999999999
lat, lon:36.595517, -121.87693999999999
DIS coord:-2707488.3677768684, -4353666.735244378, 3781450.3202754413
Sending broadcast datagram packet to /127.255.255.255
Sending broadcast datagram packet to /172.23.143.255
Sending broadcast datagram packet to /172.16.0.255
Sending broadcast datagram packet to /172.20.209.219
Espdu #4 EID=[1,1,2]
DIS coordinates location=[-2707488.3677768684,-4353666.735244378,3781450.3202754413]
BUILD SUCCESSFUL (total time: 12 seconds)
===================================================
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=OpenDis4Examples/EspduReceiver.java -Drun.class=OpenDis4Examples.EspduReceiver run-single
init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
compile-single:
run-single:
OpenDis4Examples.EspduReceiver started...
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707488.3677768684, -4353666.735244378, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707488.3677768684, -4353666.735244378, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707492.9269245286, -4353663.899966802, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707492.9269245286, -4353663.899966802, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707488.3677768684, -4353666.735244378, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707488.3677768684, -4353666.735244378, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707492.9269245286, -4353663.899966802, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707492.9269245286, -4353663.899966802, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707488.3677768684, -4353666.735244378, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
Bundle size is 1
got PDU of type: edu.nps.moves.dis.EntityStatePdu EID:[1, 1, 2] Location in DIS coordinates: [-2707488.3677768684, -4353666.735244378, 3781450.3202754413]
Bundle size is 1
got PDU of type: edu.nps.moves.dis.FirePdu
===================================================
package OpenDis4Examples;
// originally edu.nps.moves.examples.ReceiverPerformance
import java.net.*;
import edu.nps.moves.dis.*;
import edu.nps.moves.disutil.PduFactory;
import java.io.IOException;
/** Listen for IEEE DIS Protocol Data Units (PDUs) */
public class PduReceiver
{
/** Default constructor */
public PduReceiver()
{
// default constructor
}
private static final int MULTICAST_PORT = 3000;
private static final String MULTICAST_GROUP = "239.1.2.3";
private static final boolean USE_FAST_ESPDU = false;
/**
* Program invocation, execution starts here
* @param args command-line arguments
*/
public static void main(String args[])
{
PduFactory factory;
MulticastSocket socket;
InetAddress address;
DatagramPacket packet;
try
{
System.out.println("OpenDis4Examples.PduReceiver started...");
socket = new MulticastSocket (MULTICAST_PORT);
address = InetAddress.getByName(MULTICAST_GROUP);
// socket.joinGroup(address); // deprecated
// =======================================================================
// new approach using interface
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(address);
SocketAddress localMulticastSocketAddress = new InetSocketAddress(address, MULTICAST_PORT);
socket.joinGroup(localMulticastSocketAddress, networkInterface);
// =======================================================================
factory = new PduFactory();
while (true) // Loop infinitely, receiving datagrams
{
byte buffer[] = new byte[1500]; // typical MTU size
packet = new DatagramPacket(buffer, buffer.length); // reset
socket.receive(packet);
Pdu pdu = factory.createPdu (packet.getData());
if (pdu != null)
{
short currentPduType = pdu.getPduType();
String currentPduTypeName = pdu.getClass().getSimpleName();
short currentProtocolFamilyID = pdu.getProtocolFamily();
String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
StringBuilder message = new StringBuilder();
message.append("received DIS PDU: ");
message.append("pduType ");
if (currentPduType < 10)
message.append(" ");
message.append(currentPduType).append(" ").append(currentPduTypeName);
message.append(", protocolFamily ").append(currentProtocolFamilyID);
message.append(" ").append(currentPduFamilyName);
System.out.println(message.toString());
}
else System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error...");
}
}
catch (IOException e)
{
System.out.println("Problem with OpenDis4Examples.PduReceiver, see exception trace:");
System.out.println(e);
}
finally
{
System.out.println("OpenDis4Examples.PduReceiver complete.");
}
}
}
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=OpenDis4Examples/PduReceiver.java -Drun.class=OpenDis4Examples.PduReceiver run-single
init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
compile-single:
run-single:
OpenDis4Examples.PduReceiver started...
received DIS PDU: pduType 1 edu.nps.moves.dis.EntityStatePdu, protocolFamily 1 EntityInformationFamilyPdu
received DIS PDU: pduType 2 edu.nps.moves.dis.FirePdu, protocolFamily 2 WarfareFamilyPdu
received DIS PDU: pduType 3 edu.nps.moves.dis.DetonationPdu, protocolFamily 2 WarfareFamilyPdu
received DIS PDU: pduType 4 edu.nps.moves.dis.CollisionPdu, protocolFamily 1 EntityInformationFamilyPdu
received DIS PDU: pduType 5 edu.nps.moves.dis.ServiceRequestPdu, protocolFamily 3 LogisticsFamilyPdu
received DIS PDU: pduType 6 edu.nps.moves.dis.ResupplyOfferPdu, protocolFamily 3 LogisticsFamilyPdu
received packet but pdu is null, packet.getData().length=1500, error...
received DIS PDU: pduType 8 edu.nps.moves.dis.ResupplyCancelPdu, protocolFamily 3 LogisticsFamilyPdu
received DIS PDU: pduType 9 edu.nps.moves.dis.RepairCompletePdu, protocolFamily 3 LogisticsFamilyPdu
received DIS PDU: pduType 10 edu.nps.moves.dis.RepairResponsePdu, protocolFamily 3 LogisticsFamilyPdu
received DIS PDU: pduType 11 edu.nps.moves.dis.CreateEntityPdu, protocolFamily 5 SimulationManagementFamilyPdu
received DIS PDU: pduType 12 edu.nps.moves.dis.RemoveEntityPdu, protocolFamily 5 SimulationManagementFamilyPdu
received DIS PDU: pduType 13 edu.nps.moves.dis.StartResumePdu, protocolFamily 5 SimulationManagementFamilyPdu
received DIS PDU: pduType 14 edu.nps.moves.dis.StopFreezePdu, protocolFamily 5 SimulationManagementFamilyPdu
received DIS PDU: pduType 15 edu.nps.moves.dis.AcknowledgePdu, protocolFamily 5 SimulationManagementFamilyPdu
received DIS PDU: pduType 16 edu.nps.moves.dis.ActionRequestPdu, protocolFamily 5 SimulationManagementFamilyPdu
received DIS PDU: pduType 22 edu.nps.moves.dis.CommentPdu, protocolFamily 5 SimulationManagementFamilyPdu
package OpenDis4Examples;
import java.io.*;
import java.net.*;
import java.util.*;
import edu.nps.moves.dis.*;
import edu.nps.moves.disenum.*;
import edu.nps.moves.examples.ClassNameComparator;
/**
* This is an example that sends many/most types of PDUs. Useful for testing standards
* compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file.
* Adapted from OpenDIS library example package edu.nps.moves.examples
*
* @author DMcG
* @version $Id:$
*/
public class PduSender
{
/** Default multicast group address we send on.
* @see <a href="https://en.wikipedia.org/wiki/Multicast_address" target="_blank">https://en.wikipedia.org/wiki/Multicast_address</a> */
private static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
/** Default multicast port used, matches Wireshark DIS capture default
* @see <a href="https://en.wikipedia.org/wiki/Port_(computer_networking)" target="_blank">https://en.wikipedia.org/wiki/Port_(computer_networking)</a> */
private static final int DEFAULT_MULTICAST_PORT = 3000;
private int port;
InetAddress multicastAddress;
/** Object constructor
* @param port port of interest
* @param multicast address of interest */
public PduSender(int port, String multicast) {
try
{
this.port = port;
multicastAddress = InetAddress.getByName(multicast);
if (!multicastAddress.isMulticastAddress())
{
System.out.println("Not a multicast address: " + multicast);
}
}
catch (UnknownHostException e) {
System.out.println("Unable to open socket: " + e);
}
}
/** Begin operations */
public void run()
{
System.out.println("OpenDis4Examples.PduSender started...");
try {
List<Pdu> generatedPdusList = new ArrayList<>();
// Loop through all the enumerated PDU types, create a PDU for each type,
// add that PDU to generatedPdusList, and send each one
for (PduType pdu : PduType.values())
{
Pdu aPdu = null; // edu.​nps.​moves.​dis,PDU superclass for all PDUs,
switch (pdu) // using enumeration values from edu.nps.moves.disenum.*
{
case ENTITY_STATE:
aPdu = new EntityStatePdu();
EntityStatePdu espdu = (EntityStatePdu) aPdu;
Marking marking = new Marking ();
marking.setCharactersString("PduSender"); // 11 characters max
espdu.setMarking(marking);
Vector3Double espduLocation = new Vector3Double();
espduLocation.setX(1.0);
espduLocation.setY(2.0);
espduLocation.setZ(3.0);
espdu.setEntityLocation(espduLocation);
// it is important to identify questions as you think of them
// TODO how to set azimuth, i.e. course direction over ground?
break;
case COMMENT:
aPdu = new CommentPdu();
CommentPdu newCommentPdu = (CommentPdu)aPdu;
VariableDatum newVariableDatum = new VariableDatum();
// etc. see Garrett and Pete's code
break;
case FIRE:
aPdu = new FirePdu();
break;
case DETONATION:
aPdu = new DetonationPdu();
break;
case COLLISION:
aPdu = new CollisionPdu();
break;
case SERVICE_REQUEST:
aPdu = new ServiceRequestPdu();
break;
case RESUPPLY_OFFER:
aPdu = new ResupplyOfferPdu();
break;
case RESUPPLY_RECEIVED:
aPdu = new ResupplyReceivedPdu();
break;
case RESUPPLY_CANCEL:
aPdu = new ResupplyCancelPdu();
break;
case REPAIR_COMPLETE:
aPdu = new RepairCompletePdu();
break;
case REPAIR_RESPONSE:
aPdu = new RepairResponsePdu();
break;
case CREATE_ENTITY:
aPdu = new CreateEntityPdu();
break;
case REMOVE_ENTITY:
aPdu = new RemoveEntityPdu();
break;
case START_RESUME:
aPdu = new StartResumePdu();
break;
case STOP_FREEZE:
aPdu = new StopFreezePdu();
break;
case ACKNOWLEDGE:
aPdu = new AcknowledgePdu();
break;
case ACTION_REQUEST:
aPdu = new ActionRequestPdu();
break;
default:
System.out.print("PDU of type " + pdu + " not supported, created or sent ");
System.out.println();
}
if (aPdu != null)
{
generatedPdusList.add(aPdu);
}
}
// Sort the created PDUs by class name, if desired
// Collections.sort(generatedPdusList, new ClassNameComparator());
System.out.println("Send the " + generatedPdusList.size() + " PDUs we created...");
// Send the PDUs we created
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
// socket.joinGroup(localMulticastAddress); // deprecated, TODO select correct NetworkInterface
// =======================================================================
// updated approach using NetworkInterface
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localMulticastAddress);
if (networkInterface != null)
System.out.println("networkInterface=" + networkInterface.getDisplayName()); // typically null if loopback
SocketAddress localMulticastSocketAddress = new InetSocketAddress(localMulticastAddress, DEFAULT_MULTICAST_PORT);
socket.joinGroup(localMulticastSocketAddress, networkInterface);
// =======================================================================
for (int idx = 0; idx < generatedPdusList.size(); idx++)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
byte[] buffer;
Pdu aPdu = generatedPdusList.get(idx);
aPdu.marshal(dos);
buffer = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
socket.send(packet);
System.out.println("Sent PDU of type " + aPdu.getClass().getSimpleName());
}
// write the PDUs out to an XML file.
//PduContainer container = new PduContainer();
//container.setPdus(generatedPdus);
//container.marshallToXml("examplePdus.xml");
} catch (IOException e)
{
System.out.println(e);
}
}
/**
* Program invocation, execution starts here
* @param args command-line arguments
*/
public static void main(String args[])
{
if (args.length == 2) {
PduSender sender = new PduSender(Integer.parseInt(args[0]), args[1]);
sender.run();
} else {
System.out.println("Usage: PduSender <port> <multicast group>");
System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
PduSender sender = new PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
sender.run();
}
}
}
ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=OpenDis4Examples/PduSender.java -Drun.class=OpenDis4Examples.PduSender run-single
init:
Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
deps-jar:
Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties
Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes
compile-single:
run-single:
Usage: PduSender <port> <multicast group>
Default: PduSender 3000 239.1.2.3
OpenDis4Examples.PduSender started...
PDU of type OTHER not supported, created or sent
PDU of type ACTION_RESPONSE not supported, created or sent
PDU of type DATA_QUERY not supported, created or sent
PDU of type SET_DATA not supported, created or sent
PDU of type DATA not supported, created or sent
PDU of type EVENT_REPORT not supported, created or sent
PDU of type ELECTROMAGNETIC_EMISSION not supported, created or sent
PDU of type DESIGNATOR not supported, created or sent
PDU of type TRANSMITTER not supported, created or sent
PDU of type SIGNAL not supported, created or sent
PDU of type RECEIVER not supported, created or sent
PDU of type IFF_ATC_NAVAIDS not supported, created or sent
PDU of type UNDERWATER_ACOUSTIC not supported, created or sent
PDU of type SUPPLEMENTAL_EMISSION_ENTITY_STATE not supported, created or sent
PDU of type INTERCOM_SIGNAL not supported, created or sent
PDU of type INTERCOM_CONTROL not supported, created or sent
PDU of type AGGREGATE_STATE not supported, created or sent
PDU of type ISGROUPOF not supported, created or sent
PDU of type TRANSFER_CONTROL not supported, created or sent
PDU of type ISPARTOF not supported, created or sent
PDU of type MINEFIELD_STATE not supported, created or sent
PDU of type MINEFIELD_QUERY not supported, created or sent
PDU of type MINEFIELD_DATA not supported, created or sent
PDU of type MINEFIELD_RESPONSE_NAK not supported, created or sent
PDU of type ENVIRONMENTAL_PROCESS not supported, created or sent
PDU of type GRIDDED_DATA not supported, created or sent
PDU of type POINT_OBJECT_STATE not supported, created or sent
PDU of type LINEAR_OBJECT_STATE not supported, created or sent
PDU of type AREAL_OBJECT_STATE not supported, created or sent
PDU of type TSPI not supported, created or sent
PDU of type APPEARANCE not supported, created or sent
PDU of type ARTICULATED_PARTS not supported, created or sent
PDU of type LE_FIRE not supported, created or sent
PDU of type LE_DETONATION not supported, created or sent
PDU of type CREATE_ENTITY_R not supported, created or sent
PDU of type REMOVE_ENTITY_R not supported, created or sent
PDU of type START_RESUME_R not supported, created or sent
PDU of type STOP_FREEZE_R not supported, created or sent
PDU of type ACKNOWLEDGE_R not supported, created or sent
PDU of type ACTION_REQUEST_R not supported, created or sent
PDU of type ACTION_RESPONSE_R not supported, created or sent
PDU of type DATA_QUERY_R not supported, created or sent
PDU of type SET_DATA_R not supported, created or sent
PDU of type DATA_R not supported, created or sent
PDU of type EVENT_REPORT_R not supported, created or sent
PDU of type COMMENT_R not supported, created or sent
PDU of type RECORD_R not supported, created or sent
PDU of type SET_RECORD_R not supported, created or sent
PDU of type RECORD_QUERY_R not supported, created or sent
PDU of type COLLISION_ELASTIC not supported, created or sent
PDU of type ENTITY_STATE_UPDATE not supported, created or sent
Send the 17 PDUs we created...
Sent PDU of type edu.nps.moves.dis.EntityStatePdu
Sent PDU of type edu.nps.moves.dis.FirePdu
Sent PDU of type edu.nps.moves.dis.DetonationPdu
Sent PDU of type edu.nps.moves.dis.CollisionPdu
Sent PDU of type edu.nps.moves.dis.ServiceRequestPdu
Sent PDU of type edu.nps.moves.dis.ResupplyOfferPdu
Sent PDU of type edu.nps.moves.dis.ResupplyReceivedPdu
Sent PDU of type edu.nps.moves.dis.ResupplyCancelPdu
Sent PDU of type edu.nps.moves.dis.RepairCompletePdu
Sent PDU of type edu.nps.moves.dis.RepairResponsePdu
Sent PDU of type edu.nps.moves.dis.CreateEntityPdu
Sent PDU of type edu.nps.moves.dis.RemoveEntityPdu
Sent PDU of type edu.nps.moves.dis.StartResumePdu
Sent PDU of type edu.nps.moves.dis.StopFreezePdu
Sent PDU of type edu.nps.moves.dis.AcknowledgePdu
Sent PDU of type edu.nps.moves.dis.ActionRequestPdu
Sent PDU of type edu.nps.moves.dis.CommentPdu
BUILD SUCCESSFUL (total time: 2 seconds)
assignments/src/src/OpenDis4Examples/PduSenderWireshark.png

116 KiB

# DIS Protocol Examples using Open-DIS-4 Java Library
*Note:* these archived examples demonstrate an earlier version of Open-DIS-Java Library.
Please work with current version [OpenDis7Examples](../OpenDis7Examples) instead.
---
Course examples using the [Open-DIS-Java](https://github.com/open-dis/open-dis-java) library are presented in this package.
See [specifications](../../../specifications) directory to obtain reference copies of DIS and RPRFOM standards.
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