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