NetKATA Formal System for the Verification of Networks Dexter Kozen - - PowerPoint PPT Presentation

netkat a formal system for the verification of networks
SMART_READER_LITE
LIVE PREVIEW

NetKATA Formal System for the Verification of Networks Dexter Kozen - - PowerPoint PPT Presentation

NetKATA Formal System for the Verification of Networks Dexter Kozen Cornell University AutoMathA 2015 Leipzig 7 May 2015 NetKAT Collaborators Carolyn Jane Anderson, Nate Foster, Arjun Guha, Jean-Baptiste Jeannin, Dexter Kozen, Cole


slide-1
SLIDE 1

NetKAT—A Formal System for the Verification of Networks

Dexter Kozen Cornell University AutoMathA 2015 Leipzig 7 May 2015

slide-2
SLIDE 2

NetKAT Collaborators

Carolyn Jane Anderson, Nate Foster, Arjun Guha, Jean-Baptiste Jeannin, Dexter Kozen, Cole Schlesinger, and David Walker, NetKAT: Semantic Foundations for Networks. POPL 14. Nate Foster, Dexter Kozen, Matthew Milano, Alexandra Silva, and Laure Thompson, A Coalgebraic Decision Procedure for NetKAT. POPL 15.

slide-3
SLIDE 3

Networking

“The last bastion of mainframe computing” [Hamilton 2009]

◮ Modern computers

◮ implemented with commodity hardware ◮ programmed using general-purpose languages, standard interfaces

◮ Networks

◮ built and programmed the same way since the 1970s ◮ low-level, special-purpose devices implemented on custom hardware ◮ routers and switches that do little besides maintaining routing tables

and forwarding packets

◮ configured locally using proprietary interfaces ◮ network configuration (“tuning”) largely a black art

slide-4
SLIDE 4

Networking

Ill-suited to modern data centers and cloud-based applications

◮ Difficult to implement end-to-end routing policies and optimizations

that require a global perspective

◮ Difficult to extend with new functionality ◮ Effectively impossible to reason precisely about behavior

slide-5
SLIDE 5

Software Defined Networks (SDN)

Main idea behind SDN

A general-purpose controller manages a collection of programmable switches

◮ controller can monitor and respond to network events

◮ new connections from hosts ◮ topology changes ◮ shifts in traffic load

◮ controller can reprogram the switches on the fly

◮ adjust routing tables ◮ change packet filtering policies

slide-6
SLIDE 6
slide-7
SLIDE 7

Software Defined Networks (SDN)

Controller has a global view of the network Enables a wide variety of applications:

◮ standard applications

◮ shortest-path routing ◮ traffic monitoring ◮ access control

◮ more sophisticated applications

◮ load balancing ◮ intrusion detection ◮ fault tolerance

slide-8
SLIDE 8

Software Defined Networks (SDN)

“ In the SDN architecture, the control and data planes are

decoupled, network intelligence and state are logically centralized, and the underlying network infrastructure is abstracted from the applications. As a result, en- terprises and carriers gain unprecedented programma- bility, automation, and network control, enabling them to build highly scalable, flexible networks that readily adapt to changing business needs.” —Open Networking Foundation, Software-Defined Networking: The New Norm for Networks, 2012

slide-9
SLIDE 9

OpenFlow

A first step: the OpenFlow API [McKeown & al., SIGCOMM 08]

◮ specifies capabilities and behavior of switch hardware ◮ a language for manipulating network configurations ◮ very low-level: easy for hardware to implement, difficult for humans

to write and reason about

  • But. . .

◮ is platform independent ◮ provides an open standard that any vendor can implement

slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12

Network Programming Languages & Analysis Tools

◮ Formally Verifiable Networking [Wang & al., HotNets 09] ◮ FlowChecker [Al-Shaer & Saeed Al-Haj, SafeConfig 10] ◮ Anteater [Mai & al., SIGCOMM 11] ◮ Nettle [Voellmy & Hudak, PADL 11] ◮ Header Space Analysis [Kazemian & al., NSDI 12] ◮ Frenetic [Foster & al., ICFP 11] [Reitblatt & al., SIGCOMM 12] ◮ NetCore [Guha & al., PLDI 13] [Monsanto & al., POPL 12] ◮ Pyretic [Monsanto & al., NSDI 13] ◮ VeriFlow [Khurshid & al., NSDI 13] ◮ Participatory networking [Ferguson & al., SIGCOMM 13] ◮ Maple [Voellmy & al., SIGCOMM 13]

Goals:

◮ raise the level of abstraction above hardware-based APIs (OpenFlow) ◮ make it easier to build sophisticated and reliable SDN applications

