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: support windows #9253

Closed
mikioh opened this issue Dec 11, 2014 · 20 comments
Closed

x/net/icmp: support windows #9253

mikioh opened this issue Dec 11, 2014 · 20 comments

Comments

@mikioh
Copy link
Contributor

mikioh commented Dec 11, 2014

No description provided.

@mikioh mikioh changed the title x/net/icmp: support plan9, windows x/net/icmp: support windows Dec 12, 2014
@mikioh
Copy link
Contributor Author

mikioh commented Dec 12, 2014

what we need to do here is, a) enabling listenpacket and confirming it works well on windows using ping_test.go, b) verifying parseipv4header works correctly on windows by comparing wire data.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

ping_test.go is work on windows.
https://go-review.googlesource.com/#/c/1354/

@mikioh
Copy link
Contributor Author

mikioh commented Dec 19, 2014

Thanks. Can you also confirm that the behavior of Windows ICMP? Does icmp.ParseIPv4Header on Windows parse an IPv4 header in some ICMP error message such as destination unreachable correctly?

@mattn
Copy link
Member

mattn commented Dec 19, 2014

TestMarshalAndParseMessageForIPv4 is working too on windows. Do you want additional tests?

@mikioh
Copy link
Contributor Author

mikioh commented Dec 19, 2014

No, we need to add some to TestMarshalAndParseMessageForIPv4 if needed. It depends on Windows' implementation but icmp.ParseIPv4Header must handle correctly even if Windows stack tweaks a few fields of original IPv4 header in ICMP error message, such as Darwin and FreeBSD.

You can use ping_test.go with a small modification, just using ipv4.PacketConn.SetTTL, to send a TTL=1 ICMP packet and to receive an ICMP time exceeded error message on Window.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

I modified like below.
https://gist.github.com/mattn/7ff153fe8491a2900e83#file-ping_test-go-L24-L28

And test passed. Is this right?

@mikioh
Copy link
Contributor Author

mikioh commented Dec 19, 2014

Please try http://play.golang.org/p/fXWPqxlMf6 with administrator privilege.

If everything goes well it displays original IPv4 header in ICMP error message as follows:
issue9253_test.go:69: ver: 4, hdrlen: 20, tos: 0x0, totallen: 43, id: 0x3a51, flags: 0x0, fragoff: 0x0, ttl: 1, proto: 1, cksum: 0x98c2, src: 192.168.0.3, dst: 173.194.120.81

then, please compare captured wire data using wireshark or other, and fix ParseIPv4Header and wire data for TestParseIPv4Header if needed. Thanks.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

I'm waiting 10 minutes after start go test -run TestPingIPv4 but there is never response in console.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

Ooops, sorry. After I disabled Windows Firewall, tests passed.

c:\dev\go\src\golang.org\x\net\icmp>go test -run TestPingIPv4
PASS
ok      golang.org/x/net/icmp   0.254s

c:\dev\go\src\golang.org\x\net\icmp>

@mikioh
Copy link
Contributor Author

mikioh commented Dec 19, 2014

Try "go test -v -run TestPingIPv4"

@mattn
Copy link
Member

mattn commented Dec 19, 2014

@mikioh
Copy link
Contributor Author

mikioh commented Dec 19, 2014

Is it same with the captured wire data using wireshark or other? If so, no need to modify ParseIPv4Header, and I will take a look at your CL.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

@mikioh
Copy link
Contributor Author

mikioh commented Dec 19, 2014

We need a returned ICMP time exceeded message which type is 0xb, not an echo, type=0x8, message. Sorry for the confusion.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

NP :) Are you going to write test code once more?

@mikioh
Copy link
Contributor Author

mikioh commented Dec 19, 2014

Nope, sorry for my laziness. We know we can make a few tapped-test cases by using code.google.com/p/gopacket or PCAP/PF_RING/AF_PACKET/BPF directly, but I won't.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

Below is a byte dump of TimeExceeded message.

0B 00 5E B4 00 00 00 00 45 00 00 2B 0C A6 00 00 01 01 7A 48 XX XX XX XX 09 09 09 09 08 00 7E 52 0F F8 00 01

I checked checksum. It's right. Sorry I had looked send package instead of receive packet. But Wireshark seems not capture response from localhost without PCAP.
So that i guess this is working correctly.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

If you want, I can send e-mail to tell you my IP-Address.

@mattn
Copy link
Member

mattn commented Dec 19, 2014

@mikioh How about this?

I modified IP address for the test.

@mikioh mikioh added repo-net and removed repo-net labels Dec 23, 2014
@mikioh
Copy link
Contributor Author

mikioh commented Dec 26, 2014

@mikioh mikioh closed this as completed Dec 26, 2014
@mikioh mikioh changed the title x/net/icmp: support windows icmp: support windows Jan 4, 2015
@mikioh mikioh changed the title icmp: support windows x/net/icmp: support windows Jul 20, 2015
@golang golang locked and limited conversation to collaborators Jul 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants