Module: PcapParser::Proto

Defined in:
lib/pcap_parser/proto.rb,
lib/pcap_parser/proto/udp.rb,
lib/pcap_parser/proto/tcp.rb,
lib/pcap_parser/proto/icmp.rb

Overview

Transport layer protocols family. TCP, UDP, ICMP etc.

Defined Under Namespace

Classes: ICMP, TCP, UDP

Class Method Summary collapse

Class Method Details

.sum_pack_16int(packet) ⇒ Integer

Calculate sum of all 16bit integers in packet as one's complement 16bit integer. Used to calculate check sum RFC 1071.


13
14
15
16
17
# File 'lib/pcap_parser/proto.rb', line 13

def self.sum_pack_16int(packet)
  packet.reduce(0) do |res, x|
    ((res + x)>>0x10) + ((res + x) & 0xffff)
  end
end