Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>quisp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
310 changes: 103 additions & 207 deletions quisp/.cproject

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions quisp/.tmp16996
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out/clang-release//channels/QuantumChannel.o out/clang-release//modules/dummyModule.o out/clang-release//modules/Application/Application.o out/clang-release//modules/Common/Queue.o out/clang-release//modules/Common/Router.o out/clang-release//modules/PhysicalConnection/BSA/BellStateAnalyzer.o out/clang-release//modules/PhysicalConnection/BSA/HoMController.o out/clang-release//modules/PhysicalConnection/EPPS/EntangledPhotonPairSource.o out/clang-release//modules/PhysicalConnection/EPPS/SPDC_Controller.o out/clang-release//modules/QNIC/PhotonicSwitch/PhotonicSwitch.o out/clang-release//modules/QNIC/StationaryQubit/StationaryQubit.o out/clang-release//modules/QRSA/ConnectionManager/ConnectionManager.o out/clang-release//modules/QRSA/HardwareMonitor/HardwareMonitor.o out/clang-release//modules/QRSA/RealTimeController/RealTimeController.o out/clang-release//modules/QRSA/RoutingDaemon/RoutingDaemon.o out/clang-release//modules/QRSA/RuleEngine/BellPairStore.o out/clang-release//modules/QRSA/RuleEngine/RuleEngine.o out/clang-release//rules/Condition.o out/clang-release//rules/example.o out/clang-release//rules/Rule.o out/clang-release//rules/RuleSet.o out/clang-release//rules/actions/Action.o out/clang-release//rules/actions/DoublePurifyAction.o out/clang-release//rules/actions/DoubleSelectionAction.o out/clang-release//rules/actions/DoubleSelectionDualAction.o out/clang-release//rules/actions/DoubleSelectionDualActionSecond.o out/clang-release//rules/actions/GeneralizedSwappingAction.o out/clang-release//rules/actions/PurifyAction.o out/clang-release//rules/actions/RandomMeasureAction.o out/clang-release//rules/actions/SimultaneousSwappingAction.o out/clang-release//rules/actions/SwappingAction.o out/clang-release//rules/clauses/EnoughResourceClause.o out/clang-release//rules/clauses/FidelityClause.o out/clang-release//rules/clauses/MeasureCountClause.o out/clang-release//rules/clauses/PurificationCountClause.o out/clang-release//rules/clauses/WaitClause.o out/clang-release//test_utils/Gate.o out/clang-release//test_utils/QNode.o out/clang-release//test_utils/Simulation.o out/clang-release//test_utils/StaticEnv.o out/clang-release//test_utils/UtilFunctions.o out/clang-release//utils/ComponentProvider.o out/clang-release//utils/DefaultComponentProviderStrategy.o out/clang-release//PhotonicQubit_m.o out/clang-release//messages/base_messages_m.o out/clang-release//messages/connection_setup_messages_m.o out/clang-release//messages/entanglement_swapping_messages_m.o out/clang-release//messages/HoM_ipc_messages_m.o out/clang-release//messages/link_generation_messages_m.o out/clang-release//messages/purification_messages_m.o out/clang-release//messages/QNode_ipc_messages_m.o out/clang-release//messages/tomography_messages_m.o
Binary file added quisp/.tmplib16996
Binary file not shown.
5 changes: 5 additions & 0 deletions quisp/messages/connection_setup_messages.msg
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ packet ConnectionSetupRequest extends Header
int stack_of_QNodeIndexes[];
int stack_of_linkCosts[];
QNIC_pair_info stack_of_QNICs[];

int number_of_clients;
}

packet RejectConnectionSetupRequest extends Header
Expand All @@ -41,4 +43,7 @@ packet ConnectionSetupResponse extends Header
RuleSetField RuleSet;
int application_type;
int stack_of_QNodeIndexes[];

bool isMultipartite;
string label;
}
18 changes: 18 additions & 0 deletions quisp/messages/entanglement_swapping_messages.msg
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,21 @@ packet SimultaneousSwappingResult extends Header{
int index_in_path;
int path_length_exclude_IR;
}

