From 707cc565628e4a04f3c9cb15354ce0a4288acfe5 Mon Sep 17 00:00:00 2001 From: wangyu- Date: Fri, 6 Oct 2017 14:19:02 -0500 Subject: [PATCH] it works now --- fec_manager.cpp | 12 ++++- fec_manager.h | 1 + main.cpp | 118 +++++++++++++++++++++++++++++++++++------------- 3 files changed, 98 insertions(+), 33 deletions(-) diff --git a/fec_manager.cpp b/fec_manager.cpp index 2515c65..dc47aad 100644 --- a/fec_manager.cpp +++ b/fec_manager.cpp @@ -136,6 +136,7 @@ int fec_encode_manager_t::re_init(int data_num,int redundant_num,int mtu,int pen fec_redundant_num=redundant_num; fec_mtu=mtu; fec_pending_num=pending_num; + fec_pending_time=pending_time; counter=0; blob_encode.clear(); @@ -180,6 +181,7 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) output_len=blob_len+sizeof(u32_t)+4*sizeof(char);/////remember to change this 4,if modified the protocol rs_encode2(fec_data_num,fec_data_num+fec_redundant_num,output_buf,blob_len); + for(int i=0;i=mtu_warn) - { - mylog(log_warn,"huge packet,data len=%d (>=%d).strongly suggested to set a smaller mtu at upper level,to get rid of this warn\n ",data_len,mtu_warn); - } - mylog(log_trace,"Received packet from %s:%d,len: %d\n", inet_ntoa(udp_new_addr_in.sin_addr), - ntohs(udp_new_addr_in.sin_port),data_len); - ip_port_t ip_port; - ip_port.ip=udp_new_addr_in.sin_addr.s_addr; - ip_port.port=ntohs(udp_new_addr_in.sin_port); - u64_t u64=ip_port.to_u64(); u32_t conv; + int out_n;char **out_arr;int *out_len;int *out_delay; + dest_t dest; + dest.type=type_fd64; + dest.inner.fd64=remote_fd64; + + if(events[idx].data.u64 == conn_info.fec_encode_manager.get_timer_fd64()) + { + mylog(log_info,"timer!!!\n"); + uint64_t value; + if(!fd_manager.exist(fd64)) //fd64 has been closed + { + continue; + } + if(read(fd_manager.to_fd(fd64), &value, 8)!=8) + { + mylog(log_info,"unknow!!!\n"); + continue; + } + if(value==0) + { + mylog(log_info,"cancel!!!\n"); + continue; + } + assert(value==1); + from_normal_to_fec(conn_info,0,0,out_n,out_arr,out_len,out_delay); + //from_normal_to_fec(conn_info,0,0,out_n,out_arr,out_len,out_delay); + } + else + { + struct sockaddr_in udp_new_addr_in={0}; + socklen_t udp_new_addr_len = sizeof(sockaddr_in); + if ((data_len = recvfrom(local_listen_fd, data, max_data_len, 0, + (struct sockaddr *) &udp_new_addr_in, &udp_new_addr_len)) == -1) { + mylog(log_error,"recv_from error,this shouldnt happen at client\n"); + myexit(1); + }; + + if(data_len>=mtu_warn) + { + mylog(log_warn,"huge packet,data len=%d (>=%d).strongly suggested to set a smaller mtu at upper level,to get rid of this warn\n ",data_len,mtu_warn); + } + mylog(log_trace,"Received packet from %s:%d,len: %d\n", inet_ntoa(udp_new_addr_in.sin_addr), + ntohs(udp_new_addr_in.sin_port),data_len); + ip_port.ip=udp_new_addr_in.sin_addr.s_addr; + ip_port.port=ntohs(udp_new_addr_in.sin_port); + + u64_t u64=ip_port.to_u64(); + if(!conn_info.conv_manager.is_u64_used(u64)) { @@ -320,19 +354,16 @@ int client_event_loop() conv=conn_info.conv_manager.find_conv_by_u64(u64); } conn_info.conv_manager.update_active_time(conv); - - - dest_t dest; - dest.type=type_fd64; - dest.inner.fd64=remote_fd64; - char * new_data; int new_len; put_conv(conv,data,data_len,new_data,new_len); - int out_n;char **out_arr;int *out_len;int *out_delay; + //dest.conv=conv; from_normal_to_fec(conn_info,new_data,new_len,out_n,out_arr,out_len,out_delay); + + } + for(int i=0;i=%d).strongly suggested to set a smaller mtu at upper level,to get rid of this warn\n ",data_len,mtu_warn); } - dest_t dest; - dest.type=type_ip_port; - //dest.conv=conv; - dest.inner.ip_port=ip_port; + char * new_data; int new_len; put_conv(conv,data,data_len,new_data,new_len); - int out_n;char **out_arr;int *out_len;int *out_delay; + from_normal_to_fec(conn_info,new_data,new_len,out_n,out_arr,out_len,out_delay); + } + for(int i=0;i