Subject: [core] Transparent proxying CoAP

From: "Angelo P. Castellani" <[email-masked]>
Date: Thu, 22 Apr 2010 12:26:26 +0200

Dear all,
we have started developing a plugin for the Squid Cache project, that
will allow transparent proxying of compressed (BWS/CoAP?) HTTP packets
to/from a 6LoWPAN/WSN; we are trying to do this following the format
specified in the current CoAP draft.

However this requires a well defined mapping from HTTP to CoAP and viceversa.

>>>>> HTTP->CoAP:
(1) Compressed requests should be small
(2) State information should not be required by the proxy

The major problem here is that the URI cannot be represented as a code
(high-compression) but only by the full string representation.

For such a reason I suggest the use of Binary-URI instead of URI-Code.
You can find a possible definition for Binary-URI in what follows:

Binary-URI is a compressed mapping of the String-URI:
* It is N bytes long, where N is the depth of the resource in the
String-URI. example:

(a) /document/letter/order.html DEPTH: 3
(b) / DEPTH: 0
(c) /index.html DEPTH: 1

* byte K is equal to the sum modulo 256 of ASCII values forming the
K-level resource name in the tree:

(a) document = 95, letter = 144, order.html = 255. So Binary-URI = {
95, 144, 255 } (c-style representation)
(b) no byte so Binary-URI = {}
(c) index.html = 251. Binary-URI = { 251 }

Here is the code of the program used to compute the values:

sum.c
#include <stdio.h>
#include <stdlib.h>

int main (int argc, char* argv[]) {
       if (argc==2) {
               unsigned char* p = argv[1];
               int sum=0;
               do {
                       sum+=*p;
               } while (*(++p));
               printf("word: \"%s\" sum: %d\n", argv[1], sum&0xff);
       }
}

Resources created on a CoAP server should not collide with
each-other, to achieve this when we try to register a new resource the
CoAP server should check if it is colliding with other available
resources and accept the request only if this condition is satisfied.

Instead using URI-Code a table is always needed to map between String-URI

and Code-URI. Table mapping is an operation that requires knowledge on
the entity operating that translation (CoAP will require state
information to be translated, which should be avoided in my opinion),

moreover table storage, handling and search requires a non-trivial
cost on a costrained device.

Cookie and Set-Cookie headers are really useful and should be included.

Using cookies it is possible for CoAP servers to delegate state
information memorization to the client.

>>>> CoAP->HTTP:

CoAP clients accessing HTTP servers may require to send arbitrary
headers to that server.

At least the most common headers should be handled by defining an
option. Here is a very basic list to be completed:
Host: (very important both to access virtual HTTP servers and to allow
easier implementation of transparent proxying)
Cookie:
Set-Cookie:
etc. etc.

Moreover Binary-Cookie and Set-Binary-Cookie can be defined using the
same format of binary mapping as described in the URI.

An option to include an arbitrary header in my opinion is required and
should be included.

It can be Generic-Header string option carrying the header name and
the full text contained.

Best regards,
Angelo P. Castellani