def _serialize(self):
  s = list()
  s.append(self._byte_type)
  s.append(self._byte_code)
  icmp_pkt._write_word(s, self._word_checksum)
  icmp_pkt._write_word(s, self._word_id)
  icmp_pkt._write_word(s, self._word_seq)

  for i in xrange(len(self._data)):
   s.append(ord(self._data[i]))

  return s


 '''
 Similarly the deserialize method reads the values from a network buffer into the class fields
 '''

def parse(self, data, total_size):
  i = 20; # 20 bytes of ip header
  self._byte_type = ord(data[i]) & 0xFF
  i += 1
  self._byte_code = ord(data[i]) & 0xFF
  i += 1
  self._word_checksum = self.parse_word(data,i)
  i += 2
  self._word_id = self.parse_word(data,i)
  i+= 2
  self._word_seq = self.parse_word(data,i)
  i += 2

  payload_size = total_size - 8 - 20

  payload = list()
  for j in xrange(payload_size):
   payload.append(data[i+j])

  self._data = payload

 '''
 This serialize method is used to calculate the checksum and serialize the structure
 for sending over the network
 '''
 def serialize(self):
  s = self._serialize()
  c = checksum(s)
  self._word_checksum = c
  return self._serialize()