← Back to team overview

rohc team mailing list archive

[Question #228535]: result of rohc_compress() is not correct

 

New question #228535 on rohc:
https://answers.launchpad.net/rohc/+question/228535

Hi Didier,

I'm trying to use rohc lib. The result is not right. I basically used the sample data provided by simple_rohc_program.c. Code snippet is as following, which shows what I did:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        int BUFFER_SIZE = 2048;
	unsigned char rohc_packet[BUFFER_SIZE]; /* the buffer that will contain
	                                           the resulting ROHC packet */
	int rohc_packet_len;                 /* the length (in bytes) of the
	                                           resulting ROHC packet */
        int ip_packet_len;
        unsigned char ip_packet[BUFFER_SIZE];
        char FAKE_PAYLOAD[] = "hello, ROHC world!";

	ip_packet[0] = 4 << 4; /* IP version 4 */
	ip_packet[0] |= 5; /* IHL: minimal IPv4 header length (in 32-bit words) */
	ip_packet[1] = 0; /* TOS */
	ip_packet_len = 5 * 4 + strlen(FAKE_PAYLOAD);
	ip_packet[2] = (htons(ip_packet_len) >> 8) & 0xff; /* Total Length */
	ip_packet[3] = htons(ip_packet_len) & 0xff;
	ip_packet[4] = 0; /* IP-ID */
	ip_packet[5] = 0;
	ip_packet[6] = 0; /* Fragment Offset and IP flags */
	ip_packet[7] = 0;
	ip_packet[8] = 1; /* TTL */
	ip_packet[9] = 134; /* Protocol: unassigned number */
	ip_packet[10] = 0xbe; /* fake Checksum */
	ip_packet[11] = 0xef;
	ip_packet[12] = 0x01; /* Source address */
	ip_packet[13] = 0x02;
	ip_packet[14] = 0x03;
	ip_packet[15] = 0x04;
	ip_packet[16] = 0x05; /* Destination address */
	ip_packet[17] = 0x06;
	ip_packet[18] = 0x07;
	ip_packet[19] = 0x08;

	/* copy the payload just after the IP header */
	memcpy(ip_packet + 5 * 4, FAKE_PAYLOAD, strlen(FAKE_PAYLOAD));

        compressor = rohc_alloc_compressor(ROHC_SMALL_CID_MAX, 0, 0, 0);

        rohc_activate_profile(compressor, ROHC_PROFILE_UNCOMPRESSED);
        rohc_activate_profile(compressor, ROHC_PROFILE_IP);

	int ret_size = rohc_compress(compressor,
	                     ip_packet, ip_packet_len,
	                     rohc_packet, BUFFER_SIZE);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I printed the result. And I saw nothing changed in the output rohc_packet except the size increased by 3 bytes.
rohc_packet[ 0 ] = 0xfc
rohc_packet[ 1 ] = 0x0
rohc_packet[ 2 ] = 0xb7
rohc_packet[ 3 ] = 0x45
rohc_packet[ 4 ] = 0x0
rohc_packet[ 5 ] = 0x26
rohc_packet[ 6 ] = 0x0
rohc_packet[ 7 ] = 0x0
rohc_packet[ 8 ] = 0x0
rohc_packet[ 9 ] = 0x0
rohc_packet[ 10 ] = 0x0
rohc_packet[ 11 ] = 0x1
rohc_packet[ 12 ] = 0x86
rohc_packet[ 13 ] = 0xbe
rohc_packet[ 14 ] = 0xef
rohc_packet[ 15 ] = 0x1
rohc_packet[ 16 ] = 0x2
rohc_packet[ 17 ] = 0x3
rohc_packet[ 18 ] = 0x4
rohc_packet[ 19 ] = 0x5
rohc_packet[ 20 ] = 0x6
rohc_packet[ 21 ] = 0x7
rohc_packet[ 22 ] = 0x8
rohc_packet[ 23 ] = 0x68
rohc_packet[ 24 ] = 0x65
rohc_packet[ 25 ] = 0x6c
rohc_packet[ 26 ] = 0x6c
rohc_packet[ 27 ] = 0x6f
rohc_packet[ 28 ] = 0x2c
rohc_packet[ 29 ] = 0x20
rohc_packet[ 30 ] = 0x52
rohc_packet[ 31 ] = 0x4f
rohc_packet[ 32 ] = 0x48
rohc_packet[ 33 ] = 0x43
rohc_packet[ 34 ] = 0x20
rohc_packet[ 35 ] = 0x77
rohc_packet[ 36 ] = 0x6f
rohc_packet[ 37 ] = 0x72
rohc_packet[ 38 ] = 0x6c
rohc_packet[ 39 ] = 0x64
rohc_packet[ 40 ] = 0x21
You can see from the 4th byte on, everything is exactly the same as those before rohc_compress() was called. Did I miss any step in order to use this function correctly?

Thanks in advance.

Regards,
Wei

-- 
You received this question notification because you are a member of ROHC
Team, which is an answer contact for rohc.