示例#1
0
文件: wire.py 项目: madjonr/pyQuic
    def to_bytes(self):

        type_byte = 0xc0

        if self.fin:
            type_byte ^= 0b00100000

        else:
            type_byte ^= 0b00010000

        offset_length = self._get_offset_length()

        if offset_length > 0:
            type_byte ^= offset_length << 2

        stream_id_len = self._get_sream_id_length()
        type_byte ^= stream_id_len

        stream_id = write_int(stream_id_len, self.stream_id)
        offset = write_int(offset_length, self.offset)
        data_len = write_int(2, len(self.payload))

        return write_int(
            1, type_byte) + stream_id + offset + data_len + self.payload
示例#2
0
文件: wire.py 项目: madjonr/pyQuic
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(4, self.error) +
             write_int(2, len(self.reason)) + self.reason)
示例#3
0
文件: wire.py 项目: madjonr/pyQuic
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(4, self.stream_id) +
             write_int(8, self.offset) + write_int(4, self.error))
示例#4
0
文件: wire.py 项目: madjonr/pyQuic
    def to_bytes(self):
        type_byte = 0b10100000
        type_byte ^= 0b00010000
        type_byte ^= 0b00001100  # for simplicity, just use 6 bytes to encode largest_acknowledged
        type_byte ^= 0b00000011  # for simplicity, just use 6 bytes to encode ack_block

        ack_block_section = b''
        ack_block_section += write_int(6, self.ack_blocks[0])

        for gap, ack_block_len in self.ack_blocks[1:]:
            ack_block_section += write_int(1, gap) + write_int(
                6, ack_block_len)

        timestapm_section = b''
        if self.timestapms:
            delta_la, first_time_stamp = self.timestapms[0]
            timestapm_section += write_int(1, delta_la)
            timestapm_section += write_int(4, first_time_stamp)

        for delta_la_n, time_since_prev_n in self.timestapms[1:]:
            timestapm_section += write_int(1, delta_la_n)
            timestapm_section += write_ufloat16(time_since_prev_n)

        return (write_int(1, type_byte) + write_int(1, len(self.ack_blocks)) +
                write_int(1, len(self.timestapms)) +
                write_int(6, self.largest_acknowledged) +
                write_int(2, self.ack_delay) + ack_block_section +
                timestapm_section)
示例#5
0
文件: wire.py 项目: madjonr/pyQuic
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(2, self.sequence) +
             write_int(2, self.connection_id))
示例#6
0
文件: wire.py 项目: madjonr/pyQuic
 def to_bytes(self):
     return self.TYPE_BYTE + write_int(4, self.stream_id)
示例#7
0
文件: wire.py 项目: madjonr/pyQuic
 def to_bytes(self):
     return self.TYPE_BYTE + write_int(4, self.max_data)
示例#8
0
文件: wire.py 项目: madjonr/pyQuic
 def to_bytes(self):
     return (self.TYPE_BYTE + write_int(4, self.largest_client_stream_id) +
             write_int(4, self.largest_server_stream_id))