How to communicate with an E-Chord network

This guide describes the process by which you can communicate with an active E-Chord network.

Connection

In order to connect to the network, you need the address of some node that is part of it. This consists of a tuple of the IP address and the port number of the node. To connect to the network, open a TCP socket to that address.

Requests

Once you've done this, you are expected to send a request. E-Chord refers to any network message that asks a node to perform an action as a request.

Requests are serialized JSON objects of the following format:

{
    "header": {
        "type": TYPE
    },
    "body": {
        ...
    }
}

The request header needs to contain a request type. TYPE is a string representing that type.

Each request type has certain parameters that need to be included with it. Those should be placed in the request body, with their corresponding values.

For a full list of available request types and their required parameters, refer to the communication reference guide.

Note that only the first few request types, as pointed out by the reference guide, are meant for ordinary use. Others are debugging related, while the rest consist of internal requests that should normally only be used between the nodes themselves. Use those at your own risk.

Responses

E-Chord refers to anything returned to the sender after a request as a response. Responses generally follow the same format as a request:

{
    "header": {
        "status": STATUS
    },
    "body": {
        ...
    }
}

As such, responses are also serialized JSON objects.

The response header always contains a status. STATUS is an integer, representing that status.

If the request that triggered this response asked for data and data retrieval was successful according to the status, that data will be contained in the response body.

The reference guide mentioned before also contains the expected response(s) for any given request type.

Once you get a response to your request, you are generally free to close the connection.