How bhaskardharma/network_sniffing works
Project type and purpose
• This is a small, single-script, CLI network-sniffing tool written in Python. Its purpose is to capture and display (or log) network packets in real time using the Scapy library.
File structure
• Top-level files:
• README.md — describes usage and purpose
• sniffer.py — the sole Python script that imports Scapy and performs packet sniffing
• No “frontend” or “backend” directories—this is a standalone utility
• No build or deployment scripts—just a direct Python invocation
README for additional insights
• Confirms the use of Scapy for packet capture and decoding
• Usage instructions: clone repo, cd into it, run python sniffer.py
Main components and their relationships
a. User / CLI
– Invokes sniffer.py from a shell
b. sniffer.py (Application Logic)
– Defines packet-capture filters, callbacks, and display/storage logic
c. Scapy library
– Provides the programmatic API for raw socket access, packet parsing, and crafting
d. libpcap / OS Kernel Network Stack
– Underlying subsystem that actually sniffs packets at the NIC level
e. Network Interface (Ethernet/Wi-Fi)
– The source of raw traffic (LAN, Internet)
f. Output sink
– Console stdout, log file, or other storage mechanism
Relationships & Data Flow:
User → (runs) → sniffer.py → (calls) → Scapy → (interfaces with) → libpcap/Kernel → (reads) → Network Interface
Then reverse: packets flow from Network → Kernel → Scapy → sniffer.py → Console/File → User
Architectural patterns & design principles
• Single-process, imperative CLI tool
• Layered abstraction:
• sniffer.py (application layer)
• Scapy (library layer)
• libpcap/Kernel (system layer)
• Network Hardware (external layer)
• Clear separation of concerns: sniffing/filtering logic vs. packet parsing vs. output formatting