Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC509 Lecture 04

CSC509 Lecture 04

Software Design
Distributed Systems
(202410)

Javier Gonzalez-Sanchez

October 08, 2024
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 508/9 Software Engineering (Design & Deployment) Lecture 04. Distributed Systems
  2. Cobot • Univers a l Robotics e-Series 
 https://www.universal-robots.com/media/1802432/e-series-brochure.pdf •

    Comm a nds th a t c a n be used 
 https://s3-eu-west-1.amazonaws.com/ur-support-site/29983/Script command Examples.pdf 5
  3. Brain-Computer Interfaces • Emotiv He a dsets 
 https://www.emotiv.com/ •

    D a t a S a mples 
 https://emotiv.gitbook.io/cortex-api/data-subscription/data-sample-object 6
  4. Eye Tracking • Tobii Sp a rk 
 https://www.tobii.com/products/eye-trackers/screen-based/tobii-pro-spark •

    Tobii SDK 
 https://www.tobii.com/products/softw a re/ a pplic a tions- a nd-developer-kits/tobii-pro-sdk 8
  5. Eye Tracking • Petoi 
 https://www.petoi.com/pages/software-apps • Arduino IoT (with

    MQTT) 
 https://docs.arduino.cc/tutorials/uno-wifi-rev2/uno-wifi-r2-mqtt-device-to-device/ 9
  6. Communication Protocols Sockets • - Wh a t: Low-level communic

    a tion mech a nism for exch a nging d a t a between two systems. • - How: Utilizes TCP/UDP protocols for reli a ble/unreli a ble d a t a tr a nsfer. • - Use C a se: Direct communic a tion between client-server a pplic a tions (e.g., f ile tr a nsfer a nd ch a t). WebSockets • - Wh a t: Full-duplex communic a tion protocol over a single TCP connection. • - How: En a bles persistent, bidirection a l communic a tion between client a nd server in re a l- time. • - Use C a se: Re a l-time a pplic a tions like live ch a ts, g a ming, a nd stock tr a ding pl a tforms. MQTT (Mess a ge Queuing Telemetry Tr a nsport) • Wh a t: Lightweight mess a ging protocol designed for low-b a ndwidth, high-l a tency networks. • How: Uses a publish-subscribe p a ttern for e ff icient communic a tion between devices. • Use C a se: Ide a l for IoT a pplic a tions, sm a rt home devices, a nd sensor networks. 12
  7. MQTT Wh a t is MQTT? • MQTT (Mess a

    ge Queuing Telemetry Tr a nsport) is a lightweight, publish-subscribe network protocol. • Designed for constr a ined devices a nd low-b a ndwidth, high-l a tency, or unreli a ble networks. Key Fe a tures • Simple a nd e a sy to implement. • Low b a ndwidth consumption. • Reli a ble mess a ge delivery. • Sc a l a ble to millions of devices. 23
  8. MQTT Architecture Broker • The centr a l server th

    a t h a ndles mess a ge distribution. • Ex a mples: Mosquitto, HiveMQ, EMQX, AWS MQ. Clients • Devices or a pplic a tions th a t publish (send) a nd subscribe (receive) mess a ges. • Ex a mples: Sensors, mobile a pps, a nd IoT devices. Topics • Hier a rchic a l n a mesp a ces for org a nizing mess a ges. • Ex a mple: home/livingRoom/temper a ture. 24
  9. MQTT Work f low Connect • Clients connect to the

    broker. Subscribe • Clients subscribe to topics of interest. Publish • Clients publish mess a ges to topics. Receive • Clients receive mess a ges from topics they a re subscribed to. Disconnect • Clients disconnect from the broker. 25
  10. Eclipse Paho for Java Wh a t is Eclipse P

    a ho? • A set of MQTT client libr a ries developed by the Eclipse Found a tion. • It supports multiple l a ngu a ges, such a s J a v a , Python, J a v a Script, etc. J a v a Dependency (M a ven) <dependency> <groupId>org.eclipse.paho</groupId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId> <version>1.2.5</version> </dependency> 26
  11. Quality-of-service options • 0 – "at most once": A.K.A. "fire-and-forget."

    This option is suitable when message loss is acceptable, as it doesn't require acknowledgment or persistence. • 1 – "at least once": This option should be chosen when message loss is unacceptable, and your subscribers can handle duplicate messages. • 2 – "Exactly once": This option is ideal when message loss is unacceptable, and your subscribers cannot handle duplicate messages. 
 28
  12. Summary • MQTT: Lightweight, e ff i cient protocol for

    IoT and other use cases. • Mosquitto: A popular open-source MQTT broker. • Eclipse Paho: A versatile MQTT client library. • Java Example: https://github.com/CSC3100/MQTT 30
  13. Challenge 31 * Could you create an MQTT version for

    Pong? (yes, it is basically joining the two source codes) * Could it be possible to have four players (2 on each side)?
  14. CSC 509 Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected] Fall 2024

    Copyright. These slides can only be used as study material for the class CSC509 at Cal Poly. They cannot be distributed or used for another purpose.