sp-ipc-mapping-01.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?xml version="1.0" encoding="US-ASCII"?>
  2. <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
  3. <rfc category="info" docName="sp-ipc-mapping-01">
  4. <front>
  5. <title abbrev="IPC mapping for SPs">
  6. IPC Mapping for Scalability Protocols
  7. </title>
  8. <author fullname="Garrett D'Amore" initials="G." role="editor"
  9. surname="D'Amore">
  10. <address>
  11. <email>garrett@damore.org</email>
  12. </address>
  13. </author>
  14. <author fullname="Martin Sustrik" initials="M." surname="Sustrik">
  15. <address>
  16. <email>sustrik@250bpm.com</email>
  17. </address>
  18. </author>
  19. <date month="APril" year="2016" />
  20. <area>Applications</area>
  21. <workgroup>Internet Engineering Task Force</workgroup>
  22. <keyword>IPC</keyword>
  23. <keyword>UNIX</keyword>
  24. <keyword>SP</keyword>
  25. <abstract>
  26. <t>This document defines the IPC mapping for scalability protocols.
  27. It deals with how IPC (inter-process communication) should be
  28. implemented on POSIX-compliant platforms.</t>
  29. </abstract>
  30. </front>
  31. <middle>
  32. <section title = "Underlying protocol">
  33. <t>This mapping should be layered directly on the top of AF_UNIX
  34. sockets of type SOCK_STREAM. On the platforms where AF_UNIX sockets
  35. are not available IPC mapping may be done in a platform-specific way
  36. and SHOULD be described in a separate RFC.</t>
  37. <t>There's no fixed file to use for SP communication. Instead, filenames
  38. are assigned to individual services by the user.</t>
  39. </section>
  40. <section title = "Connection initiation">
  41. <t>Before binding the AF_UNIX socket the implementation SHOULD check
  42. whether there's another process bound to the address. If not so
  43. it SHOULD try to delete the associated file, if present. This measure
  44. will prevent subsequent bind from failing if there's a leftover file
  45. from the previous runs of the application.</t>
  46. <t>The check can be performed in a platform-specific way, however,
  47. a generic way to implement it is to try to connect to the address
  48. and close the connection immediately if successful.</t>
  49. <t>After establishing underlying AF_UNIX connection, both parties MUST
  50. send the protocol header immediately. Both endpoints MUST then wait
  51. for the protocol header from the peer before proceeding on.</t>
  52. <t>The protocol header is 8 bytes long and looks like this:</t>
  53. <figure>
  54. <artwork>
  55. 0 1 2 3
  56. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  57. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  58. | 0x00 | 0x53 | 0x50 | version |
  59. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  60. | type | reserved |
  61. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  62. </artwork>
  63. </figure>
  64. <t>First four bytes of the protocol header are used to make sure that
  65. the peer's protocol is compatible with the protocol used by the local
  66. endpoint.</t>
  67. <t>First four bytes of the protocol header MUST be set to 0x00, 0x53, 0x50
  68. and 0x00 respectively. If the protocol header received from the peer
  69. differs, the TCP connection MUST be closed immediately.</t>
  70. <t>The fact that the first byte of the protocol header is binary zero
  71. eliminates any text-based protocols that were accidentally connected
  72. to the endpoint. Subsequent two bytes make the check even more
  73. rigorous. At the same time they can be used as a debugging hint to
  74. indicate that the connection is supposed to use one of the scalability
  75. protocols -- ASCII representation of these bytes is 'SP'. Finally,
  76. the fourth byte rules out any incompatible versions of this
  77. protocol.</t>
  78. <t>Fifth and sixth bytes of the header form a 16-bit unsigned integer in
  79. network byte order representing the type of SP endpoint on the layer
  80. above. The value SHOULD NOT be interpreted by the mapping, rather
  81. the interpretation should be delegated to the scalability protocol
  82. above the mapping. For informational purposes, it should be noted that
  83. the field encodes information such as SP protocol ID, protocol version
  84. and the role of endpoint within the protocol. Individual values are
  85. assigned by IANA.</t>
  86. <t>Finally, the last two bytes of the protocol header are reserved for
  87. future use and must be set to binary zeroes. If the protocol header
  88. from the peer contains anything else than zeroes in this field, the
  89. implementation MUST close the underlying TCP connection.</t>
  90. </section>
  91. <section title = "Message header">
  92. <t>Once the protocol header is accepted, endpoint can send and receive
  93. messages. Every message starts with a message header consisting of
  94. of a single byte called 'message type'.</t>
  95. <t>The only value of this field that is currently allowed is 0x1, which
  96. means "in-band" message, i.e. message whose body is passed as a stream
  97. of bytes via the AF_UNIX socket.</t>
  98. <t>The intent of this field is to eventually allow out-of-band transfer
  99. of the message bodies, e.g. via shared memory.</t>
  100. <t>The in-band message type MUST be implemented.</t>
  101. </section>
  102. <section title = "In-band messages">
  103. <t>For in-band messages, message header is immediately followed by 64-bit
  104. unsigned integer in network byte order representing the payload size,
  105. in bytes. Thus, the message payload can be from 0 to 2^64-1 bytes long.
  106. The payload of the specified size follows directly after the size
  107. field:</t>
  108. <figure>
  109. <artwork>
  110. +-----------+------------+-----------------+
  111. | type (8b) | size (64b) | payload |
  112. +-----------+------------+-----------------+
  113. </artwork>
  114. </figure>
  115. </section>
  116. <section anchor="IANA" title="IANA Considerations">
  117. <t>This memo includes no request to IANA.</t>
  118. </section>
  119. <section anchor="Security" title="Security Considerations">
  120. <t>The mapping isn't intended to provide any additional security in
  121. addition to what AF_UNIX does.</t>
  122. </section>
  123. </middle>
  124. </rfc>