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. βοΈπ
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
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
- π Language: Python 3.8+
- π§ Networking: Linux raw Ethernet sockets (AF_PACKET) β constructs/parses Ethernet frames directly using EtherType
0x88B5. Requires elevated privileges orCAP_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.
- 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.
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 (βοΈπ).
The application requires raw Ethernet socket access. Typical usage on Linux (root or with CAP_NET_RAW):
GUI (desktop):
sudo -E python3 index.pyCLI (terminal):
sudo -E python3 main.pyRecommendations:
- Install Tkinter for GUI:
sudo apt-get install -y python3-tk(Debian/Ubuntu) π§©. - To avoid running Python as root, grant
CAP_NET_RAWto the interpreter:sudo setcap cap_net_raw+ep $(readlink -f $(which python3))(advanced) π.
- Python 3.8+
- Linux kernel with AF_PACKET raw socket support (Debian/Ubuntu recommended) π§
- Root privileges or
CAP_NET_RAWfor raw Ethernet access π - Display server (X11/Wayland) for the GUI π₯οΈ (optional for CLI)
- 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 hostand add capabilities (--cap-add=NET_RAW) to enable raw socket access (Docker:--cap-add=NET_RAW) π³βοΈ. - GUI issues: ensure
python3-tkinstalled and a graphical session is running π§πΌοΈ.
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. ππ§°
- 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) π΅οΈββοΈπ‘.