communication_models.rst 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. Communication models
  2. ====================
  3. The network communication in the Modelverse builds on top of the raw socket implementation of Python.
  4. Whereas we use normal HTTP requests, we explicitly opted not to use these libraries.
  5. Many of these libraries hide important implementation details, such as how successive requests are handled (sequential, threaded, ...), whether or not to keep connections open and reuse them, which HTTP version to implement, and so on.
  6. As the HTTP protocol is a simple protocol, we reimplemented it completely in SCCD (StateCharts and Class Diagrams).
  7. There are two network components: a server in the MvS, and a server and client in the MvK.
  8. MvS server
  9. ----------
  10. .. image:: img/mvs_server.svg
  11. The MvS server mainly just waits for incoming HTTP requests and presents the message to the MvS interface itself.
  12. Each part of the processing happens in a seperate orthogonal component, but in all cases, processing happens sequentially, and buffers are implemented in between each layer.
  13. This way, we can be certain that invocations on the MvS will always happen sequentially.
  14. The statechart consists of two parts.
  15. The topmost part is the HTTP server itself, which waits from messages from the sockets.
  16. When it starts up, a socket is created that listens to incoming connections.
  17. Messages from the socket are then processed.
  18. Apart from setting up the sockets, this component serializes all requests that get sent to the MvS: events are placed in a queue, and are only executed on the MvS when it has finished processing the previous request.
  19. The bottommost part is the socket server, which wraps around the socket and keeps fetching from the socket until it gets a complete HTTP request.
  20. The HTTP request is then split from the other data on the socket, and forwarded as a single request to the HTTP server.
  21. We explicitly need to check and split HTTP requests, as our protocol allows users to bundle multiple HTTP requests simultaneously.
  22. These requests will just come one after the other, so the socket buffer might contain two messages at the same time, or even fragments of a second request.
  23. A message is forwarded as soon as it is completely reconstructed.
  24. MvK server
  25. ----------
  26. .. image:: img/mvk_server.svg
  27. .. note::
  28. This figure shows the intended model, not the optimized model.
  29. For performance reasons, many of these parts are merged together in the *run_local_modelverse.py* script.
  30. As a result, it only implements the *MvKController*, *Server*, and *Socket* classes.
  31. A more elaborate statechart implementation also exists, which does implements this whole figure.