Originally posted by: Czereova
Don't you know, how to trace the back route ?
I call the function lpfnIcmpSendEcho just till I reach the destination address and thats it. But i need to compare the route to the destination and route back from the destination to the source. Thanks.
Originally posted by: nmnat
I do have similar problem what Tommaso Trani has posted.. how to solve this problem?
Thanks.
ReplyOriginally posted by: Ksek Qiu
If the operater is not a aministrator(NT),the socket cannot bind to the icmp protocol,who can tell me why?
thanks for you help!!
Originally posted by: Efran Cobisi
If you got errors from the compilation (eg infamous 65 errors), just add the following line to "icmp.h" head:
#include <afxsock.h>
It simply enables MFC WinSock support, letting all work ok!
Efran Cobisi, sercom S.r.l.
Originally posted by: April Luk
Hi Jay,
I've tried to run the demo program on a Windows NT 4.00.1381 machines but failed. I didn't modified anything. The error I got is:
CEWDPingDlg::InitSockets
WSA_PING_ASYNC Error (10013-1) : WSACCESS: Permission denied
I've ran the demo program on a Windows 98, 98SE and 95 machines and it was working fine. I would like to know do you have any idea is going wrong? Do I need any special previleges in order to get the program working?
I've tried to access the webpage http://www.earthwalkerdesigns.com
to try to search for an update version but that webpage does not exist.
I'm actually using your class for my university project and this problem is actually now holding up my project development. Can you please kindly advise as soon as possible? You can email me directly. Thanks!
Regards,
April
Originally posted by: jon howell
A very good and handly class!
ReplyOriginally posted by: Thane
I ran into problems create the project at first, then decided to open the .mak file through Visual Studio 6.0. I didn't seem an option for .mak files so I decide to use the option All files and opened the .mak file. This was on an NT 4.0 system.
Visual Studio prompt me, asking if I would like to upgrade the project to Visual Studio 6.0 and it coverted the files and created the correct .dsw file and then I buildt the program in debug mode no special settings and ran the program it worked fine.
TDG
ReplyOriginally posted by: Chris
I ran into some problems compiling. When I run through your setup steps, and I get
65 compilation errors. The first being
f:\proj1\icmp.h(234) : error C2143: syntax error : missing ';' before '*'
#pragma pack (4)
//////////////////////////////////////////////////////////////////
//
//
//
//
//////////////////////////////////////////////////////////////////
#define MAXBFRSIZE 2048
#define MAX_HOPS 30
typedef SOCKET * LPSOCKET; <---- Line 234
I know I'm probably forgetting to include something. I've been trying to implement some icmp functions over the past few days, and have had issues get visual studio to see these functions. I'm using VC++ 6. All I've done is follow your steps, nothing else.
-Thanks
Chris
Originally posted by: Tommaso Trani
Can you tell me why the call setsockopt return SOCKET_ERROR?
Result = setsockopt (icmpSocket, IPPROTO_IP, IP_TTL, (LPSTR)&TTL, sizeof(int));
I've Inserted EwdPing (I've replaced the application class) in a my project, and I've not modified anything! Your sample work, but mine not.
Ehm.. I've only modified the position of #include <afxsock.h>; if I insert it in stdafx.h I've a lot of error of redefinition, so I've inserted itto the .cpp files.
I've the fail in void CEWDPingDlg::SendPing(void)
when calling SetTTL.
if (PingSocket.SetTTL (icmpPingTTL) == SOCKET_ERROR)
...
I've seen that the parameter icmpPingTTL passed to this function is the same as in my program as in your sample.
If I go deeper (with Debug) and I trace SetTTL, I've seen that the first parameter passed to setsockopt (icmpSocket), in my program has always the value 48, but in your sample is 24.
At this point I've tried to modify manually the call to setsockopt passing 24 as first parameter:
icmpSocket=24;
Result = setsockopt (icmpSocket, IPPROTO_IP, IP_TTL, (LPSTR)&TTL, sizeof(int));
But this don't work again!
At this point I think there is same error into the initialization of object CIcmp, but I can't have seen any difference with your app.
Can you help me?
If you can, can you eMail me the solution?
Thanks in advance,
Tommaso.
P.S. If you want I can send you my app (I cut all is not needed).
Originally posted by: Minh Do
Hi Jay,
My name is Minh Do, and i am new to Windows development.
I have mostly written applications in Unix.
I am familiar with icmp issues. One of the technique
that is being used to discover devices in a subnetwork is
sending a ping sweep. A regular ping command is sent
to a broacast address, and the ping program listens on the
socket for reply.
On a Solaris machine, the command is:
Ex: ping -s 134.177.189.0
There should be many response returned.
Of course, if running the above command in Windows, it does
not work. Since the ping program explicitly tries to open
address 134.177.189.0, and when it gets the response from
the recvfrom, if the address does not match with the
sending
In my unix application, I control the replies using a select
statement:
Example code:
// Format icmp packet
// Send a ping message
sendto = sendto (socket, (char *) packet, packetlen, 0,
&whereto, sizeof (struct sockaddr));
while (1) {
numfds = 0; // reset the number of file descriptors
FD_ZERO (&fdset);
block = 0; // Set to block
timerclear (&timeout); // Reset timeout
// Check if there are any ping sent pending.
// If we sent a ping, then this value is at least 1
numping = pingSelectInfo (&numfds, &fds, tvp, &block);
if (! numping) break;
tvp = &timeout;
if (block == 1) tvp = NULL; // Block with out timeout
count = select (numfds, &fdset, 0, 0, tvp);
if (count > 0) {
pingRead (&fdset);
}
else {
switch (count) { // Count can only be 0 or negative
case 0:
// Timeout. Send more packet if this is the case
if (! ipPingTimeOut ()) return;
break;
case -1:
printf ("ERROR");
default:
return; // Exit out of the function
}
}
}
I also notice that standard header icmp structure does not
match with the Berkley icmp structure. I have changed my internal
icmp structure to match with Microsft structure to no prevail.
I have look at example of Windows ping using select statement,
but could not find one that works. They all adhere to the ping
example MSFT gives in the SDK.
Format the cmp packet
Do a sendto
Do a recvfrom
Note that, I have been able to port my other code in Unix to
Windows to do snmp using socket and select statements.
I was able to collect snmp information. I ran purify, and
nothing is out of the ordinary.
So all the winsocket calls and setups are correct.
I just want to mention the problem here, in case anybody have run
into the problem before, and have a solution for it.
If a ping broadcast message cannot be sent, then it would take
a long time to discover devices in a network.
I am waiting to get a hand on a sniffer, and intend to see what
are the packets that are coming back after a ping message.
Thanks,
- Minh Do
Reply