系统架构层面流量控制功能完善

This commit is contained in:
flswld
2023-02-05 07:18:43 +08:00
parent cfb001c18a
commit 94c8db402a
51 changed files with 1049 additions and 2408 deletions

View File

@@ -7,14 +7,14 @@ import (
// Snmp defines network statistics indicator
type Snmp struct {
BytesSent uint64 // bytes sent from upper level
BytesReceived uint64 // bytes received to upper level
MaxConn uint64 // max number of connections ever reached
ActiveOpens uint64 // accumulated active open connections
PassiveOpens uint64 // accumulated passive open connections
CurrEstab uint64 // current number of established connections
InErrs uint64 // UDP read errors reported from net.PacketConn
InCsumErrors uint64 // checksum errors from CRC32
BytesSent uint64 // bytes sent from upper level
BytesReceived uint64 // bytes received to upper level
MaxConn uint64 // max number of connections ever reached
ActiveOpens uint64 // accumulated active open connections
PassiveOpens uint64 // accumulated passive open connections
CurrEstab uint64 // current number of established connections
// InErrs uint64 // UDP read errors reported from net.PacketConn
// InCsumErrors uint64 // checksum errors from CRC32
KCPInErrors uint64 // packet iput errors reported from KCP
InPkts uint64 // incoming packets count
OutPkts uint64 // outgoing packets count
@@ -27,10 +27,10 @@ type Snmp struct {
EarlyRetransSegs uint64 // accmulated early retransmitted segments
LostSegs uint64 // number of segs inferred as lost
RepeatSegs uint64 // number of segs duplicated
FECRecovered uint64 // correct packets recovered from FEC
FECErrs uint64 // incorrect packets recovered from FEC
FECParityShards uint64 // FEC segments received
FECShortShards uint64 // number of data shards that's not enough for recovery
// FECRecovered uint64 // correct packets recovered from FEC
// FECErrs uint64 // incorrect packets recovered from FEC
// FECParityShards uint64 // FEC segments received
// FECShortShards uint64 // number of data shards that's not enough for recovery
}
func newSnmp() *Snmp {
@@ -46,8 +46,8 @@ func (s *Snmp) Header() []string {
"ActiveOpens",
"PassiveOpens",
"CurrEstab",
"InErrs",
"InCsumErrors",
// "InErrs",
// "InCsumErrors",
"KCPInErrors",
"InPkts",
"OutPkts",
@@ -60,10 +60,10 @@ func (s *Snmp) Header() []string {
"EarlyRetransSegs",
"LostSegs",
"RepeatSegs",
"FECParityShards",
"FECErrs",
"FECRecovered",
"FECShortShards",
// "FECParityShards",
// "FECErrs",
// "FECRecovered",
// "FECShortShards",
}
}
@@ -77,8 +77,8 @@ func (s *Snmp) ToSlice() []string {
fmt.Sprint(snmp.ActiveOpens),
fmt.Sprint(snmp.PassiveOpens),
fmt.Sprint(snmp.CurrEstab),
fmt.Sprint(snmp.InErrs),
fmt.Sprint(snmp.InCsumErrors),
// fmt.Sprint(snmp.InErrs),
// fmt.Sprint(snmp.InCsumErrors),
fmt.Sprint(snmp.KCPInErrors),
fmt.Sprint(snmp.InPkts),
fmt.Sprint(snmp.OutPkts),
@@ -91,10 +91,10 @@ func (s *Snmp) ToSlice() []string {
fmt.Sprint(snmp.EarlyRetransSegs),
fmt.Sprint(snmp.LostSegs),
fmt.Sprint(snmp.RepeatSegs),
fmt.Sprint(snmp.FECParityShards),
fmt.Sprint(snmp.FECErrs),
fmt.Sprint(snmp.FECRecovered),
fmt.Sprint(snmp.FECShortShards),
// fmt.Sprint(snmp.FECParityShards),
// fmt.Sprint(snmp.FECErrs),
// fmt.Sprint(snmp.FECRecovered),
// fmt.Sprint(snmp.FECShortShards),
}
}
@@ -107,8 +107,8 @@ func (s *Snmp) Copy() *Snmp {
d.ActiveOpens = atomic.LoadUint64(&s.ActiveOpens)
d.PassiveOpens = atomic.LoadUint64(&s.PassiveOpens)
d.CurrEstab = atomic.LoadUint64(&s.CurrEstab)
d.InErrs = atomic.LoadUint64(&s.InErrs)
d.InCsumErrors = atomic.LoadUint64(&s.InCsumErrors)
// d.InErrs = atomic.LoadUint64(&s.InErrs)
// d.InCsumErrors = atomic.LoadUint64(&s.InCsumErrors)
d.KCPInErrors = atomic.LoadUint64(&s.KCPInErrors)
d.InPkts = atomic.LoadUint64(&s.InPkts)
d.OutPkts = atomic.LoadUint64(&s.OutPkts)
@@ -121,10 +121,10 @@ func (s *Snmp) Copy() *Snmp {
d.EarlyRetransSegs = atomic.LoadUint64(&s.EarlyRetransSegs)
d.LostSegs = atomic.LoadUint64(&s.LostSegs)
d.RepeatSegs = atomic.LoadUint64(&s.RepeatSegs)
d.FECParityShards = atomic.LoadUint64(&s.FECParityShards)
d.FECErrs = atomic.LoadUint64(&s.FECErrs)
d.FECRecovered = atomic.LoadUint64(&s.FECRecovered)
d.FECShortShards = atomic.LoadUint64(&s.FECShortShards)
// d.FECParityShards = atomic.LoadUint64(&s.FECParityShards)
// d.FECErrs = atomic.LoadUint64(&s.FECErrs)
// d.FECRecovered = atomic.LoadUint64(&s.FECRecovered)
// d.FECShortShards = atomic.LoadUint64(&s.FECShortShards)
return d
}
@@ -136,8 +136,8 @@ func (s *Snmp) Reset() {
atomic.StoreUint64(&s.ActiveOpens, 0)
atomic.StoreUint64(&s.PassiveOpens, 0)
atomic.StoreUint64(&s.CurrEstab, 0)
atomic.StoreUint64(&s.InErrs, 0)
atomic.StoreUint64(&s.InCsumErrors, 0)
// atomic.StoreUint64(&s.InErrs, 0)
// atomic.StoreUint64(&s.InCsumErrors, 0)
atomic.StoreUint64(&s.KCPInErrors, 0)
atomic.StoreUint64(&s.InPkts, 0)
atomic.StoreUint64(&s.OutPkts, 0)
@@ -150,10 +150,10 @@ func (s *Snmp) Reset() {
atomic.StoreUint64(&s.EarlyRetransSegs, 0)
atomic.StoreUint64(&s.LostSegs, 0)
atomic.StoreUint64(&s.RepeatSegs, 0)
atomic.StoreUint64(&s.FECParityShards, 0)
atomic.StoreUint64(&s.FECErrs, 0)
atomic.StoreUint64(&s.FECRecovered, 0)
atomic.StoreUint64(&s.FECShortShards, 0)
// atomic.StoreUint64(&s.FECParityShards, 0)
// atomic.StoreUint64(&s.FECErrs, 0)
// atomic.StoreUint64(&s.FECRecovered, 0)
// atomic.StoreUint64(&s.FECShortShards, 0)
}
// DefaultSnmp is the global KCP connection statistics collector