Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/icmp: Hogs CPU on Windows, doesn't capture packets #33117

noam09 opened this issue Jul 15, 2019 · 3 comments

x/net/icmp: Hogs CPU on Windows, doesn't capture packets #33117

noam09 opened this issue Jul 15, 2019 · 3 comments


Copy link

@noam09 noam09 commented Jul 15, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.7 windows/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\bob\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\bob\go
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\bob\AppData\Local\Temp\go-build347592694=/tmp/go-build -gno-record-gcc-switchesv

What did you do?

I would like to receive all incoming ICMP packets and their payload/message, and once I am able to do that I would like to filter said packets so only specific IP sources and/or payloads/messages are captured and logged.
I would like this to work on both Linux and Windows, but at the moment I am experiencing issues specifically on Windows (works as expected on Linux). Tested on a Window 7 64-bit virtual machine on VirtualBox (running on Arch Linux).

I'm using the code found in the accepted answer for this StackOverflow question, with slight alterations:

My code (running as Admin):

I've replaced the IP address in ListenPacket() to the local address of the virtual machine on which I would like to log incoming ICMP packets ( in Playground link, also tried

I've also added if sourceIP == nil { continue } so that only ICMP packets containing a source IP are displayed. Without this condition, I was seeing infinite logs displaying an empty message and nil source address.

When I ping the virtual machine on which this code is running, the program does not display any messages. Also, the program uses up a lot of CPU (%90-%99) and the machine almost freezes up.

What did you expect to see?

Logs of ICMP packets with source IP and message. Minimal CPU usage.

What did you see instead?

With if sourceIP == nil { continue }: No logs, program hogs CPU ~%98.
Without if sourceIP == nil { continue }: Infinite logs, program uses %10-%20 CPU.

@gopherbot gopherbot added this to the Unreleased milestone Jul 15, 2019
Copy link

@dmitshur dmitshur commented Jul 15, 2019


Copy link

@VladRico VladRico commented Jul 19, 2019

Hello !
Same issue here with quite the same piece of code.

Running on Windows 10, icmp.ListenPacket(...) doesn't log icmp packet from original ping command (from Windows or Linux) but log icmp packet from

It seems to only log manually crafted icmp packet, not original ones ?

I've attached pcap files with different ping command :

  • git_windowstolinux.pcap : original ping command from host (Windows 10 to linux) --> Not logged
  • git_linuxtowidnows.pcap : original ping command from Linux to the host --> Not logged
  • git_modifiedwintolinux.pcap: custom ping from --> Logged by icmp.ListenPacket

NB: Don't take care about IP addresses, I've made a classic echo-request / echo-reply capture

No CPU issue on native Windows 10
No issue on Linux (Debian 9 Stretch), work as expected


Copy link

@noam09 noam09 commented Jul 21, 2019

@Valcada thanks for the detailed info. Glad to know it's not just me.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants