Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I guess it's socket programming. But I have never done socket programming expect for running the tutorial examples while learning Python. I need some more ideas to implement this.

What I specifically need is to run a monitoring program of a server which will poll or listen to traffic being exchange from different IPs across different popular ports. For example, how do I get data received and sent through port 80 of 192.168.1.10 and 192.168.1.1 ( which is the gateway).

I checked out a number of ready made tools like MRTG, Bwmon, Ntop etc but since we are looking at doing some specific pattern studies, we need to do data capturing within the program.

Idea is to monitor some popular ports and do a study of network traffic across some periods and compare them with some other data.

We would like to figure a way to do all this with Python....

share|improve this question

closed as off topic by Iain Jun 3 '12 at 15:45

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
You'll probably get a much better answer to this on stackoverflow. –  Iain Jun 3 '12 at 15:45
add comment

1 Answer 1

up vote 1 down vote accepted

Do you need data in realtime or not? If not, you can try dumping the data to file with tcpdump (with appropriate filters), and analyzing the content after. I think python has good-enough (lib)pcap support.

If you need realtime, you have to check if python is capable of packat capture with pcap (should be), without interfering with the traffic flow (should be).

So the first step would be too google 'python pcap', and finding the easiest wrapper for it all.

With that, you get raw packets, and you can parse them any way you wish.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.