require "pcaplet" HOST_IP = Pcap::IPAddress.new("10.0.0.1") received_bytes = 0 sent_bytes = 0 sniffer = Pcap::Pcaplet.new("-i eth1") sniffer.each_packet do |pkt| next unless pkt.ip? src, dst, = pkt.ip_src, pkt.ip_dst if src == HOST_IP sent_bytes += pkt.size elsif dst == HOST_IP received_bytes += pkt.size end end sniffer.close puts "#{HOST_IP} hat #{sent_bytes} Bytes gesandt und #{received_bytes} empfangen."