MQTT - Communication in the Internet of Things

  • 677 views
Uploaded on

Das Internet der Dinge (IoT) und Maschine-zu-Maschine Kommunikation (M2M) ist momentan in aller Munde. Studien zeigen das es bis 2020 50 Milliarden Geräte sein werden, die über das Internet …

Das Internet der Dinge (IoT) und Maschine-zu-Maschine Kommunikation (M2M) ist momentan in aller Munde. Studien zeigen das es bis 2020 50 Milliarden Geräte sein werden, die über das Internet miteinander kommunizieren und jede Sekunde kommen 80 neue Geräte hinzu. Momentan dominierende Protokolle wie HTTP/REST sind nur bedingt geeignet, um die Anforderungen abzudecken. Herausforderungen sind zum Beispiel das Senden von Nachrichten von einem Gerät zu vielen, Skalierung der Anzahl an Geräte, Push Notifications und Sicherstellung der korrekten Übermittlung. Das Publish/Subscribe-Protokoll MQTT erfüllt diese Anforderungen und wurde für mobile Geräte entwickelt. Es wird beispielsweise von Facebook für den Messenger eingesetzt. Dieser Vortrag gibt eine Einführung in MQTT sowie die Implementierung Eclipse Paho und zeigt anhand von Beispielquellcode und einer Livedemo, welche Probleme man damit lösen kann. - See more at: http://www.developer-week.de/History/2014/Programm/Veranstaltung/(event)/14178#sthash.ioXw2aoi.dpuf

More in: Internet
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
677
On Slideshare
0
From Embeds
0
Number of Embeds
5

Actions

