technology-decisions.tex 12 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. In order to meet the requirements of the concept best, a detailed consideration of the technology to be used is necessary. These decisions include the application framework itself and libraries and protocols for data exchange in a \ac{P2P} network. Basically, there are two conceivable approaches for the \ac{P2P} network:
  2. \begin{itemize}
  3. \item The creation and buildup of a separate \ac{P2P} network connecting the hybrid clients
  4. \item The use of an existing \ac{P2P} network for own purpose
  5. \end{itemize}
  6. \subsection{Creation of a \ac{P2P} Network}
  7. \label{sec:create-p2p-network}
  8. The advantage of having an extra \ac{P2P} network is that it is completely under control. Accordingly, it can be designed to fit exactly to the use case and require little or no compromise. However, setting up a \ac{P2P} network is a big challenge and some hurdles must be overcome. These challenges include peer discovery (how peers find each other), global data exchange over the Internet and data storage, and availability of the stored data. In addition, all these requirements must scale. It should work for \ac{P2P} networks with only a few peers and also for a few thousand or even more peers. In the following, we discuss two options to create the P2P network:
  9. \begin{itemize}
  10. \item The use of an established standard such as Wi-Fi Dircet and \ac{WebRTC}
  11. \item The use of a library (e.g., Hive2Hive, Yjs) to create a dedicated \ac{P2P} network
  12. \end{itemize}
  13. \subsubsection{Wi-Fi Direct}
  14. \label{sec:wifi-direct}
  15. Wi-Fi Direct is a standard (IEEE 802.11) for data transmission between two WLAN terminals. There is no need for an access point between the two devices. However, the distance that may lie between the two peers is thus limited. Without obstacles, which contribute to the attenuation of the signal, a distance of up to 200\,m is possible \cite{wifiXXXXdistance}. However, the requirement for the \ac{P2P} network to expand Twitter is different. Users can be scattered around the world and may be online through the mobile network. There is no \ac{P2P} connection via Wi-Fi Dircet possible in this case.
  16. \subsubsection{\ac{WebRTC}}
  17. \label{sec:webrtc}
  18. \ac{WebRTC} is an open standard\footnote{https://www.w3.org/TR/webrtc/} that provides various communication protocols for real-time communication between two or more peers. Above all, \ac{WebRTC} is popular for its ability to easily perform video calls, as known from Skype, in the browser without a server. Additionally it allows file transfer between peers. In a separate \ac{P2P} network, data could be exchanged between the clients. However, the connection between the clients is complex, beside two peers also a \ac{STUN} server and optionally a \ac{TURN} server is involved. Furthermore, it is unclear whether the system scales.
  19. \subsubsection{Yjs}
  20. \label{sec:yjs}
  21. The JavaScript library Yjs\footnote{https://github.com/y-js/yjs} describes itself as \enquote{a framework for offline-first \ac{P2P} shared editing on structured data-like text, richtext, \ac{JSON}, or \ac{XML}}\cite{yjsXXXXrepo}. The library takes care of solving synchronization conflicts when editing distributed files. By choosing a connector, you can set the protocol for the communication between the peers. There is the possibility to use \ac{WebRTC}, \ac{XMPP} or websockets, but with some connectors running a server is a prerequisite. Further extensions can be used to supplement a database and data types, but the focus here is on the joint editing of data by multiple peers. For all connectors, the authors of the library recommend using an own server. Yjs is released under the MIT license.
  22. \subsubsection{Hive2Hive}
  23. \label{sec:hive2hive}
  24. Hive2Hive\footnote{https://github.com/Hive2Hive/Hive2Hive} is a Java library for \enquote{secure, distributed, \ac{P2P}-based file synchronization and sharing}\cite{hive2hiveXXXXrepo}. There is no less promise than \enquote{a free and open-sourced, distributed and scalable solution that focuses on maximum security and privacy of both users and data}\cite{hive2hiveXXXXrepo}. In order to be able to use Hive2Hive globally via the Internet, it is necessary to operate at least one relay peer - five are recommended for sufficient data replication \cite{hive2hiveXXXXguide}. Since a permanent \ac{TCP} connection between peer and relay peer is maintained, the power consumption is quite high. Constant \ac{TCP} connection can be avoided by using Google Cloud Messaging. However, Google has already discontinued this service. Moreover, the development of Hive2Hive was stopped in March 2015 too, there is currently no solution to this problem. Hive2Hive is released under the MIT license.
  25. \subsubsection{GUN}
  26. \label{sec:gun}
  27. In 2014, Mark Nadal began developing a decentralized database called GUN. GUN\footnote{https://gun.eco} is written in JavaScript and will be further developed by the community as an open source\footnote{https://github.com/amark/gun} project. It is licensed under the Apache License 2.0, so free use is allowed. The \ac{P2P} database exists only within a browser and synchronizes itself with other peers over the Internet. It has offline support, so changes are automatically synchronized and merged as soon as a connection is established. The data is stored in a graph structure in the local storage of the browser. For connecting peers among each other, at least one relay server is required.
  28. \subsubsection{OrbitDB}
  29. \label{sec:orbitdb}
  30. The open source project OrbitDB\footnote{https://github.com/orbitdb/orbit-db} is a serverless, distributed, \ac{P2P} database on top of \ac{IPFS}. The data are stored in \ac{IPFS} and \ac{IPFS} Pubsub is used to sync the database automatically with other peers. Various types of databases are provided like log, feed, key-value, and counter. There is a JavaScript library for usage in browsers and NodeJS which is currently in alpha stage. OrbitDB is released under the MIT license and therefore free to use in private and commercial projects.
  31. \subsection{Using an Existing P2P Network}
  32. \label{sec:using-existing-p2p-network}
  33. As mentioned in the previous section, setting up your own \ac{P2P} network involves a number of challenges. If you use an already existing \ac{P2P} network for your own purpose, these challenges can be elegantly avoided. For this purpose, however, a suitable \ac{P2P} network must be found whose properties and possible uses meet the requirements of the hybrid \ac{OSN} client.
  34. In the following, various \ac{P2P} networks are considered and examined for their usability for a potential deployment to extend an \ac{OSN}.
  35. \subsubsection{Filesharing \ac{P2P} Networks}
  36. \subsubsection{Blockchain}
  37. \label{sec:blockchain}
  38. In a blockchain, the private data of the users could be stored encrypted and shared with other users. The corresponding smart contracts would have to be designed for this purpose. Regardless of the blockchain, executing the smart contracts to store the data, however, consumes a token. The user has to get the tokens beforehand and deposit them in his wallet. To avoid this, a test network (e.g., Rinkeby at Ethereum) could be used. A test network would have the advantage that tokens could be made available to the user free of charge and that the execution of the smart contracts would thus also be free of charge. However, test networks are used to test new software updates and usually do not offer the same security as the main network. They should only be used to test applications before releasing them to the main net. In order to protect against abuse, token requests are usually limited and take a while until they arrive in the user's wallet. Besides, it is often required to post specific content in a social network or to perform another task.
  39. A solution based on a blockchain increases complexity for the user. Since the hybrid solution was required to keep the complexity and additional effort as low as possible, such a solution using a blockchain was categorically excluded.
  40. \subsubsection{\ac{IPFS}}
  41. \label{sec:ipfs}
  42. \ac{IPFS}\footnote{https://ipfs.io/} is a distributed file system that brings together the ideas of other successful \ac{P2P} systems (DHTs, BitTorrent, Self-Certified Filesystems (SFS) and Git) \cite{benet2014ipfs}. The original idea for IPFS came from Juan Benet in 2014. Protocol Labs, founded by Benet, now manages the open source project.
  43. The goal of \ac{IPFS} is to connect all computing devices to the same file system. The basis for this is a \ac{P2P} network where the data is distributed and stored. Instead of a location-oriented approach as used in \ac{HTTP}, \ac{IPFS} uses a content-oriented protocol. A cryptographic hash function generates a hash (content identifier) for each file, which can be used to find the file on the \ac{P2P} network using a \ac{DHT}. Unnecessary redundancies are avoided in this way, as the content is only stored once and purposefully replicated. However, deleting data is impossible in IPFS. Only if all peers who have stored copies of the file leave, the file can no longer be recovered. Decentralization allows a file to be retrieved from several peers in parallel, thus making the download faster. Besides,
  44. Due to its characteristics, \ac{IPFS} is an ideal complement to the blockchain and the development of \acp{dApp}. Large amounts of data can be stored out of \ac{IPFS}, and the address hash can be written into the blockchain. This principle is used for example by AKASHA and Peepeth.
  45. \ac{IPFS} clients are available for Max OS X, Linux and Windows. Besides, there are client implementations in JavaScript and Go to include in other applications.
  46. \subsubsection{Conclusion}
  47. \subsection{Application Framework}
  48. \label{sec:application-framework}
  49. With the Android \ac{SDK} apps for Android can be written in Java, Kotlin, and C++. Tools of the Android \ac{SDK} compile code, data, and resource files to an executable \ac{APK}. This way, only device-specific applications for the Android operating system can be created. \cite{androidXXXXfundamentals}
  50. The open source framework Ionic\footnote{https://ionicframework.com/} is used to create hybrid apps and \acp{PWA}. A hybrid app combines the advantages of a native app with those of web applications. With \ac{HTML}, \ac{CSS}, and JavaScript, this framework can be used to design platform-independent applications (including Android and iOS). The core of Ionic is based on the JavaScript Framework Angular and Apache Cordova, which serves as a bridge to access sensors and functions of the device. Ionic can be used free of charge and is published under the MIT license, so private and commercial use is permitted.
  51. Comparing the standard way of programming an Android app to the use of Ionic, the platform independence and the JavaScript language are the two main advantages. With Ionic, the same code can be used to create apps for the majority of mobile operating systems. Additionally, as \ac{PWA} the app runs in every modern web browser. The previously defined requirements of a hybrid solution demanded this independence, thus Ionic is a good match. Regarding the programming language JavaScript, many projects in the field of \acp{dApp} and decentralization in general provide only libraries for JavaScript (e.g., GUN). Besides, JavaScript is the language to write add-ons for browsers. Even though Ionic cannot be used to create browser add-ons, the used JavaScript libraries are able to do so. Hence, the same technology could be used to deliver clients to all popular environments.
  52. With React Native\footnote{https://facebook.github.io/react-native/} and NativeScript\footnote{https://www.nativescript.org/} there are comparable frameworks to Ionic. They also use JavaScript and are used to create hybrid apps for several environments. But the provided components to create the user interface are most promising with Ionic and the initial learning barrier is low compared to the other two. Because of these advantages, Ionic was finally chosen for programming the Hybrid \ac{OSN} client app.