class PacketGen::Header::ICMP
ICMP
header ({tools.ietf.org/html/rfc792 RFC 792})
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
A ICMP
header consists of:
-
a {#type} field ({Types::Int8} type),
-
a {#code} field ({Types::Int8} type),
-
a {#checksum} field ({Types::Int16} type),
-
and a {#body}.
Create a ICMP
header¶ ↑
# standalone icmp = PacketGen::Header::ICMP.new # in a packet pkt = PacketGen.gen('IP').add('ICMP') # access to ICMP header pkt.icmp # => PacketGen::Header::ICMP
ICMP
attributes¶ ↑
icmp.code = 0 icmp.type = 200 icmp.checksum = 0x248a icmp.body.read 'this is a body'
@author Sylvain Daubert
Constants
- IP_PROTOCOL
ICMP
internet protocol number
Public Instance Methods
calc_checksum()
click to toggle source
Compute checksum and set checksum
field @return [Integer]
# File lib/packetgen/header/icmp.rb, line 58 def calc_checksum sum = IP.sum16(self) self.checksum = IP.reduce_checksum(sum) end