Module Frenetic_netkat.Local_compiler

module Field = Fdd.Field
module Action = Fdd.Action
module Value = Fdd.Value
type order = [
| `Default
| `Static of Field.t list
| `Heuristic
]
module FDD : sig ... end
type t = FDD.t

The type of the intermediate compiler representation (FDD).

val to_dot : t ‑> string
type cache = [
| `Keep
| `Empty
| `Preserve of t
]
type compiler_options = {
cache_prepare : cache;
field_order : order;
remove_tail_drops : bool;
dedup_flows : bool;
optimize : bool;
}

Compilation

exception Non_local

The exception that's thrown when the local compiler is given a policy with a Link term in it. To compile policies with Link terms, invoke global compiler.

val default_compiler_options : compiler_options
val prepare_compilation : options:compiler_options ‑> Syntax.policy ‑> unit
val compile : ?⁠options:compiler_options ‑> Syntax.policy ‑> t

compile p returns the intermediate representation of the local policy p. You can generate a flowtable from t by passing it to the to_table function below.

val restrict : Syntax.header_val ‑> t ‑> t

restrict hv t returns the fragment of t that applies when the assignment hv is true. The result will no longer make any reference to the header named in hv. This is equivalent to traversing the original NetKAT syntax tree and replacing all occurrences of Test(hv) with True.

This function is called by to_table to restrict t to the portion that should run on a single switch.

val to_table : ?⁠options:compiler_options ‑> ?⁠group_tbl:Frenetic_kernel.GroupTable0x04.t ‑> Frenetic_kernel.OpenFlow.switchId ‑> t ‑> Frenetic_kernel.OpenFlow.flow list

to_table sw t returns a flowtable that implements t for switch sw.

val to_table' : ?⁠options:compiler_options ‑> ?⁠group_tbl:Frenetic_kernel.GroupTable0x04.t ‑> Frenetic_kernel.OpenFlow.switchId ‑> t ‑> (Frenetic_kernel.OpenFlow.flow * string list) list

Composition

val seq : t ‑> t ‑> t

seq p q returns the sequential composotion of the two intermediate representations p and q. The result is semantically equivalent to the seqential composition of the two policies from which p and q were derived.

val union : t ‑> t ‑> t

union p q returns the parallel composition of the two intermediate representations p and q. The result is semantically equivalent to the parallel composition of the two policies from which p and q were derived.

val star : t ‑> t

star p returns the star of the intermediate representation p. The result is semantically equivalent to the star of the policy from which p was derived.

Utilities

val dedup : t ‑> t
val pipes : t ‑> string list

pipes t returns the list of pipe names that occur in t.

val queries : t ‑> (string * Syntax.pred) list

queries t returns the list of queries that occur in t along with the predicates associated with the query. Frenetic_kernel.Packet and byte counts of flows that match the predicate should count towards its associated query.

val equal : t ‑> t ‑> bool

equal a b returns whether or not the two intermediate representations are structurally equal.

If the two representations are structurally equal, then the policies they derived from are semantically equivalent. However, if the two representations are not equal, the policies they were derived from may still be semantically equivalent.

val size : t ‑> int

size t returns the size of t.

val compression_ratio : t ‑> int * int
val to_local_pol : t ‑> Syntax.policy

to_local_pol t returns a NetKAT policy that is semantically equivalent to t. If was generated from compiling a policy p, it is not guarateed that to_local_pol t will be identical to p.

val to_string : t ‑> string

to_string t returns a string representation of t. This will be a representation of the Vlr diagram from the tdk package.

Interpreter

val eval : Semantics.packet ‑> t ‑> Semantics.PacketSet.t

eval pkt t returns a PacketSet.t that is the result of the packet pkt being run through the policy represented by t.

val eval_pipes : Semantics.packet ‑> t ‑> (string * Semantics.packet) list * (string * Semantics.packet) list * Semantics.packet list

eval_pipes pkt t returns the result of running the packet pkt through the policy represented by t, with packets grouped according to the type of location to which the policy assigns them. The result is a triple whose first component is a list of packets and corresponding pipe location, whose second is a list of packets and corresponding query location, and whose third is a list of packets that are at physical locations.

val to_dotfile : t ‑> string ‑> unit
val field_order_from_string : string ‑> order
val field_order_to_string : order ‑> string
val options_from_json_string : string ‑> compiler_options

options_from_json_string s returns a compiler_options type suitable. Mostly for HTTP servers

val options_to_json_string : compiler_options ‑> string
type flow_layout = Field.t list list
include sig ... end
val flow_layout_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> flow_layout
val sexp_of_flow_layout : flow_layout ‑> Ppx_sexp_conv_lib.Sexp.t
type tableId = int
include sig ... end
val tableId_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> tableId
val sexp_of_tableId : tableId ‑> Ppx_sexp_conv_lib.Sexp.t
type metaId = int
include sig ... end
val metaId_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> metaId
val sexp_of_metaId : metaId ‑> Ppx_sexp_conv_lib.Sexp.t
type flowId = tableId * metaId
include sig ... end
val flowId_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> flowId
val sexp_of_flowId : flowId ‑> Ppx_sexp_conv_lib.Sexp.t
type instruction = [
| `Action of Frenetic_kernel.OpenFlow.group
| `GotoTable of flowId
]
include sig ... end
val instruction_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> instruction
val __instruction_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t ‑> instruction
val sexp_of_instruction : instruction ‑> Ppx_sexp_conv_lib.Sexp.t
type multitable_flow = {
pattern : Frenetic_kernel.OpenFlow.Pattern.t;
cookie : int64;
idle_timeout : Frenetic_kernel.OpenFlow.timeout;
hard_timeout : Frenetic_kernel.OpenFlow.timeout;
instruction : instruction;
flowId : flowId;
}
include sig ... end
val multitable_flow_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> multitable_flow
val sexp_of_multitable_flow : multitable_flow ‑> Ppx_sexp_conv_lib.Sexp.t
val layout_to_string : flow_layout ‑> string
val to_multitable : ?⁠options:compiler_options ‑> Frenetic_kernel.OpenFlow.switchId ‑> flow_layout ‑> t ‑> multitable_flow list * Frenetic_kernel.GroupTable0x04.t