Question? Leave a message!




Smart energy efficient gateway for Internet of mobile things

Adaptive Switching of Traffic between WebRTC and WebSocket Status of Portable Devices A Semantic Engine for Internet of Things: Cloud, Mobile Devices and Gateways
Dr.NoahGates Profile Pic
Dr.NoahGates,Netherlands,Researcher
Published Date:06-12-2017
Website URL
Comment
Evaluating WebSocket and WebRTC in the Context of a Mobile Internet of Things Gateway GU NAY MERT KARADOGAN KTH Information and Communication Technology Degree project in Communication Systems Second level, 30.0 HEC Stockholm, SwedenEvaluating WebSocket and WebRTC in the Context of a Mobile Internet of Things Gateway Gunay Mert Karadogan Master of Science Thesis Embedded Systems School of Information and Communication Technology KTH Royal Institute of Technology Stockholm, Sweden 12 January 2013 Examiner: Professor Gerald Q. Maguire Jr. c Gunay Mert Karadogan, 12 January 2013Abstract This thesis project explores two well-known real-time web technologies: WebSocket and WebRTC. It explores the use of a mobile phone as a gateway to connect wireless devices with short range of radio links to the Internet in order to foster an Internet of Things (IoT). This thesis project aims to solve the problem of how to collect real-time data from an IoT device, using the Earl toolkit. With this thesis project an Earl device is able to send real-time data to Internet connected devices and to other Earl devices via a mobile phone acting as a gateway. This thesis project facilitates the use of Earl in design projects for IoT devices. IoT enables communication with many different kinds of “things” such as cars, fridges, refrigerators, light bulbs, etc. The benefits of IoT range from financial savings due to saving energy to monitoring the heart activity of a patient with heart problems. There are many approaches to connect devices in order to create an IoT. One of these approaches is to use a mobile phone as a gateway, i.e., to act as a router, between IoT and the Internet. The WebSocket protocol provides efficient communication sessions between web servers and clients by reducing communication overhead. The WebRTC project aims to provide standards for real-time communications technology. WebRTC is important because it is the first real-time communications standard which is being built into browsers. This thesis evaluates the benefits which these two protocols offer when using a mobile phone as a gateway between an IoT and Internet. This thesis project implemented several test beds, collected data concerning the scalability of the protocols and the latency of traffic passing through the gateway, and presents a numerical analysis of the measurement results. Moreover, an LED module was built as a peripheral for an Earl device. The conclusion of the thesis is that WebSocket and WebRTC can be utilized to connect IoT devices to Internet. iSammanfattning I detta examensarbete utforskas tva ˚ valk ¨ anda ¨ realtidsteknologier pa ˚ internet: WebSocket och WebRTC. Det utforskar anvandandet ¨ av en mobiltelefon som gateway for ¨ att ansluta tradl ˚ osa ¨ enheter - med kort rackvidd ¨ - till Internet for ¨ att skapa ett Internet of Things (IoT). Det har ¨ examensarbetet fors ¨ ok ¨ er med hjalp ¨ av verktyget Earl losa ¨ problemet med hur insamlandet av realtidsdata fran ˚ en IoT-enhet skall genomforas. ¨ I det har ¨ examensprojektet kan en Earl-enhet skicka data i realtid till enheter med Internetanslutning, samt till andra Earl-enheter, med hjalp ¨ av en mobiltelefon som gateway. Detta projektarbete forenklar ¨ anvandandet ¨ av Earl i design-projekt or ¨ IoT-enheter. IoT tillater ˚ kommunikation mellan olika sorters enheter, sa ˚ som bilar, kyl- och frysskap, ˚ glodlampor ¨ etc. Fordelarna ¨ med IoT kan vara allt fran ˚ ekonomiska - tack vare minskad energiforbrukning ¨ - till medicinska i form av ov ¨ ervakning av puls hos patienter med hjartproblem. ¨ Det finns mang ˚ a olika tillvag ¨ agangss ˚ att ¨ for ¨ att sammankoppla enheter till ett IoT. Ett av dessa ar ¨ att anvanda ¨ en mobiltelefon som en gateway, dvs en router mellan IoT och internet. WebSocket-protokollet erbjuder effektiv kommunikation mellan web-servrar och klienter tack vare minskad ov ¨ erflodig ¨ dataov ¨ erforing. ¨ WebRTC-projektet vill erbjuda standarder for ¨ realtidskommunikation. WebRTC ar ¨ viktigt da ˚ det ar ¨ den forsta ¨ sadana ˚ standarden som inkluderas i weblasare. ¨ Det har ¨ examensarbetet utvarderar ¨ fordelarna ¨ dessa tva ˚ protokoll erbjuder i det fallet da ˚ en mobiltelefon anvands ¨ som gateway mellan ett IoT och Internet. I det har ¨ examensprojektet implementerades ett flertal testmiljoer ¨ , protokollens skalbarhet och fordr ¨ ojningen ¨ av trafiken genom mobiltelefonen (gateway) undersoktes. ¨ Detta presenteras i en numerisk analys av matresultaten. ¨ Dessutom byggdes en LED-modul som tillbehor ¨ till en Earl-enhet. Slutsatsen av examensarbetet ar ¨ att WebSocket och WebRTC kan anvandas ¨ till att ansluta IoT-enheter till Internet. iiiAcknowledgements I would like to acknowledge my gratitude to my examiner Professor Gerald Q. Maguire Jr. for his helpful comments and continuous suggestions during the development of this thesis. I thank my classmate Deniz Akkaya for letting me extend his thesis project by taking a different approach. Last but not the least, I would like to thank my family for supporting me throughout my life. vContents 1 Introduction 1 1.1 Problem Description . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Problem Context . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.4 Thesis Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.5 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 WebSocket Experiments 7 2.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1.1 Scaling WebSocket Connections . . . . . . . . . . . . . . 10 2.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.3 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.4 Tools and Experimental Setup . . . . . . . . . . . . . . . . . . . 14 2.4.1 Command Line Tools . . . . . . . . . . . . . . . . . . . . 14 2.4.1.1 SSH . . . . . . . . . . . . . . . . . . . . . . . 15 2.4.1.2 Sar . . . . . . . . . . . . . . . . . . . . . . . . 15 2.4.1.3 kSar . . . . . . . . . . . . . . . . . . . . . . . 16 2.4.1.4 Git . . . . . . . . . . . . . . . . . . . . . . . . 16 2.4.1.5 NTP . . . . . . . . . . . . . . . . . . . . . . . 17 2.4.1.6 Gnuplot . . . . . . . . . . . . . . . . . . . . . 17 2.4.2 Node.JS Server . . . . . . . . . . . . . . . . . . . . . . . 17 2.4.3 Amazon Web Services . . . . . . . . . . . . . . . . . . . 23 2.4.3.1 Problems with Virtualization . . . . . . . . . . 23 2.4.3.2 Setting Up Servers . . . . . . . . . . . . . . . . 24 2.4.4 Load Balancer: HAProxy . . . . . . . . . . . . . . . . . 26 2.4.5 Redis Layer . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.5 Data Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.5.1 Test Scripts . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.5.1.1 load.js . . . . . . . . . . . . . . . . . . . . . . 30 2.5.1.2 app.js . . . . . . . . . . . . . . . . . . . . . . . 31 2.5.2 Test Servers . . . . . . . . . . . . . . . . . . . . . . . . . 31 viiviii CONTENTS 2.5.3 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.6 Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.6.1 Throughput . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.6.2 Message Service Time and Event Loop Lag . . . . . . . . 36 2.6.3 Response Time . . . . . . . . . . . . . . . . . . . . . . . 42 2.6.4 CPU Usage . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.6.5 Commands processed by Redis . . . . . . . . . . . . . . 48 2.6.6 Events in Client Instances . . . . . . . . . . . . . . . . . 49 2.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3 WebRTC Experiments 51 3.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.1.1 WebRTC Protocols . . . . . . . . . . . . . . . . . . . . . 52 3.1.2 Possible Architectures for WebRTC . . . . . . . . . . . . 55 3.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.3 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.4 WebRTC API . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3.4.1 RTCPeerConnection . . . . . . . . . . . . . . . . . . . . 59 3.4.2 RTCSessionDescription . . . . . . . . . . . . . . . . . . 60 3.4.3 RTCIceCandidate . . . . . . . . . . . . . . . . . . . . . . 61 3.4.4 RTCDataChannel . . . . . . . . . . . . . . . . . . . . . . 62 3.4.5 PeerJS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.4.5.1 PeerJS Client . . . . . . . . . . . . . . . . . . 63 3.4.5.2 PeerServer . . . . . . . . . . . . . . . . . . . . 64 3.5 Experimental Setup . . . . . . . . . . . . . . . . . . . . . . . . . 65 3.6 Data Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 3.7 Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.7.1 Forwarding DataChannels over a Mobile Phone . . . . . . 68 3.7.1.1 One-way delay . . . . . . . . . . . . . . . . . . 68 3.7.1.2 Throughput . . . . . . . . . . . . . . . . . . . 71 3.7.2 Multiplexing and Demultiplexing DataChannels . . . . . 74 3.7.2.1 Multiplexing . . . . . . . . . . . . . . . . . . . 74 3.7.2.2 Demultiplexing . . . . . . . . . . . . . . . . . 80 3.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 4 LED Module for Earl 87 4.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4.2 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.3 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.4 Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 2 4.5 I C Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91CONTENTS ix 4.6 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 4.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 5 Conclusion 97 5.1 Conslusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 5.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 5.3 Required Reflections . . . . . . . . . . . . . . . . . . . . . . . . 99 Bibliography 101 A Network Kernel Configuration 113 B HAProxy Configuration 115 C Example of WebRTC DataChannel API 117 D Google’s STUN Servers 119List of Figures 1.1 LED module, Earl, Phone and Internet . . . . . . . . . . . . . . . 5 2.1 Architecture for WebSocket Tests . . . . . . . . . . . . . . . . . 7 2.2 Polling versus Long Polling . . . . . . . . . . . . . . . . . . . . . 8 2.3 WebSocket Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.4 Proxy Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.5 Publishers and Subscribers . . . . . . . . . . . . . . . . . . . . . 14 2.6 Message Events for Case 1 . . . . . . . . . . . . . . . . . . . . . 35 2.7 Message Events for Case 2 . . . . . . . . . . . . . . . . . . . . . 35 2.8 Message Service Time For Case 1 . . . . . . . . . . . . . . . . . 37 2.9 Message Service Time For Case 2 . . . . . . . . . . . . . . . . . 37 2.10 Event Loop Lag for Case 1 . . . . . . . . . . . . . . . . . . . . . 38 2.11 Event Loop Lag for Case 2 . . . . . . . . . . . . . . . . . . . . . 38 2.12 Response Time for Case 1 . . . . . . . . . . . . . . . . . . . . . 42 2.13 Response Time for Case 2 . . . . . . . . . . . . . . . . . . . . . 43 2.14 CPU Usage of the Application Server for Case 1 . . . . . . . . . . 45 2.15 CPU Usage of the Application Servers for Case 2 . . . . . . . . . 46 2.16 CPU Usage of the Redis Server for Case 2 . . . . . . . . . . . . . 47 2.17 CPU Usage of the HAProxy Server for Case 2 . . . . . . . . . . . 47 2.18 CPU Usage of Opening and Terminating Connections for Case 1 . 47 2.19 Commands Processed by the Redis Server for Case 1 . . . . . . . 48 2.20 Commands Processed by the Redis Server for Case 2 . . . . . . . 48 2.21 Number of message Events created by the Client Servers . . . . . 49 3.1 P2P WebRTC Architecture . . . . . . . . . . . . . . . . . . . . . 52 3.2 NAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.3 TURN and STUN . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.4 WebRTC - Full Mesh . . . . . . . . . . . . . . . . . . . . . . . . 55 3.5 WebRTC - Star . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.6 WebRTC - MCU . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.7 SDP flow in WebRTC . . . . . . . . . . . . . . . . . . . . . . . . 61 3.8 One-way delay of network layer . . . . . . . . . . . . . . . . . . 69 xixii LIST OF FIGURES 3.9 One-way delay of application layer . . . . . . . . . . . . . . . . . 70 3.10 Received throughput of network layer. Sent throughput was the same. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 3.11 Received throughput by the mobile phone . . . . . . . . . . . . . 73 3.12 Sent throughput by the mobile phone . . . . . . . . . . . . . . . . 74 3.13 Processing delay of multiplexing DataChannels . . . . . . . . . . 76 3.14 Processing delay of multiplexing DataChannels . . . . . . . . . . 76 3.15 CPU usage of multiplexing DataChannels . . . . . . . . . . . . . 77 3.16 Battery power consumption of multiplexing DataChannels . . . . 79 3.17 Processing delay of demultiplexing DataChannels . . . . . . . . . 81 3.18 Processing delay of demultiplexing DataChannels . . . . . . . . . 82 3.19 CPU usage of demultiplexing DataChannels . . . . . . . . . . . . 83 3.20 Battery power consumption of demultiplexing DataChannels . . . 84 4.1 Schematic of the LED module . . . . . . . . . . . . . . . . . . . 90 4.2 PCB of the LED module . . . . . . . . . . . . . . . . . . . . . . 91 2 4.3 General overview of I C bus . . . . . . . . . . . . . . . . . . . . 92 2 4.4 Data flow on I C bus . . . . . . . . . . . . . . . . . . . . . . . . 92List of Tables 2.1 Hardware specification of the local computer . . . . . . . . . . . 15 2.2 Parameters of the scripts . . . . . . . . . . . . . . . . . . . . . . 31 2.3 Specification of the Instances . . . . . . . . . . . . . . . . . . . . 32 2.4 Number of events per second for case 1 . . . . . . . . . . . . . . 36 2.5 Number of events per second for case 2 . . . . . . . . . . . . . . 36 2.6 Message service time statistics for case 1 . . . . . . . . . . . . . . 39 2.7 Message service time statistics for case 2 . . . . . . . . . . . . . . 39 2.8 Event loop lag statistics for case 1 . . . . . . . . . . . . . . . . . 40 2.9 Event loop lag statistics for case 2 . . . . . . . . . . . . . . . . . 40 2.10 Response time statistics for case 1 . . . . . . . . . . . . . . . . . 43 2.11 Response time statistics for case 2 . . . . . . . . . . . . . . . . . 44 3.1 Comparison of WebSocket and RTCDataChannel . . . . . . . . . 62 3.2 Hardware Specification of WebRTC tests . . . . . . . . . . . . . 65 3.3 One-way delay statistics of network layer . . . . . . . . . . . . . 71 3.4 One-way delay statistics of application layer . . . . . . . . . . . . 71 3.5 Througput statistics of network layer . . . . . . . . . . . . . . . . 73 3.6 Througput statistics of application layer . . . . . . . . . . . . . . 74 3.7 Processing delay statistics . . . . . . . . . . . . . . . . . . . . . . 75 3.8 CPU load statistics of multiplexing . . . . . . . . . . . . . . . . . 78 3.9 Battery power consumption statistics of multiplexing . . . . . . . 79 3.10 Processing delay statistics . . . . . . . . . . . . . . . . . . . . . . 81 3.11 CPU load statistics of demultiplexing . . . . . . . . . . . . . . . 83 3.12 Battery power consumption statistics of demultiplexing . . . . . . 84 4.1 Component list of the LED module . . . . . . . . . . . . . . . . . 90 xiiiList of listings 2.1 Request to server . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2 Response from server . . . . . . . . . . . . . . . . . . . . . . . . 10 4.1 Pseudo code of functions in i2c.c . . . . . . . . . . . . . . . . . . 93 4.2 Pseudo code of functions in tca6507.c . . . . . . . . . . . . . . . 94 xvList of Acronyms and Abbreviations 6LoWPAN IPv6 over Low Power Wireless Area Network AMI Amazon Machine Images AWS Amazon Web Services API Application Programming Interface AJAX Asynchronous JavaScript and XML BLE Bluetooth Low Energy CPU Central Processing Unit DTLS Datagram Transport Layer Protocol DNS Domain Name System EC2 Elastic Compute Cloud HTTP Hypertext Transfer Protocol HTTPS Hypertext Transfer Protocol Secure 2 I C Inter-Integrated Circuit IAAS Infrastructure as a Service ICE Interactive Connectivity Establishment IETF Internet Engineering Task Force IoT Internet of Things IP Internet Protocol JSON JavaScript Object Notation xvii