1
0

index.rst 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. raet
  2. ====
  3. # RAET
  4. # Reliable Asynchronous Event Transport Protocol
  5. .. seealso:: :ref:`RAET Overview <raet>`
  6. Protocol
  7. --------
  8. Layering:
  9. OSI Layers
  10. 7: Application: Format: Data (Stack to Application interface buffering etc)
  11. 6: Presentation: Format: Data (Encrypt-Decrypt convert to machine independent format)
  12. 5: Session: Format: Data (Interhost communications. Authentication. Groups)
  13. 4: Transport: Format: Segments (Reliable delivery of Message, Transactions, Segmentation, Error checking)
  14. 3: Network: Format: Packets/Datagrams (Addressing Routing)
  15. 2: Link: Format: Frames ( Reliable per frame communications connection, Media access controller )
  16. 1: Physical: Bits (Transceiver communication connection not reliable)
  17. Link is hidden from Raet
  18. Network is IP host address and Udp Port
  19. Transport is Raet transactions, service kind, tail error checking,
  20. Could include header signing as part of transport reliable delivery serialization of header
  21. Session is session id key exchange for signing. Grouping is Road (like 852 channel)
  22. Presentation is Encrypt Decrypt body Serialize Deserialize Body
  23. Application is body data dictionary
  24. Header signing spans both the Transport and Session layers.
  25. Header
  26. ------
  27. JSON Header (Tradeoff some processing speed for extensibility, ease of use, readability)
  28. Body initially JSON but support for "packed" binary body
  29. Packet
  30. ------
  31. Header ASCII Safe JSON
  32. Header termination:
  33. Empty line given by double pair of carriage return linefeed
  34. /r/n/r/n
  35. 10 13 10 13
  36. ADAD
  37. 1010 1101 1010 1101
  38. In json carriage return and newline characters cannot appear in a json encoded
  39. string unless they are escaped with backslash, so the 4 byte combination is illegal in valid
  40. json that does not have multi-byte unicode characters.
  41. These means the header must be ascii safe so no multibyte utf-8 strings
  42. allowed in header.
  43. Following Header Terminator is variable length signature block. This is binary
  44. and the length is provided in the header.
  45. Following the signature block is the packet body or data.
  46. This may either be JSON or packed binary.
  47. The format is given in the json header
  48. Finally is an optional tail block for error checking or encryption details
  49. Header Fields
  50. -------------
  51. In UDP header
  52. sh = source host
  53. sp = source port
  54. dh = destination host
  55. dp = destination port
  56. In RAET Header
  57. hk = header kind
  58. hl = header length
  59. vn = version number
  60. sd = Source Device ID
  61. dd = Destination Device ID
  62. cf = Corresponder Flag
  63. mf = Multicast Flag
  64. si = Session ID
  65. ti = Transaction ID
  66. sk = Service Kind
  67. pk = Packet Kind
  68. bf = Burst Flag (Send all Segments or Ordered packets without interleaved acks)
  69. oi = Order Index
  70. dt = DateTime Stamp
  71. sn = Segment Number
  72. sc = Segment Count
  73. pf = Pending Segment Flag
  74. af = All Flag (Resent all Segments not just one)
  75. nk = Auth header kind
  76. nl = Auth header length
  77. bk = body kind
  78. bl = body length
  79. tk = tail kind
  80. tl = tail length
  81. fg = flags packed (Flags) Default '00' hex string
  82. 2 byte Hex string with bits (0, 0, af, pf, 0, bf, mf, cf)
  83. Zeros are TBD flags
  84. Session Bootstrap
  85. -----------------
  86. Minion sends packet with SID of Zero with public key of minions Public Private Key pair
  87. Master acks packet with SID of Zero to let minion know it received the request
  88. Some time later Master sends packet with SID of zero that accepts the Minion
  89. Minion
  90. Session
  91. -------
  92. Session is important for security. Want one session opened and then multiple
  93. transactions within session.
  94. Session ID
  95. SID
  96. sid
  97. GUID hash to guarantee uniqueness since no guarantee of nonvolatile storage
  98. or require file storage to keep last session ID used.
  99. Service Types or Modular Services
  100. ---------------------------------
  101. Four Service Types
  102. A) One or more maybe (unacknowledged repeat) maybe means no guarantee
  103. B) Exactly one at most (ack with retries) (duplicate detection idempotent)
  104. at most means fixed number of retries has finite probability of failing
  105. B1) finite retries
  106. B2) infinite retries with exponential back-off up to a maximum delay
  107. C) Exactly one of sequence at most (sequence numbered)
  108. Receiver requests retry of missing packet with same B1 or B2 retry type
  109. D) End to End (Application layer Request Response)
  110. This is two B sub transactions
  111. Initially unicast messaging
  112. Eventually support for Multicast
  113. The use case for C) is to fragment large packets as once a UDP packet
  114. exceeds the frame size its reliability goes way down
  115. So its more reliable to fragment large packets.
  116. Better approach might be to have more modularity.
  117. Services Levels
  118. 1) Maybe one or more
  119. A) Fire and forget
  120. no transaction either side
  121. B) Repeat, no ack, no dupdet
  122. repeat counter send side,
  123. no transaction on receive side
  124. C) Repeat, no Ack, dupdet
  125. repeat counter send side,
  126. dup detection transaction receive side
  127. 2) More or Less Once
  128. A) retry finite, ack no dupdet
  129. retry timer send side, finite number of retires
  130. ack receive side no dupdet
  131. 3) At most Once
  132. A) retry finite, ack, dupdet
  133. retry timer send side, finite number of retires
  134. ack receive side dupdet
  135. 4) Exactly once
  136. A) ack retry
  137. retry timer send side,
  138. ack and duplicate detection receive side
  139. Infinite retries with exponential backoff
  140. 5) Sequential sequence number
  141. A) reorder escrow
  142. B) Segmented packets
  143. 6) request response to application layer
  144. Service Features
  145. 1) repeats
  146. 2) ack retry transaction id
  147. 3) sequence number duplicate detection out of order detection sequencing
  148. 4) rep-req
  149. Always include transaction id since multiple transactions on same port
  150. So get duplicate detection for free if keep transaction alive but if use
  151. A) Maybe one or more
  152. B1) At Least One
  153. B2) Exactly One
  154. C) One of sequence
  155. D) End to End
  156. A) Sender creates transaction id for number of repeats but receiver does not
  157. keep transaction alive
  158. B1) Sender creates transaction id keeps it for retries.
  159. Receiver keeps it to send ack then kills so retry could be duplicate not detected
  160. B2) Sender creates transaction id keeps for retries
  161. Receiver keeps tid for acks on any retires so no duplicates.
  162. C) Sender creates TID and Sequence Number.
  163. Receiver checks for out of order sequence and can request retry.
  164. D) Application layer sends response. So question is do we keep transaction open
  165. or have response be new transaction. No because then we need a rep-req ID so
  166. might as well use the same transaction id. Just keep alive until get response.
  167. Little advantage to B1 vs B2 not having duplicates.
  168. So 4 service types
  169. A) Maybe one or more (unacknowledged repeat)
  170. B) Exactly One (At most one) (ack with retry) (duplicate detection idempotent)
  171. C) One of Sequence (sequence numbered)
  172. D) End to End
  173. Also multicast or unicast
  174. Modular Transaction Table
  175. Sender Side:
  176. Transaction ID plus transaction source sender or receiver generated transaction id
  177. Repeat Counter
  178. Retry Timer Retry Counter (finite retries)
  179. Redo Timer (infinite redos with exponential backoff)
  180. Sequence number without acks (look for resend requests)
  181. Sequence with ack (wait for ack before sending next in sequence)
  182. Segmentation
  183. Receiver Side:
  184. Nothing just accept packet
  185. Acknowledge (can delete transaction after acknowledge)
  186. No duplicate detection
  187. Transaction timeout (keep transaction until timeout)
  188. Duplicate detection save transaction id duplicate detection timeout
  189. Request resend of missing packet in sequence
  190. Sequence reordering with escrow timeout wait escrow before requesting resend
  191. Unsegmentation (request resends of missing segment)