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.
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.