请教使用 golang 在 windows 上发送 icmp 报文的问题

2019-01-04 17:18:30 +08:00
 goofool
如下代码,在 windows 上收不上来 time exceeded 的包,但是 wireshark 上可以抓到。
同样的代码在 linux 上就是好使的。
有没有小伙伴知道是啥原因啊?

https://gist.github.com/goofool/6d69297e1b9e2dadbf8a7df94e14a70d
2271 次点击
所在节点    Go 编程语言
1 条回复
katsusan
2019-01-05 15:37:29 +08:00
https://godoc.org/golang.org/x/net/icmp#ListenPacket

ListenPacket listens for incoming ICMP packets addressed to address. See net.Dial for the syntax of address.

For non-privileged datagram-oriented ICMP endpoints, network must be "udp4" or "udp6". The endpoint allows to read, write a few limited ICMP messages such as echo request and echo reply. Currently only Darwin and Linux support this.

看下面的 example 里 windows 好像是不支持的.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/523940

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX