public String toColoredString(boolean colored) {
    StringBuffer buffer = new StringBuffer();
    buffer.append('[');
    if(colored) buffer.append(getColor());
    buffer.append("TCPPacket");
    if(colored) buffer.append(AnsiEscapeSequences.RESET);
    buffer.append(": ");
    buffer.append(getSourceAddress());
    buffer.append('.');
    buffer.append(IPPort.getName(getSourcePort()));
    buffer.append(" -> ");
    buffer.append(getDestinationAddress());
    buffer.append('.');
    buffer.append(IPPort.getName(getDestinationPort()));
    if(isUrg()) 
      buffer.append(" urg[0x" + Integer.toHexString(getUrgentPointer()) + "]");
    if(isAck()) 
      buffer.append(" ack[0x" + 
                    Long.toHexString(getAcknowledgmentNumber()) + "]");
    if(isPsh()) buffer.append(" psh");
    if(isRst()) buffer.append(" rst");
    if(isSyn()) 
      buffer.append(" syn[0x" + 
                    Long.toHexString(getSequenceNumber()) + "]");
    if(isFin()) buffer.append(" fin");
    buffer.append(" l=" + getTCPHeaderLength() + "," +
                  getPayloadDataLength());
    buffer.append(']');

    return buffer.toString();
  }