def header
      raise FrameError, "invalid protocol id" unless protocol_id < 2**16
      raise FrameError, "invalid sequence id" unless sequence_id.nil? || sequence_id < TT16

      l = [protocol_id]
      if @is_chunked_0
        raise FrameError, 'chunked_0 must have sequence_id' if sequence_id.nil?
        l.push sequence_id
        l.push total_payload_size
      elsif sequence_id
        l.push sequence_id
      end

      header_data = RLP.encode l, sedes: header_sedes
      raise FrameError, 'invalid rlp' unless l == RLP.decode(header_data, sedes: header_sedes, strict: false)

      bs = body_size
      raise FrameError, 'invalid body size' unless bs < 256**3

      header = Frame.encode_body_size(body_size) + header_data
      header = Utils.rzpad16 header
      raise FrameError, 'invalid header' unless header.size == header_size

      header
    end
def header
      raise FrameError, "invalid protocol id" unless protocol_id < 2**16
      raise FrameError, "invalid sequence id" unless sequence_id.nil? || sequence_id < TT16

      l = [protocol_id]
      if @is_chunked_0
        raise FrameError, 'chunked_0 must have sequence_id' if sequence_id.nil?
        l.push sequence_id
        l.push total_payload_size
      elsif sequence_id
        l.push sequence_id
      end

      header_data = RLP.encode l, sedes: header_sedes
      raise FrameError, 'invalid rlp' unless l == RLP.decode(header_data, sedes: header_sedes, strict: false)

      bs = body_size
      raise FrameError, 'invalid body size' unless bs < 256**3

      header = Frame.encode_body_size(body_size) + header_data
      header = Utils.rzpad16 header
      raise FrameError, 'invalid header' unless header.size == header_size

      header
    end
header: frame-size || header-data || padding

 frame-size: 3-byte integer, size of frame, big endian encoded
 header-data:
   normal: RLP::Sedes::List.new(protocol_type[, sequence_id])
   chunked_0: RLP::Sedes::List.new(protocol_type, sequence_id, total_packet_size)
   chunked_n: RLP::Sedes::List.new(protocol_type, sequence_id)
   normal, chunked_n: RLP::Sedes::List.new(protocol_type[, sequence_id])
   values:
     protocol_type: < 2**16
     sequence_id: < 2**16 (this value is optional for normal frames)
     total_packet_size: < 2**32
 padding: zero-fill to 16-byte boundary