%% In-Class Exercises:  Adaptive Coding and Modulation
% These are some of the in-class exercises for the unit on adaptive coding and modulation.
%% Problem 1:   Simple HARQ Simulation
%
% Write MATLAB code to simulate the following simple HARQ process:
% The gNB transmits ntbs transport blocks (TBs) in slots t=1,...,nslot
% In slot t, the gNB uses a HARQ process with index iharq = mod(t-1,nharq)+1=1,...,nharq.
% If there was no previous transmission on that HARQ process or the previous transmission has been successfully transmitted, the gNB start transmitting the TB with the lowest index that has not previous started transmission.
% Each TB transmission fails with a probability pfail.
% If it fails, the TB will be retransmitted in the next slot for that HARQ process (i.e., nharq slots later)
% If it passes, assume it arrives at the UE a time t+dly.
% Simulate this system with the parameters below.  For each t compute numRx(t)= the maximum k such that the first k TBs have been received by time t.  Plot numRx(t) vs. t.

nharq = 5;
ntbs = 20;
nslot = 100;
pfail = 0.5;
dly = 3;
