add adds bytes to the current sample for calculating bdp. It returns true only if a ping must be sent. This can be used by the caller (handleData) to make decision about batching a window update with it.
(n uint32)
| 83 | // by the caller (handleData) to make decision about batching |
| 84 | // a window update with it. |
| 85 | func (b *bdpEstimator) add(n uint32) bool { |
| 86 | b.mu.Lock() |
| 87 | defer b.mu.Unlock() |
| 88 | if b.bdp == bdpLimit { |
| 89 | return false |
| 90 | } |
| 91 | if !b.isSent { |
| 92 | b.isSent = true |
| 93 | b.sample = n |
| 94 | b.sentAt = time.Time{} |
| 95 | b.sampleCount++ |
| 96 | return true |
| 97 | } |
| 98 | b.sample += n |
| 99 | return false |
| 100 | } |
| 101 | |
| 102 | // calculate is called when an ack for a bdp ping is received. |
| 103 | // Here we calculate the current bdp and bandwidth sample and |
no test coverage detected