[Ns-developers] ns-3::Buffer and bit-sized fields, is this crap possible ?

Gustavo Carneiro gjcarneiro at gmail.com
Sun Nov 13 06:13:13 PST 2011


On Sun, Nov 13, 2011 at 13:20, Tommaso Pecorella <tpecorella at mac.com> wrote:

> Hi all,
>
> I am rewriting my 6LoWPAN stack so to submit for review, and I found a
> little issue. Nothing to die for, but still...
>
> Excerpt from RFC4944:
>      Traffic Class and Flow Label (bit 4):
>         0: not compressed; full 8 bits for Traffic Class and 20 bits
>            for Flow Label are sent
>         1: Traffic Class and Flow Label are zero
>
> Geeez, 20 bits ? How the hell do I serialize / deserialize 20 bits ? I
> don't, simple.
>
> For 6LoWPAN is not a big issue, a good 'ol assert will do, I'm not
> supporting that case. On the other hand it might happen to have to support
> it, maybe for other obscure and ultra-compressed protocols. Please note
> that the above clause means that the 6LoWPAN HC1 header might have a length
> that is not byte aligned, so I can't recover the alignment with the
> following fields like, for example, happens in the standard IPv6 header.
> I know it's totally insane to have a packet with non-byte boundaries, but
> still.
>
> Now, the question is: shall we think to a way to support this without
> killing the Buffer implementation and its performance ?
>

You shouldn't worry about alignment, the RFC says to use padding as needed:

   Header compression may result in alignment not falling on an octet
   boundary.  Since hardware typically cannot transmit data in units
   less than an octet, padding must be used.  Padding is done as
   follows: First, the entire series of contiguous compressed headers is
   laid out (this document only defines IPv6 and UDP header compression
   schemes, but others may be defined elsewhere).  Then, zero bits
   SHOULD be added as appropriate to align to an octet boundary.  This
   counteracts any potential misalignment caused by header compression,
   so subsequent fields (e.g., non-compressed headers or data payloads)
   start on an octet boundary and follow as usual.




>
> Cheers,
>
> Tommaso
>
>
> --------------------------------------------------------------
>
> $25: for you a pizza and some beers with friends, for someone
>     might change their lives. Think about it.
>
> Kiva.org - Loans That Change Lives
>
> --------------------------------------------------------------
>
> Tommaso Pecorella - Ph.D.
>
> Assistant professor
> Dpt. Elettronica e Telecomunicazioni
> Università di Firenze
>
> CNIT - Università di Firenze Unit
>
> via di S. Marta 3
> 50139, Firenze
> ITALY
>
> email: tommaso.pecorella at unifi.it
>       tommaso.pecorella at cnit.it
>
> phone : +39-055-4796412
> mobile: +39-320-4379803
> fax   : +39-055-494569
>
>
>
>
>
>
>


-- 
Gustavo J. A. M. Carneiro
INESC Porto, UTM, WiN, http://win.inescporto.pt/gjc
"The universe is always one step beyond logic." -- Frank Herbert


More information about the Ns-developers mailing list