Skip to content

Commit

Permalink
update windows buffer size
Browse files Browse the repository at this point in the history
Signed-off-by: Ken Schneider <ken.schneider@datadoghq.com>
  • Loading branch information
ken-schneider committed Jul 16, 2024
1 parent f9e4712 commit 0e91f97
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions utils_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@
package probing

import (
"math"

"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
)

const (
minimumBufferLength = 2048
)

// Returns the length of an ICMP message, plus the IP packet header.
// Calculated as:
// len(response ICMP header) + len(request IP header)
// + len(request ICMP header) + len(request ICMP data)
func (p *Pinger) getMessageLength() int {
if p.ipv4 {
return p.Size + 8 + ipv4.HeaderLen
calculatedLength := 8 + ipv4.HeaderLen + 8 + p.Size
return int(math.Max(float64(calculatedLength), float64(minimumBufferLength)))
}
return p.Size + 8 + ipv6.HeaderLen
calculatedLength := 8 + ipv6.HeaderLen + 8 + p.Size
return int(math.Max(float64(calculatedLength), float64(minimumBufferLength)))
}

// Attempts to match the ID of an ICMP packet.
Expand Down

0 comments on commit 0e91f97

Please sign in to comment.