Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
df33c124
Commit
df33c124
authored
7 years ago
by
codyt
Browse files
Options
Downloads
Patches
Plain Diff
Tackett Assignment 3 Upload
parent
5ebb387b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/Assignments/homework3/Tackett_Assignement3_OpenDisPduSender.java
+0
-182
0 additions, 182 deletions
...ents/homework3/Tackett_Assignement3_OpenDisPduSender.java
projects/Assignments/homework3/Tackett_Wireshark.pcapng
+0
-0
0 additions, 0 deletions
projects/Assignments/homework3/Tackett_Wireshark.pcapng
with
0 additions
and
182 deletions
projects/Assignments/homework3/Tackett_Assignement3_OpenDisPduSender.java
deleted
100644 → 0
+
0
−
182
View file @
5ebb387b
// package edu.nps.moves.examples; // copy example from OpenDIS distribution, modify to serve as template
import
java.io.*
;
import
java.net.*
;
import
java.util.*
;
import
edu.nps.moves.dis.*
;
import
edu.nps.moves.disenum.*
;
/**
* 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.
*
* @author DMcG
* @version $Id:$
*/
public
class
Tackett_Assignement3_OpenDisPduSender
{
public
static
final
int
PORT
=
3000
;
public
static
final
String
MULTICAST_ADDRESS
=
"239.1.2.3"
;
private
int
port
;
InetAddress
multicastAddress
;
public
Tackett_Assignement3_OpenDisPduSender
(
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
);
}
}
public
void
run
()
{
try
{
List
<
Pdu
>
generatedPdus
=
new
ArrayList
<>();
// Loop through all the enumerated PDU types, create a PDU for each type,
// and add that PDU to a list.
for
(
PduType
pdu
:
PduType
.
values
())
{
Pdu
aPdu
=
null
;
switch
(
pdu
)
{
case
ENTITY_STATE:
// TODO continue to add unit tests
EntityStatePdu
entityStatePdu
=
new
EntityStatePdu
();
Marking
espduMarking
=
new
Marking
();
espduMarking
.
setCharactersString
(
"Testing 123"
);
// TODO libary should warn if > 11 characters
entityStatePdu
.
setMarking
(
espduMarking
);
EntityID
espduEntityID
=
new
EntityID
();
espduEntityID
.
setSite
(
1
);
espduEntityID
.
setApplication
(
2
);
espduEntityID
.
setEntity
(
3
);
entityStatePdu
.
setEntityID
(
espduEntityID
);
// TODO consider adding utility methods to Open-DIS
aPdu
=
entityStatePdu
;
break
;
case
COMMENT:
aPdu
=
new
CommentPdu
();
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
)
{
generatedPdus
.
add
(
aPdu
);
}
}
// Sort the created PDUs by class name
Collections
.
sort
(
generatedPdus
,
new
edu
.
nps
.
moves
.
examples
.
ClassNameComparator
());
// Send the PDUs we created
InetAddress
localMulticastAddress
=
InetAddress
.
getByName
(
MULTICAST_ADDRESS
);
MulticastSocket
socket
=
new
MulticastSocket
(
PORT
);
socket
.
joinGroup
(
localMulticastAddress
);
for
(
int
idx
=
0
;
idx
<
generatedPdus
.
size
();
idx
++)
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
DataOutputStream
dos
=
new
DataOutputStream
(
baos
);
byte
[]
buffer
;
Pdu
aPdu
=
generatedPdus
.
get
(
idx
);
aPdu
.
marshal
(
dos
);
buffer
=
baos
.
toByteArray
();
DatagramPacket
packet
=
new
DatagramPacket
(
buffer
,
buffer
.
length
,
localMulticastAddress
,
PORT
);
socket
.
send
(
packet
);
System
.
out
.
println
(
"Sent PDU of type "
+
aPdu
.
getClass
().
getName
());
}
// 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
);
}
}
public
static
void
main
(
String
args
[])
{
if
(
args
.
length
==
2
)
{
OpenDisPduSender
sender
=
new
OpenDisPduSender
(
Integer
.
parseInt
(
args
[
0
]),
args
[
1
]);
sender
.
run
();
}
else
{
System
.
out
.
println
(
"Usage: OpenDisPduSender <port> <multicast group>"
);
System
.
out
.
println
(
"Default: OpenDisPduSender "
+
PORT
+
" "
+
MULTICAST_ADDRESS
);
OpenDisPduSender
sender
=
new
OpenDisPduSender
(
PORT
,
MULTICAST_ADDRESS
);
sender
.
run
();
}
}
}
This diff is collapsed.
Click to expand it.
projects/Assignments/homework3/Tackett_Wireshark.pcapng
0 → 100644
+
0
−
0
View file @
df33c124
File added
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment