Declarative Networking Tutorial Boon Thau Loo CIS 800/003 – Rigorous Internet Protocol Engineering Fall 2011.

Slides:



Advertisements
Similar presentations
Declarative Networking: Language, Execution and Optimization Boon Thau Loo 1, Tyson Condie 1, Minos Garofalakis 2, David E. Gay 2, Joseph M. Hellerstein.
Advertisements

1 Datalog: Logic Instead of Algebra. 2 Datalog: Logic instead of Algebra Each relational-algebra operator can be mimicked by one or several Database Logic.
Implementing Declarative Overlays From two talks by: Boon Thau Loo 1 Tyson Condie 1, Joseph M. Hellerstein 1,2, Petros Maniatis 2, Timothy Roscoe 2, Ion.
©Silberschatz, Korth and Sudarshan5.1Database System Concepts Chapter 5: Other Relational Languages Query-by-Example (QBE) Datalog.
Towards a Declarative Language and System for Secure Networking Martín Abadi 1,2, Boon Thau Loo 3 1 Microsoft Research Silicon Valley, 2 UC Santa Cruz,
Creating an Assessment Portfolio for Your Instruction Program Jennifer Nutefall Instruction Coordinator George Washington University Washington, DC
Digital Logic Design Lecture 28. Announcements Homework 9 due on Thursday 12/11 Please fill out Course Evaluations online. Final exam will be on Thursday,
RECURSIVE PATTERNS WRITE A START VALUE… THEN WRITE THE PATTERN USING THE WORDS NOW AND NEXT: NEXT = NOW _________.
UNIT 39 Animation for Web. TIME CHALLENGE Get going.
1.2 Represent Functions as Rules and Tables
COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008.
PHP Basics Course Introduction SoftUni Team Technical Trainers Software University
Equations of Linear Relationships
An Intelligent Analyzer and Understander of English Yorick Wilks 1975, ACM.
Chapter 9 Databases Objectives Understand a DBMS and define its components. Understand the architecture of a DBMS and its levels. Distinguish between.
Unit 3 Lesson 1 Are We Relations? Demonstrating Mastery.
CSC339 Computer Communications & Networks Qaisar Javaid, Assistant Professor CIIT.
Iconic Programmer A Visualization Tool for Teaching Concepts without Context.
MTH221 November 6, /6/ DISCRETE MATHEMATICS FOR IT PROFESSIONALS Pair the class Set dates See students progress Assignments Final Exam Quizzes.
Universal fuzzy system representation with XML Authors : Chris Tseng, Wafa Khamisy, Toan Vu Source : Computer Standards & Interfaces, Volume 28, Issue.
 Scheduling  Member Information  Tracking Progress  Attendance.
OVERVIEW Course summary Course schedule Assessment Ground rules.
September 6. Announcements  First Chapter analysis due September 13.
CS589 Principles of DB Systems Fall 2008 Lecture 4c: Query Language Equivalence Lois Delcambre
DBM 265 Week 4 Individual Assignment DBMS Support and Security Paper Write a 750- to 1,000-word paper in which you discuss the support and security strategies.
DBM 380 Week 2 Individual Assignment Database Design Paper Write a 350- to 700-word paper in which you do the following: Explain what database systems.
DBM 384 Week 1 Assignment Database Matrix Check this A+ tutorial guideline at 384/DBM-384-Week-1-Assignment-Database-
NTC 362 RANK Let's Do This /ntc362rank.com
COSC 5V90 Functional Programming and Interactive Theorem Proving
Overview of Data Communications and Networking
Input/Output tables.
Objective – To use tables to represent functions.
Enhanced Provenance Model (TAP): Time-aware Provenance for Distributed Systems Original Article: Wenchao Zhou, Ling Ding, Andreas Haeberlen, Zachary Ives,
TMC 1414 Introduction to Programming
Model Functions Input x 6 = Output Input x 3 = Output
Computer courses in Chandigarh. Very Brief History of Computers.
CIS 406Competitive Success/tutorialrank.com
IM 300Competitive Success/tutorialrank.com
IM 300 Education for Service-- tutorialrank.com. IM 300 Week 1 Individual Assignment Sharing Database Knowledge For more course tutorials visit
Database Processing: David M. Kroenke’s Chapter One: Introduction
שילוב קורסים לפיתוח מיומנויות למידה במכללה להנדסה
ENGT 3050 Vamsi Borra Instructor: Ph.D. candidate, EECS department
Overview of Data Communications and Networking
1.6 Represent Functions as Rules and Tables
Overview of Data Communications and Networking
Relations vs. Functions Function Notation, & Evaluation
C Graphing Functions.
Logic for Artificial Intelligence
VOCABULARY! EXAMPLES! Relation: Domain: Range: Function:
FAY Dates School Year Traditional Fall 4x4 Spring 4x
Notes Over 11.5 Recursive Rules
Function Rules and Tables.
Date, location, department
Ordered Pairs Part 1 Use the following equation to find an ordered pair (x, y) that will be a solution of: x + y = 10.
x-Value = The horizontal value in an ordered pair or input Function = A relation that assigns exactly one value in the range to each.
Date, location, department
FAY Dates School Year Traditional Fall 4x4 Spring 4x
Type in name of presentation here
Objective- To use an equation to graph the
Unit 3 Day 4.
Common Core #11 Ordered Part 1 Pairs
Warm-Up Study the patterns below to determine the next five numbers in each sequence. You may use the calculator to check your answers. 2, 4, 6, 8, 10...
Objective- To graph a relationship in a table.
X Y Relation (a set of ordered pairs) x y x y ( , ) x y Mapping
Relation (a set of ordered pairs)
NAME OF EVENT Name of Speaker Date, location, department
Path Oram An Extremely Simple Oblivious RAM Protocol
IS 551 – Preliminary Schedule
Arithmatic Logic Unit (ALU). ALU Input Data :  A0-A3  B0-B3 Output Data :  F0 – F3.
Lesson 3.3 Writing functions.
Presentation transcript:

Declarative Networking Tutorial Boon Thau Loo CIS 800/003 – Rigorous Internet Protocol Engineering Fall 2011

Announcements Guest speaker: Pamela Zave (AT&T Research) Dec 5 & 7: project presentations – 10 minute “Progress report” – Six groups on Dec 5, Five groups on Dec 7 – Food on Dec 7 – Indicate your date preference, or we will assign randomly by Nov 30. 2

Outline Brief History of Datalog Datalog crash course Declarative networking 3

A Brief History of Datalog ‘95 Control + data flow BDDBDDB ‘05‘07‘08.QL ‘10 Declarative networking Data integration ’80s … LDL, NAIL, Coral,... ‘02 Access control (Binder) Information Extraction SecureBlox ‘77 Workshop on Logic and Databases Evita Raced Doop (pointer- analysis) Orchestra CDSS 4

Syntax of Datalog Rules ,, …,. Datalog rule syntax: Body consists of one or more conditions (input tables) Head is an output table Recursive rules: result of head in rule body Body Head 5

Example: All-Pairs Reachability R2: reachable(S,D) <- link(S,Z), reachable(Z,D). R1: reachable(S,D) <- link(S,D). Input: link(source, destination) Output: reachable(source, destination) “For all nodes S,D, If there is a link from S to D, then S can reach D”. link(a,b) – “there is a link from node a to node b” reachable(a,b) – “node a can reach node b” 6

Example: All-Pairs Reachability R2: reachable(S,D) <- link(S,Z), reachable(Z,D). R1: reachable(S,D) <- link(S,D). Input: link(source, destination) Output: reachable(source, destination) “For all nodes S,D and Z, If there is a link from S to Z, AND Z can reach D, then S can reach D”. 7

Terminology and Convention An atom is a predicate, or relation name with arguments. Convention: Variables begin with a capital, predicates begin with lower-case. The head is an atom; the body is the AND of one or more atoms. Extensional database predicates (EDB) – source tables Intensional database predicates (IDB) – derived tables reachable(S,D) <- link(S,Z), reachable(Z,D). 8

Negated Atoms We may put ! (NOT) in front of a atom, to negate its meaning. Example: For any given node S, return all nodes D that are two hops away, where D is not an immediate neighbor of S. Not “cut” in Prolog. twoHop(S,D) <- link(S,Z), link(Z,D) ! link(S,D). ZD S link(S,Z)link(Z,D) 9

Safe Rules Safety condition: – Every variable in the rule must occur in a positive (non- negated) relational atom in the rule body. – Ensures that the results of programs are finite, and that their results depend only on the actual contents of the database. Examples of unsafe rules: – s(X) <- r(Y). – s(X) <- r(Y), ! r(X). 10

Semantics Model-theoretic — Most “declarative”. Based on model-theoretic semantics of first order logic. View rules as logical constraints. — Given input DB I and Datalog program P, find the smallest possible DB instance I’ that extends I and satisfies all constraints in P. Fixpoint-theoretic —Most “operational”. Based on the immediate consequence operator for a Datalog program. —Least fixpoint is reached after finitely many iterations of the immediate consequence operator. —Basis for practical, bottom-up evaluation strategy. Proof-theoretic —Set of provable facts obtained from Datalog program given input DB. —Proof of given facts (typically, top-down Prolog style reasoning) 11

The “Naïve” Evaluation Algorithm 1.Start by assuming all IDB relations are empty. 2.Repeatedly evaluate the rules using the EDB and the previous IDB, to get a new IDB. 3.End when no change to IDB. Start: IDB = 0 Apply rules to IDB, EDB Change to IDB? no yes done 12

Naïve Evaluation reachablelink reachable(S,D) <- link(S,D). reachable(S,D) <- link(S,Z), reachable(Z,D). 13

Semi-naïve Evaluation Since the EDB never changes, on each round we only get new IDB tuples if we use at least one IDB tuple that was obtained on the previous round. Saves work; lets us avoid rediscovering most known facts. – A fact could still be derived in a second way. 14

Semi-naïve Evaluation reachablelink reachable(S,D) <- link(S,D). reachable(S,D) <- link(S,Z), reachable(Z,D). 15

Recursion with Negation reachable(S,D) <- link(S,D). reachable(S,D) <- link(S,Z), reachable(Z,D). unreachable(S,D) <- node(S), node(D), ! reachable(S,D). Example: to compute all pairs of disconnected nodes in a graph. -- Stratum 0 reachable Stratum 1 unreachable Precedence graph : Nodes = IDB predicates. Edge q <- p if predicate q depends on p. Label this arc “–” if the predicate p is negated. 16

Stratified Negation Straightforward syntactic restriction. When the Datalog program is stratified, we can evaluate IDB predicates lowest-stratum-first. Once evaluated, treat it as EDB for higher strata. Non-stratified example: Stratum 0 reachable Stratum 1 unreachable reachable(S,D) <- link(S,D). reachable(S,D) <- link(S,Z), reachable(Z,D). unreachable(S,D) <- node(S), node(D), ! reachable(S,D). p(X) <- q(X), ! p(X)

Suggested Readings Survey papers: A Survey of Research on Deductive Database Systems, Ramakrishnan and Ullman, Journal of Logic Programming, 1993 What you always wanted to know about datalog (and never dared to ask), by Ceri, Gottlob, and Tanca. An Amateur’s Expert’s Guide to Recursive Query Processing, Bancilhon and Ramakrishnan, SIGMOD Record. Database Encyclopedia entry on “DATALOG”. Grigoris Karvounarakis. Textbooks: Foundations in Databases. Abiteboul, Hull, Vianu. Database Management Systems, Ramakrishnan and Gehkre. Chapter on “Deductive Databases”. Course lecture notes: Jeff Ullman’s CIS 145 class lecture slides. Raghu Ramakrishnan and Johannes Gehrke’s lecture slides for Database Management Systems textbook. 18

Outline Brief History of Datalog Datalog crash course Declarative networking 19

Declarative Networking A declarative framework for networks: – Declarative language: “ask for what you want, not how to implement it” – Declarative specifications of networks, compiled to distributed dataflows – Runtime engine to execute distributed dataflows Observation: Recursive queries are a natural fit for routing 20

A Declarative Network Distributed recursive query Traditional Networks Declarative Networks Network State Distributed database Network protocol Recursive Query Execution Network messages Distributed Dataflow Dataflow messages Dataflow messages 21

Declarative* in Distributed Systems Programming IP Routing [SIGCOMM’05, SIGCOMM’09 demo] Overlay networks [SOSP’05] Distributed debugging [Eurosys’06] Sensor networks [SenSys’07] Network composition [CoNEXT’08] Fault tolerant protocols [NSDI’08] Secure networks [ICDE’09, CIDR’09, NDSS’10, SIGMOD’10] Replication [NSDI’09] Hybrid wireless networking [ICNP’09, TON’11] Formal network verification [HotNets’09, SIGCOMM’11 demo] Network forensics [SIGMOD’10, SOSP’11] Cloud programming [Eurosys ‘10], Cloud testing [NSDI’11] … Distributed recursive query processing [SIGMOD’06, ICDE’09, PODS’11] Databases Networking Systems Security

