/**
   * Setzt alle mit den Hilfsfunktionen zum Konvertieren ermittelten Byte-Arrays zu einem Byte-Array
   * zusammen und fügt eventuell Füllbits ein.
   */
  private void buildNewPacket() {
    buf = new byte[pktLength];
    bufForCRC16 = new byte[42];
    int pos = 0, hIDlength = 0;

    // Wenn die Host-ID zu lang ist, wird sie abgeschnitten
    if (hostID.length() <= 29) hIDlength = hostID.length();
    else hIDlength = 29;
    // Setzen der Host-ID
    System.arraycopy(hostID.getBytes(), 0, buf, pos, hIDlength);
    // Rest der hostID mit Nullen auffüllen
    for (pos = hIDlength; pos < 29; pos++) buf[pos] = 0; // pos: 29
    System.arraycopy(ByteTools.convertToShortByte(senderID), 0, buf, pos, 2);
    pos += 2; // pos: 31
    System.arraycopy(ByteTools.convertToByte(txPktCnt), 0, buf, pos, 4);
    pos += 4; // pos: 35
    System.arraycopy(ByteTools.convertToShortByte(txPktRate), 0, buf, pos, 2);
    pos += 2; // pos: 37
    buf[pos] = (byte) ttl;
    pos++; // pos: 38
    System.arraycopy(ByteTools.convertToByte(reset), 0, buf, pos, 4);
    pos += 4; // pos: 42
    // Checksumme über die ersten 42 Bytes
    System.arraycopy(buf, 0, bufForCRC16, 0, 42);
    System.arraycopy(ByteTools.crc16(bufForCRC16), 0, buf, pos, 2);
    pos += 2; // pos: 44
    System.arraycopy(ByteTools.convertToByte(System.nanoTime()), 0, buf, pos, 8);
    pos += 8; // pos: 52

    // Bis zur gegebenen Menge mit Nullen auffüllen
    // Wenn ptkLength kleiner als die erforderte Mindestlänge ist, wird pktLength
    // praktisch ignoriert
    for (; pos < pktLength; pos++) buf[pos] = (byte) 0;
  }
 /**
  * Methode, mit der nachträglich die ThreadID geändert werden kann
  *
  * @param threadID die neue ThreadID
  */
 public void alterThreadID(int threadID) {
   System.arraycopy(ByteTools.convertToShortByte(threadID), 0, buf, 29, 2);
 }