netstack

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 77 Imported by: 0

README

Netstack

Netstack is a userspace TCP/IP network stack and interfaces with zircon network drivers. Netstack serves as a back-end for fdio socket API.

     +-----------+           +-----------+
     | FIDL app  |           | POSIX app |
     +--+--------+           +-----+-----+
        |                          |
        |                          |
        |                          |
        |                          |
        |                          |
        |                          |
        |   +----------------------v---------+
        |   |         BSD socket API         |
        |   |  (//sdk/lib/fdio)              |
        |   +---------+----------------------+
        |             |
     +--v-------------v----------------------+
     |            netstack                   |
     | (//src/connectivity/network/netstack) |
     +----------------+----------------------+
                      |
     +----------------v-----------------+
     |         Ethernet driver          |
     | (//zircon/system/udev/ethernet)  |
     +----------------------------------+

Benchmarking

To run the benchmarks and obtain profiling data:

REALM=bench
PROFILE_PATH=/data/r/sys/r/$REALM/fuchsia.com:netstack-bench-gotests:0#meta:bench_test.cmx/profile
fx build netstack-bench-gotests \
  && fx test -o -R=$REALM bench_test \
  && fx scp "[$(fx get-device-addr)]:$PROFILE_PATH" out/profile \
  && go tool pprof -http=:8080 out/profile

Example output (astro):

goos: fuchsia
goarch: arm64
pkg: netstack/bench
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=2048-4                  190443              6513 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=1024-4                  247176              4831 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=512-4                   326691              3842 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=256-4                   364168              3426 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=128-4                   394536              3282 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=64-4                    405102              3218 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=32-4                    423908              2967 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=16-4                    424617              2931 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=8-4                     386036              2935 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=4-4                     404241              2990 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=2-4                     371358              2887 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadDisabled/len(payload)=1-4                     431478              2889 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=2048-4                   461614              2766 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=1024-4                   417296              2924 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=512-4                    474790              2814 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=256-4                    453231              2832 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=128-4                    472670              2835 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=64-4                     469988              2894 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=32-4                     490627              2614 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=16-4                     485992              2753 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=8-4                      492573              2798 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=4-4                      487836              2923 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=2-4                      434959              2658 ns/op             112 B/op          3 allocs/op
BenchmarkWritePacket/checksumOffloadEnabled/len(payload)=1-4                      490470              3010 ns/op             112 B/op          3 allocs/op

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main()

Types

type NICRemovedHandler

type NICRemovedHandler interface {
	// RemovedNIC informs the receiver that the specified NIC has been removed.
	RemovedNIC(tcpip.NICID)
}

NICRemovedHandler is an interface implemented by types that are interested in NICs that have been removed.

type Netstack

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

A Netstack tracks all of the running state of the network stack.

func (*Netstack) AddRoute

func (ns *Netstack) AddRoute(r tcpip.Route, metric routes.Metric, dynamic bool) error

AddRoute adds a single route to the route table in a sorted fashion.

func (*Netstack) AddRoutes

func (ns *Netstack) AddRoutes(rs []tcpip.Route, metric routes.Metric, dynamic bool) error

AddRoutes adds one or more routes to the route table in a sorted fashion.

The routes will be added with the default (medium) medium preference value.

func (*Netstack) Bridge

func (ns *Netstack) Bridge(nics []tcpip.NICID) (*ifState, error)

func (*Netstack) DelRoute

func (ns *Netstack) DelRoute(r tcpip.Route) error

DelRoute deletes a single route from the route table.

func (*Netstack) GetExtendedRouteTable

func (ns *Netstack) GetExtendedRouteTable() []routes.ExtendedRoute

GetExtendedRouteTable returns a copy of the current extended route table.

func (*Netstack) UpdateRoutesByInterface

func (ns *Netstack) UpdateRoutesByInterface(nicid tcpip.NICID, action routes.Action)

UpdateRoutesByInterface applies update actions to the routes for a given interface.

type TcpIpError

type TcpIpError struct {
	Err tcpip.Error
}

TcpIpError wraps a tcpip.Error.

TcpIpError provides an error implementation over tcpip.Error so that error wrapping and unwrapping can be used. It also provides utility methods to convert it to Netstack FIDL API returns.

func WrapTcpIpError

func WrapTcpIpError(e tcpip.Error) *TcpIpError

WrapTcpIpError wraps a stack error into a type that implements the error interface.

func (*TcpIpError) Error

func (e *TcpIpError) Error() string

func (TcpIpError) ToStackError

func (e TcpIpError) ToStackError() stack.Error

ToStackError transforms the internal tcpip.Error into a FIDL fuchsia.net.stack/Error. Panics if the internal error is nil.

func (TcpIpError) ToZxStatus

func (e TcpIpError) ToZxStatus() zx.Status

ToZxStatus transforms the internal tcpip.Error into a zx.Status.

Directories

Path Synopsis
Package dhcp implements a DHCP client and server as described in RFC 2131.
Package dhcp implements a DHCP client and server as described in RFC 2131.
fidlext
Package filter provides the implementation of packet filter.
Package filter provides the implementation of packet filter.
bridge
link/bridge implements a bridging LinkEndpoint It can be writable.
link/bridge implements a bridging LinkEndpoint It can be writable.
eth
Package time defines newtypes around zx.Time and zx.Duration that provide a subset of the std time.Time and time.Duration API.
Package time defines newtypes around zx.Time and zx.Duration that provide a subset of the std time.Time and time.Duration API.
tracing

Jump to

Keyboard shortcuts

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