Protocols

qunetsim.components.protocols._decode_superdense(q1, q2)

Return the message encoded into q1 with the support of q2.

Parameters
  • q1 (Qubit) – The qubit the message is encoded into

  • q1 – The supporting entangled pair

Returns

A string of decoded message.

Return type

(str)

qunetsim.components.protocols._encode_superdense(message, q)

Encode qubit q with the 2 bit message.

Parameters
  • message – the message to encode

  • q – the qubit to encode the message

qunetsim.components.protocols._rec_classical(packet)

Receives a classical message packet , parses it into sequence number and message and sends an ACK message to receiver.

Parameters

packet (Packet) – The packet in which to receive.

Returns

A dictionary consisting of ‘message’ and ‘sequence number’

Return type

dict

qunetsim.components.protocols._rec_epr(packet)

Receives a classical message packet , parses it into sequence number and message and sends an ACK message to receiver.

Parameters

packet (Packet) – The packet in which to receive.

Returns

A dictionary consisting of ‘message’ and ‘sequence number’

Return type

dict

qunetsim.components.protocols._rec_ghz(packet)

Receives a GHZ state and stores it in quantum storage.

Parameters

packet (Packet) – The incoming packet

qunetsim.components.protocols._rec_key(packet)

Receive a QKD key.

Parameters

packet (Packet) – The incoming packet

qunetsim.components.protocols._rec_qubit(packet)

Receive a packet containing qubit information (qubit is transmitted externally)

Parameters

packet (Packet) – The packet in which to receive.

qunetsim.components.protocols._rec_superdense(packet)

Receives a superdense qubit and decodes it.

Parameters

packet (Packet) – The packet in which to receive.

Returns

A dictionary consisting of decoded superdense message and sequence number

Return type

dict

qunetsim.components.protocols._rec_teleport(packet)

Receives a classical message and applies the required operations to EPR pair entangled with the sender to retrieve the teleported qubit.

Parameters

packet (Packet) – The packet in which to receive.

qunetsim.components.protocols._rec_w(packet)

Receives a W state and stores it in quantum storage.

Parameters

packet (Packet) – The incoming packet

qunetsim.components.protocols._relay_message(packet)

Reduce TTL of network packet and if TTL > 0, sends the message to be relayed to the next node in the network and modifies the header.

Parameters

packet (RoutingPacket) – Packet to be relayed

qunetsim.components.protocols._send_ack(sender, receiver, seq_number)

Send an acknowledge message from the sender to the receiver. :param sender: The sender ID :type sender: str :param receiver: The receiver ID :type receiver: str :param seq_number: The sequence number which to ACK :type seq_number: int

qunetsim.components.protocols._send_classical(packet)

Sends a classical message to another host.

Parameters

packet (Packet) – The packet in which to transmit.

qunetsim.components.protocols._send_epr(packet)

Sends an EPR to another host in the network.

Parameters

packet (Packet) – The packet in which to transmit.

qunetsim.components.protocols._send_ghz(packet)

Gets GHZ qubits and distributes the to all hosts. One qubit is stored in own storage.

Parameters

packet (Packet) – The incoming packet

qunetsim.components.protocols._send_qubit(packet)

Transmit the qubit :param packet: The packet in which to transmit. :type packet: Packet

qunetsim.components.protocols._send_superdense(packet)

Encodes and sends a qubit to send a superdense message.

Parameters

packet (Packet) – The packet in which to transmit.

qunetsim.components.protocols._send_teleport(packet)

Does the measurements for teleportation of a qubit and sends the measurement results to another host.

Parameters

packet (Packet) – The packet in which to transmit.

qunetsim.components.protocols._send_w(packet)

Gets W qubits and distributes the to all hosts. One qubit is stored in own storage.

Parameters

packet (Packet) – The incoming packet

qunetsim.components.protocols.encode(sender, receiver, protocol, payload=None, payload_type='', sequence_num=-1, await_ack=False)

Encodes the data with the sender, receiver, protocol, payload type and sequence number and forms the packet with data and the header. :param sender: ID of the sender :type sender: str :param receiver: ID of the receiver :type receiver: str :param protocol: ID of the protocol of which the packet should be processed. :type protocol: str :param payload: The message that is intended to send with the packet. Type of payload depends on the protocol. :param payload_type: Type of the payload. :type payload_type: str :param sequence_num: Sequence number of the packet. :type sequence_num: int :param await_ack: If the sender should await an ACK :type await_ack: bool

Returns

Encoded packet

Return type

(Packet)

qunetsim.components.protocols.process(packet)

Decodes the packet and processes the packet according to the protocol in the packet header.

Parameters

packet (Packet) – Packet to be processed.

Returns

Returns what protocol function returns.