if ip-id is not increased by1 for each packet in IPV4, uor-2-ts ip-id is decoded wrong

Bug #1008329 reported by qingbaibai
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
rohc
Status tracked in Rohc-main
1.3.x
Invalid
Undecided
Didier Barvaux
1.4.x
Invalid
Undecided
Didier Barvaux
Rohc-main
Invalid
Undecided
Didier Barvaux

Bug Description

hello,

if ip-id is not increased by1 for each packet in IPV4, uor-2-ts ip-id is decoded wrong. For example, the ip-id of first packet is 65052 and the ip-id of next packet is 65054. The first packet is compressed as IR packet and the second packet is compressed as UOR-2-TS with extension3. When decoding UOR-2-TS with extension3, it uses "d_ip_id_decode()" function in ip_id.c. However, the ip-id is decoded as 65053.

Thank you.

Tags: library
Revision history for this message
qingbaibai (sunqing-cztz) wrote :

In RFC3095 page 75:
If value(RND) = 0, hdr(IP-ID) is compressed using Offset IP-ID
encoding (see section 4.5.5) using p = 0 and default-slope(IP-ID
offset) = 0.
If value(RND) = 1, IP-ID is the uncompressed hdr(IP-ID). IP-ID is
then passed as additional octets at the end of the compressed
header, after any extensions.

and page 85:
| IP-ID | 2 octets, if I = 1

Hence, in my opinion, if I=1, it corresponds to RND=1 and if I=0, it corresponds to RND=0.

Both in rohc-1.3.1 and rohc-1.3.2, in function"code_EXT3_packet()" in c_generic.c :
if(ip_get_version(ip) == IPV4)
  {
   if((nr_ip_id_bits > 0 && g_context->ip_flags.info.v4.rnd == 0) ||
      (g_context->ip_flags.info.v4.rnd_count < MAX_FO_COUNT &&
       g_context->ip_flags.info.v4.rnd == 0))
   {
    I = 1;
   }
   f_byte |= (I & 0x01) << 2;
  }
It sets I to 1 when rnd is 0.

Revision history for this message
Didier Barvaux (didier-barvaux) wrote :

> if ip-id is not increased by1 for each packet in IPV4, uor-2-ts ip-id is decoded wrong.
> For example, the ip-id of first packet is 65052 and the ip-id of next packet is 65054.
> The first packet is compressed as IR packet and the second packet is compressed
> as UOR-2-TS with extension3. When decoding UOR-2-TS with extension3, it uses
> "d_ip_id_decode()" function in ip_id.c. However, the ip-id is decoded as 65053.

You're right, there is a problem with non-regular IP-IDs and the UOR-2-TS packet. They are not compatible.

The UOR-2-TS packet type cannot be used if the IP-ID is not random (RND=1) and cannot be deduced from the reference IP-ID and the transmitted SN. In such cases, other packet types are selected. Look at the algorithm defined in the decide_SO_packet() function. In case of RTP profile with one unique IP header, the relevant part of the algorithm is as follow:

            packet = PACKET_UOR_2_TS; /* default packet */

            if(nr_sn_bits <= 4 && nr_ip_id_bits == 0 &&
               (nr_ts_bits == 0 || is_deductible(rtp_context->ts_sc)) &&
               rtp_context->tmp_variables.m_set == 0)
               packet = PACKET_UO_0;
            else if(nr_sn_bits <= 4 && nr_ip_id_bits == 0 && nr_ts_bits <= 5)
               packet = PACKET_UO_1_TS;
            else if(nr_sn_bits <= 4 && nr_ip_id_bits <= 5 &&
                    (nr_ts_bits == 0 || is_deductible(rtp_context->ts_sc)))
               packet = PACKET_UO_1_ID;
            else if(nr_ip_id_bits != 0 && nr_ts_bits <= MAX_BITS_IN_4_BYTE_SDVL)
               packet = PACKET_UOR_2_ID;

Revision history for this message
Didier Barvaux (didier-barvaux) wrote :

