Ejemplo n.º 1
0
seed = 663
N = 2 * k

print('l:%s w:%s s:%s c:%s delta:%s seed:%s N:%s' %
      (l, w, s, c, delta, seed, N))

print('number of input symbols = %d' % k)

from ctypes import *


class Symbol(Structure):
    _fields_ = [('id', c_uint), ('deg', c_uint), ('header', POINTER(c_uint)),
                ('info', c_char_p), ('symbLen', c_int)]


# ENCODER FLY
encoder = libLT.mallocEncoderFLY(seed)
libLT.setEncoderFLY_LT(encoder, w, s, delta, c)

libLT.LTencodeFLY_toFile(encoder, N, l, sourceInfo, 0, encfile)

# DECODER FLY
decoder = libLT.mallocDecoderFLY(N)
decodedInfo = libLT.LTdecodeFLY_fromFile(decoder, encfile)

if (libLT.writeFile(outfile, decodedInfo, k * l) == k * l):
    print("Output written correctly.")
else:
    sys.exit("Output NOT written correctly.")
Ejemplo n.º 2
0
delta = 0.5;
seed = 663;
N = 2*k;

print('l:%s w:%s s:%s c:%s delta:%s seed:%s N:%s' % (l,w,s,c,delta,seed,N))

print('number of input symbols = %d' % k)

from ctypes import *
class Symbol(Structure):
    _fields_ = [('id',c_uint),
                ('deg',c_uint),
                ('header',POINTER(c_uint)),
                ('info',c_char_p),
                ('symbLen',c_int)]

# ENCODER FLY
encoder = libLT.mallocEncoderFLY(seed)
libLT.setEncoderFLY_LT(encoder,w,s,delta,c)

libLT.LTencodeFLY_toFile(encoder,N,l,sourceInfo,0,encfile)

# DECODER FLY
decoder = libLT.mallocDecoderFLY(N)
decodedInfo = libLT.LTdecodeFLY_fromFile(decoder,encfile)

if (libLT.writeFile(outfile, decodedInfo, k*l) == k*l):
    print("Output written correctly.")
else:
    sys.exit("Output NOT written correctly.")
Ejemplo n.º 3
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)
Ejemplo n.º 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)