跳转至

dSpace: Composable Abstractions for Smart Spaces

Abstract

We present dSpace, an open and modular programming framework that aims to simplify and accelerate the development of smart space applications. To achieve this, dSpace provides two key building blocks — digivices that implement device control and actuation and digidata that process IoT data to generate events and insights. In addition, dSpace introduces novel abstractions – mount, yield, and pipe – via which digivices and digidata can be composed into higher-level abstractions. We apply dSpace to home automation systems and show how developers can easily and flexibly leverage these abstractions to support a wide range of home automation scenarios. Finally, we show how the dSpace concepts can be realized using a microservices-based architecture and implement dSpace as a Kubernetes-compatible framework.

我们提出了 dSpace,一个开放且模块化的编程框架,旨在简化并加速智能空间应用的开发。该框架建立在两个核心组件之上:digivices,用于实现设备控制和执行操作;以及 digidata,用于处理物联网数据以生成事件和洞察。此外,dSpace 引入了创新的抽象概念——mountyieldpipe,以支持将 digivices 和 digidata 组合为更高级别的构造模块。为了展示其灵活性,我们将 dSpace 应用于家庭自动化系统,展示这些抽象如何帮助开发者高效支持多样化的家庭自动化场景。最后,我们提出了一种基于微服务的架构来实现 dSpace 的概念,并将其作为兼容 Kubernetes 的框架加以实现。

Introduction

Living spaces – homes, offices, retail locations – are being transformed by the proliferation of IoT devices. For example, shipments of IoT devices have tripled in the last five years [2, 4] and the global smart home market is projected to surpass 1.1 trillion USD by 2023 [3]. Given these trends, it is important that we have the right systems support for building smart space applications. This need has been recognized by both research [1, 15, 58, 62, 65, 66, 72–74] and industry solutions [11, 29, 44, 45]. These address the challenge of heterogeneity across devices: they propose unified device abstractions [23, 44], common system services [23, 29, 62, 72], common policy languages [44, 45], and so forth. They also address the challenges around discovery, localization, and networking of such devices [23]. Taken together, this seminal work tackled an essential first step – making it easier to discover, network, and program individual devices.

随着物联网(IoT)设备的普及,居住空间——包括家庭、办公室和零售场所——正在经历变革。例如,物联网设备的出货量在过去五年中增长了三倍【2, 4】,全球智能家居市场预计将在2023年突破1.1万亿美元【3】。鉴于这些趋势,为构建智能空间应用提供合适的系统支持显得尤为重要。这一需求已经得到了研究界【1, 15, 58, 62, 65, 66, 72–74】和工业界解决方案【11, 29, 44, 45】的认可。相关工作针对设备异构性这一挑战提出了统一的设备抽象【23, 44】、通用系统服务【23, 29, 62, 72】、通用策略语言【44, 45】等方法。此外,这些研究还解决了设备的发现、定位和网络连接等问题【23】。总体而言,这些开创性的工作迈出了关键的第一步——简化了单个设备的发现、联网和编程。

However, looking ahead, we anticipate a future in which smart spaces will be increasingly ubiquitous and increasingly sophisticated: incorporating a greater variety of devices and use-cases that are customized to individual needs, integrated with AI/analytics, and capable of advanced operations such as delegating management to trusted 3rd parties (e.g., a gardening service, emergency services, appliance maintenance services, etc.). From a systems perspective, the challenge in realizing the above vision is to make it easy for developers to support such flexibility. Unfortunately, today’s IoT frameworks fall short in this regard. As we elaborate on in §2, for programmers, developing IoT applications is often tedious. They typically operate at a device level (e.g., lamps, cameras) with limited support for composing these into higher-level abstractions (e.g., home, building). As a result, developing an IoT application involves writing substantial ad-hoc glue code to compose these devices (e.g., configuring home settings based on the events inferred from a camera) with limited support for rich policies and few higher-level abstractions.

然而,展望未来,我们预计智能空间将变得日益普及并愈加复杂:它们将集成更多种类的设备和用例,能够根据个人需求进行定制,结合人工智能与数据分析,并支持高级操作,如将管理任务委托给可信的第三方(例如园艺服务、紧急服务或设备维护服务等)。从系统角度来看,实现这一愿景的核心挑战是如何让开发者轻松支持这样的灵活性。然而,目前的物联网框架在这方面表现不足。如我们在§2中详细说明的那样,对于程序员来说,开发物联网应用往往是一项繁琐的任务。他们通常需要以设备级别(例如灯、摄像头)操作,且缺乏将这些设备组合为更高级抽象(例如“家”或“建筑”)的支持。结果是,开发物联网应用通常需要编写大量特定的粘合代码,以将这些设备组合起来(例如,根据摄像头推断的事件配置家庭设置),且在支持复杂策略和高级抽象方面存在诸多限制。

