what would cause ICMPsendEcho to fail when ping.exe succeeds
Asked Answered
F

3

8

I have an interesting situation on my hands, and I'm not quite sure how to go about troubleshooting it. I did a few searches for something similar to my situation, but nothing quite matches it. If the answer already exists somewhere here, I would appreciate anyone that could point me in the right direction.

Ok, to the point.

I'm writing a watchdog application for monitoring internet connectivity. Its designed to ping a set of domains at a set interval, and when any of them respond to the ping, the status timer is reset. If the status timer ever goes beyond a set threshold, several stages of corrective action are attempted to fix the problem.

Simple enough right?

Here's where it gets weird.

I'm using ICMPsendecho to issue the ping request. On my development environment (win7) it seems to work fine, testing and everything went smoothly. However, in the environment where its being deployed it fails to receive a response. The deployment environment is a windows XP sp3 machine.

Throughout the trouble shooting process I've noted several things, which may or may not be helpful in actually trying to solve this problem.

windows ping.exe works just fine on the deployment environment for all of the domains i'm using to test connectivity status, its only my ICMPsendecho calls that seem to fail to generate responses.

I've installed wireshark on deployment environment and I can see packets being issue successfully for the requests on both types of ping. the windows ping generates request packets with a length of 74 bytes, and my programs call generates packets with a length of 42 bytes. Windows response packets are similarly 74 bytes when they are received.

Switching to the development environment for a minute, with wireshark installed. Windows ping generates a similiar circumstance as in the deployment environment with the packets. However, my application, when it generates requests the packets are 42 bytes in length(same as the deployment environment), but the responses it receives are 60 bytes in length.

As i said, that information may or may not be useful, but I'm trying to find out why this application is failing to generate ICMP responses when windows ping seems to work fine on that machine.

Another little tidbit that may help, the internet connection were monitoring uses AT&T's elevate 4g hotspots, the actual device is a sierra wireless MC8790 AirPrime card.

Anyone have any ideas on why these pings are failing?

thanks ahead of time for any useful information you might have and for taking the time to read my post.

PS.

Feldt answered 20/2, 2012 at 20:53 Comment(3)
did ICMPSendEcho return an error?Imperium
No error, it just fails to ever receive a response.Feldt
Windows 7 for the development machine, windows xp sp3 for the deployment machine; sorry for the late response.Feldt
M
3

The answer might be in the size of the ping you send (there seems to be an undocumented minimum size of 20 bytes for the payload). See this post for more info: http://groups.google.com/group/microsoft.public.win32.programmer.networks/browse_thread/thread/2b28b994a8067713?pli=1

Mitra answered 29/2, 2012 at 18:41 Comment(4)
Thanks for the reply! I failed to notice it right away, but the issue is still unsolved, and will need to be fixed at some point. I'll look into this as a possible cause.Feldt
This was actually the cause of the issue. The code we were using allocated an incorrect amount of space for the response packet. I would of thought that would of raised an error/exception, but that wasn't the case. There were many other issues at play at this particular client's location, so it made solving the problem that much harder.Feldt
@Feldt can you please elaborate on that? What did you end up using for the response buffer size? The Google groups link talks about experimentally increasing the size, but its not clear to me what size should be used in general. I'm seeing a similar problem, IcmpSendEcho times out when ping works fine and am curious what you ended up doing to get it to work.Kelvin
@Nerdtron. Looking back at the code, the size of the response was set to equal SizeOf(ECHO_REPLY) + 32+ 8. Where ECHO_REPLY = record Address : IPAddr; Status : ULONG; RoundTripTime : ULONG; DataSize : Word; Reserved : Word; Data : Pointer; Options : IP_OPTION_INFORMATION; end; ip_option_information = record Ttl : byte; Tos : byte; Flags : byte; OptionsSize : byte; OptionsData : pointer; end;Feldt
V
2

Have you checked the user permissions? Ping.exe does not require administrator rights, but the raw ICMP commands in Windows need administrator privileges.

See this example: http://www.delphi-central.com/tutorials/icmp-ping.aspx

Please note, however, that for Windows NT and Windows 2000 implementations, Raw Sockets are subject to security checks and are accessible only to members of the administrator's group.


Another possible reason could be a firewall which blocks ICMP packets.

Vincevincelette answered 21/2, 2012 at 8:16 Comment(2)
why would the ICMPsendecho generate responses in the development environment and not in the deployment environment? I haven't checked the user permissions, but it seems to me that unless icmp.dll use is different under windows 7 (and it may be) that they would both fail to generate responses. However seeing as i'm currently at a standstill, i will invesigate your idea further, as i am otherwise out of good ideas.... thanks for your response.Feldt
If the app have administrative rights in both environments, they both should work. So I guess a firewall setting can be different (See my edit).Vincevincelette
A
0

We had the same error with a client. The solution was to implement IcmpSendEcho2 as a plan B when IcmpSendEcho fails. It worked!

Ament answered 10/5, 2013 at 17:39 Comment(1)
How do you implement the IcmpSendEcho2 function?Everyplace

© 2022 - 2024 — McMap. All rights reserved.