pdc_project/README.md
2025-05-27 11:38:28 +02:00

1.9 KiB

Communication System README

This repository contains a Python-based transmitter/receiver system for sending 40-character text messages over a simulated noisy channel (local or remote server).


Prerequisites

  • Python 3.7+
  • NumPy

Install dependencies:

pip install numpy

Files

  • encoder.py — builds codebook and encodes messages.
  • decoder.py — decodes received samples back into text.
  • channel.py — local channel simulator.
  • client.py — client stub to send samples to the remote server.
  • main.py — main driver: wraps encode → channel → decode, plus performance testing.

Usage

All commands assume you are in the project root directory.

1. Test locally for 1 trial

python3 main.py \
  --message "Lorem ipsum dolor sit amet. consectetuer" \
  --trials 1 \
  --mode local

2. Test locally for 500 trials

python3 main.py \
  --message "Lorem ipsum dolor sit amet. consectetuer" \
  --trials 500 \
  --mode local

3. Test on the remote server (1 trial)

This will write input.txt and output.txt in your working directory.

python3 main.py \
  --message "Lorem ipsum dolor sit amet. consectetuer" \
  --trials 1 \
  --mode server \
  --input_file input.txt \
  --output_file output.txt \
  --hostname iscsrv72.epfl.ch \
  --port 80

After running, input.txt contains your transmitted samples, and output.txt contains the noisy output from the server.


Manual decoding of server output

If you want to decode output.txt yourself:

python3 - << 'EOF'
import numpy as np
import encoder, decoder

# Load noisy samples
Y = np.loadtxt("output.txt")

# Rebuild codebook
C = encoder.make_codebook(r=5, num_blocks=40)

# Decode
msg = decoder.decode_blocks(Y, C)
print("Decoded message:", msg)
EOF

Feel free to adjust --trials or swap between local and server modes as needed.