9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Regarding 9p based "protocols" message framing
@ 2012-03-16 11:40 Ciprian Dorin Craciun
  2012-03-16 17:04 ` Richard Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Ciprian Dorin Craciun @ 2012-03-16 11:40 UTC (permalink / raw)
  To: 9fans

    Hello all!

    I'm reading through the nice `factotum` paper [1], and the section
describing the `rpc` file behaviour (section "2.6. Factotum
transactions") states:

~~~~
Programs authenticate with factotum by writing a request to the rpc
file and reading back the reply; this sequence is called an RPC
transaction. Requests and replies have the same format: a textual verb
possibly followed by arguments, which may be textual or binary. [...]
Once started, an RPC conversation usually consists of a sequence of
read and write transactions.
[...]
PS -> FS: start proto=apop role=server
FS -> PS: ok
~~~~

    Now my puzzle was related to what does actually "sequence of read
and write transactions" mean. To be more clearly:
    * the cited paragraph clearly involves two protocols: one is the
factotum RPC protocol which is layered on-top of the 9p protocol;
    * if we take only the factotum RPC protocol (in abstraction of 9p)
we **might** have the impression that each "request" and "response" is
sent as an individual message whose framing is that of an text line,
and 9p is used merely as a transport; (but this framing is not clearly
expressed, see below...);
    * thus if we take only this factotum RPC protocol into
consideration the implementor might have the impression that the
implementation should roughly be: keep receiving write requests until
we have an entire request (pseudo-C):
~~~~
handle_write (context, data) {
  append (context->buffer, data);
  if (request_ready (context) {
    handle_request (context);
  }
  return (succeed);
~~~~
    * but if we look at how it is implemented [2] it is actually: one
request and reply must map over exactly one 9p read or write
operation.
~~~~
handle_write (context, data) {
  if (parse_request (context, data))
    return (handle_request (context));
  else
    return (failed);
~~~~

    Why was I puzzled: because as a non Plan9 user / developer, I
usually think of the underlaying transport technology (be it sockets
or 9p) as a stream of bytes without explicit framing. Meanwhile I
think that the Plan9 usage of 9p is:
    * sometimes as a bidirectional message pipe (i.e. read == pull
message, write == push message, similar to what ZeroMQ library
offers);
    * sometimes as an stateless RPC (like HTTP): open file, write
request data in maybe multiple write operations, read reply data in
maybe multiple read operations; (like the `ctl` file, as I guess `cat
>ctl` makes one write per read line);
    * sometimes as an un-seekable stream of data (like the `log` file);

    Now I see here advantages and disadvantages... Advantages:
    * the developer doesn't need to bother anymore with framing -- it
is done directly by the FS; (and gosh is this a relief, as every other
protocol invented its own framing: length followed by data, line feed
terminated, empty line terminated, random token ended, etc.)
    * concurrent outstanding requests -- just call write in parallel;
(I've read the protocol and the specification doesn't say its
forbidden, but I've read something a few months ago on this mailing
list which suggested it should not be done???)

    Disadvantages:
    * the tools must be aware of this mapping between 1 request == 1
write operation; thus if for example my request would be composed of
multiple lines, and I use `cat >./some-file` as an "interface"; then
`cat` would read one line and immediately send it as an individual
write operation which of course is not respecting the "protocol" built
ontop of 9p;


    Thus I would like to hear the position of the people on this
mailing list about:
    * the explicitly mapping of one request to one 9p operation;
    * the "recommended" usage "patterns" of 9p when building "control"
protocols ontop;

    Thanks,
    Ciprian.


    [1] Security in Plan 9 -- http://plan9.bell-labs.com/sys/doc/auth.html
    [2] http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/auth/factotum/rpc.c



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2012-03-21 21:35 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-16 11:40 [9fans] Regarding 9p based "protocols" message framing Ciprian Dorin Craciun
2012-03-16 17:04 ` Richard Miller
2012-03-16 17:36 ` Russ Cox
2012-03-16 17:55   ` Ciprian Dorin Craciun
     [not found] ` <CADSkJJVcsffzZo6En5A8DTApZULxkqCuzXEgKbFvv8eRjm2DpQ@mail.gmail.c>
2012-03-16 17:49   ` erik quanstrom
2012-03-20 11:42     ` Yaroslav
2012-03-20 12:32       ` Dan Cross
2012-03-20 20:30         ` Ciprian Dorin Craciun
2012-03-21  1:22           ` Dan Cross
     [not found]           ` <CAEoi9W6t2WRPTYU6+JHfAZoRAe6aWxkuCDkXb1G+VAkZZ1kYug@mail.gmail.c>
2012-03-21  1:52             ` erik quanstrom
     [not found]       ` <CAEoi9W6z_48wm8Jx__Meodnr50g0Ba00wqyfVrv0SP=Xb5ZHcw@mail.gmail.c>
2012-03-20 15:57         ` erik quanstrom
2012-03-21 20:11           ` Yaroslav
2012-03-21 20:32             ` Anthony Sorace
2012-03-21 20:37               ` erik quanstrom
     [not found]           ` <CAG3N4d_Qd-dH4pZWXGdqoNTguSjGge1oLahTwJAk5nVLvzXvjQ@mail.gmail.c>
2012-03-21 20:27             ` erik quanstrom
2012-03-21 20:38               ` Anthony Sorace
2012-03-21 20:53                 ` erik quanstrom
2012-03-21 21:24                   ` cinap_lenrek
2012-03-21 21:27                     ` erik quanstrom
2012-03-21 21:35                       ` cinap_lenrek
2012-03-21 21:07                 ` cinap_lenrek
2012-03-21 21:22                   ` erik quanstrom
2012-03-21 21:16               ` David du Colombier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).