ipgen

package
v3.8.31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type V4Gen

type V4Gen struct {
	// contains filtered or unexported fields
}

A V4Gen is a generator for IPv4 addresses

func NewV4Generator

func NewV4Generator(subnets []*net.IPNet) (*V4Gen, error)

NewV4Generator will return an IPv4 address generator which uses the specified subnets to generate traffic. A subnet may be included in the argument slice multiple times in order to generate proportionally more addresses from that network. Specifying a subnet 0.0.0.0/0 will generate addresses from the entire IPv4 space

func RandomWeightedV4Generator

func RandomWeightedV4Generator(count int) (*V4Gen, error)

RandomWeightedV4Generator builds a generator with weighted subnets intended to approximate real-world traffic. Given a count argument, the function will instantiate random subnets of the following weights: * 30% of traffic from a subnet of size /16 to /26 * 10% of traffic from between 2 and 5 subnets of size /16 to /24 * All remaining traffic from random subnets between /8 and /16 Specifying a higher count will result in a greater number in the final category.

func (*V4Gen) IP

func (g *V4Gen) IP() net.IP

IP generates an IPv4 address based on the parameters of the generator

type V6Gen

type V6Gen struct {
	// contains filtered or unexported fields
}

A V6Gen is a generator for IPv6 addresses

func NewV6Generator

func NewV6Generator(subnets []*net.IPNet) (*V6Gen, error)

NewV6Generator will return an IPv6 address generator which uses the specified subnets to generate traffic. A subnet may be included in the argument slice multiple times in order to generate proportionally more addresses from that network. Specifying a subnet ::0/0 will generate addresses from the entire IPv6 space

func RandomWeightedV6Generator

func RandomWeightedV6Generator(count int) (*V6Gen, error)

RandomWeightedV6Generator builds a generator with weighted subnets intended to approximate real-world traffic. Given a count argument, the function will instantiate random subnets of the following weights: * 30% of traffic from a subnet of size /112 to /124 * 10% of traffic from between 2 and 5 subnets of size /104 to /124 * All remaining traffic from random subnets between /64 and /124 Specifying a higher count will result in a greater number in the final category.

func (*V6Gen) IP

func (g *V6Gen) IP() net.IP

IP generates an IPv6 address based on the parameters of the generator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL