Licklider Transmission Protocol (CCSDS 734.1-B) for reliable DTN links
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-linkedin: apply dune fmt

Pure formatting changes from `dune fmt`: doc comment placement moves
from above the binding to below it for `type`s, multi-line `match`
expressions collapse onto one line where they fit, and infix operator
applications pick up spaces (`Soup.($?)` -> `Soup.( $? )`). No
semantic changes.

+127 -17
+118 -17
README.md
··· 9 9 minutes to hours. It provides selective acknowledgment and retransmission 10 10 with support for both reliable and unreliable data segments. 11 11 12 + ## Packages 13 + 14 + - **ltp** -- Core protocol: segment types, SDNV codecs, session management 15 + - **ltp-eio** -- Eio-based LTP segment transport 16 + 17 + ## Installation 18 + 19 + Install with opam: 20 + 21 + ```shell 22 + $ opam install ltp ltp-eio 23 + ``` 24 + 25 + If opam cannot find the packages, they may not yet be released in the public 26 + `opam-repository`. Add the overlay repository, then install them: 27 + 28 + ```shell 29 + $ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git 30 + $ opam update 31 + $ opam install ltp ltp-eio 32 + ``` 33 + 34 + ## Usage 35 + 36 + ### Send a block 37 + 38 + A block is delivered as a chain of data segments on a shared session, ending 39 + with `is_eob:true`: 40 + 41 + ```ocaml 42 + let send_block ~host ~port ~block = 43 + Eio_main.run @@ fun env -> 44 + Eio.Switch.run @@ fun sw -> 45 + let net = (env#net :> [`Generic] Eio.Net.ty Eio.Resource.t) in 46 + let conn = Ltp_eio.connect ~sw ~net ~host ~port in 47 + let session = { Ltp.originator = 1L; number = 42L } in 48 + let chunk_size = 1024 in 49 + let len = String.length block in 50 + let rec send offset = 51 + if offset >= len then () 52 + else 53 + let size = min chunk_size (len - offset) in 54 + let data = String.sub block offset size in 55 + let last = offset + size = len in 56 + let seg = 57 + Ltp.data_segment 58 + ~session_id:session 59 + ~client_service_id:1L 60 + ~block_offset:(Int64.of_int offset) 61 + ~is_eob:last 62 + data 63 + in 64 + Ltp_eio.send conn seg; 65 + send (offset + size) 66 + in 67 + send 0; 68 + Ltp_eio.close conn 69 + ``` 70 + 71 + ### Receive a block 72 + 73 + Read segments until one with `is_eob seg` and concatenate their payloads: 74 + 75 + ```ocaml 76 + let recv_block ~host ~port = 77 + Eio_main.run @@ fun env -> 78 + Eio.Switch.run @@ fun sw -> 79 + let net = (env#net :> [`Generic] Eio.Net.ty Eio.Resource.t) in 80 + let conn = Ltp_eio.connect ~sw ~net ~host ~port in 81 + let buf = Buffer.create 4096 in 82 + let rec loop () = 83 + match Ltp_eio.recv conn with 84 + | Ok seg -> 85 + (match seg.Ltp.content with 86 + | Ltp.Data d -> Buffer.add_string buf d.Ltp.data 87 + | _ -> ()); 88 + if Ltp.is_eob seg then () else loop () 89 + | Error msg -> Fmt.epr "Error: %s@." msg 90 + in 91 + loop (); 92 + Ltp_eio.close conn; 93 + Fmt.pr "received %d bytes@." (Buffer.length buf) 94 + ``` 95 + 12 96 ## Features 13 97 14 98 - SDNV (Self-Delimiting Numeric Value) encoding/decoding ··· 22 106 - Cancel segments 23 107 - Checkpoint and report-based flow control 24 108 25 - ## Packages 109 + ## Segment-level API 110 + 111 + For protocol-level work (checkpoints, reports, cancel flow), construct and 112 + inspect segments directly. 113 + 114 + ### Build and encode 115 + 116 + ```ocaml 117 + open Ltp 26 118 27 - - **ltp** -- Core protocol: segment types, SDNV codecs, session management 28 - - **ltp-eio** -- Eio-based LTP segment transport 119 + let session = { originator = 1L; number = 42L } 29 120 30 - ## Installation 121 + let segment = 122 + data_segment 123 + ~session_id:session 124 + ~client_service_id:1L 125 + ~block_offset:0L 126 + "hello" 31 127 32 - ``` 33 - opam install ltp ltp-eio 128 + let wire = encode_segment segment 34 129 ``` 35 130 36 - ## Usage 131 + ### SDNV 37 132 38 133 ```ocaml 39 - open Ltp 134 + let encoded = Ltp.encode_sdnv 127L 135 + 136 + let () = 137 + match Ltp.decode_sdnv encoded 0 with 138 + | Ok (value, _offset) -> Fmt.pr "Value: %Ld@." value 139 + | Error msg -> Fmt.pr "Error: %s@." msg 140 + ``` 141 + 142 + ### Predicates 40 143 41 - (* Create a session ID *) 42 - let session = { originator = 1L; number = 42L } 144 + - `is_data_segment`, `is_red_segment`, `is_green_segment` 145 + - `is_checkpoint`, `is_eorp`, `is_eob` 43 146 44 - (* Encode an SDNV value *) 45 - let encoded = encode_sdnv 127L 147 + ### Report and cancel 46 148 47 - (* Decode an SDNV value *) 48 - match decode_sdnv encoded 0 with 49 - | Ok (value, _offset) -> Printf.printf "Value: %Ld\n" value 50 - | Error msg -> Printf.printf "Error: %s\n" msg 51 - ``` 149 + - `Ltp.report_segment ~session_id ~report_serial ~checkpoint_serial ~upper_bound claims` 150 + - `Ltp.report_ack ~session_id ~report_serial` 151 + - `Ltp.cancel ~session_id ~from_sender reason` 152 + - `Ltp.cancel_ack ~session_id ~to_sender` 52 153 53 154 ## Related Work 54 155
+4
dune
··· 1 1 (env 2 2 (dev 3 3 (flags :standard %{dune-warnings}))) 4 + 5 + (mdx 6 + (files README.md) 7 + (libraries ltp ltp-eio fmt eio eio.core eio.unix eio_main))
+3
dune-project
··· 1 1 (lang dune 3.21) 2 + (using mdx 0.4) 2 3 3 4 (name ltp) 4 5 ··· 25 26 (fmt (>= 0.9)) 26 27 wire 27 28 (alcotest :with-test) 29 + (mdx :with-test) 28 30 (alcobar :with-test))) 29 31 30 32 (package ··· 39 41 (ltp (= :version)) 40 42 (eio (>= 1.0)) 41 43 (fmt (>= 0.9)) 44 + (mdx :with-test) 42 45 (logs (>= 0.7))))
+1
ltp-eio.opam
··· 16 16 "ltp" {= version} 17 17 "eio" {>= "1.0"} 18 18 "fmt" {>= "0.9"} 19 + "mdx" {with-test} 19 20 "logs" {>= "0.7"} 20 21 "odoc" {with-doc} 21 22 ]
+1
ltp.opam
··· 18 18 "fmt" {>= "0.9"} 19 19 "wire" 20 20 "alcotest" {with-test} 21 + "mdx" {with-test} 21 22 "alcobar" {with-test} 22 23 "odoc" {with-doc} 23 24 ]