1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
open Core
module SDN = OpenFlow
type node =
| Switch of SDN.switchId
| Host of Packet.dlAddr * Packet.nwAddr
[@@deriving sexp, compare]
module Node = struct
type t = node [@@deriving sexp, compare]
let to_string t = match t with
| Switch(sw_id) -> Printf.sprintf "switch %Lu" sw_id
| Host(dlAddr, nwAddr) -> Printf.sprintf "host %s/%s"
(Packet.string_of_nwAddr nwAddr)
(Packet.string_of_dlAddr dlAddr)
let parse_dot _ _ = failwith "NYI: Node.parse_dot"
let parse_gml _ = failwith "NYI: Node.parse_dot"
let to_dot t = match t with
| Switch(sw_id) -> Printf.sprintf "%s [label=SW%Lu]" (to_string t) sw_id
| Host(dlAddr, nwAddr) -> Printf.sprintf "%s [label=%s]" (to_string t) (Packet.string_of_nwAddr nwAddr)
let to_mininet _ = failwith "NYI: Node.to_mininet"
end
module Link = struct
type t = unit [@@deriving sexp, compare]
let to_string () = "()"
let default = ()
let parse_dot _ = failwith "NYI: Link.parse_dot"
let parse_gml _ = failwith "NYI: Link.parse_dot"
let to_dot = to_string
let to_mininet _ = failwith "NYI: Link.to_mininet"
end
module Net = Network.Make(Node)(Link)