shadowsocks-go icon indicating copy to clipboard operation
shadowsocks-go copied to clipboard

traffic for port reported too low

Open rchen9012 opened this issue 7 years ago • 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?

rchen9012 avatar Apr 02 '19 11:04 rchen9012

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 }

rchen9012 avatar Apr 03 '19 10:04 rchen9012

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 ?

mokitoo avatar Jun 25 '19 16:06 mokitoo