Open-source systems P2 declarative networking system – The “original” system – Based on modifications to the Click modular router. – RapidNet – Integrated with network simulator 3 (ns-3), ORBIT wireless testbed, and PlanetLab testbed. – Security and provenance extensions. – Demonstrations at SIGCOMM’09, SIGCOMM’11, and SIGMOD’11 – BOOM – Berkeley Orders of Magnitude – BLOOM (DSL in Ruby, uses Dedalus, a temporal logic programming language as its formal basis). –

All-Pairs Reachability R1: <- R2: <- Network Datalog c d reachable Output table: Input @dc link c b b c reachable Location Specifier query <- 24

Implicit Communication A networking language with no explicit communication: R2: <- Data placement induces communication 25

Path Vector Protocol Example Advertisement: entire path to a destination Each node receives advertisement, adds itself to path and forwards to neighbors path=[c,d]path=[b,c,d]path=[a,b,c,d] c advertises [c,d]b advertises [b,c,d] bdca 26

Path Vector in Network Datalog Input: destination) Query output: destination, pathVector) R1: <- P=(S,D). R2: P=S  P 2. 2 ), <- query <- Add S to front of P 2 27

SQL-99 Equivalent with recursive path(src, dst, vec, length) as ( SELECT src,dst, f_initPath(src,dst),1 from link UNION SELECT link.src,path.dst,link.src ||’.’|| vec, length+1 FROM link, path where link.dst = path.src) create view minHops(src,dst,length) as ( SELECT src,dst,min(length) FROM path group by src,dst) create view shortestPath(src,dst,vec,length) as ( SELECT P.src,P.dst,vec,P.length FROM path P, minHops H WHERE P.src = H.src and P.dst = H.dst and P.length = H.length) R2 R1

Datalog  Execution Plan R1:  P=(S,D). R2: R1 Recursion P=S  P 2. link.S=path.S R2 while (receive )) { for each neighbor S { newpath = path(S,D,S+P 2 ) send newpath to neighbor S } 2 ),  Send path.S Matching variable Z = “Join” Pseudocode at node Z: while (receive )) { for each neighbor S { newpath = path(S,D,S+P2) send newpath to neighbor S }

@SDP Query DP @dc link bdca path Forwarding table: R1: <- P=(S,D). R2: <- 2 ), P=S  P 2. query <- 30

@SDP DP Query Execution Forwarding table: bdca query <- @dc link path Communication patterns are identical to those in the actual path vector protocol Matching variable Z = “Join” R1: <- P=(S,D). R2: <- 2 ), P=S  P 2. 31

R1: <- P=(S,D). R2: <- 1 ), 2,C 2 ), C=C 1 +C 2, <- R3: ) <- R4: <- All-pairs Shortest-path P=S  P 2. 32

Distributed Semi-naïve Evaluation Semi-naïve evaluation: – Iterations (rounds) of synchronous computation – Results from iteration i th used in (i+1) th Path Table hop hop hop 4 Link TableNetwork Problem: How do nodes know that an iteration is completed? Unpredictable delays and failures make synchronization difficult/expensive. 9 33

Pipelined Semi-naïve (PSN) Fully-asynchronous evaluation: – Computed tuples in any iteration are pipelined to next iteration – Natural for distributed dataflows Path Table Link TableNetwork Relaxation of semi-naïve 34 10

Dataflow Graph Nodes in dataflow graph (“elements”): Network elements (send/recv, rate limitation, jitter) Flow elements (mux, demux, queues) Relational operators (selects, projects, joins, aggregates) Strands Messages Network In Messages Network Out Single Node 35

Rule  Dataflow “Strands” R2: <- 2 ), P=S  P2. 36

Localization Rewrite Rules may have body predicates at different locations: R2: <- 2 ), P=S  P 2. R2b:  2 ), P=S  P 2. R2a:  Matching variable Z = “Join” Rewritten rules: Matching variable Z = “Join” 37

Logical Execution Plan R2b: Recursion P=S  P 2. link.S=path.S R2 2 ),  Send path.S

Physical Execution Plan Strand Elements  path Join path.Z = linkD.Z linkD Project path(S,D,P) Send to path.S R2b: <- 2 ), P=S  P 2. Network In  linkD Join linkD.Z = path.Z path Project path(S,D,P) Send to path.S 39

