aim4.msg.udp

## Class UdpHeader

- java.lang.Object
- - aim4.msg.udp.UdpHeader

-     public class UdpHeader
      extends Object

  Small header included in all UDP messages sent to/from the real car.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `UdpHeader.UdpMessageType` The message type.

  - ### Field Summary

    Fields
    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 Summary

    Constructors
    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

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### MAX_MESSENGE_PACKAGE_LENGTH

          public static final int MAX_MESSENGE_PACKAGE_LENGTH

      The maximum length of a message package including the header (in bytes)
      See Also:
        Constant Field Values

    - #### LENGTH

          public static final int LENGTH

      The size of a UDP header (in bytes)
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### UdpHeader

          public UdpHeader(DataInputStream dis)
                    throws IOException

      Construct the header given a DataInputStream wrapped around a DatagramPacket received over UDP from the real car.
      Parameters:
        `dis` - The DataInputStream.
      Throws:
        `IOException`

    - #### UdpHeader

          public UdpHeader(float currentTime,
                   UdpHeader.UdpMessageType messageType)

      Create a header for a particular message type
      Parameters:
        `currentTime` - the current time
        `messageType` - the message type

  - ### Method Detail

    - #### getTimestamp

          public float getTimestamp()

      Get the time stamp.
      Returns:
        the timestamp

    - #### getMessageType

          public UdpHeader.UdpMessageType getMessageType()

      Get the message type.
      Returns:
        the message type

    - #### getChecksum

          public int getChecksum()

      Get the check sum.
      Returns:
        the check sum

    - #### writeToDataOutputStream

          public DataOutputStream writeToDataOutputStream(DataOutputStream dos)
                                                   throws IOException

      Write the data header to an I/O stream.
      Parameters:
        `dos` - the I/O stream
      Returns:
        the I/O stream
      Throws:
        `IOException`

    - #### computeChecksum

          public static int computeChecksum(byte[] data)

      Compute the check sum for an array of bytes.
      Parameters:
        `data` - the array of bytes
      Returns:
        the check sum

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2013. All rights reserved.