diff --git a/README.md b/README.md index e25267b..c02cc79 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ See [UDPspeeder + openvpn config guide](https://github.com/wangyu-/UDPspeeder/wi ### Full Options ``` UDPspeeder V2 -git version: 6f55b8a2fc build date: Nov 19 2017 06:11:23 +git version: 3e248b414c build date: Aug 5 2018 21:59:52 repository: https://github.com/wangyu-/UDPspeeder usage: @@ -110,6 +110,8 @@ advanced options: do not use if you dont know what it means. -i,--interval scatter each fec group to a interval of ms, to protect burst packet loss. default value: 0. do not use if you dont know what it means. + -f,--fec x1:y1,x2:y2,.. similiar to -f/--fec above,fine-grained fec parameters,may help save bandwidth. + example: "-f 1:3,2:4,10:6,20:10". check repo for details --random-drop simulate packet loss, unit: 0.01%. default value: 0. --disable-obscure disable obscure, to save a bit bandwidth and cpu. developer options: diff --git a/doc/README.zh-cn.md b/doc/README.zh-cn.md index 623eb36..dd0f3ac 100644 --- a/doc/README.zh-cn.md +++ b/doc/README.zh-cn.md @@ -106,7 +106,7 @@ https://github.com/wangyu-/udp2raw-tunnel ### 命令选项 ``` UDPspeeder V2 -git version: 6f55b8a2fc build date: Nov 19 2017 06:11:23 +git version: 3e248b414c build date: Aug 5 2018 21:59:52 repository: https://github.com/wangyu-/UDPspeeder usage: @@ -131,6 +131,8 @@ advanced options: do not use if you dont know what it means. -i,--interval scatter each fec group to a interval of ms, to protect burst packet loss. default value: 0. do not use if you dont know what it means. + -f,--fec x1:y1,x2:y2,.. similiar to -f/--fec above,fine-grained fec parameters,may help save bandwidth. + example: "-f 1:3,2:4,10:6,20:10". check repo for details --random-drop simulate packet loss, unit: 0.01%. default value: 0. --disable-obscure disable obscure, to save a bit bandwidth and cpu. developer options: @@ -151,8 +153,6 @@ log and help options: --disable-color disable log color -h,--help print this help message - - ``` ### 包发送选项,两端设置可以不同。 只影响本地包发送。 ##### `-f` 选项 diff --git a/fec_manager.h b/fec_manager.h index 41aaa5a..3f191e6 100644 --- a/fec_manager.h +++ b/fec_manager.h @@ -35,12 +35,16 @@ struct fec_parameter_t { unsigned char x;//AKA fec_data_num (x should be same as +1 at the moment) unsigned char y;//fec_redundant_num - }rs_par[255+10]; + }rs_par[max_fec_packet_num+10]; int rs_from_str(char * s)//todo inefficient { vector str_vec=string_to_vec(s,","); - if(str_vec.size()<1) return -1; + if(str_vec.size()<1) + { + mylog(log_warn,"failed to parse [%s]\n",s); + return -1; + } vector par_vec; for(int i=0;i<(int)str_vec.size();i++) { @@ -54,7 +58,7 @@ struct fec_parameter_t } if(x<1||y<0||x+y>max_fec_packet_num) { - mylog(log_warn,"invaild value x=%d y=%d\n",x,y); + mylog(log_warn,"invaild value x=%d y=%d, x should >=1, y should >=0, x +y should <%d\n",x,y,max_fec_packet_num); return -1; } tmp_par.x=x; @@ -63,6 +67,7 @@ struct fec_parameter_t } assert(par_vec.size()==str_vec.size()); + int found_problem=0; for(int i=1;i<(int)par_vec.size();i++) { if(par_vec[i].x<=par_vec[i-1].x) @@ -80,9 +85,18 @@ struct fec_parameter_t if(pre_ratiomax_fec_packet_num) { in_y=max_fec_packet_num-in_x; assert(in_y>=0&&in_y<=max_fec_packet_num); } + rs_par[in_x-1].x=in_x; rs_par[in_x-1].y=in_y; } @@ -130,7 +155,9 @@ struct fec_parameter_t assert(rs_cnt>=1); for(int i=0;i ",int(rs_par[i].x),int(rs_par[i].y)); + sprintf(tmp_buf,"%d:%d",int(rs_par[i].x),int(rs_par[i].y)); + if(i!=0) + tmp_string+=","; tmp_string+=tmp_buf; } strcpy(res,tmp_string.c_str()); diff --git a/main.cpp b/main.cpp index 3c97180..55315d4 100644 --- a/main.cpp +++ b/main.cpp @@ -44,13 +44,16 @@ static void print_help() printf(" default value: 1250. you typically shouldnt change this value.\n"); printf(" -q,--queue-len fec queue len, only for mode 0, fec will be performed immediately after queue is full.\n"); printf(" default value: 200. \n"); + printf(" -j,--jitter simulated jitter. randomly delay first packet for 0~ ms, default value: 0.\n"); printf(" do not use if you dont know what it means.\n"); printf(" -i,--interval scatter each fec group to a interval of ms, to protect burst packet loss.\n"); printf(" default value: 0. do not use if you dont know what it means.\n"); + printf(" -f,--fec x1:y1,x2:y2,.. similiar to -f/--fec above,fine-grained fec parameters,may help save bandwidth.\n"); + printf(" example: \"-f 1:3,2:4,10:6,20:10\". check repo for details\n"); printf(" --random-drop simulate packet loss, unit: 0.01%%. default value: 0.\n"); printf(" --disable-obscure disable obscure, to save a bit bandwidth and cpu.\n"); -// printf(" --disable-xor disable xor\n"); + //printf(" --disable-xor disable xor\n"); printf("developer options:\n"); printf(" --fifo use a fifo(named pipe) for sending commands to the running program, so that you\n");