Connecting to the world - norwegianblues/norwegianblues GitHub Wiki

The simulation can connect to external services and provide services to external clients. There are more than one way to do it, and the obvoius solution is to simply create a socket (an ordinary socket, not a Parrot socket) and connect over that socket.

However, the preferred way is to add a special node, called a proxy node, to the simulation that acts as a bridge between the simulation and the real world. For TCP such a socket is provided in the source: tcp_proxy.py. The point of such a component is to have a configurable means for data to enter and leave the simulation. An excerpt from the config file test_tcp_proxy.json:

    "urn:hodcp:node:server":{
    	"config":{
            "server":"127.0.0.1",
            "port":80
        },
        "interfaces": {
            "eth0": {
                "ip": "10.1.2.2",
                "network": "urn:backplane:subnet:nw"
            }
        },
        "class": "tcp_proxy"
    }

shows that any TCP traffic directed at the node with ip 10.1.2.2 inside the simulation will be forwarded to port 80 on 127.0.0.1 (localhost) in the real world.

By setting "outgoing": true in the config section, the direction of the proxy is reversed, making it possible for a real world client to connect to a server inside the simulation.

N.B. In the outgoing case an extra ip-address is clobbered by the proxy.

Playing with the provided config test_tcp_proxy.json and tcp_proxy.py should give you an idea of how to use it and how to write a more generic proxy component.

⚠️ **GitHub.com Fallback** ⚠️