Author:

Anian Kalb 
Supervisor:Prof. Gudrun Klinker, Ph.D.
Advisor:Sandro Weber 
Submission Date:

Abstract

This thesis will explain the implementation of a client node in python for the UBI-Interact framework. The role of the UBII framework is to handle communication in a distributed system. To understand the concrete implementation, the functionality of the framework will first be elaborated. This includes the role of the implemented client node as well as the underlying connection mechanisms, communication protocols, and message formats inside the framework. Through this process, the relevance of concurrency in the context of network communication will analysed. Then, two concrete python implementations for concurrency will be introduced, and the decision behind the choice for one of the concepts will be discussed. Following this, the software structure of this project will be explained, and the process of how the different parts of the python client node implement the required functionality will be elaborated on. The goal of the thesis is to give the reader an understanding of the UBII framework in general as well as language-specific solutions for its specific problems.

Conclusion

UBII is a framework that takes care of communication in distributed systems. This is done with a network of client nodes that produce and consume data and a master node that distributes this data. Multiple ways exist to establish a network connection between the nodes, such as HTTP requests to a REST server and websockets. Once the connection is established, the nodes can communicate data with a publish-subscribe pattern. The choice of communicated data is made via requests between the nodes in a request-response protocol. To share the same data between the different nodes, the framework offers several data structures that define the format of every message. These data structures are defined with protocol buffers, which include their own way of serialization and deserialization. 

Network communication like this always poses the problem of time intensive IO operations when sending messages over a network connection. This duration cannot be optimized by the program but has to be waited for. To work around this delay, python offers multiple concurrency models that allow the execution of different code while the message is being transmitted. With asyncio we have an approach where a concept called event loop schedules different tasks so the delay can be used to run other code in this time. The threading module offers an approach where those IO operations are performed in their own threads, and the operating system schedules the execution of those threads. While the asyncio library offers good functionality with coroutines that can be awaited to time different functions correctly, the threading module offers better usability for the end users of this framework since they do not have to deal with a third-party library. 

To implement all the referred functionality for the python-node-v2 a delegation model is used. The ClientNode class provides the user with the functionality of the node through a number of methods. When such a method is called, the work is delegated to a proxy that determines if the work can be performed locally or if communication with the master node is required. The TopicDataBuffer then performs the local work, and networking related requests are delegated to the NetworkClient. The NetworkClient then creates the necessary objects for the communication and delegates the sending process to the TopicDataClient or ServiceClient in its own thread.

To use the offered functionality in a project the python-node-v2 can be installed with pip and can then be imported and used. This pip package is tested for three python versions on windows and linux.

PDF Thesis

 

Repository

https://github.com/SandroWeber/ubii-node-python-v2