Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

traverse_hierarchy

Traverse the network hierarchy


Description

These functions step up and down the network hierarchy. supernet() returns the supernetwork containing the given network. subnets() returns the list of subnetworks which join to make the given network.

Usage

supernet(x, new_prefix = prefix_length(x) - 1L)

subnets(x, new_prefix = prefix_length(x) + 1L)

Arguments

x
new_prefix

An integer vector indicating the desired prefix length. By default, this steps a single level through the hierarchy.

Details

The ipaddress package does not support long vectors (i.e. vectors with more than 2^31 - 1 elements). The limits the number of subnetworks that subnets() can return. However, you might find that machine memory imposes stricter limitations.

Value

An ip_network vector

See Also

Use seq.ip_network() to list the addresses within a network.

Use is_supernet() and is_subnet() to check if one network is contained within another.

Examples

supernet(ip_network("192.168.0.0/24"))

supernet(ip_network("192.168.0.0/24"), new_prefix = 10L)

subnets(ip_network("192.168.0.0/24"))

subnets(ip_network("192.168.0.0/24"), new_prefix = 27L)

ipaddress

Tidy IP Addresses

v0.5.1
MIT + file LICENSE
Authors
David Hall [aut, cre] (<https://orcid.org/0000-0002-2193-0480>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.