The Simspark Agent Proxy is a proxy for client agents, connecting to the Simspark server. Its main purpose is to ensure independence of network issues/delays, by monitoring think cycle times of agents on the client machine. The proxy is developed using Java 1.6. It should be compatible with older JREs, too, but this is not verified.
- Command Line Interface
- Command Line Parameter
- Clone the repository:
git clone https://github.com/magmaOffenburg/magmaProxy.
- Make sure you have Java installed and available on your command line.
- Make sure you have simspark and rcsserver3d installed and the command
rcssserver3dis available on your command line.
- The proxy itself does not require an installation.
For contributions, please set up
clang-format as described here.
Before you can use the proxy, you have to configure the soccer server to run in sync mode.
agentSyncMode in the config file of the server
~/.simspark/spark.rb to true.
The process of running a soccer game with the proxy is as follows:
- Start the server on the server computer with
- Start a proxy instance on each client computer (see below).
- Start the agents making sure they get the proxy port passed to the
To simplify starting of the proxy, a start script is provided:
bash start.sh <simspark-server-IP> <simspark-server-Port> <proxy-server-port>
<simspark-server-IP>: IP address of the soccer server.
<simspark-server-Port>: Port of the soccer server.
<proxy-server-port>: Port on the proxy's machine to which the players have to connect.
Command Line Interface
The following commands are provided when the proxy is running:
- "q", or "quit" : Shutdown the proxy server and exit the program
- "l", or "list" : List active agent proxy instances
- "s", or "status" : Print proxy live status and list of all agent proxy instances
- "v", or "verbose" : Verbosly list active agent proxies
- "m" : Switch on/off printing start of all client messages
- "n" : Switch on/off printing start of all server messages
To simplify agent and server programming, the presence of an agent proxy should be transparent and not require any additional code on any side. In this concept, a proxy server instance wraps connections to one specific SimSpark server. Each incoming connection is assigned to a new agent proxy instance, which handles all proxy communication for the assigned connection. The agent proxy instance itself consists of two threads, one for forwarding server perception messages and maintaining sync-times and one for forwarding agent action messages. In this concept, maintaining the response time of agents is done by simply waiting 20ms after forwarding a perception message to the agent, before sending a "sync"-command back to the server in one thread, while the other thread keeps directly forwarding action messages from the agent. In order to stay synchronized with the SimSpark server, the perception messages forwarding thread always has to first forward all pending perception messages from the server, before waiting and responding with the next "sync"-command.
This concept is simple, transparent for client and server and dynamic with respect to the amount of connections. It restores synchronization (needed during the startup) and treats each connected agent equally. The time measurement is as accurate as the sleep command of the underlying platform. If the sleep command is not considered precise enough, this concept can be easily extended to suppress the forwarding of action messages after the specified time, until the next "sync"-command has been send.
The SimSpark Agent Proxy is implemented in Java and separated across four classes: SAProxy, SimsparkAgentProxyServer, AgentProxy and Connection.
The SAProxy class contains the main function and provides a command line interface to monitor the proxy server. It currently only maintains one proxy server instance.
The SimsparkAgentProxyServer is the actual proxy server thread. It listens to a specified port and creates an AgentProxy instance for each incoming connection request.
The AgentProxy then establishes a connection to the SimSpark server and starts two threads: ServerPerceptionsForwarder and ClientActionsForwarder. The first thread simply forwards all pending perception messages to the local client agent, sleeps for 20ms and then sends a "sync"-command to the SimSpark server. Similarly, the second thread directly forwards incoming action messages from the client agent, after removing all "sync"-commands from the respective action messages.
The Connection class handles message sending and receiving through sockets
Command Line Parameter
The SimSpark Agent Proxy has following command line parameters:
--server=<ip>: The SimSpark server host
--serverport=<port>: The SimSpark server port
--proxyport=<port>: The proxy server port for incoming connections
--verbose: Prints the messages of all agents