Skip to content

fxfwn/netcalc

Netcalc

Static Badge Static Badge Static Badge

Netcalc (netcalc) - a safe, fast command line utility program to calculate IPv4/IPv6 network characteristics without touching any system or network configurations.

Compatibility

Compatible with any terminal that supports ANSI escape codes (shell, bash, pwsh, Zsh)

For Windows native PowerShell, you may need to enable ANSI escape code support.

Features

  • calculate all network characteristics from any IP address
  • identify network type, error when given APIPA address

Dependencies

  • CLI11 by CLIUtils (CMakeLists is set up to fetch this dependency on build time)
  • (for v0.2.0) fmt by fmtlib (CMakeLists is set up to fetch this dependency on build time)
  • bitset (std)
  • a C++ 17-compatible compiler (gcc/g++, clang, MSVC etc.)
  • CMake 3.16.0 or later

⚠️ Note: Dependency changes due to changes in the source code

Starting with netcalc 0.3.0, more recent C++ features will be used, prompting a change to the CMakeLIsts.txt in the code base (Latest in main branch). These changes are:

  • CMake 3.16.0 or later CMake 3.25.0 or later
  • a C++ 17-compatible compiler a C++ 20-compatible compiler (see Compiler Support for C++ 20 for compatible compilers)
  • fmt by fmtlib This dependency has been removed with netcalc 0.3.0.

What features prompted this change?

These changes are due to the use of the std::format (introduced in C++ 20) from version 0.3.0 forward. That allows for a more maintainable and less verbose source code, also allowing for string interpolation and less verbose text formatting.

Installation

Windows manual install

  1. download netcalc.exe
  2. create a netcalc directory in the root directory of your C drive and place netcalc.exe inside of it
  3. copy the path to ther parent folder of the executable and paste it into your local PATH environment variable to install it for your account only. To install globally, add the directory to the global PATH variable.
  4. Verify installation:
netcalc -h
or
netcalc --help

.tar.gz tarball (manual installation)

  1. Download netcalc-[version]-Linux.tar.gz
  2. extract the package with
tar -xvzf netcalc-[version]-Linux.tar.gz
  1. navigate to the extracted package and find the binary
cd netcalc-[version]-Linux/bin
  1. Finally move the binary to usr/local/bin
sudo cp netcalc /usr/local/bin
  1. verify installation:
netcalc -h
or
netcalc --help

Building from Source

  1. Clone the repository
    git clone https://github.com/yourname/netcalc.git
  2. move into the directory for your desired version of netcalc
    cd netcalc
  3. make a build directory and move into it
    mkdir build && cd build
  4. Build the project
    cmake ..
    make

⚠️ Note: Installers for netcalc

Installers are still a work in progress and do not work yet (help wanted - see Issue #19). It is advised to not download the installers provided in release v0.2.0! In the meantime, binaries, .deb packages and tarballs are available.

Example usage:

Example 1, Calculating all network characteristics

netcalc 192.168.10.50 --sn /24 -A
Calculating requested network characteristics for: 192.168.10.50
IP: 192.168.10.50/24
Address type: Private
Subnet Mask: 255.255.255.0
Network Address: 192.168.10.0
Network Range: 192.168.10.0 - 192.168.10.255
Addressable Host Range: 192.168.10.1 - 192.168.10.254
Number of Addressable Hosts: 254
Broadcast Address: 192.168.10.255

Example 2, Calculating the network range only

netcalc 10.0.0.0 --sn /8 -r
Calculating requested network characteristics for: 10.0.0.0
IP: 10.0.0.0/8
Network Range: 10.0.0.0 - 10.255.255.255

Example 3, Identifying network type

netcalc 172.16.5.100 --sn /20 -i
IP: 172.16.5.100/20
Address type: Private

Contributing

If you're considering contributing to netcalc, please see CONTRIBUTING.md for instructions and standards for contributing to this project. Thank you for contributing!

About

A simple CLI utility to calculate network characteristics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published