NG Design Document/Viewer Architecture/Networking
From Rex community wiki
Introduction
The initial networking layer in the new viewer follows closely the current OpenSim protocol. The network layer will be implemented as a pluggable module, to later on allow building connectivity modules onto other VW worlds as well.
In the initial implementation of the OpenSim network layer, the following design decisions were made:
- The viewer networking is based on POCO C++ Libraries. It provides low- and mid-level networking functionality for TCP and UDP sockets. Other modules may access underlying POCO as well if necessary.
- To implement the required XMLRPC and HTTP layers, the libraries xmlrpc-epi and curl are used. To keep the system consistent, other modules requiring e.g. HTTP transport are encouraged to use these libraries as well, although it is not enforced.
- Design for virtual world protocol plugins. Later on the system may be extended to support a protocol for connecting to other virtual world servers, like VastPark. The OpenSim protocol is the initial goal.
Low level network interface for communicating with Modular realXtend
The implementation is based on the idea that the application-layer (UDP) protocol is specified by data, instead of hard-coding it into code. This allows easy changing of the packet data format and adding new custom packet types later on, and it also functions as a form of documentation of the protocol. Also a particularly nice feature about this is that we can do "reflection" (runtime examination of the packet type and contents) on all packets using a simple and straightforward API.
The core protocol works using two different methods. XMLRPC (over HTTP) is used to perform the initial connection handshake and login, which is followed by a stream of UDP messaging, until the client disconnects. Our low-level connection library encompasses both of these and provides the client with a suitable application-level interface.
The library is based around two "active" classes, NetMessageManager and PocoXMLRPCConnection, that provide the application with the capabilities to connect to an OpenSim world. The classes drawn in gray contain data or represent resources and don't perform any global state changes or communications of their own. The red packages represent dependencies to external open source libraries.
NetMessageManager
NetMessageManager handles a single bidirectional UDP communication channel between the client and the server. It implements the necessary low-level OpenSim UDP protocol features, like trusted transmission, reliability, resending of packets, pinging and so forth. It also provides a way for the application to receive and send properly crafted message packets, as defined by the common protocol data file.
Receiving packets is implemented through the INetMessageListener interface. The manager notifies this listener for all new packets. The NetInMessage structure is the object that contains the message, and to examine the received packet the application uses the methods of NetInMessage to query both the type and content of the message.
In order to send out messages, the application uses the NetOutMessage structure. The methods of NetOutMessage allow the application to add in all the data to be send, and finally the application calls FinishMessage() to send out the message.
PocoXMLRPCConnection
To perform the initial XMLRPC login, the application uses the PocoXMLRPCConnection class. It handles the crafting of the request and serializes it over the network. When the reply is received, PocoXMLRPCConnection interprets it and passes it back to the application in a readable form.
This part of the design will be augmented later on with proper security and identity features (OpenID being currently investigated).
Future Work
Review of the current design has not raised any major issues and is considered suitable due to its simplicity. The proposed design is expected to work fine in the current server/protocol model, partially because it allows adding new packets easily to the protocol. One of the concerns was whether this implementation would later on work for connecting to a totally different virtual world system that is using a different protocol, but it was seen more effective in that case to write another specialized protocol stack from scratch rather than trying to build too many abstractions for unknown systems in mind.
In the future work is needed on technical details regarding reusability of the XMLRPC and HTTP libraries, which are systems that will be used by other parts of reX-NG as well and not only by the core communications module. Also, the identification/authentication module is missing and needs to be designed and implemented. There are also few (currently inconsequential) features of the low-level protocol that are not supported yet, partly due to OpenSim and partly because of other reasons.
|