Module: PkgCount
- Defined in:
- lib/packetcount.rb
Class Method Summary collapse
Class Method Details
.run ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/packetcount.rb', line 4 def self.run require 'rubygems' require 'pcaprub' capture = PCAPRUB::Pcap.open_live('eth0', 65535, true, 0) capture.setfilter('ip') while 1==1 pkt = capture.next() if pkt parts = capture.stats().to_s().split(/(\d+)/) puts "Packets captured: #{parts[1]} received, #{parts[5]} sent, #{parts[3]} dropped" end sleep(1) end end |