public void testGoodHeader() {
    byte[] data = getGoodHeader();
    TCByteBuffer buffer = TCByteBufferFactory.getInstance(false, WireProtocolHeader.MAX_LENGTH);
    buffer.put(data);
    buffer.flip();

    WireProtocolHeader header = new WireProtocolHeader(buffer);

    System.out.println(header);

    assertTrue(header.isChecksumValid());

    assertTrue(header.getVersion() == WireProtocolHeader.VERSION_2);
    assertTrue(header.getHeaderLength() == 8);
    assertTrue(header.getTypeOfService() == 2);
    assertTrue(header.getTimeToLive() == 3);

    assertTrue(header.getTotalPacketLength() == 255);
    assertTrue(header.getChecksum() == 2744585179L);
    assertTrue(
        Arrays.equals(
            header.getSourceAddress(), new byte[] {(byte) 0xFF, (byte) 1, (byte) 0xFF, (byte) 1}));
    assertTrue(
        Arrays.equals(
            header.getDestinationAddress(),
            new byte[] {(byte) 1, (byte) 0xFF, (byte) 1, (byte) 0xFF}));
    assertTrue(header.getSourcePort() == 43605);
    assertTrue(header.getDestinationPort() == 21930);
    assertTrue(header.getMessageCount() == 5);
    assertTrue(header.getOptions().length == 0);

    try {
      header.validate();
    } catch (WireProtocolHeaderFormatException e) {
      fail(e.getMessage());
    }

    // changing data in the header should cause the checksum to need to be recomputed
    header.setVersion((byte) (header.getVersion() + 1));
    assertFalse(header.isChecksumValid());

    // Fix and validate the checksum
    header.computeChecksum();
    assertTrue(header.isChecksumValid());
  }
 private TCByteBuffer[] createDataBuffers(int length) {
   Assert.eval(mode == MODE_DATA);
   return TCByteBufferFactory.getFixedSizedInstancesForLength(false, length);
 }