Shares
Downloads
25
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. #dwx14 1 MQTT Christian Götz, dc-square - Kommunikation im Internet der Dinge
  • 2. Hi, I’m Christian Götz author & speaker building solutions CEO & co-founder developer @goetzchr
  • 3. IoT?
  • 4. GPSGPS GPS GPS GPS GPS GPS Detected: Traffic Jam! GPS GPS GPS
  • 5. THINGS?
  • 6. Consumer Goods
  • 7. Industry Machines
  • 8. objects in our everyday life
  • 9. logistics has a lot of things...
  • 10. Internet of Things?
  • 11. Technology that connects Devices over wired or wireless communication
  • 12. why should I care ?
  • 13. 6,5 per person DEVICES outnumber people 0,0 15,0 30,0 45,0 60,0 2003 2010 2015 2020 50,0 25,0 12,5 0,5 6,0 19,5 33,0 46,5 60,0 2003 2010 2015 2020 7,67,36,86,3 250 new every sec http://blogs.cisco.com/news/cisco-connections-counter/ http://www.cisco.com/web/about/ac79/docs/innov/IoT_IBSG_0411FINAL.pdf 2020 in billions people devices
  • 14. finally a use case for IPv6 ;)
  • 15. Open Hardware is everywhere simple accessible affordable
  • 16. How do things talk?
  • 17. 17
  • 18. HTTP/REST used since 1991 widely known and adapted request/response point 2 point HTTP 2.0 - still work in progress
  • 19. Challenges
  • 20. Constrained devices Bi-directional Scalability Unreliable Networks Push Messaging Security IoT HTTP IoT challenges
  • 21. CoAP Constrained Application Protocol ? HTTP
  • 22. MQTT is a good fit I’ll tell you why
  • 23. Messaging Protocol simple on top of TCP Pub/Sub binary minimal overhead data-agnostic unreliable networks
  • 24. Subscribe
  • 25. Publish
  • 26. Temperaturfühler MQTT-Broker Laptop Mobiles Endgerät publish: “21°C“ publish: “21°C“ publish: “21°C“ subscribe subscribe
  • 27. 1999 2010 2013 2014 Arlen Nipper & Andy Stanford-Clark invent MQTT royalty free OASIS TC formed MQTT becomes Standard MQTT history
  • 28. London BigBen London Eye people temp people temp / / / MQTT topics 101 / /
  • 29. London BigBen London Eye people temp people temp / / / The temperature of Big Ben London/BigBen/temp MQTT topics 101 / /
  • 30. London BigBen London Eye people temp people temp / / All temperature values London/+/temp / MQTT topics 101 / /
  • 31. London BigBen London Eye people temp people temp / / All from the London Eye London/LondonEye/# / MQTT topics 101 / /
  • 32. London BigBen London Eye people temp people temp / / All messages # / MQTT topics 101 / /
  • 33. Push instead of Poll Minimal Bandwidth is important Unreliable networks Constrained devices Low Latency MQTT use cases
  • 34. Quality of Service Retained Messages Last Will and Testament Persistent Sessions Heartbeats Topic Wildcards MQTT features
  • 35. MQTT features Quality of Services QoS 1 QoS 2 QoS 0 B B B
  • 36. MQTT features Last Will and Testament B Connect LWT device123/status: „offline“ B dropped device123/status: „offline“
  • 37. MQTT features w/o Retained Messages B device1/temp: „23,0“ device1 every 5 min device2 device1/temp: „23,0“ Delay <= 5min
  • 38. MQTT features Retained Messages B device1/temp: „23,0“ R device1 every 5 min device2 device1/temp: „23,0“ R No Delay! stores msg per topic
  • 39. MQTT features Persistent Sessions B Connect Subscribe device/+/status device/12/status: „1“ 1st B Re-Connect device/12/status: „1“ 2nd
  • 40. MQTT-SN Overview Gateway MQTT-Broker MQTT-SN MQTT / -SN • UDP instead of TCP • Topic is just an ID (Preregister/Register) • Sleeping Clients • Different types of Gateways • Discovery Mechanisms Devices B
  • 41. MQTT over Websockets
  • 42. MQTT Security Protocol Username/Password Transport TLS, client certificate authentification Broker fine-grained authentication, 3rd party integration
  • 43. Broker implementations
  • 44. MQTT Broker Mosquitto Open Source Ideal for constraint devices Supports Bridging Written in C
  • 45. MQTT Broker HiveMQ High performance broker Open Plugin System for Java Clustering Bridging Scalable to > 100.000 connections Native Websocket support
  • 46. MQTT Broker + others http://mqtt.org/wiki/doku.php/brokers
  • 47. MQTT Broker Public Broker www.mqttdashboard.com
  • 48. Real World Use Cases
  • 49. MQTT real world usage https://www.facebook.com/notes/facebook- engineering/building-facebook-messenger/ 10150259350998920
  • 50. Getting started
  • 51. MQTT Implementation
  • 52. Open Source “Reference Implementation” Many languages: Java, Javascript, Lua, C, C++, Go, Python Active Community JS Library uses MQTT over Websockets Paho facts
  • 53. MqttClient client = new MqttClient( "tcp://localhost:1883", //URI "publisher", //Client ID new MemoryPersistence()); //Persistence Paho Init Connection
  • 54. MqttClient client = new MqttClient(...); ! MqttConnectOptions connOptions = new MqttConnectOptions(); ! connOptions.setKeepAliveInterval(120); connOptions.setWill("my/status", "offline".getBytes(), 2, true); connOptions.setCleanSession(false); connOptions.setUserName("user"); connOptions.setPassword(„pass".toCharArray( )); ! client.connect(connOptions); Paho Init Connection
  • 55. ! ! client.publish("my/topic/123",//topic "Hello!".getBytes(), //message 1, //QoS false); //retained ! ! client.disconnect(); Paho Synchronous API
  • 56. final MqttClient client = new MqttClient(...); client.setCallback(new MqttCallback() { @Override public void connectionLost(Throwable cause) {} ! @Override public void messageArrived(String topic, MqttMessage message)throws Exception { System.out.println(new String(message.getPayload())); } ! @Override public void deliveryComplete(IMqttDeliveryToken token) {} }); ! client.connect(); client.subscribe("#"); Paho Synchronous API
  • 57. MqttAsyncClient client = new MqttAsyncClient(...); client.connect(null, new IMqttActionListener() { @Override public void onSuccess(IMqttToken asyncActionToken) { try { client.publish(...); } catch (MqttException e) {} } @Override public void onFailure(IMqttToken asyncActionToken, Throwable exception) {} }); ! client.disconnect(); Paho Asynchronous API
  • 58. MQTT Implementation http://m2mqtt.wordpress.com/download/ MQTT Library for .NET
  • 59. It’s Showtime Demo
  • 60. Demo from device to the web with MQTT https://github.com/dc-square/mqtt-with-paho-eclipsecon2013 available on
  • 61. Demo Under the hood
  • 62. Danke! Thanks! @goetzchr