traffic for port reported too low
rchen9012 opened this issue · 2 comments
Hi, I was playing youtube video to check port traffic output, but I found the traffic is too low for video streaming compare to that iptraf has reported. I checked source code the buffer is in []byte and which means addTraffic is also in byte. Is this correct? does it have anything to do with addTraffic int and trafficStats int64?
I've found overflow int64 when process is run for a long time. just couple lines to reset the trafficstats counter to 0 when close to overflow.
func (pm *PasswdManager) addTraffic(port string, n int) {
pm.Lock()
if pm.trafficStats[port] > math.MaxInt64 - 9999999 {
pm.trafficStats[port] = 0
}
pm.trafficStats[port] = pm.trafficStats[port] + int64(n)
pm.Unlock()
return
}
I've found overflow int64 when process is run for a long time. just couple lines to reset the trafficstats counter to 0 when close to overflow.
func (pm *PasswdManager) addTraffic(port string, n int) {
pm.Lock()
if pm.trafficStats[port] > math.MaxInt64 - 9999999 {
pm.trafficStats[port] = 0
}
pm.trafficStats[port] = pm.trafficStats[port] + int64(n)
pm.Unlock()
return
}
int64 represent that number from -9,223,372,036,854,775,808 ~ +9,223,372,036,854,775,807 ,
it's already exceed 1 EB for a port
so how can int64 get overflow when process is running for a long time ?