Main Content

DOCSIS Upstream TDMA Link Simulation

This example shows how to implement the physical layer (PHY) of Data Over Cable Service Interface Specification (DOCSIS®) in the upstream TDMA operating mode [1][2].

Introduction

DOCSIS defines the international standards for high-speed data-over-cable systems and specifies a variety of operating modes. This example focuses on the upstream Time Division Multiple Access (TDMA) mode, where Single Carrier Quadrature Amplitude Modulation (SC-QAM) is used. This access mode is compatible with all versions of DOCSIS, including 4.0. The example implements a flexible PHY signal processing chain by incorporating a configuration object that specifies numerous configurable parameters. It also includes the medium access control layer (MAC) header format and simulates data packets compliant with the MAC configuration parameters.

Using features available with Communications Toolbox™ and Signal Processing Toolbox™, the example:

  • Models the baseband PHY of a DOCSIS communications system

  • Includes helper functions to configure objects and uses these objects to specify, validate, and organize configuration parameters

  • Generates statistics to compare the error rate performance of the model to theoretical results.

System Model

The high level simulation flow is shown in this image. The individual blocks will be explained in more detail in the following paragraphs.

MAC Frame Structure

The MAC header format shown in this image complies with DOCSIS [2]. The Extended Header and Packet Protocol Data Unit (Packet PDU) fields of the frame structure use random bits.

If the Extended Header On field is 1, then MAC Parameter specifies the length of Extended Header in bytes. Otherwise MAC Parameter can be reserved for other usage.

Transmitter Signal Processing

This image shows the transmitter signal processing chain. The input data bits undergo Reed-Solomon encoding, interleaving, scrambling, preamble prepending, SC-QAM, pre-equalization (see Effect of Transmit Pre-Equalizer section), and transmit filtering.

Channel Model

The helper function helperDocsisChannel models a multipath channel with a static channel response and stochastic additive white Gaussian noise (AWGN) to reproduce the practical cable channel shown in Figures 40-42 of [3]. This code filters a unit impulse through the modeled channel and plots the channel taps and frequency response. The magnitude response matches the one shown in Figure 40.

% Probe channel with a unit impulse. Pad zeros at the beginning and end to
% account for channel delay.
probeSignal = [zeros(1,12),1,zeros(1,12)];
sampsPerSymbol = 1;
chanTaps = helperDocsisChannel(probeSignal,sampsPerSymbol);
% Remove zero values
chanTaps = nonzeros(chanTaps);
% Time domain tap values
figure
subplot(2,1,1)
stem(abs(chanTaps))
title('Channel Taps')
xlabel('Taps')
ylabel('Amplitude')
legend('Magnitude')
subplot(2,1,2)
stem(real(chanTaps))
hold on
stem(imag(chanTaps))
legend('Real','Imag')
xlabel('Taps')
ylabel('Amplitude')
hold off

Figure contains 2 axes objects. Axes object 1 with title Channel Taps, xlabel Taps, ylabel Amplitude contains an object of type stem. This object represents Magnitude. Axes object 2 with xlabel Taps, ylabel Amplitude contains 2 objects of type stem. These objects represent Real, Imag.

% Frequency domain response
freqz(chanTaps,1,-pi:pi/1024:pi)

Figure contains 2 axes objects. Axes object 1 with title Phase, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Phase (degrees) contains an object of type line. Axes object 2 with title Magnitude, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Magnitude (dB) contains an object of type line.

Receiver Signal Processing

This image shows an ideal receiver signal processing chain which assumes perfect synchronization. The input received baseband symbols undergo processing that reverses the transmitter operations to recover the transmitted data bits and compute the bit error rate (BER).

Effect of Transmit Pre-Equalizer

The DOCSIS standard specifies pre-equalization of the transmitter symbols to counter the intersymbol interference (ISI) introduced by the multipath channel. Since a static channel frequency response is used, the pre-equalizer taps at the transmitter are fixed for the duration of the simulation.

This code shows the transmission of a QPSK modulated signal with and without pre-equalization. Both signals are filtered through using the helperDocsisChannel function with no AWGN added. The constellation diagram of symbols without pre-equalization applied shows ISI distortion after the channel filtering. The constellation diagram of symbols with pre-equalization applied shows no distortion after the channel filtering.

