Exemple #1
0
    print 'Encoding the source information completed.'

    # Decoder FLY

    # Allocate the decoder data structure
    decoder = libLT.mallocDecoderFLY(N)
    # Add one bucket to the decoder (you need to add one per each seed or different parameters used. In practice, one per encoder)
    myBucket = libLT.addAndInitBucketFLY_LT(decoder,seed,l,w,s,delta,c)
    numNewReceived = libLT.receiveSymbFLY_BucketName(decoder,myBucket,encodedInfo,0,0)
    # Decode the symbols
    libLT.decodingProcessFLY(decoder)

    # See new decoded symbols
    print '\nnumber of source symbols = %s' % k
    print "number of received symbols = %d" % libLT.getNumReceived(decoder)
    
    # Count all decoded symbols
    print "TOT received symbols: %d" % libLT.getNumReceived(decoder)
    print "TOT decoded symbols: %d" % libLT.getNumDecoded(decoder)


    result = libLT.getDecodedInformation(decoder)

    for i in xrange(0,k*l):
        sys.stdout.write('_%s' % (c_ubyte.from_address(result+sizeof(c_ubyte)*i).value - sourceInfo[i]))
    sys.stdout.write('\n')
    
    
    # Finally, free the memory
    #libc.free(sourceInfo)
Exemple #2
0
print('number of input symbols = %d' % k)

# ENCODER FLY
encoder = libLT.mallocEncoderFLY(seed)
libLT.setEncoderFLY_LT(encoder, w, s, delta, c)
encodedInfo, _ = libLT.LTencodeInfoFLY(encoder, l, sourceInfo, 0, N)
print('Encoding the source information completed.')

# DECODER FLY
decoder = libLT.mallocDecoderFLY(N)
myBucket = libLT.addAndInitBucketFLY_LT(decoder, seed, l, w, s, delta, c)
numNewReceived = libLT.receiveSymbFLY_BucketName(decoder, myBucket,
                                                 encodedInfo, N * l, 0, 0)
print('Decoding the received information.')
libLT.decodingProcessFLY(decoder)
print('\nnumber of received symbols = %d' % numNewReceived)
print('TOT received symbols: %d' % libLT.getNumReceived(decoder))
print('TOT decoded symbols: %d' % libLT.getNumDecoded(decoder))

outbuffer = decodedInfo = libLT.getDecodedInformation(decoder)
bytesToWrite = k * l

if (libLT.writeFile(outfile, outbuffer, bytesToWrite) == bytesToWrite):
    print('Output written correctly.')
else:
    print('Output NOT written correctly.')

libLT.freeEncoderFLY(encoder)
libLT.freeDecoderFLY(decoder)
Exemple #3
0
    # Decoder FLY

    # Allocate the decoder data structure
    decoder = libLT.mallocDecoderFLY(N)
    # Add one bucket to the decoder (you need to add one per each seed or different parameters used. In practice, one per encoder)
    myBucket = libLT.addAndInitBucketFLY_LT(decoder, seed, l, w, s, delta, c)
    # In order to receive the encoded symbols in the correct bucket, it is necessary to get the pointer to the right bucket
    myBucketPtr = libLT.getBucketFLY(decoder, myBucket)
    # Receive the encoded symbols
    numNewReceived = libLT.receiveSymbFLY(decoder, myBucketPtr, encodedInfo, 0,
                                          0)
    # Decode the symbols
    libLT.decodingProcessFLY(decoder)

    # See new decoded symbols
    print "number of received symbols = %d\n" % libLT.getNumReceived(decoder)

    # Count all decoded symbols
    print "TOT received symbols: %d\n" % libLT.getNumReceived(decoder)
    print "TOT decoded symbols: %d\n" % libLT.getNumDecoded(decoder)

    libc.printf("sourceInfo:'%s' decoded:'%s'\n", sourceInfo,
                libLT.getDecoded(decoder))

    # Finally, free the memory
    libc.free(sourceInfo)

    libLT.freeEncoderFLY(encoder)
    libLT.freeDecoderFLY(decoder)
Exemple #4
0
encoder = libLT.mallocEncoderFLY(seed)
libLT.setEncoderFLY_LT(encoder,w,s,delta,c)
encodedInfo,_ = libLT.LTencodeInfoFLY(encoder,l,sourceInfo,0,N)
print('Encoding the source information completed.')

# DECODER FLY
decoder = libLT.mallocDecoderFLY(N)
myBucket = libLT.addAndInitBucketFLY_LT(decoder,seed,l,w,s,delta,c)
numNewReceived = libLT.receiveSymbFLY_BucketName(decoder,
                                                 myBucket,
                                                 encodedInfo,
                                                 N*l,
                                                 0,
                                                 0)
print('Decoding the received information.')
libLT.decodingProcessFLY(decoder)
print('\nnumber of received symbols = %d' % numNewReceived)
print('TOT received symbols: %d' % libLT.getNumReceived(decoder))
print('TOT decoded symbols: %d' % libLT.getNumDecoded(decoder))

outbuffer = decodedInfo = libLT.getDecodedInformation(decoder)
bytesToWrite = k*l

if (libLT.writeFile(outfile,outbuffer,bytesToWrite) == bytesToWrite):
    print('Output written correctly.')
else:
    print('Output NOT written correctly.')

libLT.freeEncoderFLY(encoder)
libLT.freeDecoderFLY(decoder)