'Sends a packet.  If it\'s been set up, compress the data, encrypt it,
and authenticate it before sending.  If key exchange is in progress and
the message is not part of key exchange, queue it to be sent later.
@param messageType: The type of the packet; generally one of the
MSG_* values.
@type messageType: L{int}
@param payload: The payload for the message.
@type payload: L{str}'

def sendPacket(self, messageType, payload):

    if (self._keyExchangeState != self._KEY_EXCHANGE_NONE):
        if (not self._allowedKeyExchangeMessageType(messageType)):
            self._blockedByKeyExchange.append((messageType, payload))
            return
    payload = (chr(messageType) + payload)
    if self.outgoingCompression:
        payload = (self.outgoingCompression.compress(payload) + self.outgoingCompression.flush(2))
    bs = self.currentEncryptions.encBlockSize
    totalSize = (5 + len(payload))
    lenPad = (bs - (totalSize % bs))
    if (lenPad < 4):
        lenPad = (lenPad + bs)
    packet = ((struct.pack('!LB', ((totalSize + lenPad) - 4), lenPad) + payload) + randbytes.secureRandom(lenPad))
    encPacket = (self.currentEncryptions.encrypt(packet) + self.currentEncryptions.makeMAC(self.outgoingPacketSequence, packet))
    self.transport.write(encPacket)
    self.outgoingPacketSequence += 1
