Evaluating Websocket and Webrtc in the Context of a Mobile Internet of Things Gateway

Evaluating Websocket and Webrtc in the Context of a Mobile Internet of Things Gateway

Evaluating WebSocket and WebRTC in the Context of a Mobile Internet of Things Gateway GUNAY MERT KARADOGAN KTH Information and Communication Technology Degree project in Communication Systems Second level, 30.0 HEC Stockholm, Sweden Evaluating 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 2013 Abstract 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. i Sammanfattning 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¨ oker¨ 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 overvakning¨ av puls hos patienter med hjartproblem.¨ Det finns manga˚ olika tillvagag¨ angss˚ 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 overfl¨ odig¨ dataoverf¨ oring.¨ 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. iii Acknowledgements 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. v Contents 1 Introduction1 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 Experiments7 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 vii viii 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 4.5 I2C Interface............................ 91 CONTENTS 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 119 List 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

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    142 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us