In fact, since there is no noise in the channel, the equalized symbols align with the reference constellation so well that they can be difficult to see. Toggle the visibility of the two sets of symbols on the constellation diagram by clicking their respective labels in the legend for a better view.

% Create a DOCSIS configuration object with the specified parameters. Do
% not use Reed-Solomon encoding or append any preamble bits. 500 bytes of
% data are transmitted in total.
docsisCfg = docsisConfig( ...
    'NumBytes',500, ...
    'RSEnabled',false, ...
    'PreambleLength',0, ...
    'SamplesPerSymbol',1);
% Validate configuration parameters after they're all set
validateConfig(docsisCfg);

% Generate random data bits manually
srcData = randi([0 1],docsisCfg.NumBytes*8,1);

% Get the output from the modulator and pre-equalizer
[~,~,modOut,eqOut] = helperDocsisTx(srcData,[],docsisCfg);

% Pass both signals through the example channel
uneqChanOut = helperDocsisChannel(modOut,docsisCfg.SamplesPerSymbol);
eqChanOut = helperDocsisChannel(eqOut,docsisCfg.SamplesPerSymbol);

% Show received symbols in constellation diagram
constDiagram0 = comm.ConstellationDiagram( ...
    'NumInputPorts',2, ...
    'Title','Zero-noise Channel Output', ...
    'ChannelNames',{'Unequalized','Equalized'}, ...
    'ShowLegend',true, ...
    'XLimits',[-18 18], ...
    'YLimits',[-18 18], ...
    'ShowReferenceConstellation',false);
constDiagram0(uneqChanOut,eqChanOut)

End-to-end Link Simulation

The simulated end-to-end communications link complies with transmissions specified by DOCSIS. These helper functions and objects are used:

  • docsisConfig: configuration object that captures all the parameters affecting waveform generation

  • docsisMACFrameConfig: configuration object that is a sub-component of docsisConfig and specifies the MAC frame structure

  • helperDocsisConstellation: returns the modulation order (total number of constellation points) and symbol mapping given the modulation name

  • helperDocsisGenerateSourceData: generates a random burst of data bits, including MAC frame configuration, according to the parameters specified by the configuration object

  • helperDocsisTx: implements the transmitter signal processing chain; accepts burst data and preamble bits as input, and returns both the baseband transmitter samples and other intermediate block outputs (refer to transmitter block diagram)

  • helperDocsisChannel: applies the example cable channel with static tap values defined earlier

  • helperDocsisRx: implements the receiver signal processing chain; takes channel output as input, and returns the decoded data bits as well as other intermediate block outputs (refer to receiver block diagram)

Run the link simulation with a range of Eb/No values. For each Eb/No, generate random source data, pass it through the transmitter and channel, and retrieve the bits at the receiver. These bits are then compared with the source data to check for bit errors. Move on to the next Eb/No value when the bit errors collected or the total bits sent exceeds a specified threshold.

Create configuration object and list all the parameters:

docsisCfg = docsisConfig( ...
    'PayloadModulation','16-QAM', ...
    'RSMessageLength',251, ...
    'RSCodewordLength',255)
docsisCfg = 
  docsisConfig with properties:

                           MACFrame: [1x1 docsisMACFrameConfig]
                           NumBytes: 2000
                     ModulationRate: 1280000
                          RSEnabled: 1
                    RSMessageLength: 251
                   RSCodewordLength: 255
                 InterleaverNumRows: 4
                      ScramblerSeed: [1 1 0 1 1 1 1 1 0 0 1 1 0 0 1]
                     PreambleLength: 1536
                 PreambleModulation: 'QPSK0'
                  PayloadModulation: '16-QAM'
                   PreEqualizerTaps: [24x1 double]
                   RaisedCosineSpan: 10
                   SamplesPerSymbol: 2
                         SampleRate: 2560000

   Read-only properties:
                  PreEqualizerDelay: 7
            PreambleModulationOrder: 4
    PreambleModulationBitsPerSymbol: 2
        PreambleModulationSymbolMap: [-8.0000 - 8.0000i -8.0000 + 8.0000i 8.0000 - 8.0000i 8.0000 + 8.0000i]
             PayloadModulationOrder: 16
     PayloadModulationBitsPerSymbol: 4
         PayloadModulationSymbolMap: [-4.0000 - 4.0000i -4.0000 -12.0000i -12.0000 - 4.0000i -12.0000 -12.0000i -4.0000 + 4.0000i -4.0000 +12.0000i -12.0000 + 4.0000i -12.0000 +12.0000i 4.0000 - 4.0000i 4.0000 -12.0000i ... ] (1x16 double)
               SignalPowerPerSample: 80

