def unpack(self, buffer):
    ipv4_header_size = struct.calcsize(IPV4_HEAD_FMT)
    ipv4_header_packed = buffer[:ipv4_header_size]
    ipv4_header_unpacked = struct.unpack(IPV4_HEAD_FMT, ipv4_header_packed)
    self.version_ihl = ipv4_header_unpacked[0]
    self.ihl = (self.version_ihl & 15)
    self.version = (self.version_ihl >> 4)
    self.tos = ipv4_header_unpacked[1]
    self.length = ipv4_header_unpacked[2]
    self.identification = ipv4_header_unpacked[3]
    self.fragment_offset = ipv4_header_unpacked[4]
    self.ttl = ipv4_header_unpacked[5]
    self.protocol = ipv4_header_unpacked[6]
    self.checksum = ipv4_header_unpacked[7]
    self.source_ip = str(ipaddress.IPv4Address(ipv4_header_unpacked[8]))
    self.destination_ip = str(ipaddress.IPv4Address(ipv4_header_unpacked[9]))
    self.data = buffer[ipv4_header_size:]
def unpack(self, buffer):
    ipv4_header_size = struct.calcsize(IPV4_HEAD_FMT)
    ipv4_header_packed = buffer[:ipv4_header_size]
    ipv4_header_unpacked = struct.unpack(IPV4_HEAD_FMT, ipv4_header_packed)
    self.version_ihl = ipv4_header_unpacked[0]
    self.ihl = (self.version_ihl & 15)
    self.version = (self.version_ihl >> 4)
    self.tos = ipv4_header_unpacked[1]
    self.length = ipv4_header_unpacked[2]
    self.identification = ipv4_header_unpacked[3]
    self.fragment_offset = ipv4_header_unpacked[4]
    self.ttl = ipv4_header_unpacked[5]
    self.protocol = ipv4_header_unpacked[6]
    self.checksum = ipv4_header_unpacked[7]
    self.source_ip = str(ipaddress.IPv4Address(ipv4_header_unpacked[8]))
    self.destination_ip = str(ipaddress.IPv4Address(ipv4_header_unpacked[9]))
    self.data = buffer[ipv4_header_size:]