Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
2 Commits
 
 
 
 
 
 

Repository files navigation

Channel-Coding Testbeds

Two standalone MATLAB testbeds for channel coding, built as supporting toolkits during wireless-security research at UC Riverside:

  1. mqam-viterbi-ber/ — parameter-swept BER characterization of Gray-coded M-QAM over AWGN, uncoded vs. rate-1/2 convolutional coding with Viterbi decoding (hard and soft decision, traceback depth 32/48).
  2. wtc-ldpc-secrecy/ — Monte-Carlo simulation of Wyner wiretap-channel secrecy coding on the 5G NR LDPC chain, showing a secret message that the legitimate receiver recovers reliably while an eavesdropper on a worse channel cannot.

Author: Ahmed Maksud — ahmedmaksud.github.io


1. M-QAM + Viterbi BER sweep (mqam-viterbi-ber/)

What it does

A scenario-driven sweep harness characterizes bit-error rate over an AWGN channel for every combination of:

Dimension Values
Modulation 4-QAM, 16-QAM (Gray-mapped, unit average power)
Coding uncoded · rate-1/2 convolutional, poly2trellis(7, [171 133])
Viterbi traceback depth 32 · 48 (continuous mode)
Decision type hard, soft (approximate LLR demodulation with per-SNR noise variance)
SNR 0–26 dB in 1 dB steps

Each BER point averages 10,000 frames × 1000 symbols; bit-error counting compensates for the Viterbi traceback delay. The SNR loop is parallelized with parfor (runs serially without the Parallel Computing Toolbox).

  • ECC_sweep.m — defines the six scenarios, runs them all, and saves a consolidated timestamped .mat
  • ECC_single.m — the simulation engine for one configuration (called by the sweep; usable standalone)
  • ECC_plot.m — loads the newest ecc_sweep_results_*.mat and renders both panels into a single figure at 300 dpi

Results

The curves reproduce the textbook behavior end to end: soft-decision Viterbi buys roughly 2 dB over hard decision at equal traceback depth; deepening traceback from 32 to 48 adds only a marginal gain at these block sizes; and at low SNR the hard-decision rate-1/2 code is worse than uncoded transmission.

Run it

cd mqam-viterbi-ber
ECC_sweep    % runs all six scenarios, saves ecc_sweep_results_<timestamp>.mat
ECC_plot     % regenerates BER-Combined.png from the newest .mat

ECC_plot saves BER-Combined.png in the folder (both panels in one figure). Requires the Communications Toolbox; Parallel Computing Toolbox optional (speeds up the SNR sweep).


2. Wiretap-channel secrecy coding on 5G NR LDPC (wtc-ldpc-secrecy/)

What it does

A Monte-Carlo model of Wyner's wiretap setting over a pair of binary symmetric channels: Alice's codeword reaches Bob through BSC(p = 0.05) and the eavesdropper Eve through the noisier BSC(q = 0.15). Because Eve's channel is worse, there is a capacity gap for a secret message.

The transmitted message is the concatenation [secret bits ; randomization bits]. The randomization bits soak up the code rate that lies above the secrecy rate, leaving the secret bits carried by the systematic part of a single LDPC codeword. Rates follow the wiretap framework:

  • main-channel capacity C_p = 1 − h(p), eavesdropper capacity C_q = 1 − h(q), secrecy capacity C_s = C_p − C_q
  • code rate R = α·C_p (reliability factor α), secret rate R_s = β·C_s (secrecy factor β)
  • block length N = 2¹³, secret/random split k_s / k_r derived from the rates

For the committed run (p = 0.05, q = 0.15, α = 0.97, β = 1): C_p = 0.714, C_q = 0.390, R = 0.692, and of the k_c = 5670 transmitted message bits, k_s = 2649 are secret and k_r = 3021 are randomization.

The physical layer is the 5G NR LDPC chain from the 5G Toolbox: nrCRCEncode('24A') → nrCodeBlockSegmentLDPC → nrLDPCEncode → nrRateMatchLDPC on the way in, exact BSC log-likelihood ratios log((1−p)/p)·(1−2y) into nrRateRecoverLDPC → nrLDPCDecode (25 iterations) → nrCodeBlockDesegmentLDPC on the way out. Each of the 10⁵ Monte-Carlo trials records secret-bit BER and BLER for both Bob and Eve; main.m reports summary statistics and kernel-density estimates of the two BER distributions.

  • main.m — configuration, Monte-Carlo driver (parfor), statistics, and the PDF figure
  • WTC.m — one end-to-end trial: message assembly → CRC/LDPC encode + rate-match → BSC pair → LLR decode → secret-bit errors
  • binaryEntropy.m — binary entropy helper

Result — Bob decodes, Eve does not

With the code rate set just below Bob's capacity (α = 0.97) but above Eve's, the two secret-bit BER distributions separate cleanly: Bob sits at a mean BER ≈ 0.037 — a small, honest finite-blocklength floor from operating near capacity — while Eve sits at ≈ 0.216, roughly one secret bit in five wrong, her decoder unable to resolve the message on the noisier channel. The secret survives at the legitimate receiver and is largely lost at the eavesdropper.

This is a reliability-gap demonstration, not a formally secure coset code.

Run it

cd wtc-ldpc-secrecy
main         % 1e5 trials (parfor); prints statistics, saves BER_PDF_Bob_Eve.png/.fig

Requires the 5G Toolbox (NR LDPC functions) and the Statistics and Machine Learning Toolbox (ksdensity); Parallel Computing Toolbox optional (the trial loop is a parfor). Raise max_iter toward 10⁶ for a publication-smooth PDF.


Repository layout

mqam-viterbi-ber/
├── ECC_sweep.m / ECC_single.m / ECC_plot.m
├── ecc_sweep_results_<timestamp>.mat          # consolidated sweep output (all six scenarios)
└── BER-Combined.png                           # committed figure
wtc-ldpc-secrecy/
├── main.m / WTC.m / binaryEntropy.m
└── BER_PDF_Bob_Eve.png / .fig                  # committed figure

Related repositories

  • CEF-ECC-Reconciliation — Reed-Solomon key reconciliation for secret-key generation (a different use of coding: agreeing on keys, not protecting messages)
  • SKC-for-MIMO--MilCom23-WCL24 — the information-theoretic side: closed-form secret-key capacity bounds
  • MC-STEEP — secrecy-rate optimization for OFDM links

About

MATLAB channel-coding testbeds: M-QAM/Viterbi BER over AWGN and Wyner wiretap secrecy coding on 5G NR LDPC.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.