> In RFC3095 page 75:
> If value(RND) = 0, hdr(IP-ID) is compressed using Offset IP-ID
> encoding (see section 4.5.5) using p = 0 and default-slope(IP-ID
> offset) = 0.
> If value(RND) = 1, IP-ID is the uncompressed hdr(IP-ID). IP-ID is
> then passed as additional octets at the end of the compressed
> header, after any extensions.
>
> and page 85:
> | IP-ID | 2 octets, if I = 1
>
> Hence, in my opinion, if I=1, it corresponds to RND=1 and if I=0, it corresponds to RND=0.

I disagree with your analysis of the RFC. The IP-ID field that is "passed as additional octets at the end of the compressed header, after any extensions" is not the optional IP-ID in extension 3 (optional field present if I=1 as you mentioned). This is clear in the general format of the ROHC header described on page 77 of RFC 3095 [1].

Regards,
Didier

[1] http://tools.ietf.org/html/rfc3095#page-77

tags: added: library
Changed in rohc:
assignee: nobody → Didier Barvaux (didier-barvaux)
milestone: none → 1.5.0
milestone: 1.5.0 → 1.4.1
status: New → Invalid
milestone: 1.4.1 → 1.3.3
Revision history for this message
qingbaibai (sunqing-cztz) wrote :

hello,

“I disagree with your analysis of the RFC. The IP-ID field that is "passed as additional octets at the end of the compressed header, after any extensions" is not the optional IP-ID in extension 3 (optional field present if I=1 as you mentioned). This is clear in the general format of the ROHC header described on page 77 of RFC 3095 [1].”

I check the RFC 3095 and I was wrong. however,

"The UOR-2-TS packet type cannot be used if the IP-ID is not random (RND=1) and cannot be deduced from the reference IP-ID and the transmitted SN."
I think RND=1 means that ip-id is random. In RFC3095 page 82, UOR-2-TS cannot be used if there is no IPv4 header in the
context or if value(RND) and value(RND2) are both 1. It seems that you mean "The UOR-2-TS packet type can be used if the IP-ID is random (RND=1)"

Revision history for this message
Didier Barvaux (didier-barvaux) wrote :

> "The UOR-2-TS packet type cannot be used if the IP-ID is
> not random (RND=1) and cannot be deduced from the
> reference IP-ID and the transmitted SN."
> I think RND=1 means that ip-id is random. In RFC3095 page 82,
> UOR-2-TS cannot be used if there is no IPv4 header in the
> context or if value(RND) and value(RND2) are both 1. It seems
> that you mean "The UOR-2-TS packet type can be used if the
> IP-ID is random (RND=1)"

Yes, you're right. I made a mistake in my explanation :-/

Regards,
Didier

Revision history for this message
Didier Barvaux (didier-barvaux) wrote :

I forget to thank you for all the tests and code analysis you're making! Given enough eyeballs, all bugs are shallow :-)

Didier

Revision history for this message
qingbaibai (sunqing-cztz) wrote :
Download full text (10.9 KiB)

Thank you. ^.^.

You mentioned "The UOR-2-TS packet type cannot be deduced from the reference IP-ID and the transmitted SN." However, I find that ip-id of the UOR-2-TS packet type with extension3 is deduced from the reference IP-ID and the transmitted SN.

here is compression:
                <compression>
                        <log>
[../rohc2-1.3.1/src/comp/rohc_comp.c:192 rohc_compress()] size of IP packet = 20
0 bytes
[../rohc2-1.3.1/src/comp/rohc_comp.c:218 rohc_compress()] IP protocol = 17
[../rohc2-1.3.1/src/comp/rohc_comp.c:978 c_get_profile_from_packet()] UDP port =
 0x139c (5020)
[../rohc2-1.3.1/src/comp/rohc_comp.c:227 rohc_compress()] using profile 'RTP / C
ompressor' (0x0001)
[../rohc2-1.3.1/src/comp/rohc_comp.c:1198 c_find_context()] using context CID =
0
[../rohc2-1.3.1/src/comp/rohc_comp.c:283 rohc_compress()] compress the packet #2

[../rohc2-1.3.1/src/comp/c_generic.c:6529 check_ip_identification()] 1) old_id =
 0xfe1c new_id = 0xfe1e
