How to get all pings generated by an application while it's downloading or installing from internet?

Hi all,
I need to know 'How to get all pings generated by an application while it's downloading or installing from internet?' using C++ win32 APIs. Looks for a quick response. It's _URGENT_
LVL 9
Subrat (C++ windows/Linux)Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
If this is urgent and you just want to see what's happening using a pre-written tool such as Wireshark is your best bet.
http://www.wireshark.org/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Infinity08Commented:
What do you mean by "get" ?
What do you mean by "pings" ?
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
// What do you mean by "get" ?
It's not related to GET/POST request. You can assume as print
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Infinity08Commented:
So, you want a log of all "pings". What do you mean by "pings" ? What information do you want to log ?
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
name of the site(ex:www.myname.com), ip adress , RLZ params etc...
0
Infinity08Commented:
What do you mean by "pings" ?
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Ex:
Go to adobe reader site ()http://get.adobe.com/reader/) and download it. At the same time start HttpAnalyzer. It can show us URL, time, which type of request it's and so on.
I need the same functionality, how exactly to write code to achieve this using C++ win32.
 
Thanks
Subrat
0
evilrixSenior Software Engineer (Avast)Commented:
>> I need the same functionality, how exactly to write code to achieve this using C++ win32.
Apologies for repeating myself but did you look at Wireshark? The source code is available, which could be modified for your specific needs.
0
Infinity08Commented:
>> Go to adobe reader site ()http://get.adobe.com/reader/) and download it. At the same time start HttpAnalyzer. It can show us URL, time, which type of request it's and so on.

So, you mean any traffic, not just ping's (http://linux.die.net/man/8/ping).


>> I need the same functionality, how exactly to write code to achieve this using C++ win32.

Writing this yourself is not straightforward, so consider evilrix' suggestion.

If you really want to write this yourself, you whould start reading up on network protocols (specifically TCP/IP, by reading the book "TCP/IP Illustrated" by W. Richard Stevens eg.), socket programming (http://beej.us/guide/bgnet/), pcap (http://www.tcpdump.org/pcap.htm), etc.
But, be prepared to put in a lot of time to get this to work.
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Hi Evilrix,
I have started working on WinPCap lib. Wireshark is also using it. I may need more clarification on WinPCap, so now I'm not closing this thread.

Thanks
Subrat
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
I'm getting compilation error due to winsock.h. I also replaced it with winshock2.h but still getting same.Plz have alook on my Log file by which u can identify the problem
BuildLog.htm
0
evilrixSenior Software Engineer (Avast)Commented:
The issue is to do with header order dependencies.

IIRC you have to include the winsock header before windows.h

I'll see if I can find the MSDN article that explains this.
0
evilrixSenior Software Engineer (Avast)Commented:
Here we go, I think this is the solution you need: http://msdn.microsoft.com/en-us/library/ms737629(VS.85).aspx
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
My order is as follows

#include "stdafx.h"
#include "pcap.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#ifndef WIN32
#include "sys/socket.h"
#include "netinet/in.h"
#else
#include <winsock.h>
#endif
0
evilrixSenior Software Engineer (Avast)Commented:
Did you read the link I posted? It also suggests to define WIN32_LEAN_AND_MEAN to prevent historical winsock symbols from being defined.
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
WIN32_LEAN_AND_MEAN is already defined.
 
0
Infinity08Commented:
The stdafx.h probably includes windows.h
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
One  Q.
 In the log file it is clear tht  my application is using vc6 sdk (c:\program files\microsoft sdks\windows\v6.0a\include\). Is it a problem?
I want to know why it's searching in this include folder by default? Where is the setting?
I've seen that this is not added by me explicitly.  
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
>>The stdafx.h probably includes windows.h
No. Already seen.
0
Infinity08Commented:
After all these modifications, I'm sure you don't get the same error message, right ?

Could you post the complete latest code, as well as the errors you are currently getting ?
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Problem solved......
It was in pcap-stdinc.h. (_WINSOCKAPI_   macro).
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Hi infinity,
One more Q.
In the log file I attached, it is clear tht  my application is using vc6 sdk (c:\program files\microsoft sdks\windows\v6.0a\include\).

I want to know why it's searching in this include folder by default? Where is the settings?

I've seen that this path is not added by me explicitly.
0
evilrixSenior Software Engineer (Avast)Commented:
Subrat2009,

Since that's unrelated to the original question it should really be asked as a new question.
http://www.experts-exchange.com/help.jsp?hi=23

The default search paths are set in the compiler settings.

Tools | Options >> Projects and Solutions >> VC++ Directories

Thanks.
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Hi all,
 Now problem is
While control reaches at pacp_loop() I'm getting assert,


pcap_compile(adhandle, &fcode, NULL, 1, netmask)
pcap_setfilter(adhandle, &fcode)
pcap_freealldevs(alldevs)
pcap_loop(adhandle, 0, packet_handler2, NULL);


I hope this much info are enough. If u want the complete code then I'll post.

Unable to upload ASSERT IMAGE So find the
Asser MSG:

file: f:\dd\vctools\crt_bld\self_x86\src\isctype.c
Line: 56
Expression: (unsigned)(c+1) <= 256


But I don't think problem in this file!

Plz help me!

Thanks,
Subrat.
0
evilrixSenior Software Engineer (Avast)Commented:
If I was to guess (and the truth is I am guessing) it looks like there is an assert that is checking that the value of an unsigned  integer is between 1 and 256. I'd suggest one or more of your parameters being passed into one of the pcap functions is incorrect.
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Hi evilrix/Infinity,

Can you plz go through the following link and let me know what exactly the problem why getting ASSERTS instead  getting URL names.

http://www.codeproject.com/KB/IP/URLLogger.aspx?msg=2288055#xx2288055xx


FYI:
I changed like below
UrlSniffer::UrlSniffer()
{
      this->SetFilterString("host www.yahoo.com"); //tcp port 8080 or tcp port 1080

}


Thanks,
Subrat.
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Hi evilrix/Infinity,

Please have a look on it.

Thanks & Regards,
Subrat
0
Infinity08Commented:
>> pcap_loop(adhandle, 0, packet_handler2, NULL);

Don't use 0 as the second argument. Either provide a positive value to sniff a given amount of packets, or provide a negative value (-1) if you want to sniff packets until an error occurs.


As evilrix already told you before - this is no longer directly related to your original question, so if you have further problems, you should probably create new questions for them.
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Hi Evilrix & Infinity,
   Really helped me! Thanks a lot. I'll open a new Q which is related  to this thread and wish u should help me. and also later I'll copy paste the entire code here or write a blog on pcap lib usages in simplest way.

Thanks,
Subrat.
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Should follow www.winpcap.org
0
Subrat (C++ windows/Linux)Software EngineerAuthor Commented:
Hi
Plz hav a look on Q. ID:26164071

Thanks,
Subrat.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.