next up previous contents
Next: Client-to-Client Interface Up: Specification Previous: System Operation   Contents


Message Data Format

Every message will have the form:
<msg version=`x.x'><msgType>...</msgType></msg>
The version number `x.x' is necessary to meet the requirement of different versions of the server being able to co-exist seamlessly. The msgType tag is one of the ones described in tables 3.1, 3.2 and 3.3 and the msgType defines the format of the part of the message represented by ellipsis. If the message requires a signature (e.g. because it is updating some user information or is a message between users) then the message format becomes:
<msg version=`x.x'><msgType>...</msgType><signature>{sig}</signature></msg>


Table 3.4: XML message formats
msgType Message format and Notes
UserInfo See section 3.1.3
serverlist The data part of this message is the list of hostnames and the ports on which they listen for new connections. If the recipient is a server then the message also contains the RTTs between each server and every other server. The encoding is described in section 3.1.2.
reqServerlist None
addServer This message needs to encode the servername and the port of the new server. This is done as:
<hostname>{IP Address}</hostname>
<port>{port}</port>

deleteServer The IP address of the server is inserted between the <deleteServer> and </deleteServer> tags.
updateRTTs Used to inform other servers when one recalculates the RTT between itself and all the other servers.
<hostname>{Source IPAddr}</hostname>
<r{destIPAddr}>{rtt value}</r{destIPAddr}>

disconnect Contains the reason for the disconnection.
ChangeCL See section 3.1.3
newuser The same format as UserInfo.
regNewUser Contains the same fields as a UserInfo message, except for UserID as that is calculated by the server.
eventCounts Acts as a request for all the entries in the recipient's database that have a later timestamp than the sender's records. The message contains two parts, userdb and contactlist, both of which contain a space separated list of userID's and timestamps which represent the current state of the user information database and the contact list database respectively.
changedEntries Sent in response to an eventCounts message. It contains the updated entries requested by the other server. Since each database entry is an XML string which does not need to be parsed by the receiver, each entry is sent as an XML comment which the parser treats as a single unit of textual information which it returns unparsed.
serverID Used to tell the server receiving the connection what port and IP address it should publish to the other servers in the network. The information encoded as:
<hostname>{IP Address}</hostname><port>{port}</port>

error Contains an error message suitable for display to the user.
reqUserInfo &
reqContactList
Requests the user information or contact list of userID specified in the message.


Table 3.4 describes the message format for each type of message. Words between curly braces({}) represents information to be inserted into the message.

The only message which has to encode really complex information is the serverlist message. It would be very easy to represent this information in a format such as: (where the ellipsis represent a data value to insert)

<server><hostname>...</hostname><port>...</port>
<rtt><hostname>...</hostname><value>...</value></rtt> </server>

A serverlist would then consist of one of these server strings for each server in the network. However, in order to provide all this information, the parsing module would have to pass back a tree structure to the calling program. This is quite an overhead when the other message types can be represented in a simple vector object (index $i$ is the tagname, $i+1$ is the text associated with that tag). The message format described above continues to be usable as it is possible to differentiate between servers by reading the array sequentially. However, during development of the server it was observed that it would be much more useful if random access to the elements of a message was possible. This meant converting the MessageParser class to return an STL3.1multimap object. While this improved the efficiency of handling the majority of message types, it rendered this format of the serverlist message unusable as the elements could no longer be processed sequentially. Therefore, a new encoding was chosen:

<h{IPAddr}>{port}</h{IPAddr}>
<r{srcIPAddr}_{destIPAddr}>{RTT value}</r{srcIPAddr}_{destIPAddr}>

The tag names begin with 'h' and 'r' because this was an efficient way of getting around XML not allowing tagnames to begin with a numeric character. For the hostname, the first character is discarded to obtain the IP address and for the RTT information, the tag name is linearly searched for an underscore character and then divided into the source IP address and the destination IP address.



Subsections
next up previous contents
Next: Client-to-Client Interface Up: Specification Previous: System Operation   Contents
Nathan Dimmock 2001-06-20