SN Encoding clarification

Karthik Balaguru <[email protected]> Mon, 13 Jul 2009 20:25:26 +0530
Newsgroups gmane.ietf.rohc
Message-ID <OF21BB8FB3.E22ABC41-ON652575F2.002CC9F6-652575F2.0051FBA8@lntinfotech.com>
Hi,

Need clarifications on SN Encoding.

I wonder why the 'g funtion' has not been very explicitly defined in the 
RFC 3095.

For SN WLSB -
1. As per the understanding & also based on the IETF mailing list 
discussions , the 'g function' in 
    the Compressor for K bit calculation looks as below -
    ( Reference - 
http://www.ietf.org/mail-archive/web/rohc/old-archive/msg02263.html )

        g(v_minmax, v) 
        { 
               FLOOR( log2 ( v_minmax XOR v ) ) + 1;
        }
        k1 = g(v_min, v);
        k2 = g(v_max, v);
        Sn_k = max(k1, k2); 
        Here, v is Received SN , v_min & v_max are the minimum SN & 
maximum SN repectively in the window

        And in the Decompressor, packet it looks as below :-
        mask = ~((1 << Sn_k) - 1);    // mask is uint16
        rtpSeq = ((v_ref & mask) | ESn);
        Here, ESn is the Extracted SN bits from the Compressed packets.


2.  But, from the opensource RoHC code , the below info was obtained :-
     ( Reference - http://rohc.sourceforge.net/download.php )

        On the compressor side, the 'g function' is as below - 
        static void f(int v_ref, int k, int p, int * min, int * max)
        {
                *min = v_ref - p;
                *max = v_ref + ((1 << k) - 1) - p;      // (1 << k) = 2 to 
the power of k
        }

        static int g(int v_ref, int v, int p, int bits)
        {
                int k, min, max;
                for(k = 0; k < bits; k++){
                        f(v_ref, k, p, &min, &max);
                        if( (v <= max) && (v >= min) ) break;
                }
                return k;
        }

        And in the decompressor , it is as below -
        int d_lsb_decode(struct sd_lsb_decode * s, int m, int k)
        { 
                int lower = (s->v_ref_d - s->p);
        //      int higher = (ref - s->p) + 1 << k - 1;
                int bitmask = ~((1 << k) - 1);
                int sn = (s->v_ref_d & bitmask) | m;
                if (sn < lower) sn += 1 << k;
                return sn & 0xFFFF;
        }

So, Kindly let me know the method that is inline with RFC 3095 for the 'g 
function' .

Thx in advans,
Karthik Balaguru

______________________________________________________________________

_______________________________________________
Rohc mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/rohc