This document presents Protelis, a programming language for aggregate computing. It discusses aggregate programming approaches that express global behavior through local interactions. Protelis builds on the Field Calculus by adding features like state, branching, and interoperability. It includes a simulator and runtime for developing and executing Protelis programs. Examples show how Protelis can be used for rendezvous at mass events and network service management through coordination of distributed processes. Future work aims to develop reusable building blocks for distributed applications using Protelis.
1. Protelis: Practical Aggregate Programming
Danilo Pianini, Mirko Viroli
{danilo.pianini,mirko.viroli}@unibo.it
Jacob Beal
jakebeal@bbn.com
Universit`a di Bologna
Italy
Raytheon BBN Technologies
United States of America
Symposium on Applied Computing 2015
Salamanca
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 1 / 37
2. Outline You’ll soon have your God, and you’ll make it with your hands.
1 Aggregate Programming
Local to Global
From Proto to Field Calculus
2 Protelis
Language features
Simulator and Runtime
Examples
3 Conclusion and Future work
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 2 / 37
3. Aggregate Programming
Outline
1 Aggregate Programming
Local to Global
From Proto to Field Calculus
2 Protelis
Language features
Simulator and Runtime
Examples
3 Conclusion and Future work
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 3 / 37
4. Aggregate Programming Local to Global
Our stage
Large number of devices or services
Possibly situated
Capable of sensing, computing, communicating
Behaviour must be coordinated to achieve a global goal
Pervasive Continuum or (pick the one you prefer):
Pervasive computing
Smart cities
Internet of things
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 4 / 37
5. Aggregate Programming Local to Global
Classic approach
Local to global
Complex global behaviour
Simple local behaviour
The whole is more than the sum of the parts
Interaction is key
Nature inspiration
Several systems use nature as inspiration:
physical particles [MZ09]
chemical reactions [ZCF+11]
ants, termites and other social insects [TM03]
Very brief list! There are many more.
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 5 / 37
6. Aggregate Programming Local to Global
Nice properties and hard challenges
The beauty
High resilience and fault tolerance
Self adaptation
Openness
Self healing
The beast
Local to global is hard to engineer
The desired functionality happens at the aggregate level
It is very difficult to design the local behaviour in such a way that the
interaction of many of them produces the desired global behaviour
Many attempts, but no good engineering processes to safely design
such systems
Often, development becomes a try-and-simulate loop
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 6 / 37
7. Aggregate Programming Local to Global
Collective to local
Device&
Neighborhood&
Manifold&
Device&
Neighborhood&
Network&
Possible solution
Create a language that allows to express collective properties
Create a runtime that can run such programs
Possibly, also create a tool to test programs prior to deployment
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 7 / 37
8. Aggregate Programming From Proto to Field Calculus
Existing languages
MIT Proto [BB06] is the most known and successful
Developed at MIT and maintained at BBN Technologies
Functional language, LISP-like syntax (I know you hate it too)
All devices run the same program
Computation happens in rounds:
Every device sleeps for some time
Processes the messages received from the neighbours
Executes its program
Sends all the neighbours its result
Complex operational semantics
Difficult to maintain and extend
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 8 / 37
9. Aggregate Programming From Proto to Field Calculus
Field Calculus
A “distillate” of Proto
Provides a lightweight operational semantics [VDB13]
((((LISP-like syntax))))
Still a functional language
Simple enough to formally prove properties, powerful enough to be
universal (proved!)
Theoretical object, no runtime nor simulation tool provided
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 9 / 37
10. Protelis
Outline
1 Aggregate Programming
Local to Global
From Proto to Field Calculus
2 Protelis
Language features
Simulator and Runtime
Examples
3 Conclusion and Future work
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 10 / 37
11. Protelis Language features
Ordinary language features
Functional language
Same operational semantics of the field calculus
C-family syntax with infix operators
Java interoperability: static methods imports and calls, method
invocation with dynamic binding
Higher order functions (functions as arguments, lambdas)
Dynamic code
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 11 / 37
12. Protelis Language features
Field calculus operators
rep
defines a locally visible variable
Retains its value at each computation round
Enables stateful computation
nbr
Builds a field
Map device →value
Includes self
*hood built-in functions summarize the field back to ordinary
expressions
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 12 / 37
13. Protelis Language features
Branching
mux / else
Functional inclusive “multiplexing” branching
Evaluates both branches, then returns the correct one
nbrs in branches can “align”
if / else
Exclusive branching: nbrs in different branches do not “align”
Network gets partitioned into two regions
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 13 / 37
15. Protelis Simulator and Runtime
Architecture
Implementation, distribution
Based on Xtext
Eclipse plugin
Integrated with Alchemist [PMV13]
Stand-alone framework for real devices
Write once, run everywhere — evolved :)
Now distributed through Maven Central a
a
artifact: it.unibo.alchemist:alchemist.protelis
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 15 / 37
19. Protelis Examples
Rendezvous at a Mass Event
Problem
Large public event
People want to rendezvous with a companion
Cloud-based services may be unreachable
Possible solution with Protelis
Simple P2P geometric calculation across network
Testbed
Simulated in Alchemist
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 19 / 37
20. Protelis Examples
Rendezvous at a Mass Event
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 20 / 37
21. Protelis Examples
Rendezvous at a Mass Event
// Follow the gradient of a potential field down from a source
def descend(source, potential) {
rep(path <- source) {
let nextStep = minHood(nbr([potential, self.getId()]));
if (nextStep.size() > 1) {
let candidates = nbr([nextStep.get(1), path]);
source || anyHood([self.getId(), true] == candidates)
} else {
source
}
}
}
def rendezvous(person1, person2) {
descend (person1 == owner, distanceTo(person2 == owner))
}
// Example of using rendezvous
rendezvous("Alice", "Bob");
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 21 / 37
22. Protelis Examples
Rendezvous at a Mass Event
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 22 / 37
23. Protelis Examples
Rendezvous at a Mass Event
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 23 / 37
24. Protelis Examples
Rendezvous at a Mass Event
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 24 / 37
25. Protelis Examples
Rendezvous at a Mass Event
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 25 / 37
26. Protelis Examples
Rendezvous at a Mass Event
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 26 / 37
27. Protelis Examples
Rendezvous at a Mass Event
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 27 / 37
28. Protelis Examples
Network Service Management
Problem
Legacy or poorly coded services do not respond gracefully to the
failure of their dependencies
Risk of inconsistent state and of being unable to resume correctly
when the failed dependency is back online
Possible solution with Protelis
Attach a Protelis daemon to each service, which watches its status
and communicates with other daemons to coordinate shutdown and
restart
Testbed
Implemented on a network of EmuLab servers
Services are emulated by query-response networking Java programs
they “hang” when triggered or when their queries consistently fail
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 28 / 37
30. Protelis Examples
Network Service Management
import it.unibo.alchemist.language.protelis.datatype.Tuple.*
import com.bbn.a3.distributedrestart.DaemonNode.*
// Compare required and available services
let nbr_set = unionHood(nbr([serviceID]));
let nbr_missing = dependencies.subtract(nbr_set);
let nbr_required = #contains(dependencies, nbr(serviceID));
let nbr_down = nbr(managedServiceStatus=="hung" || managedServiceStatus=="stop");
// Is service currently safe to run?
let problem = anyHood(nbr_down && nbr_required) || !nbr_missing.isEmpty();
// Take managed service up and down accordingly
if (managedServiceStatus == "run" && problem) {
#stopProcess(managedService);
} else {
if (managedServiceStatus=="stop" && !problem) {
#startProcess(managedService);
} else {
managedServiceStatus
}
}
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 30 / 37
32. Conclusion and Future work
Outline
1 Aggregate Programming
Local to Global
From Proto to Field Calculus
2 Protelis
Language features
Simulator and Runtime
Examples
3 Conclusion and Future work
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 32 / 37
33. Conclusion and Future work
Conclusion and Future Work
Conclusion
Universality and coherence by building atop the field calculus
Accessibility, portability and ease of integration by Java
interoperability
Important component of the toolchain necessary for using aggregate
programming in practice
Future work
Development is very active
Next step: use Protelis to build a library of reusable, high-level
building blocks for distributed applications.
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 33 / 37
34. References
References I
Jacob Beal and Jonathan Bachrach.
Infrastructure for engineered emergence on sensor/actuator networks.
IEEE Intelligent Systems, 21(2):10–19, 2006.
Marco Mamei and Franco Zambonelli.
Programming pervasive and mobile computing applications: The tota approach.
ACM Trans. Softw. Eng. Methodol., 18(4):1–56, 2009.
Danilo Pianini, Sara Montagna, and Mirko Viroli.
Chemical-oriented simulation of computational systems with Alchemist.
Journal of Simulation, 2013.
Robert Tolksdorf and Ronaldo Menezes.
Using swarm intelligence in linda systems.
In Andrea Omicini, Paolo Petta, and Jeremy Pitt, editors, ESAW, volume 3071 of Lecture
Notes in Computer Science, pages 49–65. Springer, 2003.
Mirko Viroli, Ferruccio Damiani, and Jacob Beal.
A calculus of computational fields.
In Carlos Canal and Massimo Villari, editors, Advances in Service-Oriented and Cloud
Computing, volume 393 of Communications in Computer and Information Science, pages
114–128. Springer Berlin Heidelberg, 2013.
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 34 / 37
35. References
References II
Franco Zambonelli, Gabriella Castelli, Laura Ferrari, Marco Mamei, Alberto Rosi, Giovanna
Di Marzo, Matteo Risoldi, Akla-Esso Tchao, Simon Dobson, Graeme Stevenson, Yuan Ye,
Elena Nardini, Andrea Omicini, Sara Montagna, Mirko Viroli, Alois Ferscha, Sascha
Maschek, and Bernhard Wally.
Self-aware pervasive service ecosystems.
Procedia Computer Science, 7:197–199, December 2011.
Proceedings of the 2nd European Future Technologies Conference and Exhibition 2011
(FET 11).
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 35 / 37
36. References
Protelis: Practical Aggregate Programming
Danilo Pianini, Mirko Viroli
{danilo.pianini,mirko.viroli}@unibo.it
Jacob Beal
jakebeal@bbn.com
Universit`a di Bologna
Italy
Raytheon BBN Technologies
United States of America
Symposium on Applied Computing 2015
Salamanca
Pianini, Viroli, Beal (UniBo / BBN) Protelis — Aggregate programming 2015-04-16 SAC/CM 36 / 37