Help:Listening for ICMP messages using WinSock

Help:Listening for ICMP messages using WinSock

Post by Bob Cousi » Tue, 30 Jun 1998 04:00:00




>What I am trying to do is trace route to a host by sending UDP datagrams with
>TTL=1 and listen to the 'Destination Unreachable' ICMP error message returned.

>Does anyone have an idea why socket layer won't deliver ICMP messages up to my
>program?

Did you do a bind()? Use INADDR_ANY as address.

I have used the same technique in my own traceroute program so you should be
able to get it to work. One odd thing I noticed is that after a failed DNS
lookup, I had to close the raw socket and recreate it to get further ICMP
messages.
--
Bob Cousins, Software Engineer.
Home page at http://www.lintilla.demon.co.uk/

 
 
 

Help:Listening for ICMP messages using WinSock

Post by Fran?ois Piett » Wed, 01 Jul 1998 04:00:00


Quote:> >What I am trying to do is trace route to a host by sending UDP datagrams
with
> >TTL=1 and listen to the 'Destination Unreachable' ICMP error message
returned.

> >Does anyone have an idea why socket layer won't deliver ICMP messages up
to my
> >program?

> Did you do a bind()? Use INADDR_ANY as address.

> I have used the same technique in my own traceroute program so you should
be
> able to get it to work. One odd thing I noticed is that after a failed
DNS
> lookup, I had to close the raw socket and recreate it to get further ICMP
> messages.

You can easily write a traceroute utility using the ICMP.DLL api.

--


The freeware Internet Component Suite maker
Download from http://www.rtfm.be/fpiette/indexuk.htm

 
 
 

Help:Listening for ICMP messages using WinSock

Post by Bob Cousi » Wed, 01 Jul 1998 04:00:00



Quote:>You can easily write a traceroute utility using the ICMP.DLL api.

Actually, I can't :-). traceroute using ICMP Echo doesn't work with my router so
I need to use UDP. Otherwise I'd just use tracert that MS supply.

--
Bob Cousins, Software Engineer.
Home page at http://www.lintilla.demon.co.uk/

 
 
 

Help:Listening for ICMP messages using WinSock

Post by John F. Moehrk » Wed, 01 Jul 1998 04:00:00


Create a UDP packet and send it through the ICMP.DLL API...
Yes, the ICMP.DLL api is not limited to ICMP, it is actually an
API direct to IP...   :^)



>>You can easily write a traceroute utility using the ICMP.DLL api.

>Actually, I can't :-). traceroute using ICMP Echo doesn't work with my router so
>I need to use UDP. Otherwise I'd just use tracert that MS supply.

>--
>Bob Cousins, Software Engineer.
>Home page at http://www.lintilla.demon.co.uk/

 
 
 

Help:Listening for ICMP messages using WinSock

Post by Bob Cousi » Wed, 01 Jul 1998 04:00:00



Quote:>Create a UDP packet and send it through the ICMP.DLL API...
>Yes, the ICMP.DLL api is not limited to ICMP, it is actually an
>API direct to IP...   :^)

Crikey! (Why bother with winsock? :-)

Is the ICMP.DLL API documented anywhere?

--
Bob Cousins, Software Engineer.
Home page at http://www.lintilla.demon.co.uk/

 
 
 

Help:Listening for ICMP messages using WinSock

Post by Bob Cousi » Wed, 01 Jul 1998 04:00:00



>In any case I would like to hear where the interface provided by ICMP.DLL
>is documented. Any sample code?

I found some excellent stuff from Bob Quinn at
http://www.sockets.com/ms_icmp.htm including sample code. Very useful site.

--
Bob Cousins, Software Engineer.
Home page at http://www.lintilla.demon.co.uk/

 
 
 

1. Retrieving ICMP messages in Winsock 2

From what I've heard, the Internet Control Message Protocol is to be
supported in Winsock 2. Still, when I do this:

        SOCKET sIcmp;
        sIcmp=socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

socket() returns with an error message. WSAGetLastError() tells me
that the protocol is not supported. Is this because Winsock is still
in the beta stage, or is it supposed to remain this way?

Calling getprotobyname("icmp") returns a pointer to a valid protoent,
which from my point of view should indicate that icmp is supported. I
tried this as well:

        SOCKET sIcmp;
        protoent *proto;

        proto=getprotobyname("icmp");
        sIcmp=socket(AF_INET, SOCK_RAW, proto->p_proto);

But it gives the same disappointing result, even though getprotobyname
recognizes "icmp".
I also tried replacing AF_INET with AF_INET6, and replacing SOCK_RAW
with SOCK_DGRAM.

FYI I am trying to make a Windows 95 port of the Unix utility
icmpinfo, which reports all the ICMP messages received by the system.

Thanks for any feedback,

2. Exporting groups / users to exce; / word

3. how to recieve icmp packet using winsock (sock_raw) from another host

4. Ventura under Windows 3

5. Using ICMP with the WINSOCK

6. DHCP Issue when creating new scope

7. How to do ICMP using winsock

8. Websites: FAQs/Procedures Win95/98/ME/NT4/W2K/XP networking DUN ICS DCC RAS VPN PPTP

9. ICMP socket listening problem

10. Is it possible to send a message with an attach file, using winsock.h ?

11. ICMP Router Discovery & Winsock

12. Winsock 1.x and ICMP?

13. ICMP packets with Winsock