code: def to_bytes(self):
          '''
          Create bytes from properties
          '''
          # Verify that the properties make sense
          self.sanitize()
  
          # Write the source and destination ports
          bitstream = BitStream('uint:16=%d, '
                                'uint:16=%d' % (self.source_port,
                                                self.destination_port))
  
          # Write the length
          payload_bytes = bytes(self.payload)
          length = len(payload_bytes) + 8
          bitstream += BitStream('uint:16=%d' % length)
  
          # Write the checksum
          bitstream += BitStream('uint:16=%d' % self.checksum)
  
          return bitstream.bytes + payload_bytef to_bytes(self):
          '''
          Create bytes from properties
          '''
          # Verify that the properties make sense
          self.sanitize()
  
          # Write the source and destination ports
          bitstream = BitStream('uint:16=%d, '
                                'uint:16=%d' % (self.source_port,
                                                self.destination_port))
  
          # Write the length
          payload_bytes = bytes(self.payload)
          length = len(payload_bytes) + 8
          bitstream += BitStream('uint:16=%d' % length)
  
          # Write the checksum
          bitstream += BitStream('uint:16=%d' % self.checksum)
  
          return bitstream.bytes + payload_bytes
docs: Create bytes from properties