Introducing the Zing zero-packet network utility
Zing Me
Zing is a lightweight, zero-packet network utility similar to ping that provides ping functionality without the payload.
The ping networking utility (backronym Packet InterNet Groper) [1, 2, 3] is a common tool used to determine network delay and whether a host is active at an IP address [4]. Ping sends an Internet Control Message Packet (ICMP) [5] to a host as an echo request, which then receives a response from the remote host. Ping sends data about the time and the host sends the data back – to put it at its simplest, plainest explanation.
Ping is popular with admins around the world, however, the ping utility is not without problems. For instance, ping can be used to send a packet storm to overload and crash a host system – a denial-of-service (DOS) attack called a ping flood. Some sites simply do not respond to ping requests, and some firewalls block the ICMP packets sent by the ping utility.
A problem I faced was the need for ping functionality, but without sending packets of data through the network. One of the best things about being a software development engineer is that, for interesting problems, it only takes a little creativity to find a solution. Driven by the need, I created my own network utility.
My requirements for this utility were:
- No data payload is sent or received, to avoid network congestion.
- Ability to check that both a host and the ports are alive and available
- Able to report the time to reach a host connect and disconnect
- Available to run on multiple platforms, in this case, Windows, macOS, and Linux
- Support for both Internet Protocol version 4 and version 6 addresses
- Parameters and reporting similar to ping – a familiar look and feel
With these objectives in mind, I created Zing. The name Zing is an acronym for Zero packet pING. I wanted the utility to have a name that sounds like ping, but I also liked the reference to zinging a system, much as an improv comic will zing a person in humor.
Application
Zing is implemented as both a command-line interface utility and a library function in Java. Using Java achieves cross-platform availability. Then, for each platform, I created a launch app (or kicker app) to run the Zing network utility.
Zing works by a simple approach: Measure the amount of time to connect and disconnect from specified ports for some limit to the number of operations. The idea behind Zing is not uniquely mine. I have read source code in network applications and libraries that takes a similar approach. Unlike the other tools I've seen, though, Zing is designed to look and operate more like ping.
This idea of connecting, binding, and disconnecting avoids sending any ICMP packets or other data. Zing simply requests to connect, connects, then disconnects. More measurements of each op give greater accuracy in the network timing. During this process, a host and port are determined to be reachable, available, and responding. Also, in some cases, a connection request can pass through a firewall to a remote host and port.
The host system will only see several connection requests, connects, and disconnects. In short, Zing looks like any other Internet application because it is not sending an ICMP packet.
Operation
Zing is implemented in Java and is a command line interface utility application. The Java class source code is approximately 400 lines, of which there are approximately 250 lines of code. Zing uses only JDK libraries and packages and implements some helpful internal methods. All methods and attributes are static, and the Java class does not sub-class a parent class explicitly (all Java classes are a sub-class of java.lang.Object implicitly), and Zing is a self-contained program utility using only the libraries in the JDK within the Java class.
The Zing network utility has the following command line parameters:
zing [-4 | -6] [-c count] [-op ops] flfl [-p ports] [-t timeout] [-h] hostname
Each Zing network utility parameter is:
-4: TCP IP address version 4 (IPv4) -6: TCP IP address version 6 (IPv6). -c: the count of the number of operations per port. -op: the number of ops per count. -p: a list of ports to be used by the Zing network utility. -t: the timeout waiting for a host response. -h: a request for help, giving the Zing CLI parameters.
The hostname can be the host system IP address or the host system name. The default values for the command line interface parameters for the Zing network utility are:
zing -4 -c 4 -op 4 -p 80,443 -t 4000 host
These default command line interface parameters are Internet Protocol version 4 (IPv4), with a count of four times for each port, and the default ports are port 80 for the HTTP protocol and 443 for the HTTPS protocol. The default timeout is 4,000 milliseconds or four seconds. The host you wish to zing is a required parameter with no default.
Design
The Zing network utility is a single Java class with static methods and attributes. The 12 static attributes are used by Zing and are initialized to the default values. The 10 static attributes as Java code fragments are (see Table 1 for descriptions):
boolean hostFlag = true; boolean tcp4Flag = true; InetAddress inet_addr = null; int count = 4; int limit = 4; int timeout = 4000; Integer[] ports = flfl new Integer[]{ 80, 443 }; String host = "localhost"; String hostAddr = ""; String hostName = "";
Table 1
Zing Attributes
Name | Description |
---|---|
hostFlag |
indicates if the host is available and reachable. By default, a host is presumed to be available and reachable. Thus hostFlag is initialized to true. |
tcp4Flag |
indicates if the zing will use a host IP address of Internet Protocol version 4 (IPv4) or Internet Protocol version 6 (IPv6) for the domain name. |
inet_addr |
the Internet address retrieved from a query to the domain name system. Initially null because the Internet address must be queried to create an instance value of an Internet address. |
count |
the number of times the Zing network utility will zing a host. The default number is four times. |
limit |
the number of times to perform an individual operation, a connect-disconnect to a port. The default limit is four operations. A higher limit is more accurate but requires a longer time to process. |
timeout |
the number of milliseconds to wait to reach a hostname. The default timeout is 4,000 milliseconds or four seconds. |
ports |
the ports on the remote host to process. The two default ports are port 80, for HTTP, and port 443 for HTTPS – both ports are commonly used by hosts. |
hostAddr |
a string representing the IP address of the remote host. Initially, it is an empty, blank string. |
hostName |
passed to Zing and resolved both as an IP address and a hostname. Initially, the hostName is a string but initialized to an empty string. |
The Zing network utility also has 10 specific static methods for the operation of the utility. The 10 methods are shown in Listing 1. See Table 2 for a description of these Zing methods.
Listing 1
Zing Methods
01 double doZingToHost(final String host, final int port) 02 InetAddress getHostAddrName(final String host) 03 Inet4Address getIPv4Addr(final String hostName) 04 Inet6Address getIPv6Addr(final String hostName) 05 double getTotalTime(final double totalTime, 06 final int portsLength, final int limit) 07 void main(final String[] args) 08 void processArgs(final String[] args) 09 void report(final double time) 10 void stddev(final double average, final double[] values) 11 void usage()
Table 2
Zing Methods
Method | Description |
---|---|
usage() |
displays the proper usage and an example of command line interface parameters |
main() |
a method called when the Zing network utility is run |
processArgs() |
used to process the command line parameters and configure the attributes |
report() |
prints a summary of the statistics calculated by the Zing network utility |
stddev() |
computes standard deviation [6] as part of the report after a computer system is zinged |
getHostAddrName() |
returns the host name |
getIPv4Addr() |
returns the IPv4 address |
getIPv6Addr() |
returns the IPv6 address |
getTotalTime() |
returns a double, a real number for the time calculated to zing a host computer system on a network |
doZingToHost |
the core method containing the actual functionality for the Zing utility |
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.