import socket
import struct


class IPPacket:

    # data = bytes()


    def __init__(self):
        self.version = 4
        self.hlen = 5
        self.service = 0
        self.len = 0
        self.id = 54321
        self.flags = 0
        self.fragment_ofset = 0
        self.ttl = 255
        self.ulp = 6
        self.crc = 0
        self.src = socket.inet_aton("1.1.1.1")
        self.dst = socket.inet_aton("1.1.1.1")
        self.opt = None
        self.data = b''
        print(type(self.data))


    def to_hex_string(self):
        ip_vet_hlen = (self.version << 4) + self.hlen

        return struct.pack('!BBHHHBBH4s4s', ip_vet_hlen, self.service, self.len,
                           self.id, self.fragment_ofset, self.ttl,
                           self.ulp, self.crc, self.src, self.dst) + self.data