Not surprisingly then, users also often find these applications tedious to configure and/or limited in function. For example, in current home automation products, users specify automation policies by writing rudimentary if-this-then-that rules [31, 44] over per-device state which can be hard to reuse, manage, or reason about as the number of devices and scenarios increase. In short, IoT lacks a systems architecture that would simplify and accelerate application development.

因此,用户通常也会发现这些应用的配置繁琐且功能受限。例如,在当前的家庭自动化产品中,用户需要通过编写基于单设备状态的简单的“如果-那么”规则【31, 44】来指定自动化策略。然而,当设备和场景数量增加时,这些规则难以重用、管理或推理。简言之,当前的物联网缺乏一种能够简化和加速应用开发的系统架构。

The well-established approach to simplifying development and improving developer efficiency is via abstraction and modularity [67] - allowing developers to repurpose modular building blocks and combine these into higher-level abstractions that shield downstream developers from lower-level details. This approach both improves developer efficiency and simplifies the task of providing users with high-level abstractions (e.g., programming “the home” vs. individual devices). There’s a rich literature on developing such abstractions for specific domains such as analytics [9, 56], AI [42, 51], and networking [64]. The contribution of these systems lies in identifying a minimal set of abstractions that are intuitive for the task at hand yet flexible enough to support a range of applications in that domain.

简化开发和提升开发者效率的公认方法是通过抽象和模块化设计【67】——允许开发者复用模块化的构建块,并将其组合为更高级的抽象,从而屏蔽底层细节。这种方法不仅提高了开发者效率,还简化了向用户提供高级抽象(例如对“家”的编程,而非单个设备)的任务。在特定领域(如数据分析【9, 56】、人工智能【42, 51】和网络【64】)中,已有丰富的文献研究致力于开发这样的抽象。这些系统的贡献在于识别出一组最小的抽象,这些抽象既符合任务直观性又具有足够的灵活性,以支持该领域内的多种应用。

What is this minimal set of abstractions for smart space applications? In this paper, we propose two modular building blocks and three abstractions that serve to hierarchically compose these building blocks into higher level abstractions. The two building blocks are the digivice, which abstracts the devices to be actuated, and the digidata which abstracts how IoT data is processed. A digivice is flexible in that the entity it represents may be an individual device or aggregates of devices; a physical device (e.g., lamp) or a virtual/abstract one (e.g., “home”). Digivices are declaratively controlled i.e., users specify the desired state of a digivice without specifying how that state is achieved. These design choices are in contrast to existing IoT frameworks in which a device abstraction typically corresponds to a single physical device, couples both actuation and data processing for that device, and exposes imperative APIs to control that device.

智能空间应用的这一最小抽象集合是什么?在本文中,我们提出了==两个模块化构建块和三个抽象==,用于将这些构建块分层组合为更高级的抽象。

这两个构建块分别是:digivice,用于抽象需要执行操作的设备;以及 digidata,用于抽象物联网数据的处理方式。digivice 具备灵活性,其表示的实体可以是单个设备或设备的集合,可以是物理设备(例如灯)或虚拟/抽象设备(例如“家”)。digivice 通过声明式控制,即用户仅需指定 digivice 的期望状态,而无需指定如何实现该状态。这些设计选择与现有物联网框架形成鲜明对比,后者的设备抽象通常对应单一物理设备,将设备的操作和数据处理紧密耦合,并通过命令式 API 进行控制。

Digivices and digidata – which we collectively refer to as “digis” – can be composed using three abstractions: (1) mount(A, B) allows higher-level digivice B to configure/actuate digivice A; (2) pipe(A, B) arranges for the output data from A to be consumed by B, and (3) yield(A, B), for 𝐴 mounted to 𝐵, yield allows 𝐵 to relinquish control over 𝐴. Thus digis can be easily reused and composed to form sophisticated actuation/data processing relationships which we call a digi-graph. A digi-graph describes the flow of control (or “intents”) among digivices and the flow of data through digivices and digidata.

digivicedigidata(统称为 “digis”)可以通过三个抽象进行组合:

  1. mount(A, B):允许更高层的 digivice B 配置/控制 digivice A;
  2. pipe(A, B):使 A 的输出数据被 B 消费;
  3. yield(A, B):对于已被 B 挂载的 A,yield 允许 B 放弃对 A 的控制。

通过这些抽象,digis 可以轻松复用并组合成复杂的操作/数据处理关系网络,我们称之为 digi-graphdigi-graph 描述了 digivice 之间的控制流(或“意图”)以及 digivice 和 digidata 之间的数据流。

Low-level digis can be composed into higher-level abstractions that are controlled in a declarative manner. For example: a lamp digivice may be mounted to a room digivice and a camera digivice piped to a stream digidata which is also mounted to the same room digivice. The room digivice might then configure the lamp based on the objects recognized in the camera’s stream; finally, under certain conditions, the room digivice might “yield” control over the camera to a third-party emergency control digivice.

