troubleshooting Question

VC++ Winpcap library - not getting any packets, Win7

Avatar of lunanat
lunanatFlag for Canada asked on
C++
4 Comments1 Solution423 ViewsLast Modified:
So, I'm writing an application that will sit on my network (a span port on one of my core switches, actually) and monitor the traffic going across the fabric... specifically, I am looking to generate assoications between applications.  Which servers talk to which other servers, etc.

Will be very informative and interesting.

The first step is of course to drop the NIC into promiscuous mode, and read the packets.

I've got the pcap.h file, and the libraries working... I can access the functions within the library, and I can both list and open adapters.  However, following the documented examples provided, I'm not getting any packets dumped out.

 
//open the adapter
	adapterhandle=pcap_open(adapter->name,65536,PCAP_OPENFLAG_PROMISCUOUS,1000,NULL,errorBuffer);
	if (adapterhandle==NULL){
		cout<<"Unable to open adapter "<<adapter->name<<"\n";
		pcap_freealldevs(allAdapters);
		return;
	}
	cout<<"Capture process started on adapter "<<adapter->name<<"\n";

	//recieve packets, this part does not work.
	while ((retValue=pcap_next_ex(adapterhandle,&packetHeader,&packetData))>=0){
		if (retValue==0)
			continue;
		cout<<"Packet Length: "<<packetHeader->len<<"Received at :"<<packetHeader->ts.tv_sec<<"\n\n";
	}
	//clean up
	pcap_freealldevs(allAdapters);
	cout<<"Finished\n\n";

Open in new window


Basically, my screen just sits blank and empty... I did generate traffic by browsing webpages (though there's a lot of background traffic that it should pick up anyways, ARP if nothing else) while the app was open and running.
ASKER CERTIFIED SOLUTION
lunanat

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros