Last active
November 4, 2017 17:47
-
-
Save picatz/c2507b925eab7e5e97d956e71503a973 to your computer and use it in GitHub Desktop.
Capture & Analyze 10 ICMP packets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'packetgen' | |
# capture an array of 10 parsed packets, using a bpf filter | |
icmps = PacketGen.capture(iface: 'eth0', filter: 'icmp', max: 10) | |
# analyze each packet's payload | |
icmps.each do |packet| | |
puts packet.body | |
end | |
# analyze each packet icmp header type | |
icmps.each do |packet| | |
puts packet.icmp.type | |
end | |
# get an array of each packet's icmp checksum | |
checksums = icmps.map { |packet| packet.icmp.checksum } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment