Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brh55/min-host-bits

:low_brightness: Calculate minimum host bits needed for desired number of hosts
https://github.com/brh55/min-host-bits

ipv4 networking subnet

Last synced: 30 days ago
JSON representation

:low_brightness: Calculate minimum host bits needed for desired number of hosts

Awesome Lists containing this project

README

        

# min-host-bits [![Travis](https://img.shields.io/travis/brh55/min-host-bits.svg?style=flat-square)](https://travis-ci.org/brh55/min-host-bits) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square)](https://github.com/sindresorhus/xo)

> Calculate minimum host bits needed for desired number of hosts with account for network address and broadcast address
>
> **minHostBits(256)** // 9

## Install

`$ npm install --save min-host-bits` **OR** `$ yarn add min-host-bits`

## Usage
```javascript
var desiredHosts = 3000;
var minimumHostBits = minHostBits(desiredHosts);
console.log(minimumHostBits) // 12
```

## API
### minHostBits(n)
Returns the minimum number of host bits accounting for the network address and broadcast address

#### n
*n* number of desired hosts

## Related
[min-prefix-length](https://github.com/brh55/min-prefix-length) - :1234: Calculate the minimum prefix length for an IPv4 subnet based on a desired number of host

[ip-class](https://github.com/brh55/ip-class) - :capital_abcd: Return the classful network class (A, B, C, D, E) of an IPv4 address

## License
MIT