stats

package
v0.0.0-...-81c5855 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package tsyncmap : a timeout based syncmap

Index

Constants

This section is empty.

Variables

View Source
var EnrichmentCacheDB *tsyncmap.Map

Functions

func GetColorByLatency

func GetColorByLatency(latency float64) tablewriter.Colors

func GetColorByLoss

func GetColorByLoss(loss float64) tablewriter.Colors

func MetricProcessing

func MetricProcessing(tx chan *Metric, rx chan *Metric, report chan *Report, stop chan interface{}, timeout time.Duration)

func NewSessionDB

func NewSessionDB(probeName string, probeList []string, maxPath int, maxTTL int, DelayWinSize int, LossWinSize int) *sync.Map

func PrintDB

func PrintDB(SessionDB *sync.Map, probeName string, probList []string, maxPath int)

func ProcessRecord

func ProcessRecord(ch chan *Report, g *geoip.GeoIPDB, SessionDB *sync.Map, DelayWinSize int)

Types

type LossBitMap

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

func NewLossBitMap

func NewLossBitMap(size uint64) *LossBitMap

func (*LossBitMap) BitCount

func (b *LossBitMap) BitCount() uint64

func (*LossBitMap) Set

func (b *LossBitMap) Set(pos uint64) bool

func (*LossBitMap) Unset

func (b *LossBitMap) Unset(pos uint64) bool

func (*LossBitMap) UpdateLoss

func (b *LossBitMap) UpdateLoss()

func (*LossBitMap) UpdatePass

func (b *LossBitMap) UpdatePass()

func (*LossBitMap) UpdateWeightedLoss

func (b *LossBitMap) UpdateWeightedLoss()

func (*LossBitMap) UpdateWeightedPass

func (b *LossBitMap) UpdateWeightedPass()

type Metric

type Metric struct {
	Path      int
	Host      string
	Dest      string
	SrcAddr   string
	DstAddr   string
	SrcPort   uint16
	DstPort   uint16
	TTL       uint8
	ID        uint16
	RespAddr  string
	TimeStamp time.Time
	Delay     time.Duration
}

func (*Metric) FullKey

func (m *Metric) FullKey() string

func (*Metric) Key

func (m *Metric) Key() string

type ProbeInfo

type ProbeInfo struct {
	SrcAddr net.IP
	DstAddr net.IP
	SrcPort uint16
	DstPort uint16
	TTL     uint8
	ID      uint16
}

type Report

type Report struct {
	Path     int
	Host     string
	Dest     string
	DestAddr string
	RespAddr string
	FlowKey  string
	Round    uint16
	TTL      uint8
	Delay    int32
	Loss     uint8
}

func (*Report) Key

func (r *Report) Key() string

func (*Report) String

func (r *Report) String() string

type RollingStatus

type RollingStatus struct {
	Mean   float64
	VarSum float64
	// contains filtered or unexported fields
}

func NewRollingStatus

func NewRollingStatus(delayWinSize int, lossWinSize int) *RollingStatus

func (*RollingStatus) Get

func (r *RollingStatus) Get() (float64, float64, float64)

func (*RollingStatus) GetWeighted

func (r *RollingStatus) GetWeighted(N uint64) (float64, float64, float64)

func (*RollingStatus) Update

func (r *RollingStatus) Update(xN float64)

func (*RollingStatus) UpdateLatency

func (r *RollingStatus) UpdateLatency(xN float64)

func (*RollingStatus) UpdateLoss

func (r *RollingStatus) UpdateLoss()

func (*RollingStatus) UpdateWeighted

func (r *RollingStatus) UpdateWeighted(xN float64)

func (*RollingStatus) UpdateWeightedLoss

func (r *RollingStatus) UpdateWeightedLoss()

type ServerInfo

type ServerInfo struct {
	Address string
	Name    string
	City    string
	Region  string
	Country string
	ASN     uint32
	SPName  string
	Lat     float64
	Long    float64
}

func Enrichment

func Enrichment(dst string, g *geoip.GeoIPDB) *ServerInfo

type Session

type Session struct {
	DestAddr   string
	RespAddr   map[int]string
	ServerInfo []*ServerInfo
	Stats      []*RollingStatus
	InitFlag   []uint8
	Lock       *sync.RWMutex
}

type SessionTable

type SessionTable struct {
	Name        string
	Data        sync.Map
	Timeout     int64
	CheckFreq   int64
	ExpireTime  sync.Map
	Verbose     bool
	TimeOutChan chan *Metric
	// contains filtered or unexported fields
}

Map is the base structure for tsyncmap.

func NewSessionTable

func NewSessionTable(timeout time.Duration, checkfreq time.Duration, verbose bool) *SessionTable

NewMap is a construct function to create tsyncmap.

func (*SessionTable) Delete

func (tmap *SessionTable) Delete(key interface{})

func (*SessionTable) GetRemainTime

func (tmap *SessionTable) GetRemainTime(key interface{}) (time.Duration, error)

func (*SessionTable) Load

func (tmap *SessionTable) Load(key interface{}) (value interface{}, ok bool)

Load returns the value from tsyncmap

func (*SessionTable) LoadRestApi

func (tmap *SessionTable) LoadRestApi(w http.ResponseWriter, r *http.Request)

func (*SessionTable) Run

func (tmap *SessionTable) Run()

Run is a coroutine to help tsyncmap manage the expire data.

func (*SessionTable) ShowData

func (tmap *SessionTable) ShowData()

func (*SessionTable) ShowExpireTime

func (tmap *SessionTable) ShowExpireTime()

func (*SessionTable) Stop

func (tmap *SessionTable) Stop()

func (*SessionTable) Store

func (tmap *SessionTable) Store(key interface{}, value interface{}, currentTime time.Time)

Store is used save the key,value pairs in tsyncmap

func (*SessionTable) UpdateTime

func (tmap *SessionTable) UpdateTime(key interface{}, currentTime time.Time)

UpdateTime is used update specific key's expiretime.

Jump to

Keyboard shortcuts

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