def to_bytes(self):
        '''
        Create bytes from properties
        '''
        # Verify that the properties make sense
        self.sanitize()

        # Write the next header type
        bitstream = BitStream('uint:8=%d' % self.next_header)

        # Write the header length
        header_length_unpadded = len(self.data) + 4
        header_length = math.ceil(header_length_unpadded / 8.0)
        bitstream += BitStream('uint:8=%d' % (header_length - 1))

        # Add the routing type
        bitstream += BitStream('uint:8=%d' % self.routing_type)

        # Add the segments left
        bitstream += BitStream('uint:8=%d' % self.segments_left)

        # Add the data
        bitstream += BitStream(bytes=self.data)
        padding_len = (8 - (header_length_unpadded % 8)) % 8
        bitstream += BitStream(padding_len * 8)

        return bitstream.bytes + bytes(self.payload)
Create bytes from properties