コード例 #1
0
    def decode(self, packet_bytes):
        packet = PTCPacket()
        source_ip = self.decode_source_ip_on(packet_bytes)
        destination_ip = self.decode_destination_ip_on(packet_bytes)

        transport_bytes = self.get_transport_packet_bytes_from(packet_bytes)
        source_port = self.decode_source_port_on(transport_bytes)
        destination_port = self.decode_destination_port_on(transport_bytes)
        seq_number = self.decode_seq_number_on(transport_bytes)
        ack_number = self.decode_ack_number_on(transport_bytes)
        flags = self.decode_flags_on(transport_bytes)
        window_size = self.decode_window_size_on(transport_bytes)
        data = self.decode_data_on(transport_bytes)

        packet.set_source_ip(source_ip)
        packet.set_destination_ip(destination_ip)
        packet.set_source_port(source_port)
        packet.set_destination_port(destination_port)
        packet.set_seq_number(seq_number)
        packet.set_ack_number(ack_number)
        packet.add_flags(flags)
        packet.set_window_size(window_size)
        packet.set_payload(data)

        return packet
コード例 #2
0
    def decode(self, packet_bytes):
        packet = PTCPacket()        
        source_ip = self.decode_source_ip_on(packet_bytes)
        destination_ip = self.decode_destination_ip_on(packet_bytes)
        
        transport_bytes = self.get_transport_packet_bytes_from(packet_bytes)
        source_port = self.decode_source_port_on(transport_bytes)
        destination_port = self.decode_destination_port_on(transport_bytes)
        seq_number = self.decode_seq_number_on(transport_bytes)
        ack_number = self.decode_ack_number_on(transport_bytes)
        flags = self.decode_flags_on(transport_bytes)
        window_size = self.decode_window_size_on(transport_bytes)
        data = self.decode_data_on(transport_bytes)

        packet.set_source_ip(source_ip)
        packet.set_destination_ip(destination_ip)        
        packet.set_source_port(source_port)
        packet.set_destination_port(destination_port)
        packet.set_seq_number(seq_number)
        packet.set_ack_number(ack_number)
        packet.add_flags(flags)
        packet.set_window_size(window_size)
        packet.set_payload(data)
        
        return packet
コード例 #3
0
ファイル: packet_utils.py プロジェクト: tonchis/redes
 def build(self, payload=None, flags=None, seq=None, ack=None, window=None):
     packet = PTCPacket()
     packet.set_source_ip(self.source_address)
     packet.set_destination_ip(self.destination_address)
     packet.set_source_port(self.source_port)
     packet.set_destination_port(self.destination_port)
     
     if payload is not None:
         packet.set_payload(payload)
     if flags is not None:
         packet.add_flags(flags)
     if seq is not None:
         packet.set_seq_number(seq)
     if ack is not None:
         packet.set_ack_number(ack)
     if window is not None:
         packet.set_window_size(window)       
     
     return packet   
コード例 #4
0
    def build(self, payload=None, flags=None, seq=None, ack=None, window=None):
        packet = PTCPacket()

        packet.set_source_ip(self.source_address)
        packet.set_destination_ip(self.destination_address)
        packet.set_source_port(self.source_port)
        packet.set_destination_port(self.destination_port)

        if payload is not None:
            packet.set_payload(payload)
        if flags is not None:
            packet.add_flags(flags)
        if seq is not None:
            packet.set_seq_number(seq)
        if ack is not None:
            packet.set_ack_number(ack)
        if window is not None:
            packet.set_window_size(window)

        return packet
コード例 #5
0
    def build(self, payload=None, flags=None, seq=None, ack=None):
        packet = PTCPacket()

        source_address = self.control_block.get_source_address()
        source_port = self.control_block.get_source_port()
        dst_address = self.control_block.get_destination_address()
        dst_port = self.control_block.get_destination_port()

        packet.set_source_ip(source_address)
        packet.set_destination_ip(dst_address)
        packet.set_source_port(source_port)
        packet.set_destination_port(dst_port)

        if payload is not None:
            packet.set_payload(payload)
        if flags is not None:
            packet.add_flags(flags)
        if seq is not None:
            packet.set_seq_number(seq)
        if ack is not None:
            packet.set_ack_number(ack)

        return packet
コード例 #6
0
ファイル: common.py プロジェクト: Laski/tdc
    def build(self, payload=None, flags=None, seq=None, ack=None):
        packet = PTCPacket()

        source_address = self.control_block.get_source_address()
        source_port = self.control_block.get_source_port()
        dst_address = self.control_block.get_destination_address()
        dst_port = self.control_block.get_destination_port()
        
        packet.set_source_ip(source_address)
        packet.set_destination_ip(dst_address)
        packet.set_source_port(source_port)
        packet.set_destination_port(dst_port)
        
        if payload is not None:
            packet.set_payload(payload)
        if flags is not None:
            packet.add_flags(flags)
        if seq is not None:
            packet.set_seq_number(seq)
        if ack is not None:
            packet.set_ack_number(ack)            
        
        return packet