How to catch all the packets your phone using pcap.h?

I want to catch ALL packets from mobile devices with your computer, use the library and the Winpcap driver. But I don't quite understand how it works(generally weak knowledge networks).
The phone, he always sends packets to the network card of the computer even if the phone is not configured anything ?Not only the router but also to the network card of the computers next to him ? Or winpcap as it works with the router to which prisoediniv both devices , but if the phone is using lte and not wifi ?
Plus I have a problem with what is caught only part of the packages, even on the local computer on which the program is run.
for example I load the page in the browser, and the software packages that are caught, no. The most common code examples, like there are no errors.
#include "pcap.h"

/* prototype of the packet handler */
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);

int main()
pcap_if_t *alldevs;
pcap_if_t *d;
int inum;
int i=0;
pcap_t *adhandle;
char errbuf[PCAP_ERRBUF_SIZE];

 /* Retrieve the device list on the local machine */
 if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)
 fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);

 /* Print the list */
 for(d=alldevs; d; d=d->next)
 printf("%d. %s", ++i, d->name);
 if (d->description)
 printf(" (%s)\n", d->description);
 printf(" (No description available)\n");

 printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
 return -1;

 printf("Enter the interface number (1-%d):",i);
 scanf_s("%d", &inum);

 if(inum < 1 || inum > i)
 printf("\nInterface number out of range.\n");
 /* Free the device list */
 return -1;

 /* Jump to the selected adapter */
 for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);

 /* Open the device */
 if ( (adhandle= pcap_open(d->name, // name of the device
 65536, // portion of the packet to capture
 // 65536 guarantees that the whole packet will be captured on all the link layers
 PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode
 1000, // read timeout
 NULL, // authentication on the remote machine
 errbuf // error buffer
 ) ) == NULL)
 fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name);
 /* Free the device list */
 return -1;

 printf("\nlistening on %s...\n", d->description);

 /* At this point, we don't need any more the device list. Free it */

 /* start the capture */
 pcap_loop(adhandle, 0, packet_handler, NULL);

 return 0;

/* Callback function invoked by libpcap for every incoming packet */
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
 struct tm ltime;
 char timestr[16];
 time_t local_tv_sec;

 * unused variables

 /* convert the timestamp to readable format */
 local_tv_sec = header->ts.tv_sec;
 localtime_s(&ltime, &local_tv_sec);
 strftime( timestr, sizeof timestr, "%H:%M:%S", &ltime);

 printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);


When I turn off the browser and it seems like everything that sends packets, and turn on the game for example (it needs to transmit huge number of packets per second, and the program comes only a small amount of packets every 5 seconds. And not the fact that it packs game.
April 19th 20 at 12:17
0 answer

Find more questions by tags WiresharkWi-FiComputer networksC