il.ms 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. .TL
  2. The IL protocol
  3. .AU
  4. Dave Presotto
  5. Phil Winterbottom
  6. .sp
  7. presotto,philw@plan9.bell-labs.com
  8. .AB
  9. To transport the remote procedure call messages of the Plan 9 file system
  10. protocol 9P, we have implemented a new network protocol, called IL.
  11. It is a connection-based, lightweight transport protocol that carries
  12. datagrams encapsulated by IP.
  13. IL provides retransmission of lost messages and in-sequence delivery, but has
  14. no flow control and no blind retransmission.
  15. .AE
  16. .SH
  17. Introduction
  18. .PP
  19. Plan 9 uses a file system protocol, called 9P [PPTTW93], that assumes
  20. in-sequence guaranteed delivery of delimited messages
  21. holding remote procedure call
  22. (RPC) requests and responses.
  23. None of the standard IP protocols [RFC791] is suitable for transmission of
  24. 9P messages over an Ethernet or the Internet.
  25. TCP [RFC793] has a high overhead and does not preserve delimiters.
  26. UDP [RFC768], while cheap and preserving message delimiters, does not provide
  27. reliable sequenced delivery.
  28. When we were implementing IP, TCP, and UDP in our system we
  29. tried to choose a protocol suitable for carrying 9P.
  30. The properties we desired were:
  31. .IP \(bu
  32. Reliable datagram service
  33. .IP \(bu
  34. In-sequence delivery
  35. .IP \(bu
  36. Internetworking using IP
  37. .IP \(bu
  38. Low complexity, high performance
  39. .IP \(bu
  40. Adaptive timeouts
  41. .LP
  42. No standard protocol met our needs so we designed a new one,
  43. called IL (Internet Link).
  44. .PP
  45. IL is a lightweight protocol encapsulated by IP.
  46. It is connection-based and
  47. provides reliable transmission of sequenced messages.
  48. No provision is made for flow control since the protocol
  49. is designed to transport RPC
  50. messages between client and server, a structure with inherent flow limitations.
  51. A small window for outstanding messages prevents too
  52. many incoming messages from being buffered;
  53. messages outside the window are discarded
  54. and must be retransmitted.
  55. Connection setup uses a two-way handshake to generate
  56. initial sequence numbers at each end of the connection;
  57. subsequent data messages increment the
  58. sequence numbers to allow
  59. the receiver to resequence out of order messages.
  60. In contrast to other protocols, IL avoids blind retransmission.
  61. This helps performance in congested networks,
  62. where blind retransmission could cause further
  63. congestion.
  64. Like TCP, IL has adaptive timeouts,
  65. so the protocol performs well both on the
  66. Internet and on local Ethernets.
  67. A round-trip timer is used
  68. to calculate acknowledge and retransmission times
  69. that match the network speed.
  70. .SH
  71. Connections
  72. .PP
  73. An IL connection carries a stream of data between two end points.
  74. While the connection persists,
  75. data entering one side is sent to the other side in the same sequence.
  76. The functioning of a connection is described by the state machine in Figure 1,
  77. which shows the states (circles) and transitions between them (arcs).
  78. Each transition is labeled with the list of events that can cause
  79. the transition and, separated by a horizontal line,
  80. the messages sent or received on that transition.
  81. The remainder of this paper is a discussion of this state machine.
  82. .KF
  83. \s-2
  84. .PS 5.5i
  85. copy "transition.pic"
  86. .PE
  87. \s+2
  88. .RS
  89. .IP \fIackok\fR 1.5i
  90. any sequence number between id0 and next inclusive
  91. .IP \fI!x\fR 1.5i
  92. any value except x
  93. .IP \- 1.5i
  94. any value
  95. .RE
  96. .sp
  97. .ce
  98. .I "Figure 1 - IL State Transitions
  99. .KE
  100. .PP
  101. The IL state machine has five states:
  102. .I Closed ,
  103. .I Syncer ,
  104. .I Syncee ,
  105. .I Established ,
  106. and
  107. .I Closing .
  108. The connection is identified by the IP address and port number used at each end.
  109. The addresses ride in the IP protocol header, while the ports are part of the
  110. 18-byte IL header.
  111. The local variables identifying the state of a connection are:
  112. .RS
  113. .IP state 10
  114. one of the states
  115. .IP laddr 10
  116. 32-bit local IP address
  117. .IP lport 10
  118. 16-bit local IL port
  119. .IP raddr 10
  120. 32-bit remote IP address
  121. .IP rport 10
  122. 16-bit remote IL port
  123. .IP id0 10
  124. 32-bit starting sequence number of the local side
  125. .IP rid0 10
  126. 32-bit starting sequence number of the remote side
  127. .IP next 10
  128. sequence number of the next message to be sent from the local side
  129. .IP rcvd 10
  130. the last in-sequence message received from the remote side
  131. .IP unacked 10
  132. sequence number of the first unacked message
  133. .RE
  134. .PP
  135. Unused connections are in the
  136. .I Closed
  137. state with no assigned addresses or ports.
  138. Two events open a connection: the reception of
  139. a message whose addresses and ports match no open connection
  140. or a user explicitly opening a connection.
  141. In the first case, the message's source address and port become the
  142. connection's remote address and port and the message's destination address
  143. and port become the local address and port.
  144. The connection state is set to
  145. .I Syncee
  146. and the message is processed.
  147. In the second case, the user specifies both local and remote addresses and ports.
  148. The connection's state is set to
  149. .I Syncer
  150. and a
  151. .CW sync
  152. message is sent to the remote side.
  153. The legal values for the local address are constrained by the IP implementation.
  154. .SH
  155. Sequence Numbers
  156. .PP
  157. IL carries data messages.
  158. Each message corresponds to a single write from
  159. the operating system and is identified by a 32-bit
  160. sequence number.
  161. The starting sequence number for each direction in a
  162. connection is picked at random and transmitted in the initial
  163. .CW sync
  164. message.
  165. The number is incremented for each subsequent data message.
  166. A retransmitted message contains its original sequence number.
  167. .SH
  168. Transmission/Retransmission
  169. .PP
  170. Each message contains two sequence numbers:
  171. an identifier (ID) and an acknowledgement.
  172. The acknowledgement is the last in-sequence
  173. data message received by the transmitter of the message.
  174. For
  175. .CW data
  176. and
  177. .CW dataquery
  178. messages, the ID is its sequence number.
  179. For the control messages
  180. .CW sync ,
  181. .CW ack ,
  182. .CW query ,
  183. .CW state ,
  184. and
  185. .CW close ,
  186. the ID is one greater than the sequence number of
  187. the highest sent data message.
  188. .PP
  189. The sender transmits data messages with type
  190. .CW data .
  191. Any messages traveling in the opposite direction carry acknowledgements.
  192. An
  193. .CW ack
  194. message will be sent within 200 milliseconds of receiving the data message
  195. unless a returning message has already piggy-backed an
  196. acknowledgement to the sender.
  197. .PP
  198. In IP, messages may be delivered out of order or
  199. may be lost due to congestion or faults.
  200. To overcome this,
  201. IL uses a modified ``go back n'' protocol that also attempts
  202. to avoid aggravating network congestion.
  203. An average round trip time is maintained by measuring the delay between
  204. the transmission of a message and the
  205. receipt of its acknowledgement.
  206. Until the first acknowledge is received, the average round trip time
  207. is assumed to be 100ms.
  208. If an acknowledgement is not received within four round trip times
  209. of the first unacknowledged message
  210. .I "rexmit timeout" "" (
  211. in Figure 1), IL assumes the message or the acknowledgement
  212. has been lost.
  213. The sender then resends only the first unacknowledged message,
  214. setting the type to
  215. .CW dataquery .
  216. When the receiver receives a
  217. .CW dataquery ,
  218. it responds with a
  219. .CW state
  220. message acknowledging the highest received in-sequence data message.
  221. This may be the retransmitted message or, if the receiver has been
  222. saving up out-of-sequence messages, some higher numbered message.
  223. Implementations of the receiver are free to choose whether to save out-of-sequence messages.
  224. Our implementation saves up to 10 packets ahead.
  225. When the sender receives the
  226. .CW state
  227. message, it will immediately resend the next unacknowledged message
  228. with type
  229. .CW dataquery .
  230. This continues until all messages are acknowledged.
  231. .PP
  232. If no acknowledgement is received after the first
  233. .CW dataquery ,
  234. the transmitter continues to timeout and resend the
  235. .CW dataquery
  236. message.
  237. The intervals between retransmissions increase exponentially.
  238. After 300 times the round trip time
  239. .I "death timeout" "" (
  240. in Figure 1), the sender gives up and
  241. assumes the connection is dead.
  242. .PP
  243. Retransmission also occurs in the states
  244. .I Syncer ,
  245. .I Syncee ,
  246. and
  247. .I Close .
  248. The retransmission intervals are the same as for data messages.
  249. .SH
  250. Keep Alive
  251. .PP
  252. Connections to dead systems must be discovered and torn down
  253. lest they consume resources.
  254. If the surviving system does not need to send any data and
  255. all data it has sent has been acknowledged, the protocol
  256. described so far will not discover these connections.
  257. Therefore, in the
  258. .I Established
  259. state, if no other messages are sent for a 6 second period,
  260. a
  261. .CW query
  262. is sent.
  263. The receiver always replies to a
  264. .CW query
  265. with a
  266. .CW state
  267. message.
  268. If no messages are received for 30 seconds, the
  269. connection is torn down.
  270. This is not shown in Figure 1.
  271. .SH
  272. Byte Ordering
  273. .PP
  274. All 32- and 16-bit quantities are transmitted high-order byte first, as
  275. is the custom in IP.
  276. .SH
  277. Formats
  278. .PP
  279. The following is a C language description of an IP+IL
  280. header, assuming no IP options:
  281. .P1
  282. typedef unsigned char byte;
  283. struct IPIL
  284. {
  285. byte vihl; /* Version and header length */
  286. byte tos; /* Type of service */
  287. byte length[2]; /* packet length */
  288. byte id[2]; /* Identification */
  289. byte frag[2]; /* Fragment information */
  290. byte ttl; /* Time to live */
  291. byte proto; /* Protocol */
  292. byte cksum[2]; /* Header checksum */
  293. byte src[4]; /* Ip source */
  294. byte dst[4]; /* Ip destination */
  295. byte ilsum[2]; /* Checksum including header */
  296. byte illen[2]; /* Packet length */
  297. byte iltype; /* Packet type */
  298. byte ilspec; /* Special */
  299. byte ilsrc[2]; /* Src port */
  300. byte ildst[2]; /* Dst port */
  301. byte ilid[4]; /* Sequence id */
  302. byte ilack[4]; /* Acked sequence */
  303. };
  304. .P2
  305. .LP
  306. Data is assumed to immediately follow the header in the message.
  307. .CW Ilspec
  308. is an extension reserved for future protocol changes.
  309. .PP
  310. The checksum is calculated with
  311. .CW ilsum
  312. and
  313. .CW ilspec
  314. set to zero.
  315. It is the standard IP checksum, that is, the 16-bit one's complement of the one's
  316. complement sum of all 16 bit words in the header and text. If a
  317. message contains an odd number of header and text bytes to be
  318. checksummed, the last byte is padded on the right with zeros to
  319. form a 16-bit word for the checksum.
  320. The checksum covers from
  321. .CW cksum
  322. to the end of the data.
  323. .PP
  324. The possible
  325. .I iltype
  326. values are:
  327. .P1
  328. enum {
  329. sync= 0,
  330. data= 1,
  331. dataquery= 2,
  332. ack= 3,
  333. query= 4,
  334. state= 5,
  335. close= 6,
  336. };
  337. .P2
  338. .LP
  339. The
  340. .CW illen
  341. field is the size in bytes of the IL header (18 bytes) plus the size of the data.
  342. .SH
  343. Numbers
  344. .PP
  345. The IP protocol number for IL is 40.
  346. .PP
  347. The assigned IL port numbers are:
  348. .RS
  349. .IP 7 15
  350. echo all input to output
  351. .IP 9 15
  352. discard input
  353. .IP 19 15
  354. send a standard pattern to output
  355. .IP 565 15
  356. send IP addresses of caller and callee to output
  357. .IP 566 15
  358. Plan 9 authentication protocol
  359. .IP 17005 15
  360. Plan 9 CPU service, data
  361. .IP 17006 15
  362. Plan 9 CPU service, notes
  363. .IP 17007 15
  364. Plan 9 exported file systems
  365. .IP 17008 15
  366. Plan 9 file service
  367. .IP 17009 15
  368. Plan 9 remote execution
  369. .IP 17030 15
  370. Alef Name Server
  371. .RE
  372. .SH
  373. References
  374. .LP
  375. [PPTTW93] Rob Pike, Dave Presotto, Ken Thompson, Howard Trickey, and Phil Winterbottom,
  376. ``The Use of Name Spaces in Plan 9'',
  377. .I "Op. Sys. Rev.,
  378. Vol. 27, No. 2, April 1993, pp. 72-76,
  379. reprinted in this volume.
  380. .br
  381. [RFC791] RFC791,
  382. .I "Internet Protocol,
  383. .I "DARPA Internet Program Protocol Specification,
  384. September 1981.
  385. .br
  386. [RFC793] RFC793,
  387. .I "Transmission Control Protocol,
  388. .I "DARPA Internet Program Protocol Specification,
  389. September 1981.
  390. .br
  391. [RFC768] J. Postel, RFC768,
  392. .I "User Datagram Protocol,
  393. .I "DARPA Internet Program Protocol Specification,
  394. August 1980.