Reputation: 6978
An application I'm working on needs to keep track of the connectivity of another application, meaning check that the other application is generating and receiving IP traffic.
We have no API to the other application, and so are tracking the IP traffic via WinSock. We do this by defining a RAW IP socket and setting the IO control with something equivalent to -
int opt = RCVALL_ON;
WSAIoctl((socket) s, SIO_RCV_ALL, &opt, sizeof(opt), NULL, ...); //The rest is "empty"
We then read data from the socket asynchronously and look at the IP header to see the traffic belongs to the tracked application.
Two questions arise -
Thanks,
Asaf
Upvotes: 0
Views: 359
Reputation: 91320
This is the way to track traffic if you don't want drivers. If you accept drivers, WinPCap is the way to go. With some more constraints, you could look at established tcp connections (like netstat), but with your requirements I'd definitely go for the raw socket approach you're using.
Using your method, data is copied, not stolen. The only explicit documentation I can find stating this is on MSDN: "Received datagrams are copied into all SOCK_RAW sockets ..."
Upvotes: 2
Reputation: 8099
I would take a serious look at http://en.wikipedia.org/wiki/Pcap
it's what WireShark uses to monitor traffic, and when i took a look their API look really usefull....
Upvotes: 0