and reason about them

slide-13
SLIDE 13

Network Programming Languages & Analysis Tools

  • Formally Verifiable Networking [Wang & al., HotNets 09]
  • FlowChecker [Al-Shaer & Saeed Al-Haj, SafeConfig 10]
  • Anteater [Mai & al., SIGCOMM 11]
  • Nettle [Voellmy & Hudak, PADL 11]
  • Header Space Analysis [Kazemian & al., NSDI 12]

◮ Frenetic [Foster & al., ICFP 11] [Reitblatt & al., SIGCOMM 12] ◮ NetCore [Guha & al., PLDI 13] [Monsanto & al., POPL 12]

  • Pyretic [Monsanto & al., NSDI 13]
  • VeriFlow [Khurshid & al., NSDI 13]
  • Participatory networking [Ferguson & al., SIGCOMM 13]
  • Maple [Voellmy & al., SIGCOMM 13]

Goals:

  • raise the level of abstraction above hardware-based APIs (OpenFlow)
  • make it easier to build sophisticated and reliable SDN applications

and reason about them

slide-14
SLIDE 14

NetKAT [Anderson & al. 14]

NetKAT = Kleene algebra with tests (KAT) + additional specialized constructs particular to network topology and packet switching

slide-15
SLIDE 15

Kleene Algebra (KA)

Stephen Cole Kleene (1909–1994) (0 + 1(01∗0)∗1)∗ {multiples of 3 in binary}

1 1 1

(ab)∗a = a(ba)∗ {a, aba, ababa, . . .}

a b

(a + b)∗ = a∗(ba∗)∗ {all strings over {a, b}}

a + b

slide-16
SLIDE 16

Foundations of the Algebraic Theory

John Horton Conway (1937–)

  • J. H. Conway. Regular Algebra

and Finite Machines. Chapman and Hall, London, 1971.

slide-17
SLIDE 17

Axioms of KA

Idempotent Semiring Axioms p + (q + r) = (p + q) + r p(qr) = (pq)r p + q = q + p 1p = p1 = p p + 0 = p p0 = 0p = 0 p + p = p p(q + r) = pq + pr a ≤ b

⇐ ⇒ a + b = b (p + q)r = pr + qr Axioms for ∗ 1 + pp∗ ≤ p∗ q + px ≤ x ⇒ p∗q ≤ x 1 + p∗p ≤ p∗ q + xp ≤ x ⇒ qp∗ ≤ x

slide-18
SLIDE 18

Standard Model

Regular sets of strings over Σ

A + B = A ∪ B AB = {xy | x ∈ A, y ∈ B} A∗ =

  • n≥0

An = A0 ∪ A1 ∪ A2 ∪ · · · 1 = {ε} = ∅ This is the free KA on generators Σ

slide-19
SLIDE 19

Relational Models

Binary relations on a set X

For R, S ⊆ X × X, R + S = R ∪ S RS = R ◦ S = {(u, v) | ∃w (u, w) ∈ R, (w, v) ∈ S} R∗ = reflexive transitive closure of R =

  • n≥0

Rn = R0 ∪ R1 ∪ R2 ∪ · · · 1 = identity relation = {(u, u) | u ∈ X} = ∅ KA is complete for the equational theory of relational models

slide-20
SLIDE 20

Other Models

◮ Trace models used in semantics ◮ (min, +) algebra used in shortest path algorithms ◮ (max, ·) algebra used in coding ◮ Convex sets used in computational geometry (Iwano & Steiglitz 90)

slide-21
SLIDE 21

Matrices over a KA form a KA

a b c d

  • +

e f g h

  • =

a + e b + f c + g d + h

  • a

b c d

  • ·
  • e

f g h

  • =
  • ae + bg

af + bh ce + dg cf + dh

  • 0 =
  • 1 =

1 1

  • a

b c d ∗ = (a + bd∗c)∗ (a + bd∗c)∗bd∗ (d + ca∗b)∗ca∗ (d + ca∗b)∗

  • b

a c d

slide-22
SLIDE 22

Systems of Affine Linear Inequalities

Theorem Any system of n linear inequalities in n unknowns has a unique least solution q1 + p11x1 + p12x2 + · · · p1nxn ≤ x1 . . . qn + pn1x1 + pn2x2 + · · · pnnxn ≤ xn

≤ + P = pij x1 x2 . . . xn x1 x2 . . . xn q1 q2 . . . qn Least solution is P∗q

slide-23
SLIDE 23

Kleene Algebra with Tests (KAT)

(K, B, +, ·,∗ , , 0, 1), B ⊆ K

