From 3d7391b2faaf0434ef1a0d370d834f0df3342516 Mon Sep 17 00:00:00 2001 From: wangyu- Date: Sun, 15 Oct 2017 12:03:10 -0500 Subject: [PATCH] before add debug code --- fec_manager.cpp | 52 ++++++++++++++++++++++++------------------------- fec_manager.h | 35 ++++++++++++++++++--------------- main.cpp | 22 ++++++++++++++------- 3 files changed, 60 insertions(+), 49 deletions(-) diff --git a/fec_manager.cpp b/fec_manager.cpp index d00ae46..b41cb77 100644 --- a/fec_manager.cpp +++ b/fec_manager.cpp @@ -43,7 +43,7 @@ int blob_encode_t::input(char *s,int len) assert(current_len+len+sizeof(u16_t) <=max_fec_packet_num*buf_len); assert(len<=65535&&len>=0); counter++; - assert(counter<=max_normal_packet_num); + assert(counter<=max_fec_pending_packet_num); write_u16(buf+current_len,len); current_len+=sizeof(u16_t); memcpy(buf+current_len,s,len); @@ -95,7 +95,7 @@ int blob_decode_t::output(int &n,char ** &s_arr,int *&len_arr) if(parser_pos+(int)sizeof(u32_t)>current_len) return -1; n=(int)read_u32(buf+parser_pos); - if(n>max_normal_packet_num) {mylog(log_info,"failed 1\n");return -1;} + if(n>max_fec_pending_packet_num) {mylog(log_info,"failed 1\n");return -1;} s_arr=s_buf; len_arr=len_buf; @@ -172,11 +172,11 @@ int fec_encode_manager_t::append(char *s,int len/*,int &is_first_packet*/) { mylog(log_trace,"counter=%d\n",counter); assert(len<=65535&&len>=0); - char * p=buf[counter]+sizeof(u32_t)+4*sizeof(char); + char * p=input_buf[counter]+sizeof(u32_t)+4*sizeof(char); write_u16(p,(u16_t)((u32_t)len)); p+=sizeof(u16_t); memcpy(p,s,len);//remember to change this,if protocol is modified - buf_s_len[counter]=len+sizeof(u16_t); + input_len[counter]=len+sizeof(u16_t); } else { @@ -247,8 +247,8 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) for(int i=0;i=0); - if(buf_s_len[i]>fec_len) fec_len=buf_s_len[i]; + assert(input_len[i]>=0); + if(input_len[i]>fec_len) fec_len=input_len[i]; } } @@ -259,43 +259,43 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) { int tmp_idx=0; - write_u32(buf[i] + tmp_idx, seq); + write_u32(input_buf[i] + tmp_idx, seq); tmp_idx += sizeof(u32_t); - buf[i][tmp_idx++] = (unsigned char) type; + input_buf[i][tmp_idx++] = (unsigned char) type; if (type == 1 && i < actual_data_num) { - buf[i][tmp_idx++] = (unsigned char) 0; - buf[i][tmp_idx++] = (unsigned char) 0; + input_buf[i][tmp_idx++] = (unsigned char) 0; + input_buf[i][tmp_idx++] = (unsigned char) 0; } else { - buf[i][tmp_idx++] = (unsigned char) actual_data_num; - buf[i][tmp_idx++] = (unsigned char) actual_redundant_num; + input_buf[i][tmp_idx++] = (unsigned char) actual_data_num; + input_buf[i][tmp_idx++] = (unsigned char) actual_redundant_num; } - buf[i][tmp_idx++] = (unsigned char) i; + input_buf[i][tmp_idx++] = (unsigned char) i; - tmp_output_buf[i]=buf[i]+tmp_idx; //////caution ,trick here. + tmp_output_buf[i]=input_buf[i]+tmp_idx; //////caution ,trick here. if(type==0) { output_len[i]=tmp_idx+fec_len; if(i mp; blob_decode_t blob_decode; @@ -156,8 +159,8 @@ class fec_decode_manager_t int output_n; char ** output_s_arr; int * output_len_arr; - char *output_s_arr_buf[max_normal_packet_num+100]; - int output_len_arr_buf[max_normal_packet_num+100]; + char *output_s_arr_buf[max_fec_pending_packet_num+100]; + int output_len_arr_buf[max_fec_pending_packet_num+100]; int ready_for_output; public: fec_decode_manager_t(); diff --git a/main.cpp b/main.cpp index c18782d..8681d95 100644 --- a/main.cpp +++ b/main.cpp @@ -28,9 +28,10 @@ int jitter_max=0; int mtu_warn=1350; int disable_mtu_warn=0; +int disable_fec=1; int fec_data_num=20; -int fec_redundant_num=8; +int fec_redundant_num=10; int fec_mtu=1000; int fec_pending_num=30; int fec_pending_time=10000; @@ -125,13 +126,14 @@ int delay_send(my_time_t delay,const dest_t &dest,char *data,int len) } int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,char **&out_arr,int *&out_len,int *&out_delay) { + static int out_delay_buf[max_fec_packet_num+100]={0}; //static int out_len_buf[max_fec_packet_num+100]={0}; static int counter=0; out_delay=out_delay_buf; //out_len=out_len_buf; - if(0) + if(disable_fec) { if(data==0) return 0; out_n=1; @@ -158,10 +160,14 @@ int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,ch conn_info.fec_encode_manager.output(out_n,out_arr,out_len); - + for(int i=0;i",n); /* for(int i=0;i