Skip to content

Commit

Permalink
feat: count response size
Browse files Browse the repository at this point in the history
  • Loading branch information
b4nst committed Sep 3, 2024
1 parent 7bf815a commit ef11c05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/icmperf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
pinger.OnRecv(func(m *icmp.Message, t time.Time) error {
body := m.Body.(*icmp.Echo)
id := uint64(body.ID)<<32 | uint64(body.Seq)
record.PacketReceived(id, t)
record.PacketReceived(id, len(body.Data), t)
return nil
})

Expand Down
3 changes: 2 additions & 1 deletion pkg/recorder/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *Record) PacketSent(id uint64, size int, sent time.Time) {
}
}

func (s *Record) PacketReceived(id uint64, received time.Time) {
func (s *Record) PacketReceived(id uint64, size int, received time.Time) {
// Remove the packet from the inflight map
s.inlock.Lock()
tm, ok := s.inflight[id]
Expand All @@ -63,6 +63,7 @@ func (s *Record) PacketReceived(id uint64, received time.Time) {
} else {
// Record bandwidth ping
tm.Received = received
tm.Bytes += size
s.tms = append(s.tms, tm)
}
}
Expand Down

0 comments on commit ef11c05

Please sign in to comment.