◮ (K, +, ·,∗ , 0, 1) is a Kleene algebra ◮ (B, +, ·, , 0, 1) is a Boolean algebra ◮ (B, +, ·, 0, 1) is a subalgebra of (K, +, ·, 0, 1) ◮ p, q, r, . . . range over K ◮ a, b, c, . . . range over B

slide-24
SLIDE 24

Kleene Algebra with Tests (KAT)

+, ·, 0, 1 serve double duty

◮ applied to actions, denote choice, composition, fail, and skip, resp. ◮ applied to tests, denote disjunction, conjunction, falsity, and truth,

resp.

◮ these usages do not conflict!

bc = b ∧ c b + c = b ∨ c

slide-25
SLIDE 25

Modeling While Programs

p; q

= pq if b then p else q

= bp + bq while b do p

= (bp)∗b

slide-26
SLIDE 26

KAT Subsumes Hoare Logic

{b} p {c}

⇐ ⇒ bp ≤ pc ⇐ ⇒ bp = bpc ⇐ ⇒ bpc = 0 The Hoare while rule {bc} p {c} {c} while b do p {bc} becomes the universal Horn sentence bcpc = 0 ⇒ c(bp)∗bbc = 0

slide-27
SLIDE 27

KAT Results

Deductive Completeness and Complexity

◮ deductively complete over language, relational, and trace models ◮ subsumes propositional Hoare logic (PHL) ◮ deductively complete for all relationally valid Hoare-style rules

{b1} p1 {c1}, . . . , {bn} pn {cn} {b} p {c}

◮ decidable in PSPACE

Applications

◮ protocol verification ◮ static analysis and abstract interpretation ◮ verification of compiler optimizations

slide-28
SLIDE 28

Models of KAT

◮ Language-theoretic models

◮ K = sets of guarded strings over Σ, T ◮ B = free Boolean algebra generated by T

◮ Relational models

◮ K = binary relations on a set X ◮ B = subsets of the identity relation

◮ Trace models

◮ K = sets of traces s0p0s1p1s2 · · · sn−1pn−1sn ◮ B = traces of length 0

◮ n × n matrices over K, B

slide-29
SLIDE 29

NetKAT

slide-30
SLIDE 30

NetKAT

◮ a packet π is an assignment of constant values n to fields x ◮ a packet history is a nonempty sequence of packets

π1 :: π2 :: · · · :: πk

◮ the head packet is π1

NetKAT

◮ assignments x ← n

assign constant value n to field x in the head packet

◮ tests x = n

if value of field x in the head packet is n, then pass, else drop

◮ dup

duplicate the head packet

slide-31
SLIDE 31

NetKAT

Example

sw = 6 ; pt = 88 ; dest ← 10.0.0.1 ; pt ← 50 “For all packets incoming on port 88 of switch 6, set the destination IP address to 10.0.0.1 and send the packet out on port 50.”

slide-32
SLIDE 32

NetKAT Axioms

x ← n ; y ← m ≡ y ← m ; x ← n (x = y) assignments to distinct fields may be done in either order x ← n ; y = m ≡ y = m ; x ← n (x = y) an assignment to a field does not affect a different field x = n ; dup ≡ dup ; x = n field values are preserved in a duplicated packet x ← n ≡ x ← n ; x = n an assignment causes the field to have that value x = n ; x ← n ≡ x = n an assignment of a value that the field already has is redundant x ← n ; x ← m ≡ x ← m a second assignment to the same field overrides the first x = n ; x = m ≡ 0 (n = m) (

n x = n) ≡ 1

every field has exactly one value

slide-33
SLIDE 33

Standard Model

Standard model of NetKAT is a packet-forwarding model e : H → 2H where H = {packet histories} x ← n(π1 :: σ)

= {π1[n/x] :: σ} x = n(π1 :: σ)

=

  • {π1 :: σ}

if π1(x) = n ∅ if π1(x) = n dup(π1 :: σ)

= {π1 :: π1 :: σ}

slide-34
SLIDE 34

Standard Model

p + q(σ)

= p(σ) ∪ q(σ) p ; q(σ)

=

  • τ∈p(σ)

q(τ) p∗(σ)

=

  • n

pn(σ) 1(σ)

= pass(σ) = {σ} 0(σ)

= drop(σ) = ∅

slide-35
SLIDE 35

Examples

Reachability

◮ Can host A communicate with host B? Can every host

communicate with every other host?

Security

◮ Does all untrusted traffic pass through the intrusion detection

system located at C?

Loop detection

◮ Is it possible for a packet to be forwarded around a cycle in the

network?

slide-36
SLIDE 36

Encoding Network Topology

Modeling Links

sw = A ; pt = n ; sw ← B ; pt ← m

A B n m

◮ filters out all packets not located at the source end of the link ◮ updates switch and port fields to the location of the target end ◮ this captures the effect of sending the packet across the link ◮ network topology is expressed as a sum of link expressions

slide-37
SLIDE 37

Switch Policies

Switch behavior for switch A is specified by a NetKAT term sw = A ; pA where pA specifies what to do with packets entering switch A

pA pA A

Example pt = n ; dest = a ; dest ← b ; (pt ← m + pt ← k) Incoming packets on port n with destination a ⇒ modify destination to b and send out on ports m and k Switch policy pA is the sum of all such behaviors for A

slide-38
SLIDE 38

Putting It Together

Let

◮ t = sum of all link expressions ◮ p = sum of all switch policies

Then

◮ pt = one step of the network ◮ each switch processes its packets, then sends them along links to the

next switch

◮ cross terms vanish! (x ← n; x = m ≡ 0 for n = m) ◮ (pt)∗ = the multistep behavior of the network in which the

single-step behavior is iterated

slide-39
SLIDE 39

Reachability

To check if any packet can travel from A to B given the topology and the switch policies, ask whether sw = A ; t(pt)∗ ; sw = B ≡ 0 (drop).

◮ prefix sw = A filters out packets not at A ◮ suffix sw = B filters out packets not at B

It can be shown that the lhs is equivalent to a sum of terms of the form sw = A ; x1 = n1 ; · · · ; xk = nk ; x1 ← m1 ; · · · ; xk ← mk ; sw = B each describing conditions under which a packet can travel from A to B

slide-40
SLIDE 40

All-Pairs Reachability

To check whether every host in the network can physically communicate with every other host, use switch policies sw = A ;

  • n

pt = n ;

  • m

pt ← m where

◮ n ranges over all active input ports of A ◮ m ranges over all active output ports of A

Let

◮ q = sum of these policies for all A ◮ t = encoding of the topology

Then check whether (qt)∗ ≡

  • A

(sw = A ;

  • n

pt = n) ;

  • B

(sw ← B ;

  • m

pt ← m)

slide-41
SLIDE 41

Waypointing

A waypoint between A to B is a location F that all packets must traverse enroute from A to B

◮ modify F’s switch policy to duplicate the head packet:

sw = F ; pF ⇒ sw = F ;dup; pF

◮ this marks traffic through F ◮ check whether

sw = A ; t(pt)∗ ; sw = B ≤ sw = A ; t(pt)∗ ; sw = F ;dup; pF ; t(pt)∗ ; sw = B

◮ true if and only if all packet histories contain a dup generated by

traversing F

slide-42
SLIDE 42

Forwarding Loops

A network has a forwarding loop if some packet would endlessly traverse a cycle in the network

◮ frequent source of error ◮ have caused major outages in LANs and the Internet ◮ usually handled by a TTL (time-to-live) field

To check for loops, check if a packet can visits the same state twice: α ; pt(pt)∗ ; α = 0 for each valuation α such that in ; (pt)∗ ; α does not vanish.

slide-43
SLIDE 43

Other Applications

◮ traffic isolation ◮ access control ◮ correctness of a compiler that maps a NetKAT expression to a set of

individual flow tables that can be deployed on the switches

slide-44
SLIDE 44

Results

Soundness and Completeness [Anderson et al. 14]

◮ ⊢ p = q if and only if p = q

Decision Procedure [Foster et al. 15]

◮ NetKAT coalgebra ◮ efficient bisimulation-based decision procedure ◮ implementation in OCaml ◮ deployed in the Frenetic suite of network management tools

slide-45
SLIDE 45

A Language Model

Let e be an expression to be analyzed and let x1, . . . , xk be all fields appearing in e.

◮ A complete assignment is a sequence x1 ← n1; · · · ; xk ← nk ◮ A complete test is a sequence x1 = n1; · · · ; xk = nk

Facts:

◮ Every test is (provably) equivalent to a sum of complete tests. ◮ Every assignment is (provably) equivalent to sum of complete tests

and complete assignments.

◮ The complete tests and complete assignments are in one-to-one

correspondence (one of each for each tuple (n1, . . . , nk))

slide-46
SLIDE 46

A Language Model

Let P = {complete assignments} = {p, q, . . .} and At = {complete tests} = {α, β, . . .} Let αp be the complete test corresponding to the complete assignment p Reduced NetKAT axioms: α dup = dup α αα = α pαp = p αβ = 0, α = β αpp = αp

  • α∈At α = 1

qp = p

slide-47
SLIDE 47

A Language Model

Regular sets of NetKAT reduced strings

N = At · P · (dup ·P)∗ For A, B ⊆ N, A + B = A ∪ B AB = {αxyq | αxp ∈ A, αpyq ∈ B} A∗ =

  • n≥0

An 1 = {αpp | p ∈ P} 0 = ∅

◮ p ∈ P interpreted as {αp | α ∈ At} ◮ α ∈ At interpreted as {αpα} ◮ dup interpreted as {αpp dup αp | p ∈ P}

Lemma Every string over P, At, and dup is equivalent to a sum of

strings in N

slide-48
SLIDE 48

Completeness

Theorem [Anderson & al. 14]

◮ RegN , the family of regular subsets of N, forms a NetKAT and is

isomorphic to the standard packet-switching model

◮ This is the free NetKAT on generators P and At ◮ The following are equivalent:

◮ NetKAT ⊢ e1 = e2 ◮ e1 = e2 ◮ RegN e1 = e2

slide-49
SLIDE 49

NetKAT Automata [Foster & al. 14]

A NetKAT automaton is a tuple (S, ε, δ) where ε : S → 2At×At δ : S → SAt×At Acceptance of strings in N = At · P · (dup · P)∗ defined by

◮ Accept(s, αpβ dup x)

= Accept(δαβ(s), βx)

◮ Accept(s, αpβ)

= εαβ(s)

slide-50
SLIDE 50

NetKAT Automata [Foster & al. 14]

A NetKAT automaton is a tuple (S, ε, δ) where ε : S → 2At×At δ : S → SAt×At Acceptance of strings in N = At · P · (dup · P)∗ defined by

◮ Accept(s, αpβ dup x)

= Accept(δαβ(s), βx)

◮ Accept(s, αpβ)

= εαβ(s) The final coalgebra is ε : 2N → 2At×At δ : 2N → (2N )At×At εαβ(A) =

  • 1

αpβ ∈ A αpβ ∈ A δαβ(A) = {βx | αpβ dup x ∈ A}

slide-51
SLIDE 51

Brzozowski Derivatives for NetKAT [Foster & al. 14]

E : Exp → 2At×At D : Exp → ExpAt×At E(e1 + e2) = E(e1) + E(e2) D(e1 + e2) = D(e1) + D(e2) E(e1e2) = E(e1) · E(e2) D(e1e2) = D(e1) · I(e2) + E(e1) · D(e2) E(e∗) = E(e)∗ D(e∗) = E(e)∗D(e)I(e∗) Eαβ(b) =

  • 1

α = β ≤ b

  • therwise

D(b) = 0 Eαβ(p) =

  • 1

β = αp

  • therwise

D(p) = 0 E(dup) = 0 Dαβ(dup) =

  • α

β = α

  • therwise
slide-52
SLIDE 52

Kleene’s Theorem for NetKAT [Foster & al. 14]

Theorem

  • 1. Let M be a finite NetKAT automaton. The set of strings in N

accepted by M is L(e) for some NetKAT expression e.

  • 2. For every NetKAT expression e, there is a deterministic NetKAT

automaton M with at most |At| · 2ℓ states accepting L(e), where ℓ is the number of occurrences of dup in e.

slide-53
SLIDE 53

A Bisimulation-Based Algorithm

To check e1 = e2, convert to automata, check bisimilarity

◮ exploits a sparse matrix representation ◮ Hopcroft-Karp union-find data structure to represent bisimilarity

classes

◮ BDDs to represent tests (new — based on Pous, POPL 15) ◮ algorithm is competitive with state of the art

slide-54
SLIDE 54

A Bisimulation-Based Algorithm

5 10 15 20 25 30 All-Pairs Connectivity Loop Freedom Translation Validation Time to solve (s)

slide-55
SLIDE 55

Conclusion

◮ Automata/regular expressions have a key role to play in emerging

platforms for managing software-defined networks

◮ NetKAT is a high-level language for programming and reasoning

about network behavior in the SDN paradigm

◮ based on sound mathematical principles ◮ formal denotational semantics, complete deductive system ◮ efficient bisimulation-based decision procedure ◮ lots of applications and abstractions: reachability, noninterference,

cycle detection, fault tolerance, load balancing, QoS, virtual

  • networks. . .

◮ Future work:

◮ further optimizations to reduce state space ◮ probabilistic semantics ◮ generating proof artifacts

slide-56
SLIDE 56

For papers and code, please visit: http://frenetic-lang.org/

Thanks!