virtual

package
v0.0.0-...-56ea410 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: ISC Imports: 8 Imported by: 0

Documentation

Overview

Package virtual contains an implementation of an IPX network that forwards packets between nodes, similar to a network switch.

Index

Constants

This section is empty.

Variables

View Source
var (

	// UnknownNodeError is returned by Network.Write() if the destination
	// MAC address is not associated with any known node.
	UnknownNodeError = errors.New("unknown destination address")
)

Functions

This section is empty.

Types

type Network

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

func New

func New() *Network

New creates a new Network.

func (*Network) NewNode

func (n *Network) NewNode() network.Node

NewNode creates a new node on the network.

func (*Network) Tap

func (n *Network) Tap() *Tap

Tap creates a new network tap for listening to network traffic. The caller must call Read() on the tap regularly otherwise it may stall the operation of the network.

type Tap

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

func (*Tap) Close

func (t *Tap) Close() error

Close removes the tap from the network; no more packets will be delivered to it and all future calls to Read() will return EOF.

func (*Tap) Read

func (t *Tap) Read(data []byte) (int, error)

Read reads a packet from the network tap.

func (*Tap) Write

func (t *Tap) Write(packet []byte) (int, error)

Write writes a packet into the network.

Jump to

Keyboard shortcuts

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