- OCaml 100%
cgr #
Contact Graph Routing (CGR) for networks whose links come and go on a known schedule.
Internet routing assumes that a link which is up now stays up. A satellite talks to a ground station only while it is overhead, a Mars relay only while both planets are in view, and a constellation's inter-satellite links follow the orbits, so a path from source to destination may never exist all at once. The schedule is known in advance, though. CGR takes that schedule, the contact plan, and finds the route that delivers data earliest, waiting at a node for the next contact when it has to.
The package follows CCSDS Schedule-Aware Bundle Routing (SABR, CCSDS
734.3-B-1). route is the route with the earliest best-case delivery time
(Section 3.2.4) and routes the next best routes, each the shortest path
through the contact graph excluding every previously identified path (Section
3.2.6.10, by Yen's algorithm). Sabr selects the routes one bundle is
forwarded on: it adds the radiation latency of the bundle's estimated volume
consumption (3.2.6.4), the backlog queued ahead of it (3.2.6.2) and each
contact's volume still unreserved at its priority (3.2.6.8), ignores the
routes that arrive after it expires or cannot hold it (3.2.6.9), picks the
best candidate (3.2.8.1.4), and reserves its volume on the route it is
enqueued on (3.2.8.1.2). Anticipatory fragmentation (3.2.8.2), an
implementation option, is not taken.
Features #
- Contact plans: scheduled transmission windows between nodes, with a data rate.
- Routes that respect the start and end of each contact.
- One-way light time (OWLT) on each contact, for deep-space links.
- The next best routes, excluding every route already found.
- SABR route selection for a bundle: estimated volume consumption, priority, expiration, backlog, reserved volume, excluded neighbors and critical bundles.
- The bottleneck capacity of a route, the smallest capacity along its hops.
This package selects routes and does not forward bundles. A forwarding engine
composes it with bundle (the RFC 9171 Bundle Protocol Agent), tcpcl and
bpsec; none of those depend on cgr.
Installation #
Install with opam:
$ opam install cgr
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install cgr
Usage #
open Cgr
(* Define nodes *)
let earth = Node.v "EARTH"
let mars = Node.v "MARS"
let relay = Node.v "RELAY"
(* Define contacts (scheduled communication windows) *)
let contacts = [
Contact.v ~from:earth ~to_:relay ~start:0. ~stop:100. ~rate:1_000_000. ();
Contact.v ~from:relay ~to_:mars ~start:50. ~stop:150. ~rate:500_000.
~owlt:600. (); (* 10 min light time *)
]
(* Create contact plan and find route *)
let plan = Contact_plan.of_list contacts
let () =
match route plan ~src:earth ~dst:mars ~time:0. with
| None -> print_endline "No route available"
| Some route ->
Format.printf "Route found: %a@." Route.pp route;
Format.printf "Arrival time: %.0f seconds@." (Route.arrival_time route)
API #
Node.v namecreates a node, andNode.namereturns its name.Contact.v ~from ~to_ ~start ~stop ~rate ?owlt ()creates a contact;Contact.is_activesays whether it is open at a given time, andContact.capacityis the number of bytes it can carry.Contact_plan.of_listbuilds a plan from contacts;Contact_plan.contacts_fromreturns the contacts leaving a node, andContact_plan.active_atthose open at a given time.route plan ~src ~dst ~timefinds the route with the earliest arrival, androutes plan ~src ~dst ~time ~maxthe firstmaxroutes of the route list.Sabr.v plan ~localis the local node's selection state;Sabr.candidatesare the candidate routes for aSabr.bundle, andSabr.forwardselects the best one and reserves its volume.Route.hopslists the contacts of a route,Route.arrival_timegives its earliest delivery time, andRoute.capacityits bottleneck capacity.Cgr.Dijkstraexposes the search itself, for debugging or a custom strategy.
The source tree also has Cgr_gen, a library that is not installed, which
generates synthetic contact plans (rings, meshes, random graphs and
constellations) for the tests.
Algorithm #
route is Dijkstra's algorithm with the arrival time as the distance:
- The arrival time is the query time at the source and infinite elsewhere.
- Select the unvisited node with the earliest arrival time.
- For each contact leaving that node, skip it if it ends before the data
arrives (Section 3.2.4.1.1); otherwise the arrival at the neighbour is
max(arrival, contact_start) + owlt, which replaces the neighbour's arrival time if it is earlier. - Mark the node visited, and repeat until the destination is reached.
routes and Sabr search the contact graph of Section 3.2.1, whose vertices
are the contacts, with the same cost, and Yen's K shortest paths algorithm,
which the note to Section 3.2.6.10 names, gives each next best route.
Related work #
- ION, the DTN implementation in C from NASA JPL, includes the reference CGR.
- DtnSim is a DTN network simulator with CGR routing.
References #
- Scott Burleigh, Contact Graph Routing, IETF Internet-Draft.
- CCSDS 734.3-B-1, Schedule-Aware Bundle Routing (SABR).
- Juan A. Fraire, Olivier De Jonckère and Scott C. Burleigh, "Routing in the Space Internet: A contact graph routing tutorial", Journal of Network and Computer Applications.
Licence #
ISC. See LICENSE.md.