Skip to content
Snippets Groups Projects
Commit 3f77bf7c authored by Oblak, William (Maj)'s avatar Oblak, William (Maj)
Browse files

Merge origin/master

parents cc74bca8 1e1a7d57
No related branches found
No related tags found
No related merge requests found
Showing
with 796 additions and 531 deletions
.DS_Store 0 → 100644
File added
File added
......@@ -36,14 +36,20 @@ All MV3500 cohorts have source code collected under a common Netbeans project.
4. Name all of your files starting with your last name, e.g. **LastnameProgram.java** **LastnameScreenshot.png** etc.
5. Be sure that names match for **LastnameProgram.java** and the class name, i.e. **public class LastnameJava**
6. Be sure to start each .java source file with correct package name, for example:
1. package MV3500Cohort2021JulySeptember.homework1;
7. The Run and Debug context menus should be available for you to test your .java source.
8. Be sure to Commit (with description) and Push Upstream, as discussed above.
* package MV3500Cohort2022MayJune.homework1;
* package MV3500Cohort2022MayJune.homework2; etc.
7. Add a copy of **package-info.java** file to your directory. If you use NetBeans to copy, then it helpfully performs a rename refactoring and the file's package name is correct.
8. Check the javadoc by going to [build.xml](build.xml) and running target **javadoc.custom**
9. Be sure to Commit (with description) and Push Upstream, as discussed above.
After committing and pushing, you can now verify that your files are been shared by checking the website:
* https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/tree/master/assignments/src/MV3500Cohort2023MarchJune
**Clarity is key.** Good practices
* Note your changes in a **README.md** file.
* For nontrivial projects, you will also need to add a UML flow diagram and a UML timing sequence diagram.
* Visio has templates for UML diagrams, drawings with another tool or hand sketches are fine.
## References
......
......@@ -2,6 +2,8 @@
This directory holds temporary PDU log files which may be deleted at any time!
To clean out old log files, simply run this directory's **[build.xml](build.xml)** target `clean.all.pduLogs`
Each time you run a DIS simulation and a PduRecorder is listening, another
log file is created. File names are numbered sequentially and uniquely, so that
important PDU log captures can later be copied and saved to where they are needed.
......@@ -14,4 +16,4 @@ the corresponding homework or project directory (and likely renaming as well).
Note that the PDU log files are very tolerant of inline comments starting with
a # character, so you can document success/failure and TODO issues there as well.
To clean out old log files, simply run [build.xml](build.xml) target `clean.all.log.files`
<!-- https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/blob/master/assignments/pduLog/README.md -->
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 1995-2021 held by the author(s). All rights reserved.
Copyright (c) 1995-2023 held by the author(s). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
......
File added
File added
## Student assignments: homework submission directories
<!-- View this page at https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/blob/master/assignments/src/MV3500Cohort2023MarchJune/README.md -->
* [Homework 1 README](homework1/README.md) Netbeans, Wireshark, Telnet, TCP Sockets
* [Homework 2 README](homework2/README.md) UDP Multicast Client/Server Networking
* [Homework 3 README](homework3/README.md) Example Simulation Recording OpenDIS Network Streams
......
/**
* Assignment 3 - Example Simulation Program for MV3500.
*
* @see <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/assignments">networkedGraphicsMV3500 assignments</a>
* @see java.lang.Package
* @see <a href="https://stackoverflow.com/questions/22095487/why-is-package-info-java-useful">StackOverflow: why-is-package-info-java-useful</a>
* @see <a href="https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java">StackOverflow: how-do-i-document-packages-in-java</a>
*/
package MV3500Cohort2023MarchJune.homework3.Chojnacki;
/**
* Final project assignments supporting the NPS MOVES MV3500 Networked Graphics course.
*
* @see <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/assignments">networkedGraphicsMV3500 assignments</a>
* @see java.lang.Package
* @see <a href="https://stackoverflow.com/questions/22095487/why-is-package-info-java-useful">StackOverflow: why-is-package-info-java-useful</a>
* @see <a href="https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java">StackOverflow: how-do-i-document-packages-in-java</a>
*/
package MV3500Cohort2023MarchJune.homework3.Fredrickson;
......@@ -176,6 +176,14 @@ public class ExampleSimulationProgram
// more is needed here by scenario authors...
munitionDescriptor1.setQuantity(1);
firePdu_1a.setDescriptor(munitionDescriptor1).setRange(1000.0f);
entityStatePdu_2.getEntityLocation().setX(0.0); // Initial location of Entity 2
entityStatePdu_2.getEntityLocation().setZ(0.0); // Initial location of Entity 2
entityStatePdu_2.getEntityLocation().setY(0.0); // Initial location of Entity 2
entityStatePdu_1.getEntityLocation().setX(1050.0); // Initial location of Entity 2
entityStatePdu_1.getEntityLocation().setZ(0.0); // Initial location of Entity 2
entityStatePdu_1.getEntityLocation().setY(500.0); // Initial location of Entity 2
}
/**
......@@ -223,12 +231,37 @@ public class ExampleSimulationProgram
// compute a track, update an ESPDU, whatever it is that your model is doing...
// Where is my entity? Insert changes in position; this sample only changes X position.
// Adjusted to change all X, Y, and Z positions - swislas
entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep
entityStatePdu_1.getEntityLocation().setY(entityStatePdu_1.getEntityLocation().getY() + 1.0); // 1m per timestep
entityStatePdu_1.getEntityLocation().setZ(entityStatePdu_1.getEntityLocation().getZ() + 1.0); // 1m per timestep
// Velocity calculations for Entity 1 moving towards Entity 2
Double dMinusP_X = entityStatePdu_2.getEntityLocation().getX() - entityStatePdu_1.getEntityLocation().getX();
Double dMinusP_Z = entityStatePdu_2.getEntityLocation().getZ() - entityStatePdu_1.getEntityLocation().getZ();
Double magnitudeDMinusP = Math.sqrt(dMinusP_X * dMinusP_X + dMinusP_Z * dMinusP_Z);
Double speed = 77.2; // Average speed of CH53 - meters per second
// Final velocity values
Double velocityX = dMinusP_X * speed / magnitudeDMinusP;
Double velocityZ = dMinusP_Z * speed / magnitudeDMinusP;
// Moves Entity 1 towards Entity 2
entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + velocityX);
entityStatePdu_1.getEntityLocation().setZ(entityStatePdu_1.getEntityLocation().getZ() + velocityZ);
// decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoot at!
// Calculates the total distance between the two Entities
double magnitudeX = entityStatePdu_2.getEntityLocation().getX() - entityStatePdu_1.getEntityLocation().getX();
double magnitudeY = entityStatePdu_2.getEntityLocation().getY() - entityStatePdu_1.getEntityLocation().getY();
double magnitudeZ = entityStatePdu_2.getEntityLocation().getZ() - entityStatePdu_1.getEntityLocation().getZ();
double magnitude = Math.sqrt(magnitudeX * magnitudeX + magnitudeY * magnitudeY + magnitudeZ * magnitudeZ);
// Shows an easy to identify log of Entity movement and a firing action
System.out.println("");
System.out.println(entityStatePdu_1.getEntityLocation());
if (magnitude < firePdu_1a.getRange()) {
firePdu_1a.setFiringEntityID(entityID_1);
firePdu_1a.setTargetEntityID(entityID_2);
firePdu_1a.setDescriptor(munitionDescriptor1);
System.out.println("Fire at target");
}
System.out.println("");
// etc. etc. your code goes here for your simulation of interest
......
/**
* Assignment3 for the NPS MOVES MV3500 Networked Graphics course.
*
* @see <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/assignments">networkedGraphicsMV3500 assignments</a>
* @see java.lang.Package
* @see <a href="https://stackoverflow.com/questions/22095487/why-is-package-info-java-useful">StackOverflow: why-is-package-info-java-useful</a>
* @see <a href="https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java">StackOverflow: how-do-i-document-packages-in-java</a>
*
* Sets coordinates for Entity 1 and Entity 2. When simulations starts, Entity 1 advances towards Entity 2 and
* fires munitions when in range. Prints Entity 1 location and firing info (on occurance) to console after each step of the simulation.
*
* Adjusted time between loops to three seconds to allow for ease of reading.
*
* Adjusted total number of loops to 4 to shorten simulation time.
*
*/
package MV3500Cohort2023MarchJune.homework3.Islas;
No preview for this file type
ant -f C:\\x3d-nps-gitlab\\NetworkedGraphicsMV3500\\assignments -Dnb.internal.action.name=run.single -Djavac.includes=MV3500Cohort2023MarchJune/homework3/Oblak/ExampleSimulationProgram.java -Drun.class=MV3500Cohort2023MarchJune.homework3.Oblak.ExampleSimulationProgram run-single
init:
Deleting: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\assignments\build\built-jar.properties
deps-jar:
Updating property file: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\assignments\build\built-jar.properties
Compiling 1 source file to C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\assignments\build\classes
warning: [options] system modules path not set in conjunction with -source 17
1 warning
compile-single:
run-single:
[MV3500Cohort2023MarchJune.homework3.Oblak.ExampleSimulationProgram] started...
[DisThreadedNetworkInterface] using network interface Intel(R) Wi-Fi 6E AX210 160MHz
[DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete.
[DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true
[DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true
Network confirmation: address=239.1.2.3 port=3000
Beginning pdu save to directory ./pduLog
[PduRecorder ExampleSimulationProgramAllen_3 pduRecorder] Recorder log file open: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\assignments\pduLog\PduCaptureLog11.dislog
[PduRecorder ExampleSimulationProgramAllen_3 pduRecorder] listening to IP address 239.1.2.3 on port 3000
range: 6.0 hops from our Network DMZ!
... My simulation just did something, no really...
... [Pausing for 1.0 seconds]
sending PDUs for simulation step 1, monitor loopback to confirm sent
*** [Narrative comment sent: APPLICATION_TIMESTEP] [MV3500 ExampleSimulationProgramAllen_3, runSimulation() loop 1, this is working!]
... [PDUs successfully sent for this loop]
range: 5.0 hops from our Network DMZ!
... My simulation just did something, no really...
... [Pausing for 1.0 seconds]
sending PDUs for simulation step 2, monitor loopback to confirm sent
*** [Narrative comment sent: APPLICATION_TIMESTEP] [MV3500 ExampleSimulationProgramAllen_3, runSimulation() loop 2, this is working!]
... [PDUs successfully sent for this loop]
range: 4.0 hops from our Network DMZ!
Entity#103 is firing Other.Country 13 AUSTRALIA_AUS.2.8.1. at Entity#6666
... My simulation just did something, no really...
... [Pausing for 1.0 seconds]
sending PDUs for simulation step 3, monitor loopback to confirm sent
*** [Narrative comment sent: APPLICATION_TIMESTEP] [MV3500 ExampleSimulationProgramAllen_3, runSimulation() loop 3, this is working!]
... [PDUs successfully sent for this loop]
range: 3.0 hops from our Network DMZ!
Entity#103 is firing Other.Country 13 AUSTRALIA_AUS.2.8.1. at Entity#6666
Malware Packet DESTROYED BY Firewall after 2pings from the traceroute.
... My simulation just did something, no really...
... [Pausing for 1.0 seconds]
sending PDUs for simulation step 4, monitor loopback to confirm sent
*** [Narrative comment sent: APPLICATION_TIMESTEP] [MV3500 ExampleSimulationProgramAllen_3, runSimulation() loop 4, this is working!]
... [PDUs successfully sent for this loop]
... [Termination condition met, simulationComplete=true]
*** [Narrative comment sent: COMPLETE_EVENT_REPORT] [MV3500 ExampleSimulationProgramAllen_3, runSimulation() completed successfully, this is working!]
... [final CommentPdu successfully sent for simulation]
PduRecorder.stop() closing recorder log file: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\assignments\pduLog\PduCaptureLog11.dislog
[MV3500Cohort2023MarchJune.homework3.Oblak.ExampleSimulationProgram] complete.
BUILD SUCCESSFUL (total time: 14 seconds)
## Homework 3: Example Simulation Recording OpenDIS Network Streams
## Homework 3: Example Simulation Recording using OpenDIS Network Streams
### Assignment
* Adapt the functionality for [OpenDIS ExampleSimulationProgram](../../../../examples/src/OpenDis7Examples/ExampleSimulationProgram.java), modifying provided code
* Result streams are recorded/saved/replayed using [PduRecorder](https://savage.nps.edu/opendis7-java/javadoc/edu/nps/moves/dis7/utilities/stream/PduRecorder.html), [Wireshark](https://www.wireshark.org) or [X3D-Edit](https://savage.nps.edu/X3D-Edit).
1. Adapt the functionality for [OpenDIS ExampleSimulationProgram](../../../../examples/src/OpenDis7Examples/ExampleSimulationProgram.java), modifying provided code
2. Experiment with the enumeration values that set up each entity and PDU. What works for you? What makes sense for your future work?
3. Adapt or replace the UML diagrams to describe what you have going on.
4. Record, save and replay your result stream using [PduRecorder](https://savage.nps.edu/opendis7-java/javadoc/edu/nps/moves/dis7/utilities/stream/PduRecorder.html) or [Wireshark](https://www.wireshark.org)
* see local [assignments/src/pduLog](../../../pduLog) subdirectory for latest opendis log files
* Coming soon, we will also (again have) [X3D-Edit](https://savage.nps.edu/X3D-Edit) for DIS stream recording/replay
5. Observe good-practice conventions in the [assignments README](../../../README.md) and [current-course README](../README.md) instructions.
This assignment presents a Problem Prototyping opportunity.
While some minimal functionality is expected, the general outline of
a networking problem and proposed solution holds great interest.
Think of it as a warmup preparation for your final project.
Think of it as warmup preparation for your future work.
This is also a freeplay opportunity.
You have the option to pick one or more of the provided course example programs
......@@ -17,8 +22,8 @@ and adapt the source to demonstrate a new client-server handshake protocol of in
Be sure to provide a rationale that justifies why the networking choices you made
(TCP/UDP, unicast/multicast, etc.) are the best for the problem you are addressing.
Refer to [homework2 README](../homework2/README.md) and [assignments README](../../../README.md)
for further details on what specific deliverables are expected in each homework assignment.
You may find that the prior [homework2 README](../homework2/README.md) still provides
helpful details on what specific deliverables are expected in each homework assignment.
Team efforts are encouraged, though if you choose a team approach be sure to justify why.
This is a good warmup prior to final projects. Have fun with Java networking!
......
/**
* Final project assignments supporting the NPS MOVES MV3500 Networked Graphics course.
*
* @see <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/assignments">networkedGraphicsMV3500 assignments</a>
* @see java.lang.Package
* @see <a href="https://stackoverflow.com/questions/22095487/why-is-package-info-java-useful">StackOverflow: why-is-package-info-java-useful</a>
* @see <a href="https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java">StackOverflow: how-do-i-document-packages-in-java</a>
*/
package MV3500Cohort2023MarchJune.homework3.Sloan;
File added
import java.io.*;
import java.net.*;
public class Client_Customer {
public static void main(String[] args) {
// TODO - Fill out the following questionairre:
double averageBeefPurchase = 2; // How many pounds of beef do you typically purchase when you buy groceries?
double averageVariationInBeefPurchase = 0.5; // How much do you typically vary from the above amount (also in pounds)?
double averagePorkPurchase = 4; // How many pounds of pork do you typically purchase when you buy groceries?
double averageVariationInPorkPurchase = 0.5; // How much do you typically vary from the above amount (also in pounds)?
double averageChickenPurchase = 6; // How many pounds of chicken do you typically purchase when you buy groceries?
double averageVariationInChickenPurchase = 0.5; // How much do you typically vary from the above amount (also in pounds)?
double averageEggsPurchase = 2; // How many eggs do you typically purchase when you buy groceries (amount in dozens)?
double averageVariationInEggsPurchase = 0.5; // How much do you typically vary from the above amount (also in dozens)?
// End of TODO section
Customer myCustomer = new Customer(averageBeefPurchase, averageVariationInBeefPurchase, averagePorkPurchase, averageVariationInPorkPurchase, averageChickenPurchase, averageVariationInChickenPurchase, averageEggsPurchase, averageVariationInEggsPurchase);
try {
// Create client socket and connect to the server
Socket clientSocket = new Socket("localhost", 12345);
System.out.println("Connected to server.");
// Send request to server
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
String request = "doTransaction," + myCustomer.getBeefPreference().generate() + "," + myCustomer.getPorkPreference().generate() + "," + myCustomer.getChickenPreference().generate() + "," + myCustomer.getEggsPreference().generate();
out.println(request);
System.out.println("Sent request to server: " + request);
// Receive response from server
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
StringBuilder responseBuilder = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
responseBuilder.append(line).append("\n");
}
String response = responseBuilder.toString();
System.out.print("Received response from server: " + response);
// Close connections
in.close();
out.close();
clientSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.*;
import java.net.*;
public class Client_Farm {
public static void main(String[] args) {
// TODO - Fill out the following questionairre:
int cattleCount = 50; // How many cows are on the farm?
int pigCount = 50; // How many pigs are on the farm?
int broilerChickenCount = 300; // How many broiler chickens (think supermarket chickens - they don't lay eggs) are on the farm?
int layerChickenCount = 500; // How many egg laying chickens are on the farm?
// End of TODO section
LivestockRanch myFarm = new LivestockRanch(cattleCount, pigCount, broilerChickenCount, layerChickenCount);
try {
// Create client socket and connect to the server
Socket clientSocket = new Socket("localhost", 12345);
System.out.println("Connected to server.");
// Send request to server
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
String request = "doResupply," + myFarm.getCattleProcessRate() + "," + myFarm.getPigProcessRate() + "," + myFarm.getChickenProcessRate() + "," + myFarm.getEggLayingRate();
out.println(request);
System.out.println("Sent request to server: " + request);
// Receive response from server
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
StringBuilder responseBuilder = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
responseBuilder.append(line).append("\n");
}
String response = responseBuilder.toString();
System.out.print("Received response from server: " + response);
// Close connections
in.close();
out.close();
clientSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
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