Module netsim::spawn [] [src]

The spawn family of functions allows spawning network-isolated threads and virtual networkds which you can read+write raw ethernet or IP data to.

new_namespace is the most primitive of these functions. It can be used to spawn a thread into a container with no network interfaces. with_iface takes network interface parameters as an argument and will automatically set up an ethernet/IP interface in the container for you. Other functions are convenience functions will automatically configure interfaces with common settings.

network_v4 can be used to launch a heirarchal network of nodes using the functions in the node module.

Functions

behind_nat_v4

Spawn a thread with a single interface, operating a behind a NAT.

network_v4

Construct a hierarchical network of nodes. The returned plug can be used to write packets to the network and read packets that try to leave the network.

new_namespace

Run the function func in its own network namespace. This namespace will not have any network interfaces. You can create virtual interfaces using Tap, or use one of the other functions in the spawn module which do this for you.

on_internet_v4

Spawn a thread with a single network interface with a global IP address.

on_subnet_v4

Spawn a function into a new network namespace with a single network interface with an address in subnet. Returns a JoinHandle which can be used to join the spawned thread, along with an Ipv4Plug which can be used to read/write network activity from the spawned thread.

with_ether_iface

Spawn a function into a new network namespace with a network interface described by iface. Returns a JoinHandle which can be used to join the spawned thread, along with a channel which can be used to read/write ethernet frames to the spawned thread's interface.

with_ipv4_iface

Spawn a function into a new network namespace with a network interface described by iface. Returns a JoinHandle which can be used to join the spawned thread, along with a channel which can be used to read/write IPv4 packets to the spawned thread's interface.