MonkeyManChfKiller has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to make a script that will read data from a specific ip, and read the size of data in Kbps its sending. then put that into a variable. I know its possible in C with pcap, but with perl i am not too sure.I'm Actually asking for a solution for this.

Replies are listed 'Best First'.
Re: Net::Pcap Packet Capturing
by AppleFritter (Vicar) on May 18, 2014 at 00:14 UTC

    Howdy MonkeyManChfKiller, welcome to the Monastery! Can you be a bit more specific as to what you're trying to accomplish? Some current code would be best -- it'd allow us to see what you want to do, and what isn't working right now.

    You've already mentioned Net::Pcap. CPAN is down for me at the moment, so I can't take a look at that, but if libpcap does what you want, I'd wager a guess so does Net::Pcap. (If not, contact the latter's author to get the necessary wrappers implemented.)

    Perl and Net::Pcap also looks like it might be of interest, despite being a rather old node (from 2002).

      Well basicly im trying to read the amout of data coming in from a specific ip, lets say 1.1.1.1 is flooding my server with 100byte packets, i want to be able to just listen for that ip and read the exact packet size that 1 moment.
        If you are on a linux/unix machine, you could just use tcpdump. Something like:
        sudo tcpdump host 1.1.1.1
        will print a line for each packet sent to or received from 1.1.1.1. Most packet types will include the length at the end of the line, following the word "length" or in parentheses.

        tcpdump is a pretty complete tool for working with libpcap. It is worth a look to avoid re-inventing the wheel.