code: def encode(self, b64=False):
          
          encoded_payload = b''
          for pkt in self.packets:
              encoded_packet = pkt.encode(b64=b64)
              packet_len = len(encoded_packet)
              if b64:
                  encoded_payload += str(packet_len).encode('utf-8') + b':' + \
                      encoded_packet
              else:
                  binary_len = b''
                  while packet_len != 0:
                      binary_len = six.int2byte(packet_len % 10) + binary_len
                      packet_len = int(packet_len / 10)
                  if not pkt.binary:
                      encoded_payload += b'\0'
                  else:
                      encoded_payload += b'\1'
                  encoded_payload += binary_len + b'\xff' + encoded_packet
          return encoded_payload
docs: Encode the payload for transmission.