rohc team mailing list archive
-
rohc team
-
Mailing list archive
-
Message #01977
Re: [Question #269935]: IP/UDP/RTP header compression issue
Question #269935 on rohc changed:
https://answers.launchpad.net/rohc/+question/269935
Status: Solved => Open
Kumar is still having a problem:
Hi,
I am getting one more issue from the decompressor side.
In the given below program , I am able to decompress the first inital
packets which are more or less larger than the actual packet . But I am
getting following decompression errors when compressing the 1 byte
headers. What could be the problem .Please help.
[d_generic.c:5567 build_uncomp_ipv4()] IP checksum = 0xa912
[d_rtp.c:1793 rtp_build_uncomp_rtp()] UDP + RTP length = 0x00b4
[d_generic.c:5789 check_uncomp_crc()] CRC-3 on uncompressed header = 0x5
[d_generic.c:5795 check_uncomp_crc()] CRC failure (computed = 0x05, packet = 0x03)
[d_generic.c:5450 build_uncomp_hdrs()] CRC detected a decompression failure for packet of type UO-0 in state Full Context and mode O-mode
[d_generic.c:1574 d_generic_decode()] CID 0: failed to build uncompressed headers (CRC failure)
[d_generic.c:5830 attempt_repair()] CID 0: CRC repair: feature disabled
[d_generic.c:1585 d_generic_decode()] CID 0: failed to build uncompressed headers (CRC failure)
[rohc_decomp.c:2062 d_decode_header()] failed to decompress packet (code = 4)
[rohc_decomp.c:1376 rohc_decompress3()] d_decode_header returned code 4
[rohc_decomp.c:1459 rohc_decompress3()] packet decompression failed because of malformed packet or bad CRC
[rohc_decomp.c:1476 rohc_decompress3()] feedback curr 100
[rohc_decomp.c:1478 rohc_decompress3()] feedback max 300
De compression of RTP packet failed: CRC failure (4)
The following is the Total program !!
#include "rohc_rtp.h"
int runcond=1;
void stophandler(int signum)
{
runcond=0;
}
static int gen_random_num(const struct rohc_comp *const comp,void *const user_context)
{
return rand();
}
static bool rtp_detect(const unsigned char *const ip,
const unsigned char *const udp,
const unsigned char *const payload,
const unsigned int payload_size,
void *const rtp_private)
{
uint16_t udp_dport;
bool is_rtp;
/* check UDP destination port */
memcpy(&udp_dport, udp + 2, sizeof(uint16_t));
if(ntohs(udp_dport) == 10042)
{
/* we think that the UDP packet is a RTP packet */
fprintf(stderr, "RTP packet detected (expected UDP port)\n");
is_rtp = true;
}
else
{
/* we think that the UDP packet is not a RTP packet */
fprintf(stderr, "RTP packet not detected (wrong UDP port)\n");
is_rtp = false;
}
return is_rtp;
}
static void print_rohc_traces(void *const priv_ctxt,
const rohc_trace_level_t level,
const rohc_trace_entity_t entity,
const int profile,
const char *const format,
...)
{
va_list args;
va_start(args, format);
vfprintf(stdout, format, args);
va_end(args);
}
int main()
{
char buffer[160]="",data[256]="";
int i;
FILE *infile;
char *ssrc;
uint32_t user_ts=0;
int clockslide=0;
int jitter=0;
mblk_t *m=NULL;
int count =0;
long int t_s = 0;
uint8_t rtp_buffer[BUFFER_SIZE]="",rtp_buffer_decomp[BUFFER_SIZE]="";
struct rohc_buf rtp_r_packet = rohc_buf_init_empty(rtp_buffer, BUFFER_SIZE);
struct rohc_buf rtp_r_packet_decomp = rohc_buf_init_empty(rtp_buffer_decomp, BUFFER_SIZE);
uint8_t rohc_buffer[BUFFER_SIZE]="";
struct rohc_buf rohc_packet = rohc_buf_init_empty(rohc_buffer, BUFFER_SIZE);
struct rohc_comp *compressor=NULL;
struct rohc_decomp *decompressor=NULL;
unsigned int *rtpheader = (unsigned int*)data;
RtpSession *rtp_session=NULL;
rohc_status_t rohc_status,rohc_decom_status;
rtp_header_t *rtp_h;
struct rohc_buf *rcvd_feedback = NULL;
struct rohc_buf *feedback_send = NULL;
printf("Testing RTP header compression\n");
/*create ROHC compressor */
compressor = rohc_comp_new2(ROHC_SMALL_CID, ROHC_SMALL_CID_MAX,gen_random_num, NULL);
if(compressor == NULL)
{
printf("Failed create the ROHC compressor\n");
return 1;
}
if(!rohc_comp_set_traces_cb2(compressor, print_rohc_traces, NULL))
{
printf("failed to set the callback for traces on compressor\n");
return 1;
}
decompressor = rohc_decomp_new2(ROHC_SMALL_CID,ROHC_SMALL_CID_MAX, ROHC_U_MODE);
if(decompressor == NULL)
{
printf("failed create the ROHC decompressor\n");
return 1;
}
/* Compressor profile creation */
if(!rohc_comp_enable_profile(compressor, ROHC_PROFILE_RTP))
{
printf("failed to enable the RTP profile\n");
/* cleanup compressor, then leave with an error code */
rohc_comp_free(compressor);
return 1;
}
if(!rohc_decomp_enable_profiles(decompressor,ROHC_PROFILE_UNCOMPRESSED,ROHC_PROFILE_RTP,ROHC_PROFILE_UDP,ROHC_PROFILE_ESP,ROHC_PROFILE_IP,ROHC_PROFILE_TCP,ROHC_PROFILE_UDPLITE,-1))
{
printf("failed to enable the Uncompressed profile\n");
rohc_decomp_free(decompressor);
return 1;
}
/*Prepare Fake RTP packet */
/* Create the actual packet that we will be sending */
ortp_init();
ortp_scheduler_init();
rtp_session=rtp_session_new(RTP_SESSION_SENDONLY);
rtp_session_set_scheduling_mode(rtp_session,1);
rtp_session_set_blocking_mode(rtp_session,1);
rtp_session_set_remote_addr(rtp_session,"192.168.1.36",5087);
rtp_session_set_payload_type(rtp_session,0);
ssrc=getenv("SSRC");
if (ssrc!=NULL) {
printf("using SSRC=%i.\n",atoi(ssrc));
rtp_session_set_ssrc(rtp_session,atoi(ssrc));
}
infile=fopen("prepaid-press1-listen-lastcall.wav","r");
if (infile==NULL) {
perror("Cannot open file");
return -1;
}
signal(SIGINT,stophandler);
printf("Reading DATA FROM FILE AND CREATING RTP STREAM\n");
while( ((i=fread(buffer,1,160,infile))>0) && (runcond) )
{
rohc_buf_reset(&rtp_r_packet);
rohc_buf_reset(&rohc_packet);
rohc_buf_reset(&rtp_r_packet_decomp);
m = rtp_session_create_packet_with_data(rtp_session,(char*)buffer,i,NULL);
count++;
((rtp_header_t*) m->b_rptr)->seq_number = htons(count) ;
t_s = t_s + 160;
(((rtp_header_t*) m->b_rptr)->timestamp) = htonl(t_s);
printf("SIZE OF ACTUAL RTP : < %d > , RTP HEADER LENGTH : < %d > , RTP PAYLOAD LENGTH : < %d >, RTP PACKET NO : < %d > , SN : < %d > \n", msgdsize(m),rtpheader_size(m),rtppayload_size(m),count,((rtp_header_t*) m->b_rptr)->seq_number);
rtp_r_packet.len = 5 * 4 + 8 + 12 + rtppayload_size(m);
/* IPv4 header */
rohc_buf_byte_at(rtp_r_packet, 0) = 4 << 4; /* IP version 4 */
rohc_buf_byte_at(rtp_r_packet, 0) |= 5; /* IHL: minimal IPv4 header length (in 32-bit words) */
rohc_buf_byte_at(rtp_r_packet, 1) = 0; /* TOS */
rohc_buf_byte_at(rtp_r_packet, 2) = (rtp_r_packet.len >> 8) & 0xff; /* Total Length */
rohc_buf_byte_at(rtp_r_packet, 3) = rtp_r_packet.len & 0xff;
rohc_buf_byte_at(rtp_r_packet, 4) = 0; /* IP-ID */
rohc_buf_byte_at(rtp_r_packet, 5) = 0;
rohc_buf_byte_at(rtp_r_packet, 6) = 0; /* Fragment Offset and IP flags */
rohc_buf_byte_at(rtp_r_packet, 7) = 0;
rohc_buf_byte_at(rtp_r_packet, 8) = 1; /* TTL */
rohc_buf_byte_at(rtp_r_packet, 9) = 17; /* Protocol: UDP */
rohc_buf_byte_at(rtp_r_packet, 10) = 0xa9; /* fake Checksum */
rohc_buf_byte_at(rtp_r_packet, 11) = 0xa0;
rohc_buf_byte_at(rtp_r_packet, 12) = 0x01; /* Source address */
rohc_buf_byte_at(rtp_r_packet, 13) = 0x02;
rohc_buf_byte_at(rtp_r_packet, 14) = 0x03;
rohc_buf_byte_at(rtp_r_packet, 15) = 0x04;
rohc_buf_byte_at(rtp_r_packet, 16) = 0x05; /* Destination address */
rohc_buf_byte_at(rtp_r_packet, 17) = 0x06;
rohc_buf_byte_at(rtp_r_packet, 18) = 0x07;
rohc_buf_byte_at(rtp_r_packet, 19) = 0x08;
/* UDP header */
rohc_buf_byte_at(rtp_r_packet, 20) = 0x42; /* source port */
rohc_buf_byte_at(rtp_r_packet, 21) = 0x42;
rohc_buf_byte_at(rtp_r_packet, 22) = 0x27; /* destination port = 10042 */
rohc_buf_byte_at(rtp_r_packet, 23) = 0x3a;
rohc_buf_byte_at(rtp_r_packet, 24) = 0x00; /* UDP length */
rohc_buf_byte_at(rtp_r_packet, 25) = 8 + 12 + rtppayload_size(m);
rohc_buf_byte_at(rtp_r_packet, 26) = 0x00; /* UDP checksum = 0 */
rohc_buf_byte_at(rtp_r_packet, 27) = 0x00;
/* RTP header */
memcpy(rohc_buf_data_at(rtp_r_packet, 28), (uint8_t
*)m->b_rptr,rtpheader_size(m));
/* copy the payload just after the IP/UDP/RTP headers */
memcpy(rohc_buf_data_at(rtp_r_packet, 40), (uint8_t
*)m->b_cont->b_rptr,rtppayload_size(m));
printf(" RTP detection Check uncompress \n");
if(!rohc_comp_set_rtp_detection_cb(compressor, rtp_detect, NULL))
{
printf("failed to set RTP detection callback\n");
return 1;
}
printf("IP/UDP/RTP PACKET SIZE BEFORE COMPRESSION : HEADER : < %d > , PAYLOAD : < %d > , TOTAL PACKET SIZE : < %d >\n" ,28 + rtpheader_size(m),rtppayload_size(m),28 + rtpheader_size(m) + rtppayload_size(m));
/*compress the packet */
rohc_status = rohc_compress4(compressor,rtp_r_packet, &rohc_packet);
if(rohc_status != ROHC_STATUS_OK)
{
printf("compression of fake RTP packet failed: %s (%d)\n",rohc_strerror(rohc_status), rohc_status);
rohc_comp_free(compressor);
fclose(infile);
rtp_session_destroy(rtp_session);
ortp_exit();
return 1;
}
/*Print the size of compressed one */
/*Decompress the packet */
printf("DE COMPRESSION STARATED !!!\n");
rohc_decom_status = rohc_decompress3(decompressor, rohc_packet, &rtp_r_packet_decomp,rcvd_feedback, feedback_send);
if(rohc_decom_status != ROHC_STATUS_OK){
printf("De compression of RTP packet failed: %s
(%d)\n",rohc_strerror(rohc_decom_status), rohc_decom_status);
}
memset(buffer,0,sizeof(buffer));
}
fclose(infile);
rtp_session_destroy(rtp_session);
ortp_exit();
// ortp_global_stats_display();
/* Free compressor */
if(compressor){
rohc_comp_free(compressor);
}
if(decompressor){
rohc_decomp_free(decompressor);
}
return 0;
}
--
You received this question notification because you are a member of ROHC
Team, which is an answer contact for rohc.