LOOPBACK(3)LOOPBACK(3)

NAME

loopback – network link simulation

SYNOPSIS

bind -a #λ /net

/net/loopbackn/[0-1] /net/loopbackn/[0-1]/data /net/loopbackn/[0-1]/ctl /net/loopbackn/[0-1]/status /net/loopbackn/[0-1]/stats

DESCRIPTION

The loopback interface, /net/loopbackn, is a directory containing two subdirectories, one for each end of a simulated network link. The number n is the device number of the link, permitting multiple links to be used on a single machine.

Each directory contains files to control the associated connection, receive and send data, monitor the simulation parameters, and supply statistics.

The data files for the two directories are cross-connected. Writes to one are divided into packets of at most a certain size, typically 32768 bytes, written to a flow-controlled output queue, transferred across the link, and put into an input queue where it is readable from the other data file.

Options are set by writing to the ctl file for the receiving end of the link, and are reported in the same format by reading status. The following options are supported.

delay latency bytedelay

Control the time a packet takes in the link. A packet n bytes long takes bytedelay * n nanoseconds to exit the output queue and is available for reading latency nanoseconds later.  

droprate n

Randomly drop approximately one out of n packets. If zero drop no packets.  

indrop [01]

Disallow or allow packets to be dropped if the input queue overflows.  

limit n

Set the input and output queues to hold at most n bytes.  

reset

Clear all of the statistics recorded for the link.  

Reading stats returns a list of 4 tagged numbers representing:

	packets sent to this receiver
	bytes sent to this receiver
	packets dropped due to droprate
	packets dropped due to input queue overflows

SOURCE

/sys/src/9/port/devloopback.c