低层 digis 可以组合成以声明式方式控制的更高级抽象。例如,一个灯光 digivice 可以挂载到一个房间 digivice,摄像头 digivice 的数据流可以连接到一个流式 digidata,该 digidata 同样挂载到同一个房间 digivice。然后,房间 digivice 可以根据摄像头数据流中识别的对象来配置灯光;最终,在特定条件下,房间 digivice 可以将摄像头的控制权“移交”给第三方应急控制 digivice。

As we’ll discuss, dSpace faces unique challenges that stem from its role in integrating with the physical world. We address these challenges with certain novel design choices:

Adaptive composition. In dSpace the composition between digis is dynamic and automatically adapted based on policies and real-world events; e.g., a roomba digivice that moves between rooms might automatically detach from one room digivice and get mounted to another.

Embedded policies. In dSpace, policies are expressed and enforced independently within each digi rather than as a standalone flat file of rules as is common today. This modularity makes it easier to correctly maintain and execute policies even as the digi-graph evolves.

Intent reconciliation: A software system that is implemented in a declarative style will typically accept a target intent and implement “state reconciliation” to move its current state to match this intent [54]. As we’ll discuss, in dSpace, a system might need to go further and adapt its target intent and must do so in an autonomous manner based on policy and real-world conditions (e.g., overriding the home’s target “sleep” state when certain human activities are detected). To support this in a modular manner, digis implement “intent reconciliation” in which a digivice may update its own intent which is then recursively propagated to its upstream neighbors in the digi-graph.

如本文所述,dSpace 面临因其需与物理世界集成而带来的独特挑战。我们通过以下设计创新应对这些挑战:

  1. 自适应组合:在 dSpace 中,digis 之间的组合是动态的,并会根据策略和现实事件自动调整。例如,一个在房间之间移动的 roomba digivice 可能会自动从一个房间 digivice 分离并挂载到另一个房间 digivice。

  2. 嵌入式策略:在 dSpace 中,策略以模块化的方式独立表达和执行在每个 digi 内,而不是像目前常见的那样作为独立的平面规则文件。这种模块化设计使得即使在 digi-graph 演变的过程中,也能更容易地正确维护和执行策略。

  3. 意图协调:声明式风格的软件系统通常会接受目标意图,并通过“状态协调”将当前状态调整为匹配该意图【54】。在 dSpace 中,系统可能需要更进一步,根据策略和现实条件(例如,当检测到某些人类活动时覆盖家庭的目标“睡眠”状态)自主调整其目标意图。为支持这种模块化特性,digis 实现了“意图协调”功能,其中一个 digivice 可以更新自身意图,并将其递归地传播到 digi-graph 中的上游节点。

A final challenge is that we want dSpace’s implementation to match the modularity of its design. For this, we implement dSpace using a microservices based architecture. Specifically, we adapt the Kubernetes (k8s) design pattern of stateless controllers that coordinate only via a persistent data store. We show how to map our abstractions to k8s-style controllers and implement them in a manner that is compatible with, yet decoupled from k8s. Doing so allows us to reuse much of the k8s tooling while still providing features tailored to our smart-space domain.

最后一个挑战是,我们希望 dSpace 的实现能够匹配其设计的模块化特性。为此,我们采用了基于微服务的架构实现 dSpace。具体而言,我们借鉴了 Kubernetes(k8s)的设计模式,采用仅通过持久化数据存储进行协调的无状态控制器。我们展示了如何将我们的抽象映射到 k8s 风格的控制器,并以与 k8s 兼容但又相对独立的方式实现这些控制器。这种实现方式使我们能够复用大量 k8s 工具,同时为智能空间领域提供量身定制的功能。

We evaluate dSpace in the context of smart home applications. 1 We implement digis for 9 real-world home IoT devices from 9 different vendors, and 4 data processing frameworks. Using these, we implement 10 different deployment scenarios of mounting complexity, showing that dSpace allows developers to easily construct rather sophisticated use-cases. In addition, we show that these scenarios cannot be easily realized by existing smart-home frameworks such as SmartThings and Home Assistant: 40% of our scenarios cannot be supported by any of these other frameworks. For those scenarios that could be supported, doing so requires as much as 4x more lines of code/configuration than dSpace.

我们在智能家居应用的背景下评估了 dSpace 的性能。具体而言,我们为来自 9 个不同厂商的 9 种实际家居物联网设备以及 4 个数据处理框架实现了对应的 digis。在此基础上,我们实现了 10 个复杂程度逐步提升的部署场景,证明 dSpace 可以让开发者轻松构建相当复杂的应用场景。此外,我们还展示了这些场景难以通过现有智能家居框架(如 SmartThings 和 Home Assistant)实现:其中 40% 的场景无法被任何其他框架支持。而对于能够支持的场景,其实现所需的代码量/配置量最多是 dSpace 的 4 倍。