accounting

package
v0.0.0-...-2a45537 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultFlowCollectionHistorySize = 300
View Source
const DefaultFlowDbSize = 2
View Source
const DefaultL3FlowCollectionSize = 300
View Source
const DefaultL4FlowCollectionSize = 600
View Source
const DefaultRotateInterval = 5
View Source
const DefaultStatChannelSize = 16

Variables

View Source
var FlowPool = sync.Pool{
	New: func() interface{} { return new(Flow) },
}

Functions

This section is empty.

Types

type Accounting

type Accounting struct {
	FlowAccd  map[string]*FlowCollectionHistory
	Retention int64
	Ch        chan *FlowCollection
}
var GlobalAcct *Accounting

func NewAccounting

func NewAccounting() (acct *Accounting)

func (*Accounting) AddInterface

func (a *Accounting) AddInterface(ifaceName string)

func (*Accounting) SetRetention

func (a *Accounting) SetRetention(t int64)

func (*Accounting) Start

func (a *Accounting) Start(ctx context.Context)

type Flow

type Flow struct {
	FlowFingerprint
	InboundBytes     int64
	InboundPackets   int64
	InboundDuration  int64
	OutboundBytes    int64
	OutboundPackets  int64
	OutboundDuration int64
}

type FlowCollection

type FlowCollection struct {
	InterfaceName string
	FlowTimestamp
	L3FlowMap map[FlowFingerprint]*Flow
	L4FlowMap map[FlowFingerprint]*Flow
	Mu        *sync.Mutex
}

func NewFlowCollection

func NewFlowCollection(ifaceName string) (flowCol *FlowCollection)

func (*FlowCollection) Copy

func (c *FlowCollection) Copy() (flowCol *FlowCollection)

func (*FlowCollection) Reset

func (c *FlowCollection) Reset()

func (*FlowCollection) SetTimestamp

func (c *FlowCollection) SetTimestamp(start int64, end int64)

func (*FlowCollection) UpdateByFlowCol

func (c *FlowCollection) UpdateByFlowCol(fc *FlowCollection)

func (*FlowCollection) UpdateL3Inbound

func (c *FlowCollection) UpdateL3Inbound(flowFp FlowFingerprint, numBytes int64, numPkts int64)

func (*FlowCollection) UpdateL3Outbound

func (c *FlowCollection) UpdateL3Outbound(flowFp FlowFingerprint, numBytes int64, numPkts int64)

func (*FlowCollection) UpdateL4Inbound

func (c *FlowCollection) UpdateL4Inbound(flowFp FlowFingerprint, numBytes int64, numPkts int64)

func (*FlowCollection) UpdateL4Outbound

func (c *FlowCollection) UpdateL4Outbound(flowFp FlowFingerprint, numBytes int64, numPkts int64)

type FlowCollectionHistory

type FlowCollectionHistory struct {
	InterfaceName  string
	HistCollection map[FlowTimestamp]*FlowCollection
	LastTimestamp  FlowTimestamp
	Mu             *sync.Mutex
}

func NewFlowCollectionHistory

func NewFlowCollectionHistory(ifaceName string) (flowColHist *FlowCollectionHistory)

func (*FlowCollectionHistory) AggregationByDuration

func (h *FlowCollectionHistory) AggregationByDuration(duration int64) (fc *FlowCollection, timestamp *FlowTimestamp)

Assume duration = 5, flow timestamp list is aggregated as below: 10, 11, | 12, 13, 14, 15, 16, | 17, 18, 19, 20, 21, | 22, 23, 24, 25, 26(LastTimestamp.End)

func (*FlowCollectionHistory) Retention

func (h *FlowCollectionHistory) Retention(before int64)

func (*FlowCollectionHistory) SetLastTimestamp

func (h *FlowCollectionHistory) SetLastTimestamp(ts FlowTimestamp)

type FlowFingerprint

type FlowFingerprint struct {
	SrcAddr  string
	DstAddr  string
	SrcPort  uint16
	DstPort  uint16
	Protocol string
}

type FlowTimestamp

type FlowTimestamp struct {
	Start int64
	End   int64
}

func (*FlowTimestamp) Offset

func (t *FlowTimestamp) Offset(offset int64) (ts FlowTimestamp)

Jump to

Keyboard shortcuts

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