Exemple #1
0
def main():

    # In this example, we are Charlie.
    myName = "Bob"

    # This file defines the network of virtual quantum nodes
    virtualFile = os.environ.get("NETSIM") + "/config/virtualNodes.cfg"

    # This file defines the nodes acting as servers in the classical communication network
    classicalFile = os.path.join(os.path.dirname(__file__), "classicalNet.cfg")

    # Read configuration files for the virtual quantum, as well as the classical network
    virtualNet = networkConfig(virtualFile)
    classicalNet = networkConfig(classicalFile)

    # Check if we should run a local classical server. If so, initialize the code
    # to handle remote connections on the classical communication network
    if myName in classicalNet.hostDict:
        lNode = localNode(classicalNet.hostDict[myName], classicalNet)
    else:
        lNode = None

        # Set up the local classical server if applicable, and connect to the virtual
        # node and other classical servers. Once all connections are set up, this will
        # execute the function runClientNode
    setup_local(myName, virtualNet, classicalNet, lNode, runClientNode)
Exemple #2
0
def main(myName):
    # This file defines the network of virtual quantum nodes
    virtualFile = os.environ.get("NETSIM") + "/config/virtualNodes.cfg"

    # This file defines the network of CQC servers interfacing to virtual quantum nodes
    cqcFile = os.environ.get("NETSIM") + "/config/cqcNodes.cfg"

    # Read configuration files for the virtual quantum, as well as the classical network
    virtualNet = networkConfig(virtualFile)
    cqcNet = networkConfig(cqcFile)

    # Check if we are in the host-dictionary
    if myName in cqcNet.hostDict:
        myHost = cqcNet.hostDict[myName]
        cqc_factory = CQCFactory(myHost, myName, cqcNet, SimulaqronCQCHandler)
    else:
        logging.error(
            "LOCAL %s: Cannot start classical communication servers.", myName)
        return

        # Connect to the local virtual node simulating the "local" qubits
    connect_to_virtNode(myName, cqc_factory, virtualNet)

    # Run reactor
    reactor.run()
Exemple #3
0
def main():

    # Read config file
    config = networkConfig("../../../config/virtualNodes.cfg")

    # We are Alice
    myName = "Alice"

    # Connect to the local virtual Node
    node = config.hostDict[myName]
    factory = pb.PBClientFactory()
    reactor.connectTCP(node.hostname, node.port, factory)
    def1 = factory.getRootObject()
    def1.addCallback(got_root)
    def1.addErrback(err_obj1)
    reactor.run()
Exemple #4
0
def main(names):
    # This file defines the network of CQC servers interfacing to virtual quantum nodes
    cqcFile = os.environ.get("NETSIM") + "/config/cqcNodes.cfg"

    # Read configuration files for the virtual quantum, as well as the classical network
    cqcNet = networkConfig(cqcFile)

    # Check if we are in the host-dictionary
    myHosts = {}
    cqc_factories = {}
    for myName in names:
        if myName in cqcNet.hostDict:
            myHosts[myName] = cqcNet.hostDict[myName]
            cqc_factories[myName] = CQCFactory(myHosts[myName], myName, cqcNet, CQCLogMessageHandler)
        else:
            logging.error("LOCAL %s: Cannot start classical communication servers.", myName)
            return

    setup_CQC_server(names, myHosts, cqc_factories)

    # Run reactor
    reactor.run()
Exemple #5
0
def init(name, cqcFile=None):
    """
    Initialize a connection to the cqc server with the name given as input.
    A path to a configure file for the cqc network can be given,
    if it's not given the config file '$NETSIM/config/cqcNodes.cfg' will be used.
    Returns a socket object.
    """

    # This file defines the network of CQC servers interfacing to virtual quantum nodes
    if cqcFile is None:
        cqcFile = os.environ.get("NETSIM") + "/config/cqcNodes.cfg"

        # Read configuration files for the cqc network
    cqcNet = networkConfig(cqcFile)

    # Host data
    if name in cqcNet.hostDict:
        myHost = cqcNet.hostDict[name]
    else:
        logging.error("The name '%s' is not in the cqc network.", name)
        raise LookupError(
            "The name '%s' is not in the cqc network.".format(name))

    addr = myHost.addr

    # Connect to cqc server and run protocol
    cqc = None
    try:
        cqc = socket.socket(addr[0], addr[1], addr[2])
    except socket.error:
        logging.error("Could not connect to cqc server: %s", name)
    try:
        cqc.connect(addr[4])
    except socket.error:
        cqc.close()
        logging.error("Could not connect to cqc server: %s", name)
    return cqc
Exemple #6
0
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#    This product includes software developed by Stephanie Wehner, QuTech.
# 4. Neither the name of the QuTech organization nor the
#    names of its contributors may be used to endorse or promote products
#    derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


from SimulaQron.general.hostConfig import networkConfig

newNet = networkConfig("network.cfg")

newNet.print_details("Alice")
newNet.print_details("Bob")
newNet.print_details("Charlie")