The Trickle Algorithm
Analysis, Use, and Implementation
Philip Levis
Computer Systems Lab
Stanford University
Trickle Summary
• An algorithm for establishing eventual
consistency in a wireless network
• Establishes consistency quickly
• Imposes low overhead when consistent
• Cost scales logarithmically with density
• Requires very little RAM or code
• Makes no topology assumptions
IETF 74 2
Consistency
• Powerful primitive with many uses
• Routing tree maintenance
• Invariant: next hop has lower cost
• Network configuration
•Invariant: all have the most recent config
• Neighbor discovery
•Invariant: node is in all neighbor’s lists
IETF 74 3
Overview
• Trickle operates over time intervals
• No synchronization needed between nodes
• In each interval, node optionally transmits
• Transmits if it hasn’t heard transmissions
that are consistent with its own
• Dynamically scales interval lengths to have
fast updates yet low cost when consistent
IETF 74 4
Suppression
• Motivation: don’t waste messages (energy and
channel) if all nodes agrees
• Interval of length τ
• At beginning of interval, counter c=0
• On consistent transmission, c++
• Node picks a time t in range [τ/2,τ]
•At t, transmit if c < k (redundancy constant)
IETF 74 5
Example Execution
k=1
c
A 0 tA1 tA2
B tB1 tB2
0
C tC1 tC2
0
τ
time
transmission suppressed transmission reception
IETF 74 6
Example Execution
k=1
c
A 0 tA1 tA2
B tB1 tB2
1
C tC1 tC2
0
τ
time
transmission suppressed transmission reception
IETF 74 7
Example Execution
k=1
c
A 0 tA1 tA2
B tB1 tB2
2
C tC1 tC2
0
τ
time
transmission suppressed transmission reception
IETF 74 8
Example Execution
k=1
c
A 0 tA1 tA2
B tB1 tB2
2
C tC1 tC2
0
τ
time
transmission suppressed transmission reception
IETF 74 9
Example Execution
k=1
c
A 0 tA1 tA2
B tB1 tB2
0
C tC1 tC2
0
τ
time
transmission suppressed transmission reception
IETF 74 10
Example Execution
k=1
c
A 1 tA1 tA2
B tB1 tB2
0
C tC1 tC2
1
τ
time
transmission suppressed transmission reception
IETF 74 11
Example Execution
k=1
c
A 1 tA1 tA2
B tB1 tB2
0
C tC1 tC2
1
τ
time
transmission suppressed transmission reception
IETF 74 12
Example Execution
k=1
c
A 1 tA1 tA2
B tB1 tB2
0
C tC1 tC2
1
τ
time
transmission suppressed transmission reception
IETF 74 13
log(L)
(k=1)
12
Transmissions/Interval
60%
10
8
40%
6
20%
4
2 0%
0
1 2 4 8 16 32 64 128 256
Nodes
IETF 74 14
Logarithmic Behavior
• Transmission increase is due to the probability
that one node has not heard n transmissions
• Example: 10% loss
• 1 in 10 nodes will not hear one transmission
• 1 in 100 nodes will not hear two transmissions
• 1 in 1000 nodes will not hear three, etc.
• Fundamental bound to maintaining a per-node
communication rate
IETF 74 15
Intervals
(exponential timers)
• Two constants: τl << τh
• One variable: τ
• Operate over time intervals of length τ
•At end of interval, double τ up to τh
•On detecting an inconsistency, set τ to τl
• Consistent network has large intervals
• Inconsistency leads to small intervals
IETF 74 16
Simulated Propagation
• Inconsistency at
lower left corner
• 16 hop network
• Time to reception
in seconds
• Set τl = 1 sec
• Set τh = 1 min
• 20s for 16 hops
• Wave of activity
IETF 74 17
Example: Routing
(distance vector)
• Reset τ when
• Receive a packet with a higher distance
• Distance drops significantly
• Use τl =32ms, τh =1 hour, compare with fixed
beacons of 30s
• Reduces control traffic by 75%
• Reduces latency to repair loops by 99.9%
IETF 74 18
Details
• Current implementations require
• 4-7 bytes of RAM
• 30-100 lines of code
• Diversity addresses topology edge cases
• Node diversity
• Spatial diversity
• Temporal diversity
• Self-regulating and adapting
IETF 74 19
Summary
• Trickle: algorithm for eventual consistency in
a wireless network
• Very simple, highly efficient
• Many uses
•Routing topology
•Reliable broadcasts
•Neighbor discovery
IETF 74 20
References
• Philip Levis, Eric Brewer, David Culler, David Gay, Samuel Madden, Neil Patel, Joe
Polastre, Scott Shenker, Robert Szewczyk, and Alec Woo. "The Emergence of a
Networking Primitive in Wireless Sensor Networks." In Communications of the
ACM,Volume 51, Issue 7, July 2008.
Best starting point.
• Jonathan W. Hui and David E. Culler. “IP is Dead, Long Live IP for Wireless Sensor
Networks.” In Proceedings of the 6th International Conference on Embedded
Networked Sensor Systems (SenSys), 2008.
• Philip Levis, Neil Patel, David Culler, and Scott Shenker. "Trickle: A Self-Regulating
Algorithm for Code Propagation and Maintenance in Wireless Sensor Networks." In
Proceedings of the First USENIX/ACM Symposium on Networked Systems Design
and Implementation (NSDI 2004).
• Omprakash Gnawali, Rodrigo Fonseca, Kyle Jamieson, and Philip Levis. "Robust and
Efficient Collection through Control and Data Plane Integration." Technical Report
SING-08-02.
IETF 74 21
Questions
IETF 74 22
Draft Plans
• Precise algorithm specification
• Statement of how to reference algorithm in
protocol specification documents
• Consistency criteria
• Constants: k, τl, τh
• Discussion of interoperability concerns and
performance implications of inconsistent
constant values
IETF 74 23
Cumulative(Number of beacons) Experimental Data 1
35000
CTP
30000 MultiHopLQI
25000
20000
15000
10000
5000
0
0 1 2 3 4 5
Time(hours)
IETF 74 24
Experimental Data 2
IETF 74 25