% Validate configuration parameters after they're all set
validateConfig(docsisCfg);

The example preamble sequence reproduces the sequence specified in Appendix I of [4].

load('docsisExamplePreamble.mat')
prmbBits = examplePreamble(end-docsisCfg.PreambleLength+1:end);

Initialize other relevant variables and visualization scopes:

% Max number of bit errors to collect and max number of bits to send
maxErr = 1e3;
maxBits = 1e6;
% Use an Eb/No range that results in meaningful BERs
EbNoRange = helperDocsisEbNoRange(docsisCfg.PayloadModulationOrder);
ber = zeros(size(EbNoRange));
berUncoded = zeros(size(EbNoRange));
% Initialize spectrum analyzer scope and constellation diagram scope
[specAnalyzer,constDiagram] = helperInitializeScopes(docsisCfg);
% Initialize AWGN channel
awgnChan = comm.AWGNChannel( ...
    'BitsPerSymbol',docsisCfg.PayloadModulationBitsPerSymbol, ...
    'SignalPower',docsisCfg.SignalPowerPerSample, ...
    'SamplesPerSymbol',docsisCfg.SamplesPerSymbol);

Run the main loop:

for i = 1:length(EbNoRange)
    awgnChan.EbNo = EbNoRange(i);
    totalErr = 0; totalBits = 0;
    totalErrUncoded = 0; totalBitsUncoded = 0;
    while totalErr < maxErr && totalBits < maxBits
        % Generate source data bits
        srcData = helperDocsisGenerateSourceData(docsisCfg);
        % Transmitter signal processing
        [txrcOut,modIndexOut] = helperDocsisTx(srcData,prmbBits,docsisCfg);
        % Apply example cable channel and add Gaussian noise
        chanOut = helperDocsisChannel(txrcOut,docsisCfg.SamplesPerSymbol);
        awgnOut = awgnChan(chanOut);
        % Receiver signal processing
        [decoderOut,rxrcOut,demodOut] = helperDocsisRx(awgnOut,docsisCfg);
        
        % Helper function to show visualization on the scopes
        helperShowScopes(specAnalyzer,constDiagram,txrcOut,rxrcOut,awgnOut, ...
            EbNoRange(i),docsisCfg)
        
        % Tally bit errors and total bits sent
        [nErr,nBits,nErrUncoded,nBitsUncoded] = helperBitErrors( ...
            srcData,decoderOut,modIndexOut,demodOut,docsisCfg);
        totalErr = totalErr + nErr;
        totalBits = totalBits + nBits;
        totalErrUncoded = totalErrUncoded + nErrUncoded;
        totalBitsUncoded = totalBitsUncoded + nBitsUncoded;
    end
    % Compute BER
    ber(i) = totalErr / totalBits;
    berUncoded(i) = totalErrUncoded / totalBitsUncoded;
end

The spectrum analyzer shows the power spectral density of the signals at the transmit filter output and at the cable channel output. The transmit filter output signal has been pre-equalized and thus its spectrum has the reciprocal shape of the channel response (see Channel Model) in the main lobe. The side lobes and notches are due to raised cosine filtering. After channel filtering, the channel output signal has a flat spectrum in its bandwidth, and the out of band signal power is increased due to AWGN.

The constellation diagram shows three sets of symbols: channel output, receive filter output preamble symbols, and receive filter output payload symbols. The channel output symbols do not align with the reference constellations; after receiver raised cosine filtering, they separate into clusters centered at the reference constellation points. The preamble symbols are always modulated with QPSK, and they may be different from the modulation of the payload symbols. Note that the example preamble bits from DOCSIS are not independently and uniformly distributed -- they result in fewer constellation symbols in the upper left cluster than the other three clusters. The payload bits, however, are mostly randomly generated, so they result in evenly distributed clusters of points.

