From 0e91f978af2b3cedc47c0d9c01e1ec94e05de8db Mon Sep 17 00:00:00 2001 From: Ken Schneider Date: Mon, 1 Jul 2024 20:27:36 -0400 Subject: [PATCH] update windows buffer size Signed-off-by: Ken Schneider --- utils_windows.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils_windows.go b/utils_windows.go index 0eac36e..2934e52 100644 --- a/utils_windows.go +++ b/utils_windows.go @@ -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.