### Random Interleaver:

The Random Interleaver rearranges the elements of its input vector using a random permutation. The incoming data is rearranged using a series of generated permuter indices. A permuter is essentially a device that generates pseudo-random permutation of given memory addresses. The data is arranged according to the pseudo-random order of memory addresses.

The de-interleaver must know the permuter-indices exactly in the same order as that of the interleaver. The de-interleaver arranges the interleaved data back to the original state by knowing the permuter-indices.

The interleaver depth (D) (Not sure what this term means ? – check out this article – click here) is essentially the number of memory addresses taken for permutation at a time. If the number of memory addresses taken for permutation increases, the interleaver depth increases.

In the Matlab simulation that is given below, an interleaver depth of 15 is used for illustration. This means that 15 letters are taken at a time and are permuted (rearranged randomly). This process is repeated consecutively for the next block of 15 letters.

As you may observe from the simulation that increasing the interleaver depth will increase the degree of randomness in the interleaved data and will decrease the maximum burst length after the de-interleaver operation.

### Matlab Code:

A sample Matlab code that simulates the above mentioned random interleaver is given below. The input data is a repeatitive stream of following symbols – “**THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG_**“. This code simulates only the interleaving/de-interleaving part.The burst errors produced by channel are denoted by ‘*****‘.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
%Demonstration of PseudoRandom Interleaver/Deinterleaver %Author : Mathuranathan for http://www.gaussianwaves.com %License - Creative Commons - cc-by-nc-sa 3.0 clc; clear; %____________________________________________ %Input Parameters %____________________________________________ D=15; %Interleaver Depth. More the value of D more is the randomness n=5; %Number of Data blocks that you want to send. data='THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG_'; % A constant pattern used as a data %____________________________________________ %Make the length of the data to be a multiple of D. This is for %demonstration only.Otherwise the empty spaces has to be zero filled. data=repmat(data,1,n); %send n blocks of specified data pattern if mod(length(data),D) ~=0 data=[data data(1:(D*(fix(length(data)/D+1))-length(data)))]; end %We are sending D blocks of similar data %intlvrInput=repmat(data(1:n),[1 D]); %fprintf('Input Data to the Interleaver -> \n'); %disp(char(intlvrInput)); %disp('____________________________________________________________________________'); %INTERLEAVER %Writing into the interleaver row-by-row permuterIndex=randperm(D); intrlvrOutput=[]; index=1; for i=1:fix(length(data)/D) intrlvrOutput=[intrlvrOutput data(permuterIndex+(i-1)*D)]; end for i=1:mod(length(data),D) intrlvrOutput=[intrlvrOutput data(permuterIndex(i)+fix(length(data)/D)*D)]; end uncorruptedIntrlvrOutput=intrlvrOutput; %Corrupting the interleaver output by inserting 10 '*' intrlvrOutput(1,25:34)=zeros(1,10)+42; %DEINTERLEAVER deintrlvrOutput=[]; for i=1:fix(length(intrlvrOutput)/D) deintrlvrOutput(permuterIndex+(i-1)*D)=intrlvrOutput((i-1)*D+1:i*D); end for i=1:mod(length(intrlvrOutput),D) deintrlvrOutput((fix(length(intrlvrOutput)/D))*permuterIndex+i)=intrlvrOutput((i+1):(i+1)*D); end deintrlvrOutput=char(deintrlvrOutput); disp('Given Data -->'); disp(data); disp(' ') disp('Permuter Index-->') disp(permuterIndex); disp(' ') disp('PseudoRandom Interleaver Output -->'); disp(uncorruptedIntrlvrOutput); disp(' ') disp('Interleaver Output after being corrupted by 10 symbols of burst error - marked by ''*''->'); disp(char(intrlvrOutput)); disp(' ') disp('PseudoRandom Deinterleaver Output -->'); disp(deintrlvrOutput); |

### Simulation Result:

**Given Data –>**

THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG_THE_QUICK_BROWN_FOX

_JUMPS_OVER_THE_LAZY_DOG_THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY

_DOG_THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG_THE_QUICK_BROWN

_FOX_JUMPS_OVER_THE_LAZY_DOG_THE_Q

**Permuter Index–>**

15 1 11 9 7 12 5 6 13 4 2 10 3 8 14

**PseudoRandom Interleaver Output –>**

NTBKIRQUO_H_ECWR__PUO_JVXFSOMET_DYAO_LGET_HZ__HR_COUIWQEB_KN_

FOSMVJUE_O_XPRHTO_ZGLA__HDEYTFEOBKWICNU_RQ__TOV_PEUMRJXO_S_EH

GDY_AZTLEO__HO_WR_NCK_IQOUBFHXEOSRMP_U_VJ_T_E_O_TZYHA_GLDEXQN

OB_K_FCUWIROE_RV__PSTMJEUOHQ_TGDHY_EZL_AO_

**Interleaver Output after being corrupted by 10 symbols of burst error – marked by ‘*‘->**

NTBKIRQUO_H_ECWR__PUO_JV**********AO_LGET_HZ__HR_COUIWQEB_KN_FOS

MVJUE_O_XPRHTO_ZGLA__HDEYTFEOBKWICNU_RQ__TOV_PEUMRJXO_S_EHGDY

_AZTLEO__HO_WR_NCK_IQOUBFHXEOSRMP_U_VJ_T_E_O_TZYHA_GLDEXQNOB_K

_FCUWIROE_RV__PSTMJEUOHQ_TGDHY_EZL_AO_

**PseudoRandom Deinterleaver Output –>**

THE_QUICK_BROWN_***_JU*P*_OV*R*THE_LAZ*_*OG_*HE_QUICK_BROWN_FOX_

JUMPS_OVER_THE_LAZY_DOG_THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LA

ZY_DOG_THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG_THE_QUICK_BR

OWN_FOX_JUMPS_OVER_THE_LAZY_DOG_THE_Q

As we can see from the above simulation that, even though the channel introduces 10 symbols of consecutive burst error, the interleaver/deinterleaver operation has effectively distributed the errors and reduced the maximum burst length to 3 symbols.

### See also:

[1] Introduction to Interleavers and deinterleavers

[2] Block Interleaver Design for RS codes

### Additional Resources:

[1] Concatenation and Advanced Codes – Applications of interleavers- Stanford University