Skip to content

jery04/Messaging-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

41 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ZAP Messaging Application βš™οΈπŸ–§πŸ”πŸ“‘πŸ› οΈ

Peer-to-peer link-layer messaging system implemented in Python 🐍. ZAP constructs and parses custom Ethernet frames (EtherType 0x88B5) to deliver text messages and files directly between MAC addresses on the same LAN β€” no IP/TCP/UDP required. πŸ§©πŸ”—

Two user entry points are provided: a desktop GUI (index.py) implemented with Tkinter (πŸ–₯️🎨) and a terminal CLI (main.py) for headless/scripted operation (βŒ¨οΈπŸ“Ÿ). Both use the same low-level transmission engine. βš™οΈπŸ”

Project Overview πŸ§­πŸ”¬

ZAP is designed for local networks where raw Ethernet access is available. Key capabilities include:

  • πŸ“‘ Device discovery via link-layer broadcasts and neighbor detection
  • πŸ“¦ Reliable, fragmented file transfer with batch ACKs and windowed flow control
  • πŸ’¬ Peer-to-peer text messaging addressed by destination MAC
  • πŸ–₯️ GUI and CLI frontends sharing a common link-layer protocol

Project Structure πŸ—‚οΈπŸ“‚

Messaging-application/
β”œβ”€β”€ main.py        # CLI entry point (⌨️)
β”œβ”€β”€ index.py       # GUI entry point (Tkinter, πŸ–₯️)
β”œβ”€β”€ Enviar.py      # Transmitter: frame building, fragmentation, send logic (πŸ“€πŸ› οΈ)
β”œβ”€β”€ Recibir.py     # Receiver: raw socket listener, parsing, reassembly (πŸ“₯πŸ”Ž)
β”œβ”€β”€ Detector.py    # Network interface detection & MAC utilities (πŸ”πŸ§­)
β”œβ”€β”€ Values.py      # Protocol constants and global configuration (βš™οΈπŸ“)
β”œβ”€β”€ assets/        # UI assets and test resources (πŸ–ΌοΈ)
└── __pycache__/    # Compiled Python files

Technical Summary πŸ§ πŸ’»

  • 🐍 Language: Python 3.8+
  • πŸ–§ Networking: Linux raw Ethernet sockets (AF_PACKET) β€” constructs/parses Ethernet frames directly using EtherType 0x88B5. Requires elevated privileges or CAP_NET_RAW.
  • πŸ–₯️ GUI: Tkinter (standard library) used by index.py.
  • πŸ” Concurrency: threading + non-blocking sockets for parallel send/receive pipelines.
  • 🧩 Protocol design: fragmentation for payloads larger than ~1450 bytes (MTU-aware), per-fragment IDs, sequence numbers, transfer IDs, and batch ACKs for file transfers.

⚠️ Note: Raw Ethernet access from user-space is limited on Windows/macOS. Use Linux (native or a privileged container) for full capabilities. πŸ§πŸ“¦

Protocol (high-level) πŸ”¬πŸ“‘

  • EtherType: 0x88B5 β€” application frames identifier on the wire (πŸ› οΈ).
  • Frame types: Discovery (broadcast), Message (unicast), File Chunk (fragment), ACK/Control (reliability control).
  • Fragmentation: payloads exceeding the threshold are split into numbered chunks; receiver reassembles chunks by transfer_id + sequence.
  • Flow control: windowing and batched ACKs prevent receiver overload and manage retransmissions.

Component Details πŸ§©πŸ”§

  • main.py β€” CLI client: interactive commands (/list, /msg, /file, /broadcast) and logging (βŒ¨οΈπŸ“).
  • index.py β€” Desktop UI: message timeline, device list, file chooser, and transfer progress indicators (πŸ–₯οΈπŸŽ›οΈ).
  • Enviar.py β€” Transmission engine: frame construction, fragmentation, send queue, retransmit logic, and rate/window control (πŸ“€πŸ”).
  • Recibir.py β€” Reception engine: raw socket listener, EtherType filtering, header parsing, fragment reassembly, and delivery to UI/CLI (πŸ“₯πŸ”Ž).
  • Detector.py β€” Interface utilities: enumerate interfaces, read MAC addresses, convert formats, detect container/host environments (πŸ”πŸ§­).
  • Values.py β€” Protocol constants: EtherType, frame type codes, default MTU/fragment sizes, timeout and retry settings (βš™οΈπŸ“).

Running (quick) β–ΆοΈπŸ› οΈ

The application requires raw Ethernet socket access. Typical usage on Linux (root or with CAP_NET_RAW):

GUI (desktop):

sudo -E python3 index.py

CLI (terminal):

sudo -E python3 main.py

Recommendations:

  • Install Tkinter for GUI: sudo apt-get install -y python3-tk (Debian/Ubuntu) 🧩.
  • To avoid running Python as root, grant CAP_NET_RAW to the interpreter: sudo setcap cap_net_raw+ep $(readlink -f $(which python3)) (advanced) πŸ”.

Requirements & Environment βš™οΈπŸ§ͺ

  • Python 3.8+
  • Linux kernel with AF_PACKET raw socket support (Debian/Ubuntu recommended) 🐧
  • Root privileges or CAP_NET_RAW for raw Ethernet access πŸ”’
  • Display server (X11/Wayland) for the GUI πŸ–₯️ (optional for CLI)

Limitations & Troubleshooting πŸ› οΈπŸ”Ž

  • Windows/macOS: user-space raw Ethernet is generally unsupported β€” limited functionality πŸͺŸπŸ.
  • WSL: direct interface/raw Ethernet may be unavailable depending on WSL version 🐧🚧.
  • Containers: use --network host and add capabilities (--cap-add=NET_RAW) to enable raw socket access (Docker: --cap-add=NET_RAW) πŸ³βš™οΈ.
  • GUI issues: ensure python3-tk installed and a graphical session is running πŸ”§πŸ–ΌοΈ.

Security Considerations πŸ”πŸ›‘οΈ

Running at the link layer requires administrative privileges. ZAP frames are not encrypted by default β€” avoid use on untrusted networks without additional encryption or VPN tunneling. Consider application-layer encryption (e.g., symmetric keys) if confidentiality is required. πŸ”’πŸ§°

Development & Testing πŸ”¬πŸ§ͺ

  • Uses Python standard library (socket, threading) β€” no external dependencies required for core features.
  • Test in an isolated LAN or VM to avoid unintended frame injection on production networks. Use packet capture tools (tcpdump, wireshark) for debugging (monitor EtherType 0x88B5) πŸ•΅οΈβ€β™‚οΈπŸ“‘.

About

πŸ”— This project aims to implement a peer-to-peer messaging application operating strictly at the data link layer, enabling message and file exchange between computers within the same local network.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages