@@ -0,0 +1,389 @@
7+Here are the data types used by Ames, as defined in `lull.hoon`.
15+Opaque atomic transport address to or from Unix. For Ames over UDP, it will encode the IP address and port.
20++$ verb ?(%snd %rcv %odd %msg %ges %for %rot)
23+Verbosity flag for Ames.
25+- `%snd` - Sending packets.
26+- `%rcv` - Receiving packets.
27+- `%odd` - Unusual events.
28+- `%msg` - Message-level events.
29+- `%ges` - Congestion control.
30+- `%for` - Packet forwarding.
31+- `%rot` - Routing attempts.
39+Raw atom to or from Unix, representing a packet.
44++$ error [tag=@tas =tang]
47+Tagged diagnostic trace.
52++$ lane (each @pC address)
55+Ship transport address; either opaque [$address](#address) or galaxy. The runtime knows how to look up galaxies, so we don't need to know their transport addresses.
60++$ plea [vane=@tas =path payload=*]
63+Application-level message, as a `%pass`.
65+- `vane` - Destination vane on remote ship.
66+- `path` - Internal route on the receiving ship.
67+- `payload` - Semantic message contents.
75+Message flow index - mapped to `duct`s in the [$ossuary](#ossuary).
77+The first `bone` is 0. They increment by 4, since each flow includes a bit for each message determining forward vs. backward and a second bit for whether the message is on the normal flow or the associated diagnostic flow (for naxplanations).
79+The least significant bit of a `bone` is:
81+- 1 if "forward", i.e. we send `%plea`s on this flow.
82+- 0 if "backward", i.e. we receive `%plea`s on this flow.
84+The second-least significant bit is 1 if the `bone` is a naxplanation `bone`, and 0 otherwise. Only naxplanation messages can be sent on a naxplanation `bone`, as `%boon`s.
89++$ fragment @uwfragment
97++$ fragment-num @udfragmentnum
100+Message fragment count.
105++$ message-blob @udmessageblob
108+Unfragmented message blob.
113++$ message-num @udmessagenum
121++$ public-key @uwpublickey
129++$ symmetric-key @uwsymmetrickey
132+A symmetric key for encrypting messages to a peer. This is produced by performing an elliptic curve Diffie-Hellman using our private key and the peer's public key.
140+ [%naxplanation =error]
144+A message acknowledgement.
146+- `%ok` - Positive acknowledgement.
147+- `%nack` - Negative acknowledgement.
148+- `%naxplanation` - Nack trace.
154+ $% [%alien alien-agenda]
159+All Ames knows about a peer.
161+- `%alien` - No PKI data, so enqueue actions to perform once we learn it.
162+- `%known` - We know their `life` and public keys, so we have a channel.
168+ $: messages=(list [=duct =plea])
174+What to do when Ames learns a peer's life and keys.
176+- `messages` - [$plea](#plea)s local vanes have asked Ames to send.
177+- `packets` - Packets we've tried to send.
178+- `heeds` - Local tracking requests; passed through into [$peer-state](#peer-state).
184+ $: $: =symmetric-key
189+ route=(unit [direct=? =lane])
192+ snd=(map bone message-pump-state)
193+ rcv=(map bone message-sink-state)
194+ nax=(set [=bone =message-num])
199+State for a peer with known life and keys.
201+- `route` - Transport-layer destination for packets to the peer.
202+- `qos` - Quality of service; connection status to the peer.
203+- `ossuary` - [$bone](#bone) to `duct` mapper.
204+- `snd` - Per-`bone` message pumps to send messages as fragments.
205+- `rcv` - Per-`bone` message sinks to assemble messages from fragments.
206+- `nax` - Unprocessed nacks (negative acknowledgments).
207+- `heeds` - Listeners for `%clog` notifications.
214+ [?(%live %dead %unborn) last-contact=@da]
217+Quality of service; how is the connection to a peer doing?
219+- `%live` - Peer is ok.
220+- `%dead` - Peer is not responding.
221+- `%unborn` - Peer is sunken.
222+- `last-contact` - Last time Ames heard from the peer, or if `%unborn`, the time when we first started tracking then.
229+ by-duct=(map duct bone)
230+ by-bone=(map bone duct)
234+[$bone](#bone) to `duct` mapping, `next` is the next `bone` to map to a `duct`.
236+## `$message-pump-state`
239++$ message-pump-state
240+ $: current=_`message-num`1
241+ next=_`message-num`1
242+ unsent-messages=(qeu message-blob)
243+ unsent-fragments=(list static-fragment)
244+ queued-message-acks=(map message-num ack)
249+Persistent state for a `|message-pump`.
251+- `current`- Sequence number of earliest message sent or being sent.
252+- `next` - Sequence number of next message to send.
253+- `unsent-messages` - Messages to be sent after current message.
254+- `unsent-fragments` - Fragments of current message waiting for sending.
255+- `queued-message-acks` - Future message acks to be applied after current.
256+- `packet-pump-state` - State of corresponding `|packet-pump`.
258+## `$static-fragment`
263+ num-fragments=fragment-num
269+A packet; a fragment of a message and metadata.
271+## `$packet-pump-state`
275+ $: next-wake=(unit @da)
276+ live=(tree [live-packet-key live-packet-val])
277+ metrics=pump-metrics
281+Persistent state for a `|packet-pump`.
283+- `next-wake` - Last timer we've set, or null.
284+- `live` - Packets in flight; sent but not yet acked.
285+- `metrics` - Congestion control information.
301+Congestion control state for a `|packet-pump`.
303+- `rto` - Retransmission timeout.
304+- `rtt` - Roundtrip time estimate, low-passed using EWMA.
305+- `rttvar` - Mean deviation of `rtt`, also low-passed with EWMA.
306+- `num-live` - How many packets sent, awaiting ack.
307+- `ssthresh` - Slow-start threshold.
308+- `cwnd` - Congestion window; max unacked packets.
314+ $: key=live-packet-key
319+A packet in flight, as tracked in the [$packet-pump-state](#packet-pump-state).
321+## `$live-packet-key`
330+Identifier of a packet in flight.
332+## `$live-packet-val`
337+ num-fragments=fragment-num
342+Content and metadata about a packet in flight.
354+Sending statistics about a packet in flight.
356+## `$message-sink-state`
359++$ message-sink-state
360+ $: last-acked=message-num
361+ last-heard=message-num
362+ pending-vane-ack=(qeu [=message-num message=*])
363+ live-messages=(map message-num partial-rcv-message)
364+ nax=(set message-num)
368+State of a `|message-sink` to assemble received messages.
370+- `last-acked` - Highest [$message-num](#message-num) Ames has fully acknowledged.
371+- `last-heard` - Highest `message-num` Ames has heard all fragments for.
372+- `pending-vane-ack` - Heard but not processed by local vane.
373+- `live-messages` - Partially received messages.
375+## `$partial-rcv-message`
378++$ partial-rcv-message
379+ $: num-fragments=fragment-num
380+ num-received=fragment-num
381+ fragments=(map fragment-num fragment)
385+A message for which Ames has received some fragments.
387+- `num-fragments` - Total number of fragments in the message.
388+- `num-received` - How many fragments Ames has received so far.
389+- `fragments` - The received fragments themselves.