Skip to content

Darawsha/Manchester-Encoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Manchester Encoding for File Transmission and Reception Using Python

Prepared by: Ameed Darawsha
Date: May 2, 2026

This project implements a simple simulation of Manchester Encoding using Python. The program reads text from an input file, converts it into binary bits, applies Manchester Encoding, decodes the encoded data back into binary, reconstructs the received file, and compares it with the original input file.

The full project report is available here: docs/report.pdf.

Abstract

Manchester Encoding is a line coding technique used in digital communication systems. It represents each bit using a transition, which helps the receiver maintain synchronization with the transmitter.

In this project, the transmitter side reads data from input.txt, converts it to binary, and applies Manchester Encoding. The receiver side decodes the Manchester data, reconstructs the original file as received_file.txt, and checks whether the transmission was successful.

Manchester Encoding Rule

This project uses the following mapping:

0 -> 10
1 -> 01

Example:

Binary:      01000001
Manchester: 1001101010101001

System Design

The project has two main parts:

  1. Transmitter side
Input File -> Text -> Bytes -> Binary Bits -> Manchester Encoding
  1. Receiver side
Manchester Data -> Decoded Bits -> Bytes -> Received File

Procedure

  1. Read input.txt using UTF-8 encoding.
  2. Remove an extra trailing new line from the input text.
  3. Convert each character to bytes.
  4. Convert each byte into an 8-bit binary value.
  5. Encode each bit using the Manchester rule.
  6. Decode every Manchester pair back into binary.
  7. Rebuild the received file from the decoded bits.
  8. Compare the received file with the original input file.

Main Functions

Function Description
file_to_bits(filename) Reads the input file and converts its content into binary bits.
bits_to_manchester(bits) Converts binary bits to Manchester encoded data.
manchester_to_bits(encoded) Decodes Manchester data back into binary bits and counts errors.
bits_to_file(bits, output_filename, original_size) Reconstructs the received file from decoded bits.
compare_files(file1, file2) Checks whether the received file matches the original file.

Project Structure

.
|-- ManchesterEncoding.py
|-- input.txt
|-- readme.md
|-- docs/
|   `-- report.pdf
`-- assets/
    `-- images/
        |-- binary-conversion.png
        |-- bits-to-manchester.png
        |-- file-to-bits.png
        `-- program-output.png

Requirements

  • Python 3
  • No external libraries are required

How to Run

  1. Put the text you want to transmit inside input.txt.
  2. Run the Python file:
python ManchesterEncoding.py

Output Files

When the program runs, it generates these files:

File Description
binary.txt Binary representation of the input file.
manchester.txt Manchester encoded output.
decoded_bits.txt Binary data after decoding the Manchester stream.
received_file.txt Reconstructed file at the receiver side.

These files are generated automatically and are ignored by Git.

Example Program Output

Manchester Encoding Project
---------------------------
Input file: input.txt
Output file: received_file.txt
Original bits: 8
Manchester bits: 16
Decode errors: 0
Transmission success: True

Screenshots

File to Bits

File to bits function

Binary Conversion

Binary conversion line

Manchester Encoding Function

Manchester encoding function

Program Output

Program output

Discussion

The program shows that the transmitted file can be reconstructed successfully when no transmission errors are introduced. Manchester Encoding improves synchronization because every bit contains a transition, but it also doubles the number of bits compared with the original binary data.

The decoder also counts invalid Manchester pairs, such as 00 or 11, as decode errors.

Conclusion

This project demonstrates the basic transmitter and receiver flow for Manchester Encoding. It converts file data into binary, encodes it, decodes it, rebuilds the received file, and verifies the result by comparing the original and received files.

About

Manchester Encoding for File Transmission and Reception Using Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages