views:

337

answers:

2

Hi! I want to write a library (C\C++) which would be able to monitor network traffic (TCP and UDP) as well as limit bandwidth to a particular network area (apply different traffic shaping rules to different network zones). This library should work on Windows 7 (64-bit). I would be glad if this kind of library can be written as entirely user-mode. Right now I'm learning about Windows Filtering Platform. It seems like what I need, but there's lack of samples on the net and I've never written drivers before. I will really appreciate if someone will just nudge me in the right direction or give me an overview of how such kind of library can be implemented.

+3  A: 

Did you take a look at the winpcap library? It's essentially the Windows version of the libpcap library widely used in the Unix world. The source of the same is available here. That'll help you get started.

I am not sure about what you mean by limiting bandwidth to a particular network area, though.

Sudhanshu
On taking a quick look at the WinPcap docs, it allows you to implement filtering. You should be able to put packets for a particular protocol in a queue after the bandwidth limits are exceeded and push them to the ethernet interface as bandwidth becomes available.
Chinmay Kanchi
Thanks a lot! I will try WinPcap."I am not sure about what you mean by limiting bandwidth to a particular network area, though"In other words: apply different traffic shaping rules to different network zones.
Stepan
Turned out WinPcap works great for network monitoring but it can't do traffic shaping: "WinPcap receives and sends the packets independently from the host protocols, like TCP-IP. This means that it isn't able to block, filter or manipulate the traffic generated by other programs on the same machine: it simply "sniffs" the packets that transit on the wire. Therefore, it does not provide the appropriate support for applications like traffic shapers, QoS schedulers and personal firewalls."
Stepan
Yeah, that's what I thought it does. I don't quite know if there's an open-source firewall for Windows, otherwise that would have been a good place to look at for your traffic-shaping requirement.
Sudhanshu
+1  A: 

Also, in conjunction to using the WinPCap library, you can have a peek at PeerGuardian which includes a driver for filtering out peer IP addresses.

Hope this helps, Best regards, Tom.

tommieb75