Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

traffic for port reported too low #471

Open
rchen9012 opened this issue Apr 2, 2019 · 2 comments
Open

traffic for port reported too low #471

rchen9012 opened this issue Apr 2, 2019 · 2 comments

Comments

@rchen9012
Copy link

rchen9012 commented Apr 2, 2019

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 rchen9012 changed the title traffic for port reported too little traffic for port reported too low Apr 2, 2019
@rchen9012
Copy link
Author

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
}

@mokitoo
Copy link

mokitoo commented Jun 25, 2019

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 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants