# Simulation of Fidelity in Entanglement-Based Networks with Repeater Chains
## 5 Simulation Framework  
According to our model in Figure 1, we have designed and developed a NetSquid simulation setting for EBNs. NetSquid [13] offers a range of foundational classes for the establishment of a quantum network (Figure 2). When coupled with the discrete-event simulation engine PyDnAA, a comprehensive quantum network simulation can be executed. Figure 1: Illustration of a quantum switch. In this case, there is one switch connected to multiple nodes, with one quantum memory position dedicated to each end node. [PERSON] and [PERSON] (highlighted) request communication with the network controller, which has knowledge of the state of the full network. By sharing an Einstein–Podolsky–Rose (EPR) pair with the switch and the action of entanglement swapping, they can establish a virtual link. The lifecycle of a simulation in NetSquid consists of three steps:  
1. A network is constructed by using the subpackages nodes (main network elements) and components (physical elements and models). 2. Protocols are assigned to network nodes to establish the networking behavior. 3. The simulation is compiled in PyDynAA. NetSquid software [[https://netsquid.org/](https://netsquid.org/)]([https://netsquid.org/](https://netsquid.org/)) (28 November 2024) is designed around PyDynAA entities, which are capable of generating and receiving events (class Event in the core of PyDynAA). These events are automatically triggered by the simulation core and have a class type (EventType), which allows to construct event expressions to wait for (EventExpression). A NetSquid protocol is a virtual entity that describes the logic behind a quantum network. There is not a clear notion of layers as in a classical networking architecture. However, a hierarchy can be set up in NetSquid by using protocols and sub-protocols, i.e., a network protocol running on multiple nodes can start sub-protocols that run on one node. Different protocols are coordinated by a signaling mechanism to indicate a status change or announce a result. The physical behavior of a component is described by the Model instances assigned to it, which can specify various classical and quantum physical characteristics, such as transmission delays or noise. Our NetSquid-based simulation setting for EBN uses standard classes in NetSquid for the channels, i.e., the combination of QuantumChannel and ClassicalChannel instances to provide a quantum connection between two nodes by using ports. From these standard connection elements in NetSquid, our EEE module implements a main class to deploy the topology, SetUp_Network and two specific node classes for the logic of end-nodes and switches in the network (EndNode and Switch). Switch inherits from the Node class and adds the attributes (memory and EPR sources) and methods for managing the concurrency of entanglement swapping operations. On the other hand, the EndNode class has the logic associated with an end node. It inherits from the Node class and adds the properties and methods for managing the send buffer (queues) of qubits to be transmitted in the case of an Alice role. Finally, SetUp_Network constructs the network by creating instances for connections, switches, and end-nodes. Figure 2: Overview of software architecture in NetSquid (extracted from [13]). NetSquid protocols are the elements that include the dynamics in the simulation. Three protocols are provided to support EEE in a quantum network: (1) SwapProtocol waits for a qubit in the two associated memory locations, performs a Bell measurement using the SwapCorrectProgram and sends the measurements to the end node; (2) CorrectProtocol, in the end node with the Bob role, receives all the measurements and notifies the coordination protocol; (3) DistilProtocol contains the distillation logic (purification) to be executed in the source and destination nodes. In the NetSquid base code and snippets [13] qrepchain and qswitch, contributions have been aimed at concrete cases that support network architectures in which routing is not possible.