Skip to content
myaut edited this page Nov 28, 2012 · 5 revisions

JSON-TS is a protocol for communication between server and agent. It uses JSON for message representation, and runs over raw TCP (no HTTP is needed).

Message format

Each message is obviously represented in JSON format, and has one mandatory field: id. For commands it is sequence number of invoked command.

There are three types of messages:

  • Commands:
   "id": ...  
   "cmd": name of the command  
   "msg": { "arg1": { value of arg1 },  
            "arg2": { value of arg2 } ... }  
  } ```
* Responses:   
``` {   
   "id": ...   
   "response": { "arg1": { value of arg1 },   
                "arg2": { value of arg2 } ... }   
  } ```
* Errors:  
` { 
   "id": ...
   "error": "Error message"
  } `

**All messages are null-terminated!**

### Structure of clients

Because of nature of multi-agent environment of vPerfGenerator, traditional RPC protocols are not fit, because they can send requests only in one direction. In JSON-TS, every node may send requests and respond to them, but there is small difference in server and agent behaviour: server listens on socket and accepts connection from everybody, while agent only connects to one dedicated server.

Here is dataflow diagram for JSON-TS client/server/agent:
![JSON-TS](http://funkyimg.com/u2/2711/662/475282vpg-json-ts.png)

Command invocation is synchronious, so it will block invoking thread until response or error message arrive, while incoming commands, response and error to invoked commands are processed in separate threads - receiver (that reads it from socket) and processor (that notifies invoking thread or executes incoming command).
Clone this wiki locally