TraceRoute Program


Create a new Project (Application)
Files in the Project
aa.c
#include "windows.h"
#include <stdio.h>

void abc(char *p)
{ FILE *fp=fopen("z.txt","a+");
fprintf(fp,"%s\n",p);
fclose(fp);}

struct o
{
unsigned char Ttl;unsigned char a[7];
};
struct
{
DWORD Address;
unsigned long  Status,RoundTripTime;
unsigned char a[8];
struct o  Options;
} E;

HANDLE hIP;WSADATA wsa;HANDLE hIcmp;DWORD *dwIPAddr;struct hostent *phostent;
DWORD d;char aa[100];struct o I;char bb[100];int z;

HANDLE ( WINAPI *pIcmpCreateFile )( VOID );
BOOL ( WINAPI *pIcmpCloseHandle )( HANDLE );
DWORD (WINAPI *pIcmpSendEcho)(HANDLE,DWORD,LPVOID,WORD,LPVOID,LPVOID,DWORD,DWORD);

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrev,
                                        LPSTR lpCmd,int nShow )
{
hIcmp = LoadLibrary( "ICMP.DLL" );
WSAStartup( 0x0101, &wsa );  
pIcmpCreateFile=GetProcAddress( hIcmp,"IcmpCreateFile");
pIcmpCloseHandle=GetProcAddress( hIcmp,"IcmpCloseHandle");
pIcmpSendEcho =GetProcAddress( hIcmp,"IcmpSendEcho" );
hIP = pIcmpCreateFile();

for ( z = 1; z<= 20 ; z++)
{
I.Ttl=(unsigned char)z;
phostent = gethostbyname( "www.neca.com");
dwIPAddr = (DWORD *)( *phostent->h_addr_list );
pIcmpSendEcho(hIP,*dwIPAddr,0,0,&I,&E,sizeof(E),8000 );
d=E.Address;
phostent = gethostbyaddr((char *)&d,4,PF_INET);
if ( phostent != 0) 
        strcpy(aa,phostent->h_name)  ;
else 
        strcpy(aa,"no host name");
wsprintf(bb," RTT: %dms,  TTL: %d",E.RoundTripTime,E.Options.Ttl );
strcat(aa,bb);
abc(aa);
if ( E.Options.Ttl )
        break;
}
MessageBox(0,"over","hi",0);
pIcmpCloseHandle( hIP );
FreeLibrary( hIcmp );
WSACleanup();                                       
}
z.txt
no host name RTT: 241ms,  TTL: 0
no host name RTT: 224ms,  TTL: 0
border7-serial3-7.WestOrange.mci.net RTT: 798ms,  TTL: 0
core2-fddi-0.WestOrange.mci.net RTT: 856ms,  TTL: 0
core3.WestOrange.mci.net RTT: 841ms,  TTL: 0
sprint-nap.WestOrange.mci.net RTT: 990ms,  TTL: 0
sl-pen-2-F4/0.sprintlink.net RTT: 804ms,  TTL: 0
sl-pen-7-F0/0.sprintlink.net RTT: 796ms,  TTL: 0
sl-new2-1-S0-1544k.sprintlink.net RTT: 850ms,  TTL: 0
cygnus.neca.com RTT: 803ms,  TTL: 246
Download the source Code


Have any suggestions, comments, ideas, cracked code, feedback. Feel free to get in touch with us.

Move back to the Vijay Mukhi's Technology Cornucopia Page to learn more about the other new Internet Technologies.


Vijay Mukhi's Computer Institute
VMCI, B-13, Everest Building, Tardeo, Bombay 400 034, India
E-mail:vmukhi@giasbm01.vsnl.net.in Tel : 91-22-496 4335 /6/7/8/9 Fax : 91-22-307 28 59
http://www.vijaymukhi.com