packet GeneralizedSwappingResult extends Header{
unsigned long RuleSet_id;
unsigned long Rule_id;
int action_index;
bool is_for_root; //maybe soon to be obsolete

int measurement_result;
int number_of_corr;
int correction_type;
string label;

//Used only for internal communication
int size_of_arrays;
int responder_dests[];
int responder_number_of_corr[];
int measurement_results[];
}
40 changes: 39 additions & 1 deletion quisp/modules/Application/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Application::Application() : provider(utils::ComponentProvider{this}) {}
*/
void Application::initialize() {
// Since we only need this module in EndNode, delete it otherwise.

if (!gate("toRouter")->isConnected()) {
deleteThisModule *msg = new deleteThisModule("DeleteThisModule");
scheduleAt(simTime(), msg);
Expand All @@ -36,6 +37,7 @@ void Application::initialize() {
WATCH_VECTOR(other_end_node_addresses);
storeEndNodeAddresses();


if (!is_e2e_connection) {
return;
}
Expand Down Expand Up @@ -70,7 +72,30 @@ void Application::initialize() {
scheduleAt(simTime() + 0.00001 * my_address, pk);
return;
}

/*
Simple GHZ distribution setup, not logic to have number_of_clients sent by clients.
The Lone initiator should send a message to itself to define the number of clients,
clients should send a setup request with a bool (and not a int) specifying the connection
is multipartite. This is to ensure, QNIC are locked not in the setup phase but on the response phase.
*/
if (traffic_pattern == 3) {
int initiator_adress = par("LoneInitiatorAddress");
int number_of_clients = par("NumberOfClients");
if (my_address != initiator_adress) {

EV_INFO << "My multipartite connection setup request will be sent from " << my_address << " to " << initiator_adress << "\n";
EV_INFO << number_of_clients;
ConnectionSetupRequest *pk = createMultiConnectionSetupRequest(initiator_adress, number_of_resources, number_of_clients);
// delay to avoid conflict
scheduleAt(simTime() + 0.00001 * my_address, pk);
} else {
EV_INFO << "Initiator setup" << "\n";
ConnectionSetupRequest *pk = createMultiConnectionSetupRequest(initiator_adress, number_of_resources, number_of_clients);
// delay to avoid conflict
scheduleAt(simTime() + 0.00001 * my_address, pk);
}
return;
}
error("Invalid TrafficPattern specified.");
}

Expand All @@ -86,9 +111,22 @@ ConnectionSetupRequest *Application::createConnectionSetupRequest(int dest_addr,
pk->setSrcAddr(my_address);
pk->setNum_measure(num_measure);
pk->setKind(7);
pk->setNumber_of_clients(1); //CM
return pk;
}

//CM
ConnectionSetupRequest *Application::createMultiConnectionSetupRequest(int dest_addr, int num_of_required_resources, int number_of_clients) {
ConnectionSetupRequest *pk = new ConnectionSetupRequest("ConnSetupRequest");
pk->setActual_srcAddr(my_address);
pk->setActual_destAddr(dest_addr);
pk->setDestAddr(my_address);
pk->setSrcAddr(my_address);
pk->setNum_measure(num_measure);
pk->setKind(7);
pk->setNumber_of_clients(number_of_clients); // CM
return pk;
}
/**
* \brief Message handler
*
Expand Down
1 change: 1 addition & 0 deletions quisp/modules/Application/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Application : public IApplication {
int getOneRandomEndNodeAddress();

messages::ConnectionSetupRequest *createConnectionSetupRequest(int dest_addr, int num_of_required_resources);
messages::ConnectionSetupRequest *createMultiConnectionSetupRequest(int dest_addr, int num_of_required_resources, int number_of_clients);
utils::ComponentProvider provider;
};

Expand Down
2 changes: 2 additions & 0 deletions quisp/modules/Application/Application.ned
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ simple Application
// int TrafficPattern = default(1);
int TrafficPattern;
int LoneInitiatorAddress;
int NumberOfResources = default(1);
int NumberOfClients;
int distant_measure_count = default(7000);
// Maybe don't have to set the default here.

Expand Down
52 changes: 28 additions & 24 deletions quisp/modules/Common/Router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Router : public cSimpleModule {

protected:
virtual void initialize(int stage) override;
virtual void handleMessage(cMessage *msg) override;
virtual void handleMessage(cMessage* msg) override;
virtual int numInitStages() const override { return 1; };
};

Expand All @@ -37,13 +37,13 @@ void Router::initialize(int stage) {
myAddress = getParentModule()->par("address");

// Topology creation for routing table
cTopology *topo = new cTopology("topo");
cTopology* topo = new cTopology("topo");
topo->extractByParameter("includeInTopo", "\"yes\""); // Any node that has a parameter includeInTopo will be included in routing
if (topo->getNumNodes() == 0 || topo == nullptr) { // If no node with the parameter & value found, do nothing.
return;
}

cTopology::Node *thisNode = topo->getNodeFor(getParentModule()); // The parent node with this specific router
cTopology::Node* thisNode = topo->getNodeFor(getParentModule()); // The parent node with this specific router

int number_of_links_total = 0;

Expand Down Expand Up @@ -80,7 +80,7 @@ void Router::initialize(int stage) {
// Check the number of shortest paths towards the target node. This may be more than 1 if multiple paths have the same minimum cost.
if (thisNode->getNumPaths() == 0) continue; // not connected

cGate *parentModuleGate = thisNode->getPath(0)->getLocalGate(); // Returns the next link/gate in the ith shortest paths towards the target node.
cGate* parentModuleGate = thisNode->getPath(0)->getLocalGate(); // Returns the next link/gate in the ith shortest paths towards the target node.
int gateIndex = parentModuleGate->getIndex();
int address = topo->getNode(i)->getModule()->par("address");
rtable[address] = gateIndex; // Store gate index per destination from this node
Expand All @@ -96,83 +96,87 @@ void Router::initialize(int stage) {
delete topo;
}

void Router::handleMessage(cMessage *msg) {
void Router::handleMessage(cMessage* msg) {
// check the header of the received package
Header *pk = check_and_cast<Header *>(msg);
Header* pk = check_and_cast<Header*>(msg);
int destAddr = pk->getDestAddr(); // read destination from the packet
int who_are_you = pk->getKind(); // read the type of packet // This might be better fixed

if (destAddr == myAddress && who_are_you == 1) { // If destination is this node: Path selection
send(pk, "toApp"); // send to Application locally
return;
} else if (destAddr == myAddress && dynamic_cast<BSMtimingNotifier *>(msg) != nullptr) { // Timing for BSM
} else if (destAddr == myAddress && dynamic_cast<BSMtimingNotifier*>(msg) != nullptr) { // Timing for BSM
bubble("Timing Notifier from HoM (stand-alone or internal) received");
send(pk, "rePort$o"); // send to Application locally
return;
} else if (destAddr == myAddress && dynamic_cast<EPPStimingNotifier *>(msg) != nullptr) { // Timing for BSM
} else if (destAddr == myAddress && dynamic_cast<EPPStimingNotifier*>(msg) != nullptr) { // Timing for BSM
bubble("Timing Notifier from EPPS received");
send(pk, "rePort$o"); // send to Application locally
return;
} else if (destAddr == myAddress && dynamic_cast<ConnectionSetupRequest *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<ConnectionSetupRequest*>(msg) != nullptr) {
bubble("Connection setup request received");
send(pk, "cmPort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<ConnectionSetupResponse *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<ConnectionSetupResponse*>(msg) != nullptr) {
bubble("Connection setup response received");
send(pk, "cmPort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<RejectConnectionSetupRequest *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<RejectConnectionSetupRequest*>(msg) != nullptr) {
bubble("Reject connection setup response received");
send(pk, "cmPort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<InternalRuleSetForwarding *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<InternalRuleSetForwarding*>(msg) != nullptr) {
bubble("Internal RuleSet Forwarding packet received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<InternalRuleSetForwarding_Application *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<InternalRuleSetForwarding_Application*>(msg) != nullptr) {
bubble("Internal RuleSet Forwarding Application packet received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<SwappingResult *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<SwappingResult*>(msg) != nullptr) {
bubble("Swapping Result packet received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<SimultaneousSwappingResult *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<SimultaneousSwappingResult*>(msg) != nullptr) {
bubble("Swapping Result packet received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyRequest *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyRequest*>(msg) != nullptr) {
bubble("Link tomography request received");
send(pk, "hmPort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyAck *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyAck*>(msg) != nullptr) {
bubble("Link tomography ack received");
send(pk, "hmPort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyRuleSet *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyRuleSet*>(msg) != nullptr) {
bubble("Link tomography rule set received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyResult *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<LinkTomographyResult*>(msg) != nullptr) {
bubble("Link tomography result received");
send(pk, "hmPort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<PurificationResult *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<PurificationResult*>(msg) != nullptr) {
bubble("Purification result received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<DoublePurificationResult *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<DoublePurificationResult*>(msg) != nullptr) {
bubble("DoublePurification result received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<DS_DoublePurificationResult *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<DS_DoublePurificationResult*>(msg) != nullptr) {
bubble("DS_DoublePurification result received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<DS_DoublePurificationSecondResult *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<DS_DoublePurificationSecondResult*>(msg) != nullptr) {
bubble("DS_DoublePurificationSecond result received");
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<StopEmitting *>(msg) != nullptr) {
} else if (destAddr == myAddress && dynamic_cast<StopEmitting*>(msg) != nullptr) {
send(pk, "rePort$o");
return;
} else if (destAddr == myAddress && dynamic_cast<GeneralizedSwappingResult*>(msg) != nullptr) {
send(pk, "rePort$o");
return;
}
Expand Down
6 changes: 4 additions & 2 deletions quisp/modules/PhysicalConnection/BSA/BellStateAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void BellStateAnalyzer::initialize() {
error_rate = par("error_rate");
// duration = par("duration");
required_precision = par("required_precision");
//CM Waiting for a better solution
//required_precision = 0.00001;
left_arrived_at = -1;
right_arrived_at = -1;
left_last_photon_detected = false;
Expand Down Expand Up @@ -348,8 +350,8 @@ void BellStateAnalyzer::forDEBUG_countErrorTypes(cMessage *msg) {
count_I++;
}
count_total++;
EV << "Y%=" << (double)count_Y / (double)count_total << ", X%=" << (double)count_X / (double)count_total << ", Z%=" << (double)count_Z / (double)count_total
<< ", L%=" << (double)count_L / (double)count_total << ", I% =" << (double)count_I / (double)count_total << "\n";
//EV << "Y%=" << (double)count_Y / (double)count_total << ", X%=" << (double)count_X / (double)count_total << ", Z%=" << (double)count_Z / (double)count_total
// << ", L%=" << (double)count_L / (double)count_total << ", I% =" << (double)count_I / (double)count_total << "\n";
}

bool BellStateAnalyzer::isPhotonLost(cMessage *msg) {
Expand Down
3 changes: 2 additions & 1 deletion quisp/modules/PhysicalConnection/BSA/BellStateAnalyzer.ned
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ simple BellStateAnalyzer
double loss_rate = default(0);
double error_rate = default(0);
double duration = default(0);
double required_precision = default(1.5e-9);
// double required_precision = default(1.5e-9); CM
double required_precision = default(1.5e-5);
int photon_detection_per_sec = default(10000);
int address;
@signal[Num_Bell_state](type=long);
Expand Down
Empty file.
13 changes: 8 additions & 5 deletions quisp/modules/QNIC/StationaryQubit/IStationaryQubit.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ namespace quisp {

namespace types {
enum class MeasureXResult : int {
NO_ERROR,
HAS_Z_ERROR,
NO_X_ERROR,
HAS_X_ERROR,
};
enum class MeasureYResult : int {
NO_ERROR,
NO_Y_ERROR,
HAS_XZ_ERROR,
};
enum class MeasureZResult : int {
NO_ERROR,
HAS_X_ERROR,
NO_Z_ERROR,
HAS_Z_ERROR,
};
} // namespace types

Expand Down Expand Up @@ -169,6 +169,9 @@ class IStationaryQubit : public cSimpleModule {
int qnic_address;
int qnic_type;
int qnic_index;
//CM
bool is_in_multipartite = false;
std::string label = "";

int action_index;
bool no_density_matrix_nullptr_entangled_partner_ok;
Expand Down
15 changes: 8 additions & 7 deletions quisp/modules/QNIC/StationaryQubit/StationaryQubit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ void StationaryQubit::setTwoQubitGateErrorCeilings(TwoQubitGateErrorModel &model
MeasureXResult StationaryQubit::measure_X() {
applySingleQubitGateError(Measurement_error);
if (par("GOD_Zerror").boolValue()) {
return MeasureXResult::HAS_Z_ERROR;
return MeasureXResult::HAS_X_ERROR;
}
return MeasureXResult::NO_ERROR;
return MeasureXResult::NO_X_ERROR;
}

MeasureYResult StationaryQubit::measure_Y() {
Expand All @@ -236,15 +236,16 @@ MeasureYResult StationaryQubit::measure_Y() {
if (error) {
return MeasureYResult::HAS_XZ_ERROR;
}
return MeasureYResult::NO_ERROR;
return MeasureYResult::NO_Y_ERROR;
return MeasureYResult::NO_Y_ERROR;
}

MeasureZResult StationaryQubit::measure_Z() {
applySingleQubitGateError(Measurement_error);
if (par("GOD_Xerror")) {
return MeasureZResult::HAS_X_ERROR;
return MeasureZResult::HAS_Z_ERROR;
}
return MeasureZResult::NO_ERROR;
return MeasureZResult::NO_Z_ERROR;
}

// Convert X to Z, and Z to X error. Therefore, Y error stays as Y.
Expand Down Expand Up @@ -539,7 +540,7 @@ bool StationaryQubit::Xpurify(IStationaryQubit *resource_qubit /*Controlled*/) {
applyMemoryError();
check_and_cast<StationaryQubit *>(resource_qubit)->applyMemoryError();
/*Target qubit*/ this->CNOT_gate(resource_qubit /*controlled qubit*/);
bool meas = this->measure_Z() == MeasureZResult::NO_ERROR;
bool meas = this->measure_Z() == MeasureZResult::NO_Z_ERROR;
return meas;
}

Expand All @@ -549,7 +550,7 @@ bool StationaryQubit::Zpurify(IStationaryQubit *resource_qubit /*Target*/) {
check_and_cast<StationaryQubit *>(resource_qubit)->applyMemoryError();
/*Target qubit*/ resource_qubit->CNOT_gate(this /*controlled qubit*/);
this->Hadamard_gate();
bool meas = this->measure_Z() == MeasureZResult::NO_ERROR;
bool meas = this->measure_Z() == MeasureZResult::NO_Z_ERROR;
return meas;
}

Expand Down
Loading