tunstats

package
v1.32.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package tunstats maintains statistics about connections flowing through a TUN device (which operate at the IP layer).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counts

type Counts struct {
	TxPackets uint64 `json:"txPkts,omitempty"`
	TxBytes   uint64 `json:"txBytes,omitempty"`
	RxPackets uint64 `json:"rxPkts,omitempty"`
	RxBytes   uint64 `json:"rxBytes,omitempty"`
}

Counts are statistics about a particular connection.

func (Counts) Add

func (c1 Counts) Add(c2 Counts) Counts

Add adds the counts from both c1 and c2.

type Statistics

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

Statistics maintains counters for every connection. All methods are safe for concurrent use. The zero value is ready for use.

func (*Statistics) Extract

func (s *Statistics) Extract() map[flowtrack.Tuple]Counts

Extract extracts and resets the counters for all active connections. It must be called periodically otherwise the memory used is unbounded.

func (*Statistics) UpdateRx

func (s *Statistics) UpdateRx(b []byte)

UpdateRx updates the counters for a received IP packet. The source and destination of the packet are inverted with respect to the source and destination in flowtrack.Tuple.

func (*Statistics) UpdateTx

func (s *Statistics) UpdateTx(b []byte)

UpdateTx updates the counters for a transmitted IP packet The source and destination of the packet directly correspond with the source and destination in flowtrack.Tuple.

Jump to

Keyboard shortcuts

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