Skip to content

Repository files navigation

Network Information & IP Analyzer

The Network Information & IP Analyzer is a Python-based tool designed to automatically identify a system's network configuration, calculate IP network parameters, and evaluate basic network connectivity. The system provides users with an easy-to-understand view of their IP address, subnet, network address, gateway, and connectivity status.

A network analysis tool with three front-ends over one shared engine — a desktop GUI (Tkinter), a browser UI (no web framework required) and a command-line interface — answering three questions about the machine it runs on:

  1. What is my network configuration? — interface, IP, mask, MAC, gateway, DNS, hostname
  2. What does that configuration actually mean? — network/broadcast address, host range, host count, class, scope
  3. Is the connection working? — gateway, DNS server and internet reachability, with latency grading

Features

  • Three interfaces over one engine: desktop window, browser UI, terminal
  • Automatic detection of the active interface (the one carrying the default route)
  • Full interface enumeration with a dropdown to inspect any of them
  • IPv4 and IPv6 detection
  • Subnet analysis: network address, broadcast, first/last host, usable hosts, wildcard mask, host bits, address class, private/public scope
  • Standalone CIDR calculator — analyze any address without touching this machine's config, including subnet splitting
  • Connectivity walk: gateway → DNS server → internet → name resolution, each timed
  • Link-quality grading (Excellent / Good / Moderate / Poor) from average latency
  • Visual subnet map showing where this host sits between the network and broadcast addresses
  • Latency scale showing the measured ping against the Excellent/Good/Moderate/Poor thresholds
  • Export results to .txt, .csv or .json
  • Runs the analysis on a background thread, so the window never freezes during ping tests
  • Graceful fallbacks everywhere: no netifaces, no ping binary, blocked ICMP, no display — the tool still produces an answer

Flow

              ┌──────────────────────┐
              │     Start Tool       │
              └──────────┬───────────┘
                         ↓
              ┌──────────────────────┐
              │ Detect Network       │   Module 1
              │ Interface            │   network_info.py
              └──────────┬───────────┘
                         ↓
              ┌──────────────────────┐
              │ Get IP Configuration │
              └──────────┬───────────┘
                         ↓
        ┌────────────────┼────────────────┐
        ↓                ↓                ↓
   IP Address       Subnet Mask      MAC Address
        ↓                ↓                ↓
        └────────────────┼────────────────┘
                         ↓
              ┌──────────────────────┐
              │ Calculate Network    │   Module 2
              │ & Broadcast Address  │   ip_analyzer.py
              └──────────┬───────────┘
                         ↓
              ┌──────────────────────┐
              │ Test Connectivity    │   Module 3
              │ GW → DNS → Internet  │   connectivity.py
              └──────────┬───────────┘
                         ↓
              ┌──────────────────────┐
              │ Display Results      │   gui/interface.py
              └──────────────────────┘

Project structure

NetworkAnalyzer/
│
├── main.py                  # entry point: desktop GUI, --web, or --cli
├── analyzer.py              # controller: runs the 3 modules, formats and exports results
│
├── modules/
│   ├── network_info.py      # Module 1 - OS network configuration detection
│   ├── ip_analyzer.py       # Module 2 - IP / subnet calculations (pure logic)
│   └── connectivity.py      # Module 3 - ping, DNS and reachability tests
│
├── gui/
│   └── interface.py         # Tkinter window: dashboard, CIDR calculator, full report
│
├── web/
│   ├── server.py            # http.server + JSON API over the same three modules
│   └── static/              # index.html, style.css, app.js (no frameworks)
│
├── tests/
│   └── test_modules.py      # 25 offline unit tests
│
├── requirements.txt
└── README.md

analyzer.py exists so all three front-ends share one copy of the pipeline, the report formatting and the export logic — none of them duplicates it. Swapping the interface never changes the numbers, because the numbers come from the same three modules either way.


Installation

# Python 3.8 or newer
pip install -r requirements.txt

On some Linux distributions Tkinter is packaged separately:

sudo apt install python3-tk          # Debian / Ubuntu
sudo dnf install python3-tkinter     # Fedora

No admin rights are needed to run the tool.


Usage

GUI

python main.py

The window opens, runs an analysis automatically, and shows three panels:

╔══════════════════════════════════════════╗
║       NETWORK INFORMATION ANALYZER       ║
╠══════════════════════════════════════════╣
║  Interface       wlo1                    ║
║  IP Address      10.208.127.91           ║
║  MAC Address     14:AC:60:FA:16:2B       ║
║  Subnet Mask     255.255.255.0           ║
║  Gateway         10.208.127.206          ║
╠══════════════════════════════════════════╣
║          NETWORK ANALYSIS                ║
╠══════════════════════════════════════════╣
║  Network         10.208.127.0/24         ║
║  Broadcast       10.208.127.255          ║
║  First Host      10.208.127.1            ║
║  Last Host       10.208.127.254          ║
║  Usable Hosts    254                     ║
╠══════════════════════════════════════════╣
║          CONNECTIVITY                    ║
╠══════════════════════════════════════════╣
║  Gateway         OK Reachable   26.2 ms  ║
║  Internet        OK Connected   64.7 ms  ║
║  Link Quality    Good                    ║
╚══════════════════════════════════════════╝

             [ ANALYZE NETWORK ]

Tabs: Dashboard (above) · CIDR Calculator (analyze any subnet) · Full Report (plain-text output).

Browser UI

