A cross-platform network diagnostic toolkit β ping, traceroute, DNS lookup, and port scanner
Your own network toolkit, built from raw sockets.
NetPing is a command-line network diagnostic tool built from scratch in C++17 using raw ICMP sockets and POSIX networking APIs. It reimplements classic tools β ping, traceroute, nslookup, and nmap-style port scanner β as a learning project in low-level network programming.
| Command | Description |
|---|---|
netping ping |
ICMP echo request/reply with RTT stats |
netping trace |
Traceroute using TTL manipulation |
netping dns |
DNS A, AAAA, MX, TXT record lookup |
netping scan |
TCP port scanner with banner grabbing |
netping whois |
WHOIS lookup for domains and IPs |
git clone https://github.com/Alice699/netping.git
cd netping
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
# Install to /usr/local/bin (Linux/macOS)
sudo make installNote:
pingandtracerequire root/admin privileges (raw socket access).
Ping
$ netping ping google.com -c 5
PING google.com (142.250.185.46) 56 bytes of data.
64 bytes from 142.250.185.46: icmp_seq=1 ttl=117 time=12.4 ms
64 bytes from 142.250.185.46: icmp_seq=2 ttl=117 time=11.9 ms
64 bytes from 142.250.185.46: icmp_seq=3 ttl=117 time=12.1 ms
64 bytes from 142.250.185.46: icmp_seq=4 ttl=117 time=13.2 ms
64 bytes from 142.250.185.46: icmp_seq=5 ttl=117 time=11.8 ms
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss
rtt min/avg/max = 11.8/12.3/13.2 msTraceroute
$ netping trace github.com
traceroute to github.com (140.82.121.4), 30 hops max
1 192.168.1.1 1.2 ms 1.0 ms 1.1 ms
2 10.0.0.1 5.4 ms 5.2 ms 5.3 ms
3 203.0.113.1 11.2 ms 11.1 ms 11.4 ms
...
15 140.82.121.4 28.3 ms 27.9 ms 28.1 msPort Scanner
$ netping scan example.com -p 1-1000 --timeout 500
Scanning example.com (93.184.216.34) ports 1-1000...
PORT STATE SERVICE BANNER
22/tcp open ssh OpenSSH_8.9
80/tcp open http nginx/1.22.1
443/tcp open https
8080/tcp closed
Scan complete: 4 ports scanned, 3 open, 1 closed (0.8s)DNS Lookup
$ netping dns github.com --type ALL
DNS query for github.com
ββββββββββββββββββββββββ
A β 140.82.121.4
AAAA β (none)
MX β 10 aspmx.l.google.com
TXT β "v=spf1 ip4:192.30.252.0/22 include:_netblocks.google.com ~all"netping/
βββ include/
β βββ ping.hpp # ICMP ping implementation
β βββ traceroute.hpp # Traceroute via TTL
β βββ dns.hpp # DNS resolver
β βββ scanner.hpp # TCP port scanner
β βββ whois.hpp # WHOIS client
β βββ socket.hpp # RAII socket wrapper
β βββ cli.hpp # CLI argument parser
βββ src/
β βββ ping.cpp
β βββ traceroute.cpp
β βββ dns.cpp
β βββ scanner.cpp
β βββ whois.cpp
β βββ main.cpp
βββ tests/
βββ CMakeLists.txt
βββ README.md
ICMP Ping:
Uses SOCK_RAW with IPPROTO_ICMP. Constructs ICMP echo packets manually, calculates checksum, measures RTT with std::chrono::high_resolution_clock.
Traceroute: Sends UDP packets with incrementing TTL (1 to 30). Each router that drops the packet sends back an ICMP Time Exceeded β that's your hop.
Port Scanner:
Attempts connect() with non-blocking socket + select() timeout. Optionally reads first 64 bytes for banner grabbing.
DNS:
Manually constructs and parses DNS query packets per RFC 1035. No getaddrinfo β raw UDP to port 53.
- Raw socket programming with ICMP and UDP
- Manual packet construction and binary protocol parsing
- Non-blocking I/O with
select()/poll() - RAII wrappers for C-style resource handles
- Cross-platform socket abstraction (POSIX vs Winsock)
- IPv6 full support
- MTU path discovery
- Continuous monitoring mode with graph output
- JSON output for scripting integration
- Windows Winsock2 backend
MIT Β© Robbian Saputra Gumay