Plot BER against Eb/No

Plot the empirically found BER against the Eb/No values, and compare them with theoretical results. The figure omits the theoretical curves for modulation orders of odd powers of 2 because the DOCSIS standard uses different symbol constellations than the ones assumed in the bercoding and berawgn functions. For even powers of 2, the functions assume the same constellations as the simulations, and thus the simulation is comparable with theory.

The BER curves show that both the coded and uncoded error rates match the theory reasonably well. For some combinations of (n,k) in Reed-Solomon codes, the coding gain may only appear in the higher Eb/No range, and sometimes the coded BER may even be higher than the uncoded BER at low Eb/No. This is expected behavior of R-S codes.

To get a more accurate simulated BER at higher Eb/No where the errors are very rare, increase the values of maxErr and maxBits in the previous section, and rerun the simulation. This allows the system to collect more bit errors for each Eb/No. If no errors occur at an Eb/No value, the BER curve will omit that data point.

% Find theoretical uncoded and coded BER
berUncodedTheoretical = berawgn(EbNoRange, ...
    'qam',docsisCfg.PayloadModulationOrder);
% Theoretical BER with R-S coding is only available when the codeword
% length is of the form 2^m-1.
if mod(log2(docsisCfg.RSCodewordLength+1),1) == 0
    berTheoretical = bercoding(EbNoRange,'RS','hard', ...
        docsisCfg.RSCodewordLength,docsisCfg.RSMessageLength, ...
        'qam',docsisCfg.PayloadModulationOrder);
else
    berTheoretical = [];
end

% Plot the curves
figure
semilogy(EbNoRange,berUncoded,'*-')
hold on
semilogy(EbNoRange,ber,'o-')
legendText = {'Uncoded simulation','Coded simulation'};
if mod(docsisCfg.PayloadModulationBitsPerSymbol,2) == 0
    semilogy(EbNoRange,berUncodedTheoretical,'--')
    legendText{end+1} = 'Uncoded theoretical';
    if ~isempty(berTheoretical)
        semilogy(EbNoRange,berTheoretical,'--')
        legendText{end+1} = 'Coded theoretical';
    end
end
grid on

if docsisCfg.RSEnabled
    title(sprintf('DOCSIS BER - Upstream TDMA, %s, R-S (%d,%d)', ...
        docsisCfg.PayloadModulation, ...
        docsisCfg.RSCodewordLength,docsisCfg.RSMessageLength))
else
    title(sprintf('DOCSIS BER - Upstream TDMA, %s, uncoded', ...
        docsisCfg.PayloadModulation))
end
xlabel('Eb/No (dB)')
ylabel('BER')
legend(legendText,'Location','southwest')

Figure contains an axes object. The axes object with title DOCSIS BER - Upstream TDMA, 16-QAM, R-S (255,251), xlabel Eb/No (dB), ylabel BER contains 4 objects of type line. These objects represent Uncoded simulation, Coded simulation, Uncoded theoretical, Coded theoretical.

Further Exploration

Alter the parameters of docsisCfg to see how they affect the output. For instance, alter the modulation and coding rate and rerun the simulations to see what effect they have on the system BER performance. Alter the raised cosine filter span, samples per symbol, and sample rate to see how they affect the visualization.

References

[1] CM-SP-PHYv4.0-I02-200429: Data-Over-Cable Service Interface Specifications DOCSIS® 4.0; Physical Layer Specification. Cable Television Laboratories, Inc., 2019-2020.

[2] CM-SP-MULPIv4.0-I02-200429: Data-Over-Cable Service Interface Specifications DOCSIS® 4.0; MAC and Upper Layer Protocols Interface Specification. Cable Television Laboratories, Inc., 2019-2020.

[3] CM-GL-PNMP-V03-160725: DOCSIS® Best Practices and Guidelines; PNM Best Practices: HFC Networks (DOCSIS 3.0). Cable Television Laboratories, Inc., 2010-2016.

[4] CM-SP-PHYv3.0-C01-171207: Data-Over-Cable Service Interface Specifications DOCSIS® 3.0; Physical Layer Specification. Cable Television Laboratories, Inc., 2006-2017.