code: def encodeLength(length):
          
          if length < 128:
              ored_length = length
              offset = -1
          elif length < 16384:
              ored_length = length | 0x8000
              offset = -2
          elif length < 2097152:
              ored_length = length | 0xC00000
              offset = -3
          elif length < 268435456:
              ored_length = length | 0xE0000000
              offset = -4
          else:
              raise ConnectionError('Unable to encode length of {}'.format(length))
  
          return pack('!I', ored_length)[offset:]
docs: Encode given length in mikrotik format.
  
          :param length: Integer < 268435456.
          :returns: Encoded length.