Pipelined Delta Rules Given a rule, decompose into “event-condition-action” delta rules Delta rules translated into rule strands Consider the rule  2 ), P=S  P 2. Insertion delta rules:  2 ), P=S  P 2.  2 ), P=S  P 2. Deletion delta rules:  2 ), P=S  P 2.  2 ), P=S  P 2.

Pipelined Evaluation Challenges: – Does PSN produce the correct answer? – Is PSN bandwidth efficient? I.e. does it make the minimum number of inferences? Theorems [SIGMOD’06]: – RS SN (p) = RS PSN (p), where RS is results set – No repeated inferences in computing RS PSN (p) – Require per-tuple timestamps in delta rules and FIFO and reliable channels 41

Incremental View Maintenance Leverages insertion and deletion delta rules for state modifications. Complications arise from duplicate evaluations. Consider the Reachable query. What if there are many ways to route between two nodes a and b, i.e. many possible derivations for reachable(a,b)? Mechanisms: still use delta rules, but additionally, apply – Count algorithm (for non-recursive queries). – Delete and Rederive (SIGMOD’93). Expensive in distributed settings. Maintaining Views Incrementally. Gupta, Mumick, Ramakrishnan, Subrahmanian. SIGMOD

Recent PSN Enhancements Provenance-based approach – Condensed form of provenance piggy-backed with each tuple for derivability test. – Recursive Computation of Regions and Connectivity in Networks. Liu, Taylor, Zhou, Ives, and Loo. ICDE Relaxation of FIFO requirements: – Maintaining Distributed Logic Programs Incrementally. Vivek Nigam, Limin Jia, Boon Thau Loo and Andre Scedrov. 13th International ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming (PPDP),

Overview of Optimizations Traditional: evaluate in the NW context – Aggregate Selections – Magic Sets rewrite – Predicate Reordering New: motivated by NW context – Multi-query optimizations: Query Results caching Opportunistic message sharing – Cost-based optimizations Neighborhood density function Hybrid rewrites – Policy-based adaptation See PUMA. PV/DV  DSR Zone Routing Protocol

Magic Sets Rewrite Unlike Prolog goal-oriented top-down evaluation, Datalog’s bottom-up evaluation produces too many unnecessary facts. Networking analogy: computing all-pairs shortest paths is an overkill, if we are only interested in specific routes from sources to destinations. Solution: magic sets rewrite. IBM’s DB2 for non-recursive queries. Dynamic Source Routing (DSR): PV + magic sets :- P = (S,D). :- link C = C1 + C2, P = P1  Z. ) :- :-

Aggregate Selections Prune communication using running state of monotonic aggregate – Avoid sending tuples that do not affect value of agg – E.g., shortest-paths query Challenge in distributed setting: – Out-of-order (in terms of monotonic aggregate) arrival of tuples – Solution: Periodic aggregate selections Buffer up tuples, periodically send best-agg tuples

Suggested Readings Networking use cases: – Declarative Routing: Extensible Routing with Declarative Queries. Loo, Hellerstein, Stoica, and Ramakrishnan. SIGCOMM – Implementing Declarative Overlays. Loo, Condie, Hellerstein, Maniatis, Roscoe, and Stoica. SOSP Distributed recursive query processing: – *Declarative Networking: Language, Execution and Optimization. Loo, Condie, Garofalakis, Gay, Hellerstein, Maniatis, Ramakrishnan, Roscoe, and Stoica, SIGMOD 06. – Recursive Computation of Regions and Connectivity in Networks. Liu, Taylor, Zhou, Ives, and Loo. ICDE

Evolution of Declarative Networking (A Penn Perspective) ‘08 ‘06 ‘10 ‘05 ‘09 ‘11 Routing [SIGCOMM’05] Overlays [SOSP’05] Overlay Composition [CoNEXT’08] NetTrails release [SIGMOD’11 demo] Secure Network Provenance [SOSP’11] Network Provenance [SIGMOD’10] Declarative Network Verification [PADL’08] Formally Safe Routing Toolkit [SIGCOMM’11 demo] Formally Verifiable Networking [HotNets’09] Cloud Optimizations [SOCC’11] Adaptive Wireless Routing [ICNP’09, TON’11, COMSNET’11] Recursive Views [ICDE’09] Network Datalog and PSN [SIGMOD’06’] SecureBlox [SIGMOD’10] Declarative Anonymity [NDSS’10] Secure Network Datalog [ICDE’09] ns-3 compatible release [SIGCOMM’09 demo] [SIGCOMM’11 Education] [SIGMOD’11 Tutorial]