frp iot modules as a scala dsl
play

FRP IoT Modules as a Scala DSL BenCalus, BobReynders , - PowerPoint PPT Presentation

FRP IoT Modules as a Scala DSL BenCalus, BobReynders , DominiqueDevriese, Job Noorman, FrankPiessens imec - DistriNet - KU Leuven FRP IoT Modules Maintainable sensor network applications High-level FRP-based API FRP-modules compile


  1. FRP IoT Modules as a Scala DSL BenCalus, BobReynders , DominiqueDevriese, Job Noorman, FrankPiessens imec - DistriNet - KU Leuven

  2. FRP IoT Modules • Maintainable sensor network applications • High-level FRP-based API • FRP-modules compile to Protected Module Architecture (Sancus) • As a library in Scala using LMS 1

  3. FRP IoT Modules • Maintainable sensor network applications • High-level FRP-based API • FRP-modules compile to Protected Module Architecture (Sancus) • As a library in Scala using LMS 1

  4. FRP IoT Modules • Maintainable sensor network applications • High-level FRP-based API • FRP-modules compile to Protected Module Architecture (Sancus) • As a library in Scala using LMS 1

  5. FRP IoT Modules • Maintainable sensor network applications • High-level FRP-based API • FRP-modules compile to Protected Module Architecture (Sancus) • As a library in Scala using LMS 1

  6. FRP: Summary Event sequences of time-stamped values (button presses) Behavior time-varying values (temperature readings) 2

  7. FRP: Summary Event sequences of time-stamped values (button presses) Behavior time-varying values (temperature readings) 2

  8. FRP: Summary 3

  9. def createModule[A](f: ModuleName �> OutputEvent[A]): Module[A] trait Module[A] { val name: ModuleName val output: OutputEvent[A] } FRP-Modules • Unit of compilation/deployment • First-class values 4

  10. FRP-Modules • Unit of compilation/deployment • First-class values 4 def createModule[A](f: ModuleName �> OutputEvent[A]): Module[A] trait Module[A] { val name: ModuleName val output: OutputEvent[A] }

  11. val timer: Event[Unit] = SystemTimerEvent() val button: Event[Unit] = ButtonEvent(Buttons.button1) val m1 = createModule[Int] { ... } val m2 = createModule[Unit] { val out: Event[Int] = ExternalEvent(m1.output) } FRP-Modules: Interface • Timer • Button • Modules! 5 • val input: Event[T] = InputEvent[T]

  12. val button: Event[Unit] = ButtonEvent(Buttons.button1) val m1 = createModule[Int] { ... } val m2 = createModule[Unit] { val out: Event[Int] = ExternalEvent(m1.output) } FRP-Modules: Interface • Timer • Button • Modules! 5 • val input: Event[T] = InputEvent[T] val timer: Event[Unit] = SystemTimerEvent()

  13. val m1 = createModule[Int] { ... } val m2 = createModule[Unit] { val out: Event[Int] = ExternalEvent(m1.output) } FRP-Modules: Interface • Timer • Button • Modules! 5 • val input: Event[T] = InputEvent[T] val timer: Event[Unit] = SystemTimerEvent() val button: Event[Unit] = ButtonEvent(Buttons.button1)

  14. FRP-Modules: Interface • Timer • Button • Modules! 5 • val input: Event[T] = InputEvent[T] val timer: Event[Unit] = SystemTimerEvent() val button: Event[Unit] = ButtonEvent(Buttons.button1) val m1 = createModule[Int] { ... } val m2 = createModule[Unit] { val out: Event[Int] = ExternalEvent(m1.output) }

  15. Example

  16. Example: Parking lot Parking Module Figure 1: Parking Alarm Sensor Node Module Timer Module Sensor Sensor Node Alarm Node Module Timer Module Sensor Parking Module Alarm Module 6

  17. 7 Example: Parking module val parkingMod = createModule[Boolean] { implicit n: ModuleName �> val t = 1000 val sensorE = ExternalEvent(sensorMod.output) val timer = ExternalEvent(timerMod.output) val isParked: Behavior[Boolean] = sensorE.startWith(false) val isParkedOnTick: Event[Boolean] = isParked.snapshot(timer) val ticksParked: Behavior[Int] = isParkedOnTick.foldp((taken, s) �> if (taken) s + 1 else 0, 0) val violations = ticksParked.changes().map(_ >= t) out("violations", violations) }

  18. • def parkingMod(timeout: Long) = createModule[Boolean] { ... } Example: Parking module as First-class values • Code generation 8 • val parkingMod = createModule[Boolean] { ... }

  19. • def parkingMod(timeout: Long) = createModule[Boolean] { ... } Example: Parking module as First-class values • Code generation 8 • val parkingMod = createModule[Boolean] { ... }

  20. Example: Parking module as First-class values • Code generation 8 • val parkingMod = createModule[Boolean] { ... } • def parkingMod(timeout: Long) = createModule[Boolean] { ... }

  21. Example: Parking lot Parking Module Figure 2: Parking Alarm Sensor Node Module Timer Module Sensor Sensor Node Alarm Node Module Timer Module Sensor Parking Module Alarm Module 9

  22. Example: Safely reusing the network Parking Module Figure 3: Parking Counter Sensor Node Module Timer Module Sensor Sensor Node Space Node Module Timer Module Sensor Parking Module Space Module 10

  23. Example: Safely reusing the network with Sancus • Spoofed events • Tampered execution • “If the program were to produce an output event, it produces the same event regardless of an attacker.” • Authentic Execution of Distributed Event-Driven Applications with a Small TCB (Noorman, Mühlberg, and Piessens 2017) 11

  24. Example: Safely reusing the network with Sancus • Spoofed events • Tampered execution • “If the program were to produce an output event, it produces the same event regardless of an attacker.” • Authentic Execution of Distributed Event-Driven Applications with a Small TCB (Noorman, Mühlberg, and Piessens 2017) 11

  25. Example: Safely reusing the network with Sancus • Spoofed events • Tampered execution • “If the program were to produce an output event, it produces the same event regardless of an attacker.” • Authentic Execution of Distributed Event-Driven Applications with a Small TCB (Noorman, Mühlberg, and Piessens 2017) 11

  26. Example: Safely reusing the network with Sancus • Spoofed events • Tampered execution • “If the program were to produce an output event, it produces the same event regardless of an attacker.” • Authentic Execution of Distributed Event-Driven Applications with a Small TCB (Noorman, Mühlberg, and Piessens 2017) 11

  27. Compilation

  28. Compilation Pipeline: Scala (EDSL) Scala (EDSL) LMS Program (annotated) C Sancus Compiler Node Deployment Figure 4: Compilation Pipeline 12

  29. 13 Building the graph 1 val input1 = InputEvent[Int] 2 val input2 = InputEvent[Int] 3 val negate2 = input2.map( (i) => 0-i ) 4 val merged = input1.merge(negate2, (x,y) => x + y) 5 val filtered = merged.filter( (x) => abs(x) < 10) 6 val counter = filtered.foldp((x,state)=>state + x, 0)

  30. 13 Building the graph 1 val input1 = InputEvent[Int] 2 val input2 = InputEvent[Int] 3 val negate2 = input2.map( (i) => 0-i ) 4 val merged = input1.merge(negate2, (x,y) => x + y) 5 val filtered = merged.filter( (x) => abs(x) < 10) 6 val counter = filtered.foldp((x,state)=>state + x, 0)

  31. 13 Building the graph 1 val input1 = InputEvent[Int] 2 val input2 = InputEvent[Int] 3 val negate2 = input2.map( (i) => 0-i ) 4 val merged = input1.merge(negate2, (x,y) => x + y) 5 val filtered = merged.filter( (x) => abs(x) < 10) 6 val counter = filtered.foldp((x,state)=>state + x, 0)

  32. 13 Building the graph 1 val input1 = InputEvent[Int] 2 val input2 = InputEvent[Int] 3 val negate2 = input2.map( (i) => 0-i ) 4 val merged = input1.merge(negate2, (x,y) => x + y) 5 val filtered = merged.filter( (x) => abs(x) < 10) 6 val counter = filtered.foldp((x,state)=>state + x, 0)

  33. 13 Building the graph 1 val input1 = InputEvent[Int] 2 val input2 = InputEvent[Int] 3 val negate2 = input2.map( (i) => 0-i ) 4 val merged = input1.merge(negate2, (x,y) => x + y) 5 val filtered = merged.filter( (x) => abs(x) < 10) 6 val counter = filtered.foldp((x,state)=>state + x, 0)

  34. Building the graph 13

  35. Compilation Pipeline: LMS Program Scala (EDSL) LMS Program (annotated) C Sancus Compiler Node Deployment Figure 5: Compilation Pipeline 14

  36. Compiling to (Sancus) C 15

  37. Compiling to (Sancus) C 15

  38. Compiling to (Sancus) C 15 void toplevel1( ) { input1( ); mergefun( ); filterfun( ); foldpfun( ); } void foldpfun( ) { … }

  39. Compiling to (Sancus) C 15 int foldp_w; void toplevel1( ) { bool input1_p; int input1_w; input1(&input1_p, &input1_w); mergefun( ... ); filterfun( … ); bool foldp_p; foldpfun(&foldp_p, … ); }

  40. Compiling to (Sancus) C Scala (EDSL) LMS Program (annotated) C Sancus Compiler Node Deployment Figure 6: Compilation Pipeline 16

  41. 17 Compiling to (Sancus) C SM_DATA(mod1) int foldp_w; SM_DATA(mod1) void toplevel1( ) { bool input1_p; int input1_w; input1(&input1_p, &input1_w); mergefun( ... ); filterfun( … ); bool foldp_p; foldpfun(&foldp_p, … ); }

  42. Figure 7: Module Communication (EDSL) Compiling to (Sancus) C 18 val m1 = createModule[Int] { implicit m �> val data: Event[Int] = ... out(data) } val m2 = createModule[Unit] { implicit m �> ExternalEvent(m1.output) }

  43. Figure 8: Module Communication (Sancus) Compiling to (Sancus) C 19 SM_DATA(m1) ... SM_OUTPUT(m1, out); SM_INPUT(m1) { SM_DATA(m2) ... ... SM_INPUT(m2) { } ... } SM_FUNC(m1) { ... out(&data, sizeof(data)) }

  44. Deployment Scala (EDSL) LMS Program (annotated) C Sancus Compiler Node Deployment Figure 9: Compilation Pipeline 20

  45. Deployment • Sancus configuration file • Future Work • Configuration DSL • Well-typed deployments 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend