Class: Nmunch::Dissectors::Arp

Inherits:
Base
  • Object
show all
Defined in:
lib/nmunch/dissectors/arp.rb

Overview

Public: Address Resolution Protocol dissector

Extracts IP and MAC address from an ARP packet

See en.wikipedia.org/wiki/Address_Resolution_Protocol for protocol details

Instance Attribute Summary

Attributes inherited from Base

#pcap_packet, #raw_data

Instance Method Summary collapse

Methods inherited from Base

factory, #initialize

Constructor Details

This class inherits a constructor from Nmunch::Dissectors::Base

Instance Method Details

#ip_addressObject

Public: Get sender IP address from ARP packet

Returns IP address



14
15
16
# File 'lib/nmunch/dissectors/arp.rb', line 14

def ip_address
  @ip_address ||= IPAddr.new(raw_data[28..31].join.hex, Socket::AF_INET).to_s
end

#mac_addressObject

Public: Get sender MAC address from ARP packet

Returns MAC address



21
22
23
# File 'lib/nmunch/dissectors/arp.rb', line 21

def mac_address
  @mac_address ||= raw_data[22..27].join(':')
end