No description
Find a file
2025-05-30 00:44:52 +02:00
.gitignore first commit 2025-05-19 19:44:29 +02:00
channel.py feat: add channel and main 2025-05-20 20:04:09 +02:00
channel_helper.py first commit 2025-05-19 19:44:29 +02:00
client.py first commit 2025-05-19 19:44:29 +02:00
decoder.py feat: good code 2025-05-30 00:44:20 +02:00
decoder_backup.py feat: good code 2025-05-30 00:44:20 +02:00
encoder.py feat: good code 2025-05-30 00:44:20 +02:00
encoder_backup.py chore 2025-05-30 00:44:52 +02:00
main.py feat: good code 2025-05-30 00:44:20 +02:00
main_backup.py chore 2025-05-30 00:44:52 +02:00
README.md feat: good code 2025-05-30 00:44:20 +02:00

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_backup.py \
  --message "Lorem ipsum dolor sit amet. consectetuer" \
  --trials 1 \
  --mode local

2. Test locally for 500 trials

python3 main_backup.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_backup.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.