python main.py --web              # serves http://127.0.0.1:8000 and opens a browser
python main.py --web --port 9000 --no-browser

Built on Python's own http.server — no Flask, no npm, nothing extra to install. The page calls a small JSON API (/api/interfaces, /api/analyze, /api/calc) that runs the same three modules the desktop window uses.

The server binds to 127.0.0.1 by default. The pages report this machine's network configuration, which is not something to expose to the rest of the LAN — override with --host only if you mean to.

Same three tabs as the desktop build, plus two visualisations the terminal cannot show: a subnet map marking this host's position between the network and broadcast addresses, and a latency scale placing the measured ping against the quality thresholds.

Command line

Command What it does
python main.py Launch the desktop GUI
python main.py --web Serve the browser UI on 127.0.0.1:8000
python main.py --web --port 9000 Serve it on a different port
python main.py --cli Print the full report to the terminal
python main.py --list List every interface, marking the active one
python main.py --cli -i wlan0 Analyze a specific interface
python main.py --cli --no-ping Skip connectivity tests (instant)
python main.py --calc 192.168.1.15/24 Analyze any subnet, no GUI
python main.py --calc 172.20.10.5 -m 255.255.255.240 Same, with a dotted mask
python main.py --json Machine-readable output
python main.py --cli -e report.csv Export to .txt / .csv / .json

Sample output

NETWORK INTERFACE
------------------------------------------
Interface     : wlo1
Status        : UP
IP Address    : 10.208.127.91
Subnet Mask   : 255.255.255.0
MAC Address   : 14:AC:60:FA:16:2B
Gateway       : 10.208.127.206
Hostname      : nivx

IP & NETWORK ANALYSIS
------------------------------------------
CIDR              : /24
Network Address   : 10.208.127.0
Broadcast Address : 10.208.127.255
First Host        : 10.208.127.1
Last Host         : 10.208.127.254
Usable Hosts      : 254
Address Class     : A
Scope             : Private

CONNECTIVITY STATUS
------------------------------------------
Gateway         : OK Reachable     26.2 ms
DNS Server      : OK Reachable     62.8 ms
Internet        : OK Reachable     64.7 ms
Name Resolution : OK Working       www.google.com -> 142.251.150.119

Overall Status  : Connected
Average Ping    : 48.8 ms
Link Quality    : Good

The three modules

Module 1 — modules/network_info.py

Collects configuration from the operating system into an InterfaceInfo object. Uses psutil for addresses and link stats; the default gateway comes from netifaces if installed, otherwise from /proc/net/route, ip route, route print or netstat -rn depending on the platform. DNS servers come from /etc/resolv.conf, scutil or ipconfig /all.

The active interface is chosen by: default-route owner → the source address the kernel picks for outbound traffic (via an unconnected UDP socket, no packets sent) → first non-loopback interface that is up.

Module 2 — modules/ip_analyzer.py

Pure computation built on Python's ipaddress module — no OS calls, no network traffic, which is what makes it fully unit-testable. Accepts 192.168.1.15/24, or an IP plus a dotted mask, or an IP plus a prefix. Handles the two edge cases the 2^n − 2 formula gets wrong: a /31 point-to-point link (RFC 3021 — both addresses usable) and a /32 single-host route. Also exposes subnet_split(), netmask_to_prefix(), prefix_to_netmask() and is_in_network() for the CIDR calculator tab.

Module 3 — modules/connectivity.py

Walks outwards one hop at a time and times each step. Builds the platform-correct ping command, then parses Linux, macOS and Windows output formats. Because ICMP is commonly filtered on campus and corporate networks, a failed ping falls back to a TCP connect probe before the host is declared unreachable. A local stub resolver (127.0.0.53 from systemd-resolved) is detected and swapped for a real external resolver, since pinging localhost proves nothing.

Latency grading: < 30 ms Excellent · 30–80 ms Good · 80–150 ms Moderate · > 150 ms Poor.


Front-ends

File Notes
Desktop gui/interface.py Tkinter. Analysis runs on a worker thread and returns through a queue, so the window stays responsive during ping tests.
Browser web/server.py + web/static/ http.server and vanilla JS. Exports are built client-side from the JSON the API already returned.
Terminal main.py Argparse. Also the fallback when no display is available.

Testing

python -m unittest discover -s tests -v

25 tests, fully offline (no network required): subnet maths including /31, /32 and IPv6 edge cases, address-class detection, mask/prefix conversion, subnet splitting, ping-output parsing for all three platform formats, and the overall connectivity verdict logic.


Notes and limitations

  • ICMP may be blocked. Many networks filter ping. The tool falls back to a TCP probe and labels the result, so "unreachable" means "no ICMP and no TCP response".
  • Speed shows N/A on Wi-Fi, because psutil reports link speed only for wired interfaces on most systems.
  • Ping latency is not throughput — a good ping does not guarantee a fast connection.
  • Virtual interfaces (docker0, br-*, veth*) appear in the interface list; that is correct behaviour, they are real interfaces on the system.

Possible extensions

  • Internet speed test (download/upload)
  • Reverse DNS and WHOIS lookup for the public IP
  • Continuous monitoring with a latency graph over time
  • Network topology visualisation
  • Local subnet host discovery — only on networks you own or are authorised to scan

About

System network configuration, IPv4/IPv6 subnet math and connectivity checks — one engine behind a Tkinter GUI, a browser UI and a CLI. Pure standard-library Python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages