software defined networking coms 6998-8, fall 2013 instructor: li erran li...

65
Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li ([email protected]) http://www.cs.columbia.edu/ ~lierranli/coms6998-8SDNFall20 13/ 9/24/2013: SDN Programming

Upload: anissa-burnsworth

Post on 16-Dec-2015

223 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined NetworkingCOMS 6998-8, Fall 2013

Instructor: Li Erran Li ([email protected])

http://www.cs.columbia.edu/~lierranli/coms6998-8SDNFall2013/

9/24/2013: SDN Programming Language

Page 2: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 2

Outline

• Announcements– Homework 2 posted due in 18 days – Next lecture: first half by Josh Reich from

Princeton on Pyretic• Review of previous lecture• SDN programming language– Maple: generic programming language syntax such

as Java, Python– Frenetic

9/24/13

Page 3: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 3

Review of Previous Lecture

• How do we design scalable software defined networks?– Design scalable controllers– Offload control plane processing to switches

• How do we design scalable controllers? – Flat structure multiple controllers – Recursive controller design– Hierarchical controller design

9/24/13

Page 4: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 4

Review of Previous Lecture (Cont’d)

• How to offload control plane processing to switches?– Offload to switch control plane

• Controller proactively generates the rules and distributes them to authority switches

• Authority switches keep packets always in the data plane and ingress switches reactively cache rules

– Offload to switch data plane• Try to stay in data-plane, by default• Provide enough visibility: for significant flows & sec-sensitive

flows; Otherwise, aggregate or approximate statistics

9/24/13

Page 5: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 5

Review of Previous Lecture (Cont’d)

How do we divide work among controller instances?• Partition– Controller instances with different computations

tasks– Controller instances have only subsets of the NIB– Switches connect to a subset of controller instances

• Aggregation– Reduce fidelity of information

9/24/13

Page 6: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 6

Review of Previous Lecture (Cont’d)

• How to maintain network information base (NIB)?– Replicated transactions (SQL) storage for strong

consistency (more static information)– One-hop memory-based DHT for weak consistency

(more dynamic information)

9/24/13

Page 7: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 7

Following packets

Review of Previous Lecture (Cont’d)

Ingress Switch

Authority Switch

Egress Switch

First packet Redirect

Forward

Feedback:

Cache rules

Hit cached rules and forward

Offload to switch control plane

Source: Minlan Yu9/24/13

Page 8: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 8

Outline

• Announcements– Homework 2 posted due in 18 days – Next lecture: first half by Josh Reich from

Princeton on Pyretic• Review of previous lecture• SDN programming language– Maple: generic programming language syntax such

as Java, Python– Frenetic: domain specific programming language

9/24/13

Page 9: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 9

A Key Source of Complexity in Openflow Controllers

• onPacketIn(p):

examine p and decide what to do with p.Step 1

construct and install OF rules so that similar packets are processed at switches with same action.

Step 2

9/24/13 Source: Andreas Voellmy, Yale

Page 10: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 10

Simple, generic solution using exact matches

• onPacketIn(p):

examine p and decide what to do with p.Step 1

insert rule with “exact match” for p, i.e. match on ALL attributes, with action determined above.

Step 2

Every flow incurs flow setup delay.

9/24/13 Source: Andreas Voellmy, Yale

Page 11: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 11

Step 1 Step 2

p.TcpDst=22?

dropmatch:{TcpDst=22} action:drop

send to next hop for p.EthDst

match:{EthDst=p.EthDst} action:nextHop(p)

yes

no

priority:HIGH

priority:LOW

tcpDst!=22

9/24/13 Source: Andreas Voellmy, Yale

Page 12: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 12

EthDst:A,TcpDst:80

Controller

Switch

EthDst:A,TcpDst:22

Low EthDst:A Port 1

If p.TcpDst=22:

insert rule

{prio:HIGH, match:{TcpDst=22}, action:drop }

Else:

insert rule

{prio:LOW, match:{EthDst=p.EthDst},action:nextHop(p.EthDst)

9/24/13

Page 13: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 13

OF Switches

User Level

Under the hood

OF Controller Library

Step 1. Make Decisions

Step 2. Generate Rules

9/24/13 Source: Andreas Voellmy, Yale

Page 14: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 14

Algorithmic Policy

OF Switches

OF Controller Library

Step 1. Make Decisions

Step 2. Generate Rules

User Level

Under the hood

9/24/13 Source: Andreas Voellmy, Yale

Page 15: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 15

Algorithmic Policies

• Function in a general purpose language that describes how a packet should be routed, not how flow tables are configured.

• Conceptually invoked on every packet entering the network; may also access network environment state; hence it has the form:

• Written in a familiar language such as Java, Python, or Haskell

9/24/13 Source: Andreas Voellmy, Yale

Page 16: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 16

Example Algorithmic Policy in Java

Route f(Packet p, Env e) { if (p.tcpDstIs(22)) return null(); else { Location sloc = e.location(p.ethSrc()); Location dloc = e.location(p.ethDst()); Path path = shortestPath(e.links(), sloc,dloc); return unicast(sloc,dloc,path); }}

Does not specify flow table configutation

9/24/13 Source: Andreas Voellmy, Yale

Page 17: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 17

How to implement algorithmic policies?

• Naive solutions -- process every packet at controller or use only exact match rules -- perform poorly

• Static analysis to determine layout of flow tables is possible, but has drawbacks:– Static analysis of program in general-purpose

language is hard and is typically conservative– System becomes source-language dependent

9/24/13 Source: Andreas Voellmy, Yale

Page 18: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 18

Maple’s approach: runtime tracing

Prio Match Action

1 tcpDst:22ToControll

er

0 ethDst:2 discard

0ethDst:4, ethSrc:6

port 30

Prio Match Action

1 tcpDst:22ToControll

er

0 ethDst:2 discard

0ethDst:4, ethSrc:6

port 30Prio Match Action

1 tcpDst:22ToControll

er

0 ethDst:2 discard

0ethDst:4, ethSrc:6

port 30

1. Maple observes the dependency of f on packet data.

2. Build a trace tree (TT), a partial decision tree for f.3. Compile flow

tables (FTs) from a trace tree.

9/24/13 Source: Andreas Voellmy, Yale

Page 19: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 19

Route f(Packet p, Env e) {

if (p.tcpDstIs(22))

return null();

else {

Location sloc = e.location(p.ethSrc());

Location dloc = e.location(p.ethDst());

Path path = shortestPath( e.links(),sloc,dloc);

return unicast(sloc,dloc,path); }}

EthDest:1,TcpDst:80

Assert(TcpDst,22)

false

Read(EthSrc)

Read(EthDst)

path1

1

2

Policy

9/24/13 Source: Andreas Voellmy, Yale

Page 20: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 20

EthDst:1,TcpDst:22

1

2

?

true

null

true

Assert(TcpDst,22)

Policy Trace Tree

false

Route f(Packet p, Env e) {

if (p.tcpDstIs(22))

return null();

else {

Location sloc = e.location(p.ethSrc());

Location dloc = e.location(p.ethDst());

Path path = shortestPath( e.links(),sloc,dloc);

return unicast(sloc,dloc,path); }}

Assert(TcpDst,22)

Read(EthSrc)

Read(EthDst)

path1

9/24/13 Source: Andreas Voellmy, Yale

Page 21: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 21

Compile recorded executions into flow table

tcpDst==22

False

ethDst

2

drop

4

port 30

ethSrc

6

drop

True

match:{tcpDst==22}

action:ToController

match:{ethDst:4,ethSrc:6}action:[port 30]

Priority

barrier rule:

1

2

3

9/24/13 Source: Andreas Voellmy, Yale

Page 22: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 22

Basic compilation: in-order traversal & barrier rules

accumulated match: {}

{tcpDst:22}

(prio:3,{tcpDst:22},action:drop)

{}

{ethDst:2}{ethDst:4}

{ethDst:4,ethSrc:6}

(prio:0,{ethDst:4, ethSrc:6},action:[port 30])

(prio:1,{ethDst:2},action:drop)

(prio:2,{tcpDst:22},action:ToController)

Priority := 0Priority := 1Priority := 2Priority := 3

barrier rule:

tcpDst==22

ethDst

2

null

4

port 30

6

null

True

ethSrc

False

9/24/13 Source: Andreas Voellmy, Yale

Page 23: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 23

Basic compilation example result

• Trace tree method converts arbitrary algorithmic policies into correct forwarding tables that effectively use wildcard rules.

• Deficiencies:– More priorities levels than necessary– More rules than necessary

• Annotate TT nodes with extra information to improve compilation

(prio:3,{tcpDst:22},action:drop)

(prio:0,{ethDst:4, ethSrc:6},action:[port 30])

(prio:1,{ethDst:2},action:drop)

(prio:2,{tcpDst:22},action:ToController) No effect

Can use priority 0

9/24/13 Source: Andreas Voellmy, Yale

Page 24: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 24

Optimization 1: Annotate TT nodes with completeness

tcpDst==22

False

ethDst

2

drop

4

port 30

ethSrc

6

drop

True

{}

{tcpDst:22}

(prio:2,{tcpDst:22},action:drop)

{}

{ethDst:2} {ethDst:4}

{ethDst:4, ethSrc:6}

(prio:0,{ethDst:4, ethSrc:6},action:[port 30])

(prio:1,{ethDst:2},action:drop)

no barrier

complete

complete

complete

9/24/13 Source: Andreas Voellmy, Yale

Page 25: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 25

Optimization 2: Annotate nodes with priority dependencies

tcpDst==22

False

ethDst

2

drop

4

port 30

ethSrc

6

drop

True

{}

{tcpDst:22}

(prio:1,{tcpDst:22},action:drop)

{}

{ethDst:2} {ethDst:4}

{ethDst:4, ethSrc:6}

(prio:0,{ethDst:4, ethSrc:6},action:[port 30])

(prio:0,{ethDst:2},action:drop)

1

9/24/13 Source: Andreas Voellmy, Yale

Page 26: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 26

Improved compilation result

(prio:1,{tcpDst:22},action:drop)

(prio:0,{ethDst:4, ethSrc:6},action:[port 30])

(prio:0,{ethDst:2},action:drop)

9/24/13 Source: Andreas Voellmy, Yale

Page 27: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 27

Maple Status

• Maple has been implemented in Haskell using the McNettle Openflow controller, which implements Openflow 1.0.

• The implementation includes several other features: – Incremental TT compilation, to avoid full recompilation on

every update.– Trace reduction, to ensure traces and trace trees do not

contain redundant nodes.– Automatic and user-specified invalidation, to support

removing and updating TT and FT when network state changes.

9/24/13 Source: Andreas Voellmy, Yale

Page 28: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 28

Summary: Contributions

• Algorithmic policies provide a simple, expressive programming model for SDN, eliminating a key source of errors and performance problems.

• Maple provides a scalable implementation of algorithmic policies through several novel techniques, including:– runtime tracing of algorithmic policies,– maintaining a trace tree and compiling TT to flow tables to

distribute processing to switches;– using TT annotations to implement compiler optimizations

such as rule and priority reductions.

9/24/13 Source: Andreas Voellmy, Yale

Page 29: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 29

Outline

• Announcements– Homework 2 posted due in 18 days – Next lecture: first half by Josh Reich from

Princeton on Pyretic• Review of previous lecture• SDN programming language– Maple: generic programming language syntax such

as Java, Python– Frenetic: domain specific programming language

9/24/13

Page 30: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 30

Key questions:

•What are the right abstractions for programming software-defined networks?

•How can we engineer trustworthy implementations that provide assurance?

9/24/13 Source: Nate Foster, Cornell

Page 31: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 31

Modular Abstractions

9/24/13 Source: Nate Foster, Cornell

Page 32: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 32

Combining Functionality

Challenges:•Writing, testing, and debugging programs•Reusing code across applications•Porting applications to new platforms

Controller Platform

Monitor + Route + Load Balance + Firewall

One monolithicapplication

9/24/13 Source: Nate Foster, Cornell

Page 33: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 33

RoutePattern Actions

dstip=10.0.0.1 Fwd 1

dstip=10.0.0.2 Fwd 2

Pattern Actionssrcip=1.2.3.4 CountMonitor+

Pattern Actionssrcip=1.2.3.4, dstip=10.0.0.1 Fwd 1, Count

srcip=1.2.3.4, dstip=10.0.0.2 Fwd 2, Count

srcip=1.2.3.4 Count

dstip=10.0.0.1 Fwd 1

dstip=10.0.0.1 Fwd 2

Route+ Monitor

9/24/13 Source: Nate Foster, Cornell

Page 34: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

34

+

Pattern Actionssrcip=1.2.3.4, dstip=10.0.0.1 Fwd 1, Count

srcip=1.2.3.4, dstip=10.0.0.2 Fwd 2, Count

srcip=1.2.3.4 Count

dstip=10.0.0.1 Fwd 1

dstip=10.0.0.2 Fwd 2

Route+ Monitor

Pattern Actionstcpdst = 22 Drop

* Fwd ?

Firewall

Pattern Actionssrcip=1.2.3.4, tcpdst = 22 Count, Drop

srcip=1.2.3.4, dstip=10.0.0.1 Fwd 1, Count

srcip=1.2.3.4, dstip=10.0.0.2 Fwd 2, Count

srcip=1.2.3.4 Count

tcpdst = 22 Drop

dstip=10.0.0.1 Fwd 1

dstip=10.0.0.2 Fwd 2

RouteMonitorFirewall

++

9/24/13 Software Defined Networking (COMS 6998-8) Source: Nate Foster, Cornell

Page 35: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 35

Modular Applications

Controller PlatformMonitor Route Load Balance Firewall

Benefits:•Easier to write, test, and debug programs•Can reuse modules across applications•Possible to port applications to new platforms

One module for each task

9/24/13 Source: Nate Foster, Cornell

Page 36: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 36

Beyond Multi-Tenancy

Relatively straightforward to split rule, bandwidth, and network events across these modules

Slice 1 Slice 2 Slice 3 Slice N...

Controller Platform

Each module controls a different portion of the traffic

9/24/13 Source: Nate Foster, Cornell

Page 37: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 37

Modules Affect the Same Traffic

How should we combine a collection of such modules into a single application?

Controller Platform

Monitor Route Load Balance Firewall

Each module partially specifieshandling of all traffic

9/24/13 Source: Nate Foster, Cornell

Page 38: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 38

Language-Based Approach

Design languages based on modular programming abstractions, and engineer efficient implementations using a compiler and run-time system

Compiler + Run-Time System

Controller Platform

Monitor Route Load Balance Firewall

9/24/13 Source: Nate Foster, Cornell

Page 39: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 39

Language Constructs[POPL ’12, NSDI ’13]

9/24/13 Source: Nate Foster, Cornell

Page 40: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

40

Parallel Composition

Controller Platform

Monitor Route

Pattern Actionsdstip=3.4.5.6 Fwd 1

dstip=6.7.8.9 Fwd 2

Pattern Actionssrcip=1.2.3.4 Count

+

Pattern Actionssrcip=1.2.3.4, dstip=3.4.5.6 Fwd 1, Count

srcip=1.2.3.4, dstip=6.7.8.9 Fwd 2, Count

srcip=1.2.3.4 Count

dstip=3.4.5.6 Fwd 1

dstip=6.7.8.9 Fwd 29/24/13

Software Defined Networking (COMS 6998-8) Source: Nate Foster, Cornell

Page 41: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 41

Sequential Composition

Controller Platform

Load Balance Route

Pattern Actionsdstip=10.0.0.1 Fwd 1

dstip=10.0.0.2 Fwd 2

Pattern Actionssrcip=*0 dstip:=10.0.0.1

srcip=*1 dstip:=10.0.0.2

;

Pattern Actions

srcip=*0 dstip:=10.0.0.1, Fwd 1

srcip=*1 dstip:=10.0.0.2, Fwd 2

9/24/13 Source: Nate Foster, Cornell

Page 42: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 42

Dividing Traffic Over Modules

Load Balance Route;

Monitor Route+

if then

else if then

dstport=80

dstport=22

elseDrop

Predicates specify which packets traverse which modules, using ingress port and packet-header fields

9/24/13 Source: Nate Foster, Cornell

Page 43: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

43

The NetKAT Languagefield ::= switch | inport | srcmac | dstmac | ... val ::= 0 | 1 | 2 | 3 | ... a,b,c ::= true (* true constant *) | false (* false constant *) | field = val (* test value *) | a1 | a2 (* disjunction *) | a1 & a2 (* conjunction *) | ! a (* negation *)p,q,r ::= filter a (* filter by predicate *) | field := val (* modify value *) | p1 + p2 (* parallel composition *) | p1 ; p2 (* sequential composition *) | p*

(* iteration *)

Syntactic sugar: if a then p1 else p2 = filter a; p1 + filter !a; p29/24/13

Software Defined Networking (COMS 6998-8) Source: Nate Foster, Cornell

Page 44: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 44

Example: Topology Abstraction

Abstract topologyPhysical topology

It is often useful to write programs in terms of a simplified abstract network topology

Benefits:•Information hiding: limit what each module sees•Protection: limit what each module does•Reuse: write code for appropriate interface

Example: load balancer

9/24/13 Source: Nate Foster, Cornell

Page 45: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 45

• Simplest example of topology abstraction• Can be used in many applications, including access

control, load balancing, distributed middleboxes, etc.

Abstract Network

Physical Network

Example: “One Big Switch”

(ingress; raise; application; lower; fabric; egress)

Implementation:

9/24/13 Source: Nate Foster, Cornell

Page 46: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 46

Formal Reasoning

9/24/13 Source: Nate Foster, Cornell

Page 47: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 47

Program Equivalence

A B

Given a program and a topology:

Formally, does the following equivalence hold?

(filter switch = A ; firewall; routing + filter switch = B; routing) ~ (filter switch = A ; routing + filter switch = B; firewall; routing)

Want to be able to answer questions like:“Will my network behave the same if I put the firewall rules on A, or on switch B (or both)?”

9/24/13 Source: Nate Foster, Cornell

Page 48: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

48

NetKAT Equational Theory

Boolean Algebraa | (b & c) ~ (a | b) & (a | c)

a | true ~ true

a | ! a ~ true

a & b ~ b & a

a & !a ~ false

a & a ~ a

Packet Algebraf := n; f’ := n’ ~ f’ := n’ ; f := n if f ≠ f’

f := n; f’ = n’ ~ f’ = n’; f := n if f ≠ f’

f := n; f = n ~ f := n

f = n; f := n ~ f = n

f := n; f’ = n’ ~ f := n’

f = n; f = n’ ~ filter drop if n ≠ n’

Kleene Algebrap + (q + r) ~ (p + q) + rp + q ~ q + pp + filter false ~ pp + p ~ pp ; (q ; r) ~ (p ; q) ; rp; (q + r) ~ p ; q + p ; r(p + q) ; r ~ p ; r + q ; r

filter true ; p ~ p ~ p ; filter truefilter false ; p ~ filter false p ; filter false ~ filter falsefilter true + p ; p* ~ p*

filter true + p* ; p ~ p*

p + q ; r + r ~ r ⟹ p* ; q + r ~ rp + q ; r + q ~ q ⟹ p ; r* + q ~q

9/24/13 Software Defined Networking (COMS 6998-8) Source: Nate Foster, Cornell

Page 49: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 49

NetKAT and Kleene Algebras

Theorems• Soundness: programs related by the axioms are equivalent• Completeness: equivalent programs are related by the axioms• Decidabilty: program equivalence is decidable (PSPACE)

Its foundations rest upon canonical mathematical structure:• Regular operators (+, ;, and *) encode paths through topology• Boolean operators (&, |, and !) encode switch tables

The design of NetKAT is not an accident!

This is called a Kleene Algebra with Tests [Kozen ’96]

9/24/13 Source: Nate Foster, Cornell

Page 50: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 50

NetKAT Verification

•Model programs and topologies in the Z3 SMT solver•Encode network-wide function as the transitive closure of

the sequential composition of the program and topology•Verify reachability properties automatically

9/24/13 Source: Nate Foster, Cornell

Page 51: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 51

Machine-Verified Controllers

9/24/13 Source: Nate Foster, Cornell

Page 52: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 52

Inductive pred : Type :=  | OnSwitch : Switch -> pred  | InPort : Port -> pred  | DlSrc : EthernetAddress -> pred  | DlDst : EthernetAddress -> pred  | DlVlan : option VLAN -> pred | ...   | And : pred -> pred -> pred  | Or : pred -> pred -> pred  | Not : pred -> pred  | All : pred  | None : pred

Inductive act : Type :=  | ForwardMod : Mod -> PseudoPort -> act | ...

Inductive pol : Type :=  | Policy : pred -> list act -> pol  | Union : pol -> pol -> pol  | Restrict : pol -> pred -> pol | ...

Certified Software Systems

Recent Successes•seL4 [SOSP ’09]•CompCert [CACM ’09]•F* [ICFP ’11, POPL ’12, ’13]

Tools

Textbooks

Certified Programming with Dependent Types

Write code

 Lemma inter_wildcard_other : forall x,    Wildcard_inter WildcardAll x = x.  Proof.    intros; destruct x; auto.  Qed.    Lemma inter_wildcard_other1 : forall x,    Wildcard_inter x WildcardAll = x.  Proof.    intros; destruct x; auto.  Qed.    Lemma inter_exact_same : forall x,    Wildcard_inter (WildcardExact x) (WildcardExact x) = WildcardExact x.  Proof.    intros.    unfold Wildcard_inter. destruct (eqdec x x); intuition.   Qed.

Prove correct

Extract code

(** val handle_event : event -> unit Monad.m **) let handle_event = function | SwitchConnected swId -> handle_switch_connected swId | SwitchDisconnected swId -> handle_switch_disconnected swId | SwitchMessage (swId, xid0, msg) -> (match msg with | PacketInMsg pktIn -> handle_packet_in swId pktIn | _ -> Monad.ret ()) (** val main : unit Monad.m **) let main = Monad.forever (Monad.bind Monad.recv (fun evt -> handle_event evt))

Certifiedbinary

9/24/13 Source: Nate Foster, Cornell

Page 53: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 53

NetKAT

Flow tables

OpenFlow messages

Compiler

Run-time system

Optimizer

•Each level of abstraction formalized in Coq

•Machine-checked proofs that the transformations between levels preserve semantics

•Code extracted to OCaml and deployed with real switch hardware

Certified NetKAT Controller

9/24/13 Source: Nate Foster, Cornell

Page 54: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 54

NetKAT Compiler

Correctness Theorem

Overview•Compiler: maps NetKAT programs to flow tables

•Optimizer: eliminates “empty” and “shadowed” rules

Formalization Highlights

•Library of algebraic properties of flow tables

•New tactic for proving equalities on bags

•Key invariant: all packet patterns “natural”

Theorem compile_correct : forall opt pol sw pt pk bufId, SemanticsPreserving opt -> netcore_eval pol sw pt pk bufId = flowtable_eval (compile pol sw) sw pt pk bufId.

9/24/13 Source: Nate Foster, Cornell

Page 55: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 55

OpenFlow 1.0 Specification42 pages...

...of informal prose

...and C struct definitions

...diagrams and flow charts

9/24/13 Source: Nate Foster, Cornell

Page 56: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 56

Featherweight OpenFlowSyntax Semantics

Key Features:•Models all features related to packet forwarding and all essential asynchrony•Supports arbitrary controllers

9/24/13 Source: Nate Foster, Cornell

Page 57: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

57

Forwarding

Definition Pattern_inter (p p':Pattern) :=  let dlSrc := Wildcard_inter EthernetAddress.eqdec (ptrnDlSrc p) (ptrnDlSrc p') in  let dlDst := Wildcard_inter EthernetAddress.eqdec (ptrnDlDst p) (ptrnDlDst p') in  let dlType := Wildcard_inter Word16.eqdec (ptrnDlType p) (ptrnDlType p') in  let dlVlan := Wildcard_inter Word16.eqdec (ptrnDlVlan p) (ptrnDlVlan p') in  let dlVlanPcp := Wildcard_inter Word8.eqdec (ptrnDlVlanPcp p) (ptrnDlVlanPcp p') in  let nwSrc := Wildcard_inter Word32.eqdec (ptrnNwSrc p) (ptrnNwSrc p') in  let nwDst := Wildcard_inter Word32.eqdec (ptrnNwDst p) (ptrnNwDst p') in  let nwProto := Wildcard_inter Word8.eqdec (ptrnNwProto p) (ptrnNwProto p') in  let nwTos := Wildcard_inter Word8.eqdec (ptrnNwTos p) (ptrnNwTos p') in  let tpSrc := Wildcard_inter Word16.eqdec (ptrnTpSrc p) (ptrnTpSrc p') in  let tpDst := Wildcard_inter Word16.eqdec (ptrnTpDst p) (ptrnTpDst p') in  let inPort := Wildcard_inter Word16.eqdec (ptrnInPort p) (ptrnInPort p') in    MkPattern dlSrc dlDst dlType dlVlan dlVlanPcp               nwSrc nwDst nwProto nwTos               tpSrc tpDst               inPort.Definition exact_pattern (pk : Packet) (pt : Word16.T) : Pattern :=  MkPattern    (WildcardExact (pktDlSrc pk)) (WildcardExact (pktDlDst pk)) (WildcardExact (pktDlTyp pk)) (WildcardExact (pktDlVlan pk)) (WildcardExact (pktDlVlanPcp pk))    (WildcardExact (pktNwSrc pk)) (WildcardExact (pktNwDst pk))    (WildcardExact (pktNwProto pk)) (WildcardExact (pktNwTos pk))    (Wildcard_of_option (pktTpSrc pk)) (Wildcard_of_option (pktTpDst pk))    (WildcardExact pt).Definition match_packet (pt : Word16.T) (pk : Packet) (pat : Pattern) : bool :=  negb (Pattern_is_empty (Pattern_inter (exact_pattern pk pt) pat)).

/* Fields to match against flows */struct ofp_match {    uint32_t wildcards; /* Wildcard fields. */    uint16_t in_port; /* Input switch port. */    uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */    uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */    uint16_t dl_vlan; /* Input VLAN. */    uint8_t dl_vlan_pcp; /* Input VLAN priority. */    uint8_t pad1[1]; /* Align to 64-bits. */    uint16_5 dl_type; /* Ethernet frame type. */    uint8_t nw_tos; /* IP ToS (DSCP field, 6 bits). */    uint8_t nw_proto; /* IP protocol or lower 8 bits of ARP opcode. */    uint8_t pad2[2]; /* Align to 64-bits. */    uint32_t nw_src; /* IP source address. */    uint32_t nw_dst; /* IP destination address. */    uint16_t tp_src; /* TCP/UDP source port. */    uint16_t tp_dst; /* TCP/UDP destination port. */};OFP_ASSERT(sizeof(struct ofp_match) == 40);

Record Pattern : Type := MkPattern {  dlSrc : Wildcard EthernetAddress;  dlDst : Wildcard EthernetAddress;  dlType : Wildcard EthernetType;  dlVlan : Wildcard VLAN;  dlVlanPcp : Wildcard VLANPriority;  nwSrc : Wildcard IPAddress;  nwDst : Wildcard IPAddress;  nwProto : Wildcard IPProtocol;  nwTos : Wildcard IPTypeOfService;  tpSrc : Wildcard TransportPort;  tpDst : Wildcard TransportPort;  inPort : Wildcard Port}.

Detailed model of matching, forwarding, and flow table update

9/24/13Software Defined Networking (COMS 6998-8) Source: Nate Foster, Cornell

Page 58: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 58

Asynchrony“In the absence of barrier messages, switches may arbitrarily reorder messages to maximize performance.”

“There is no packet output ordering guaranteed within a port.”

  Definition InBuf := Bag Packet.  Definition OutBuf := Bag Packet.  Definition OFInBuf := Bag SwitchMsg.  Definition OFOutBuf := Bag CtrlMsg.

Essential asynchrony: packet buffers, message reordering, and barriers

9/24/13 Source: Nate Foster, Cornell

Page 59: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 59

Priority Predicate Action

Priority Predicate Action

10 SSH Drop

5 dst_ip = H1 Fwd 1

5 dst_ip = H2 Fwd 2

Priority Predicate Action

5 dst_ip = H1 Fwd 1

Priority Predicate Action

5 dst_ip = H1 Fwd 1

5 dst_ip = H2 Fwd 2

update re-ordering

Priority Predicate Action

10 SSH Drop

Priority Predicate Action

10 SSH Drop

5 dst_ip = H1 Fwd 1

Distributed Programming:non-atomic table updates

Asynchrony (Cont’d)

9/24/13 Source: Nate Foster, Cornell

Page 60: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 60

Controllers

: abstract type of controller statefin :

fout :

Controller Parameters

Ultimately we want to prove theorems about controllers that implement the NetKAT run-time system...

...but we didn’t want to bake specific controllers into Featherweight OpenFlow!

Controller model: fully abstract

9/24/13 Source: Nate Foster, Cornell

Page 61: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 61

(H1, ) (S1,pt1, ) (S2,pt1, ) (H2, )

≈ ≈

≈≈ ≈

add rules

add

rule

s

Weak Bisimulation

  Theorem fwof_abst_weak_bisim :    weak_bisimulation concreteStep abstractStep bisim_relation.

9/24/13 Source: Nate Foster, Cornell

Page 62: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 62

Frenetic

OX

implemented usingOCaml embedding• predicates and policies• queries

OCaml OpenFlow Platform• similar to Nox, Pox, Floodlight, etc.

predicatespoliciesqueries

stream of snapshots over time

predicatespoliciesqueries

predicatespoliciesqueries

Frenetic

Ox

The System

9/24/13 Source: Nate Foster, Cornell

Page 63: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 63

Frenetic DSL

Frenetic

OX

implemented using

implemented using

Domain-specific language• predicates and policies• monitoring• mac learning• network address translation

OCaml embedding• predicates and policies• queries

OCaml OpenFlow Platform• similar to Nox, Pox, Floodlight, etc.

Frenetic

Ox

The System

9/24/13 Source: Nate Foster, Cornell

Page 64: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 64

ConclusionModularity is a key concern in the design of any language

NetKAT provides rich abstractions for building modular network programs, including parallel and sequential composition operators

By leveraging recent advances in formal methods, can build trustworthy compilers, run-time systems, and verification tools

Implementation status:•Stand-alone controller platform implemented in OCaml•Sophisticated, proactive compiler for OpenFlow rules•Large parts of the system formally verified in Coq•Experimental support for OpenFlow 1.3

9/24/13 Source: Nate Foster, Cornell

Page 65: Software Defined Networking COMS 6998-8, Fall 2013 Instructor: Li Erran Li (lierranli@cs.columbia.edu) lierranli/coms 6998-8SDNFall2013

Software Defined Networking (COMS 6998-8) 65

Questions?

9/24/13