Skip to content
Snippets Groups Projects
Commit c03c7c1f authored by KReynolds's avatar KReynolds
Browse files

Homework 3: a space battle between two craft using DIS example template.

parent 02b4df14
No related branches found
No related tags found
No related merge requests found
......@@ -3,9 +3,8 @@
* This work is provided under a BSD open-source license, see project license.html and license.txt
*
* This Program is a modified version of ExampleSimulationProgram in order to see the
* verbose plain text pdu log. This simulates a firewall identifying a malicious packet
* and tracing its source before destroying it - updated September 12, 2021 to ensure
* correct file pushed to Gitlab.
* verbose plain text pdu log. This simulates a battle between two opposing
* spacecraft traveling toward each other at an equal rate.
*
* @author snapp
*/
......@@ -36,7 +35,7 @@ public class ExampleSimulationProgramReynolds {
String DEFAULT_OUTPUT_DIRECTORY = "./pduLog";
private EntityID createFriendSpaceCraft() {
EntityID FNSPaceCraftID = new EntityID(); // 1.1.225.1.1.1 Platform,Cyber,USA,FireWall
EntityID FNSPaceCraftID = new EntityID(); // 1.1.225.1.1.1 Platform,Cyber,USA,SpaceCraft
FNSPaceCraftID.setSiteID(1);
FNSPaceCraftID.setApplicationID(1);
FNSPaceCraftID.setEntityID(1);
......@@ -55,7 +54,8 @@ public class ExampleSimulationProgramReynolds {
}
private EntityID createHostileSpaceCraft() {
EntityID HHostileSpaceCraftID = new EntityID(); // 1.1.45.1.7.1 Platform,Cyber,China,MaliciousPacket
EntityID HHostileSpaceCraftID = new EntityID(); // 1.1.45.1.7.1 Platform,Space,Russia,HostileSpaceCraft
HHostileSpaceCraftID.setSiteID(2);
HHostileSpaceCraftID.setApplicationID(2);
HHostileSpaceCraftID.setEntityID(2);
......@@ -120,7 +120,7 @@ public class ExampleSimulationProgramReynolds {
// TODO reset clock to zero each time for consistent outputs
// Your model setup: define participants. who's who in this zoo?
// Assuming you keep track of entity objects... here is some support for for Entity 1.
// create PDU object for US Firewall and set its values.
// create PDU object for US SpaceCraft and set its values.
EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu();
entityStatePdu_1.setEntityID(createFriendSpaceCraft());
entityStatePdu_1.setEntityType(createFriendSpaceCraftType());
......@@ -128,15 +128,13 @@ public class ExampleSimulationProgramReynolds {
entityStatePdu_1.setForceId(ForceID.FRIENDLY);
// TODO someday, use enumerations; is there a unique site triplet for MOVES Institute?
// create PDU object for Malware Packet and set its values.
// create PDU object for Hostile SpaceCraft and set its values.
EntityStatePdu entityStatePdu_2 = pduFactory.makeEntityStatePdu();
entityStatePdu_2.setEntityID(createHostileSpaceCraft());
entityStatePdu_2.setEntityType(createHostileSpaceCraftType());
entityStatePdu_2.getEntityLocation().setX(10);
entityStatePdu_2.setForceId(ForceID.OPPOSING);
FirePdu firePdu = pduFactory.makeFirePdu(); // for entity 1 first weapon (possible traceroute)
// should we customize this munition? what is it for your simulation?
EntityID fireID = new EntityID();
......@@ -157,8 +155,8 @@ public class ExampleSimulationProgramReynolds {
TracerouteID.setEntityID(1);
firePdu.setMunitionExpendibleID(TracerouteID);
CommentReliablePdu HostileSpaceCraftDestroyedComment = pduFactory.makeCommentReliablePdu("Malware Packet DESTROYED BY Firewall");
CommentReliablePdu HostileSpaceCraftDetectedComment = pduFactory.makeCommentReliablePdu("Firewall Detects Malware engage Traceroute");
CommentReliablePdu HostileSpaceCraftDestroyedComment = pduFactory.makeCommentReliablePdu("Hostile SpaceCraft DESTROYED BY Friendly SpaceCraft");
CommentReliablePdu HostileSpaceCraftDetectedComment = pduFactory.makeCommentReliablePdu("Friendly SpaceCraft Detects Hostile SpaceCraft engage Pulse Torpedo's");
// TODO simulation management PDUs for startup, planning to design special class support
//DetonationPdu detonationPdu = pduFactory.makeDetonationPdu();
......@@ -185,7 +183,7 @@ public class ExampleSimulationProgramReynolds {
if (!fireBool) {
sendSinglePdu(HostileSpaceCraftDetectedComment);
// Inform the user of the detection
System.out.println("Friendly SpaceCraft Detects Hostile SpaceCraft from "
System.out.println("Friendly SpaceCraft Detects Hostile SpaceCraft from "
+ entityStatePdu_2.getEntityType().getCountry()
+ "... Engaging with Pulse Torpedo's");
}
......@@ -209,7 +207,7 @@ public class ExampleSimulationProgramReynolds {
if (firePdu.getTargetEntityID().getEntityID() == 6666) {
TorpedoDamageRecieved += 1;
if (TorpedoDamageRecieved > 1) {
// The Firewall destroys the MalPacket
// The Friendly destroys the Hostile
System.out.println("Hostile SpaceCraft DESTROYED BY Friendly SpaceCraft after "
+ TorpedoDamageRecieved
......
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