Class: Nmunch::Dissectors::Ip

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

Overview

Public: Internet Protocol dissector

Extracts IP and MAC address from IP packet

See en.wikipedia.org/wiki/Internet_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 IP packet

Returns IP address



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

def ip_address
  @ip_address ||= pcap_packet.ip_src.to_s
end

#mac_addressObject

Public: Get sender MAC address from IP packet

Returns MAC address



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

def mac_address
  @mac_address ||= raw_data[6..11].join(':')
end