public class UdpHeader extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UdpHeader.UdpMessageType
The message type.
|
Modifier and Type | Field and Description |
---|---|
static int |
LENGTH
The size of a UDP header (in bytes)
|
static int |
MAX_MESSENGE_PACKAGE_LENGTH
The maximum length of a message package including the header (in bytes)
|
Constructor and Description |
---|
UdpHeader(DataInputStream dis)
Construct the header given a DataInputStream wrapped around a
DatagramPacket received over UDP from the real car.
|
UdpHeader(float currentTime,
UdpHeader.UdpMessageType messageType)
Create a header for a particular message type
|
Modifier and Type | Method and Description |
---|---|
static int |
computeChecksum(byte[] data)
Compute the check sum for an array of bytes.
|
int |
getChecksum()
Get the check sum.
|
UdpHeader.UdpMessageType |
getMessageType()
Get the message type.
|
float |
getTimestamp()
Get the time stamp.
|
String |
toString() |
DataOutputStream |
writeToDataOutputStream(DataOutputStream dos)
Write the data header to an I/O stream.
|
public static final int MAX_MESSENGE_PACKAGE_LENGTH
public static final int LENGTH
public UdpHeader(DataInputStream dis) throws IOException
dis
- The DataInputStream.IOException
public UdpHeader(float currentTime, UdpHeader.UdpMessageType messageType)
currentTime
- the current timemessageType
- the message typepublic float getTimestamp()
public UdpHeader.UdpMessageType getMessageType()
public int getChecksum()
public DataOutputStream writeToDataOutputStream(DataOutputStream dos) throws IOException
dos
- the I/O streamIOException
public static int computeChecksum(byte[] data)
data
- the array of bytesCopyright © 2013. All rights reserved.