diff --git a/fec_manager.cpp b/fec_manager.cpp index c53bb4e..fb08282 100644 --- a/fec_manager.cpp +++ b/fec_manager.cpp @@ -20,7 +20,7 @@ fec_parameter_t g_fec_par; -int debug_fec=1; +int debug_fec=0; //int dynamic_update_fec=1; const int encode_fast_send=1; @@ -288,15 +288,18 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) if(fec_par.mode==0) { - actual_data_num=fec_par.get_tail().x; - actual_redundant_num=fec_par.get_tail().y; + + int tail_x=fec_par.get_tail().x; + int tail_y=fec_par.get_tail().y; + actual_data_num=tail_x; + actual_redundant_num=tail_y; if(short_packet_optimize) { - u32_t best_len=(blob_encode.get_shard_len(actual_data_num,0)+header_overhead)*(actual_data_num+actual_redundant_num); - int best_data_num=actual_data_num; - assert(actual_data_num<=fec_par.rs_cnt); - for(int i=1;i=1&&best_data_num<=fec_par.rs_cnt); actual_redundant_num=fec_par.rs_par[best_data_num-1].y; - - if(debug_fec) - mylog(log_debug,"actual_data_num=%d actual_redundant_num=%d len=%d\n",actual_data_num,actual_redundant_num,blob_encode.get_shard_len(actual_data_num,0)); - else - mylog(log_trace,"actual_data_num=%d actual_redundant_num=%d\n",actual_data_num,actual_redundant_num); } assert(blob_encode.output(actual_data_num,blob_output,fec_len)==0); + } else { @@ -337,7 +336,11 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) } } - mylog(log_trace,"%d %d %d\n",actual_data_num,actual_redundant_num,fec_len); + if(debug_fec) + mylog(log_debug,"x=%d y=%d len=%d\n",actual_data_num,actual_redundant_num,fec_len); + else + mylog(log_trace,"x=%d y=%d len=%d\n",actual_data_num,actual_redundant_num,fec_len); + //mylog(log_trace,"%d %d %d\n",actual_data_num,actual_redundant_num,fec_len); char *tmp_output_buf[max_fec_packet_num+5]={0}; for(int i=0;imax_fec_packet_num) + if(x<1||y<0||x+y>max_fec_packet_num) { mylog(log_warn,"invaild value x=%d y=%d\n",x,y); return -1; diff --git a/misc.cpp b/misc.cpp index 563efc8..5ce3caa 100644 --- a/misc.cpp +++ b/misc.cpp @@ -650,6 +650,8 @@ void process_arg(int argc, char *argv[]) {"queue-len", required_argument, 0,'q'}, {"fec", required_argument, 0,'f'}, {"jitter", required_argument, 0,'j'}, + {"header-overhead", required_argument, 0, 1}, + {"debug-fec", no_argument, 0, 1}, {"fifo", required_argument, 0, 1}, {"sub-net", required_argument, 0, 1}, {"tun-dev", required_argument, 0, 1}, @@ -660,6 +662,7 @@ void process_arg(int argc, char *argv[]) {NULL, 0, 0, 0} }; int option_index = 0; + assert(g_fec_par.rs_from_str((char *)"20:10")==0); for (i = 0; i < argc; i++) { @@ -939,6 +942,11 @@ void process_arg(int argc, char *argv[]) } g_fec_par.timeout*=1000; } + else if(strcmp(long_options[option_index].name,"debug-fec")==0) + { + debug_fec=1; + mylog(log_info,"debug_fec enabled\n"); + } else if(strcmp(long_options[option_index].name,"fifo")==0) { sscanf(optarg,"%s",fifo_file); @@ -969,6 +977,11 @@ void process_arg(int argc, char *argv[]) sscanf(optarg,"%d",&tun_mtu); mylog(log_warn,"changed tun_mtu,tun_mtu=%d\n",tun_mtu); } + else if(strcmp(long_options[option_index].name,"header-overhead")==0) + { + sscanf(optarg,"%d",&header_overhead); + mylog(log_warn,"changed header_overhead,header_overhead=%d\n",header_overhead); + } else if(strcmp(long_options[option_index].name,"disable-mssfix")==0) { mssfix=0;