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
2f9881c0
Commit
2f9881c0
authored
6 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
PduReader example
parent
4e8689f9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CourseExamples/src/DisExamples/PduReceiver.java
+70
-0
70 additions, 0 deletions
CourseExamples/src/DisExamples/PduReceiver.java
CourseExamples/src/DisExamples/PduReceiverTerminalLog.txt
+19
-0
19 additions, 0 deletions
CourseExamples/src/DisExamples/PduReceiverTerminalLog.txt
with
89 additions
and
0 deletions
CourseExamples/src/DisExamples/PduReceiver.java
0 → 100644
+
70
−
0
View file @
2f9881c0
package
DisExamples
;
// originally edu.nps.moves.examples.ReceiverPerformance
import
java.net.*
;
import
edu.nps.moves.dis.*
;
import
edu.nps.moves.disutil.PduFactory
;
import
java.io.IOException
;
public
class
PduReceiver
{
public
static
final
int
MULTICAST_PORT
=
3000
;
public
static
final
String
MULTICAST_GROUP
=
"239.1.2.3"
;
public
static
final
boolean
USE_FAST_ESPDU
=
false
;
public
static
void
main
(
String
args
[])
{
PduFactory
factory
;
MulticastSocket
socket
=
null
;
InetAddress
address
=
null
;
DatagramPacket
packet
;
try
{
System
.
out
.
println
(
"DisExamples.PduReceiver started..."
);
socket
=
new
MulticastSocket
(
MULTICAST_PORT
);
address
=
InetAddress
.
getByName
(
MULTICAST_GROUP
);
socket
.
joinGroup
(
address
);
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
pduType
=
pdu
.
getPduType
();
String
pduTypeName
=
pdu
.
getClass
().
getName
();
short
protocolFamily
=
pdu
.
getProtocolFamily
();
// TODO get string enumeration
StringBuilder
message
=
new
StringBuilder
();
message
.
append
(
"received DIS PDU: "
);
message
.
append
(
"pduType "
);
if
(
pduType
<
10
)
message
.
append
(
" "
);
message
.
append
(
pduType
).
append
(
" "
).
append
(
pduTypeName
);
message
.
append
(
", protocolFamily="
).
append
(
protocolFamily
);
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 DisExamples.PduReceiver, see exception trace:"
);
System
.
out
.
println
(
e
);
}
finally
{
System
.
out
.
println
(
"DisExamples.PduReceiver complete."
);
}
}
}
This diff is collapsed.
Click to expand it.
CourseExamples/src/DisExamples/PduReceiverTerminalLog.txt
0 → 100644
+
19
−
0
View file @
2f9881c0
run:
DisExamples.PduReceiver started...
received DIS PDU: pduType 15 edu.nps.moves.dis.AcknowledgePdu, protocolFamily=5
received DIS PDU: pduType 16 edu.nps.moves.dis.ActionRequestPdu, protocolFamily=5
received DIS PDU: pduType 4 edu.nps.moves.dis.CollisionPdu, protocolFamily=1
received DIS PDU: pduType 22 edu.nps.moves.dis.CommentPdu, protocolFamily=5
received DIS PDU: pduType 11 edu.nps.moves.dis.CreateEntityPdu, protocolFamily=5
received DIS PDU: pduType 3 edu.nps.moves.dis.DetonationPdu, protocolFamily=2
received DIS PDU: pduType 1 edu.nps.moves.dis.EntityStatePdu, protocolFamily=1
received DIS PDU: pduType 2 edu.nps.moves.dis.FirePdu, protocolFamily=2
received DIS PDU: pduType 12 edu.nps.moves.dis.RemoveEntityPdu, protocolFamily=5
received DIS PDU: pduType 9 edu.nps.moves.dis.RepairCompletePdu, protocolFamily=3
received DIS PDU: pduType 10 edu.nps.moves.dis.RepairResponsePdu, protocolFamily=3
received DIS PDU: pduType 8 edu.nps.moves.dis.ResupplyCancelPdu, protocolFamily=3
received DIS PDU: pduType 6 edu.nps.moves.dis.ResupplyOfferPdu, protocolFamily=3
received packet but pdu is null, packet.getData().length=1500, error...
received DIS PDU: pduType 5 edu.nps.moves.dis.ServiceRequestPdu, protocolFamily=3
received DIS PDU: pduType 13 edu.nps.moves.dis.StartResumePdu, protocolFamily=5
received DIS PDU: pduType 14 edu.nps.moves.dis.StopFreezePdu, protocolFamily=5
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