cadet.tm 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <TeXmacs|2.1>
  2. <project|scheme-gnunet.tm>
  3. <style|tmmanual>
  4. <\body>
  5. Two arbitrary peers on GNUnet can communicate with the CADET<index|CADET>
  6. service<\footnote>
  7. With some restrictions: there must be a path between the nodes, in a
  8. lossy and malicious network with few connections the connection will be
  9. lossy, etc.
  10. </footnote>. Before describing the API the software can use, some
  11. background on CADET's capabilities is given.
  12. <\warning>
  13. To be implemented, this is a draft of the API!
  14. </warning>
  15. <section|Qualities and limitations \V avoiding reinventing the wheel>
  16. <dfn|Channels><index|tunnel><\footnote>
  17. They could have been called <em|connections>, but that means something
  18. different in CADET.
  19. </footnote> \U i.e., bidirectional communication channels between two peers
  20. over CADET, are encrypted and authentication and hence are impractical to
  21. eavesdrop on or be modified by an attacker<\footnote>
  22. Assuming that the cryptography is not broken.
  23. </footnote>. To aid reliability and performance, CADET aims to keep three
  24. independent connections between the two peers so manually creating multiple
  25. channels ought to be unnecessary.
  26. The unit of information sent over a channel is a
  27. <with|font-shape|italic|message> \U essentially, a bytevector. The software
  28. can select multiple options: it can choose between <em|reliable> or
  29. <em|unreliable>, <em|in-order> and <em|out-of-order> and <em|low-latency>
  30. or <em|corked>, see <reference|mq-prio-prefs>.
  31. <todo|ACKs for messages, opening, closing, window size>
  32. <section|Addresses>
  33. To contact a peer over CADET, the remote peer must have an <dfn|open
  34. port><index|port> and the local peer needs to contact this port. The remote
  35. peer\Uport identifier pair is called a <dfn|CADET address><index|CADET
  36. address> in Scheme-GNUnet. A <dfn|CADET address> can be made with the
  37. <scm|make-cadet-address> procedure:
  38. <\explain>
  39. <scm|(make-cadet-address <var|peer> <var|port>)>
  40. <|explain>
  41. Make a CADET address for the peer <var|peer> (a readable bytevector slice
  42. containing a <scm|/peer-identity>) at the port <var|port> (a readable
  43. bytevector slice containing a <scm|/hashcode:512>). The slices <var|peer>
  44. and <var|port> are copied, so future changes to them do not have any
  45. impact on the CADET address.
  46. The predicate for CADET addresses is <scm|cadet-address?>. The peer and
  47. port can be extracted with the accessors <scm|cadet-address-peer> and
  48. <scm|cadet-address-port>. CADET addresses can be compared with
  49. <scm|equal?>.
  50. </explain>
  51. Guile has a generic interface for network addresses, see (guile)Network
  52. Socket Address. If BSD socket integration is activated (see <todo|todo>),
  53. this interface is extended to support CADET addresses. In particular,
  54. <scm|sockaddr:fam> will return <scm|AF_CADET> (a symbol, also available as
  55. the variable <scm|AF_CADET>) an <scm|sockaddr:addr> and <scm|sockaddr:port>
  56. will return the peer and port respectively as a bytevector that should not
  57. be modified<\footnote>
  58. A copy is made to avoid letting buggy code mutate the CADET address, but
  59. this is an implementation detail.
  60. </footnote>.
  61. <section|Listening at an address>
  62. To listen at some address such that other peers can connect, the
  63. <scm|open-port!> procedure is used.
  64. <\explain>
  65. (open-port! <var|server> <var|port> <var|connected> HANDLERS)
  66. </explain|>
  67. <section|Connecting to an address>
  68. <section|Performing I/O \U GNUnet style>
  69. <section|Performing I/O \U BSD style>
  70. <scm|send>, <scm|recv!> (MSG_PEEK), getsockname \U\<gtr\> ???, getpeername
  71. \U\<gtr\> ???, accept, listen, bind, shutdown
  72. No reuseport
  73. <section|BSD socket integration>
  74. (AF_CADET, SOCK_RAW, 0) \U\<gtr\> GNUnet messages (with reliability
  75. according to socket options).
  76. (AF_CADET, SOCK_STREAM, 0) \U\<gtr\> TCP/CADET (VPN)
  77. (AF_CADET, SOCK_DGRAM, 0) \U\<gtr\> UDP/CADET (VPN)
  78. (AF_CADET, SOCK_SEQPACKET, 0) \U\<gtr\> UDP/CADET (VPN), in-order, reliable
  79. (AF_CADET, SOCK_RDM, 0) \U\<gtr\> UDP/CADET (VPN), out-of-order, reliable
  80. These sockets not dupable, don't have a fd.<todo|>
  81. <section|Constructing and analysing network messages>
  82. <todo|difference between channels and ports>
  83. <todo|acknowledgement>
  84. <todo|readable bytevector slices>
  85. <todo|verify against GNUnet documentation>
  86. <todo|analysis>
  87. <\explain>
  88. (construct-open-local-port <var|port>)<index|construct-open-local-port>
  89. </explain|Create a new <scm|/:msg:cadet:local:port:open><index|/:msg:cadet:local:port:open>
  90. message for instructing the service to open the port <var|port> at the
  91. local peer.>
  92. <\explain>
  93. (construct-close-local-port <var|port>)<index|construct-close-local-port>
  94. </explain|Crreate a new <scm|/:msg:cadet:local:port:close><index|/:msg:cadet:local:port:close>
  95. message for closing the port.>
  96. <\explain>
  97. (construct-local-data <var|client-channel-number> <var|priority>
  98. <var|data>)<index|construct-local-data>
  99. </explain|Construct a new <scm|/:msg:cadet:local:data><index|/:msg:cadet:local:data>
  100. message for sending <var|data> \ <todo|client\<less\>-\<gtr\>service>
  101. <todo|to/from> the channel with identifier <var|client-channel-number> at
  102. the priority specified by the numeric priority-preference value
  103. <var|priority>.>
  104. <\explain>
  105. <scm|(construct-local-acknowledgement
  106. <var|client-channel-number>)><index|construct-local-acknowledgement>
  107. </explain|Construct a new <scm|/:msg:cadet:local:acknowledgement><index|/:msg:cadet:local:acknowledgemeent>
  108. message for the channel with identifier <var|client-channel-number>, for
  109. informing the client that the service is ready for more data.>
  110. <\explain>
  111. <scm|(construct-local-channel-create <todo|arguments> <var|#:options>)>
  112. </explain|Construct a new <scm|msg:cadet:local:channel:create> message for
  113. <todo|which direction? client\<less\>-\<gtr\>service, reasonable options>>
  114. <\explain>
  115. (construct-destroy-local-channel <var|client-channel-number>)
  116. <|explain>
  117. Construct a new <scm|msg:cadet:local:channel:destroy> message to destroy
  118. the channel with identifier <var|client-channel-number>. This can be sent
  119. in two directions: from the client to the service, to close the channel,
  120. or from service to client, to inform the channel has been closed.
  121. <todo|Can the service send this without the client requesting this? If
  122. the client send this message, will the service send this message in
  123. return as an acknowledgment?>
  124. </explain>
  125. </body>
  126. <\initial>
  127. <\collection>
  128. <associate|page-medium|paper>
  129. <associate|save-aux|false>
  130. </collection>
  131. </initial>