You can see all the IP addresses in server logs, or in your case possibly a javascript equivalent of the code posted by microdesign will be a more viable solution, as you are not trying to get the IPs of hits to your own server, but for your ads hosted on other sites.
On the downside: this will not solve your issue. If anybody only a little bit experienced is doing a click fraud it is very likely that they are using zombies or bot networks to reach their goal.
If they are using hacked servers, that is an easier solution, you just have to look at irregularly high number of hits from the same IP address accross your network, and block the IP.
Using cookies and testing for them is a wise decision, because a php only bot won't be able to mimic cookies, if you set them with javascript.
If you do all the above, there are still ways around it. If I were you I would contact a company experienced in user validating, there is no one stop shop solution for what you are trying to do.