[../rohc2-1.3.1/src/comp/c_generic.c:6565 check_ip_identification()] NBO = 1, RN
D = 0
[../rohc2-1.3.1/src/common/ts_sc_comp.c:89 c_add_ts()] Timestamp = 3016314151
[../rohc2-1.3.1/src/common/ts_sc_comp.c:109 c_add_ts()] state INIT_STRIDE
[../rohc2-1.3.1/src/common/ts_sc_comp.c:114 c_add_ts()] ts_stride = 160
[../rohc2-1.3.1/src/common/ts_sc_comp.c:118 c_add_ts()] ts_offset = 3016314151 m
odulo 160 = 71
[../rohc2-1.3.1/src/common/ts_sc_comp.c:121 c_add_ts()] ts_scaled = (3016314151
- 71) / 160 = 18851963
[../rohc2-1.3.1/src/comp/c_generic.c:837 c_generic_encode()] SN = 197
[../rohc2-1.3.1/src/comp/c_generic.c:6325 changed_dynamic_both_hdr()] check for
changed fields in the outer IP header
[../rohc2-1.3.1/src/comp/c_generic.c:860 c_generic_encode()] send_static = 0, se
nd_dynamic = 0
[../rohc2-1.3.1/src/comp/c_generic.c:669 change_state()] change from state 1 to
state 3
[../rohc2-1.3.1/src/comp/c_generic.c:868 c_generic_encode()] ip_id = 0xfe1e, con
text_sn = 197
[../rohc2-1.3.1/src/comp/c_generic.c:2351 update_variables()] ip_id delta = 0xfd
59 / 64857
[../rohc2-1.3.1/src/comp/c_generic.c:2352 update_variables()] ip_id bits = -1
[../rohc2-1.3.1/src/comp/c_generic.c:2362 update_variables()] sn bits=-1
[../rohc2-1.3.1/src/comp/c_generic.c:2725 decide_packet()] SO state
[../rohc2-1.3.1/src/comp/c_generic.c:2564 decide_SO_packet()] nr_ip_bits=-1 nr_s
n_bits=-1 nr_of_ip_hdr=1 rnd=0
[../rohc2-1.3.1/src/comp/c_generic.c:4096 code_UO2_packet()] code UOR-2-TS packe
t (CID = 0)
[../rohc-1.3.1final/src/comp/cid.c:74 code_cid_values()] CID = 0 => no add-CID
[../rohc2-1.3.1/src/comp/c_generic.c:4701 code_UOR2_TS_bytes()] code UOR-2-TS pa
cket with extension 3
[../rohc2-1.3.1/src/comp/c_generic.c:4714 code_UOR2_TS_bytes()] TS to send = 0xb
3c94d27
[../rohc2-1.3.1/src/comp/c_generic.c:4716 code_UOR2_TS_bytes()] bits of TS = 32
(3 in header, 29 in EXT3)
[../rohc2-1.3.1/src/comp/c_generic.c:4732 code_UOR2_TS_bytes()] bits of TS in 1s
t byte = 0x5 (mask = 0x7)
[../rohc2-1.3.1/src/comp/c_generic.c:4171 code_UO2_packet()] f_byte = 0xc5
[../rohc2-1.3.1/src/comp/c_generic.c:4175 code_UO2_packet()] s_byte = 0x85
[../rohc2-1.3.1/src/comp/c_generic.c:4178 code_UO2_packet()] t_byte = 0xfa
[../rohc2-1.3.1/src/comp/c_gen...

Revision history for this message
Didier Barvaux (didier-barvaux) wrote :

When I said:
    The UOR-2-TS packet type cannot be used if the IP-ID is
    random* (RND=1) and cannot be deduced from the
    reference IP-ID and the transmitted SN.

one should read:
    The UOR-2-TS packet type cannot be used if:
       1/ the IP-ID is random* (RND=1),
       2/ the IP-ID cannot be deduced from the reference
            IP-ID and the transmitted SN.

To summarize, it means that UOR-2-TS cannot be used if there is at least 1 IP-ID bit to transmit in the ROHC packet.

* I fixed my previous mistake to avoid confusion again.

Regards,
Didier

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.