static public function DecodeLength($msg, &$pos)
    {
        $multiplier = 1;
        $value = 0 ;
        do{
            $digit = ord($msg[$pos]);
            $value += ($digit & 0x7F) * $multiplier;
            $multiplier *= 0x80;
            $pos++;
        } while (($digit & 0x80) != 0);

        return $value;
    }