more options

This commit is contained in:
wangyu 2017-08-09 17:15:35 +08:00
parent f41494bd9c
commit d012aad859
4 changed files with 448 additions and 493 deletions

View File

@ -201,9 +201,9 @@ unsigned short csum(const unsigned short *ptr,int nbytes) {
return(answer); return(answer);
} }
int set_buf_size(int fd) int set_buf_size(int fd,int size)
{ {
int socket_buf_size=1024*1024; //int socket_buf_size=1024*1024;
if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &socket_buf_size, sizeof(socket_buf_size))<0) if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &socket_buf_size, sizeof(socket_buf_size))<0)
//if(setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0) //if(setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
{ {

View File

@ -49,6 +49,7 @@
#include<unordered_map> #include<unordered_map>
#include<unordered_set> #include<unordered_set>
#include<list>
using namespace std; using namespace std;
@ -61,10 +62,19 @@ typedef int i32_t;
const int max_data_len=1600; const int max_data_len=1600;
const int buf_len=max_data_len+200; const int buf_len=max_data_len+200;
const u32_t conv_clear_interval=200;
const u32_t timer_interval=400;
const int conv_clear_ratio=40;
const int conv_clear_min=5;
const u32_t conv_timeout=20000;
const int max_conv_num=10000;
/*
const u32_t max_handshake_conn_num=10000; const u32_t max_handshake_conn_num=10000;
const u32_t max_ready_conn_num=1000; const u32_t max_ready_conn_num=1000;
//const u32_t anti_replay_window_size=1000; //const u32_t anti_replay_window_size=1000;
const int max_conv_num=10000;
const u32_t client_handshake_timeout=5000; const u32_t client_handshake_timeout=5000;
const u32_t client_retry_interval=1000; const u32_t client_retry_interval=1000;
@ -76,7 +86,7 @@ const int conn_clear_ratio=10;
const int conv_clear_min=5; const int conv_clear_min=5;
const int conn_clear_min=1; const int conn_clear_min=1;
const u32_t conv_clear_interval=1000;
const u32_t conn_clear_interval=1000; const u32_t conn_clear_interval=1000;
@ -94,6 +104,7 @@ const u32_t client_conn_uplink_timeout=client_conn_timeout+2000;
//const uint32_t server_conn_timeout=conv_timeout+60000;//this should be 60s+ longer than conv_timeout,so that conv_manager can destruct convs gradually,to avoid latency glicth //const uint32_t server_conn_timeout=conv_timeout+60000;//this should be 60s+ longer than conv_timeout,so that conv_manager can destruct convs gradually,to avoid latency glicth
const u32_t server_conn_timeout=conv_timeout+60000;//for test const u32_t server_conn_timeout=conv_timeout+60000;//for test
*/
extern int about_to_exit; extern int about_to_exit;
@ -132,7 +143,7 @@ u64_t hton64(u64_t a);
bool larger_than_u16(uint16_t a,uint16_t b); bool larger_than_u16(uint16_t a,uint16_t b);
bool larger_than_u32(u32_t a,u32_t b); bool larger_than_u32(u32_t a,u32_t b);
void setnonblocking(int sock); void setnonblocking(int sock);
int set_buf_size(int fd); int set_buf_size(int fd,int size=socket_buf_size);
unsigned short csum(const unsigned short *ptr,int nbytes); unsigned short csum(const unsigned short *ptr,int nbytes);

902
main.cpp

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,18 @@
ccarm=mips-openwrt-linux-g++ cross_cc=mips-openwrt-linux-g++
FLAGS=-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter FLAGS=-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -ggdb
FLAGS2= -O3 FLAGS2= -O3
all: all:
g++ main.cpp common.cpp log.cpp -I. -o dupd -static -lrt -std=c++11 ${FLAGS} ${FLAGS2} g++ main.cpp common.cpp log.cpp -I. -o speeder -static -lrt -std=c++11 ${FLAGS} ${FLAGS2}
release: release:
g++ main.cpp -o dupd_amd64 -static -lrt ${FLAGS} ${FLAGS2} g++ main.cpp common.cpp log.cpp -I. -o speeder_amd64 -static -lrt -std=c++11 ${FLAGS} ${FLAGS2}
g++ main.cpp -o dupd_x86 -static -lrt -m32 ${FLAGS} ${FLAGS2} g++ -m32 main.cpp common.cpp log.cpp -I. -o speeder_x86 -static -lrt -std=c++11 ${FLAGS} ${FLAGS2}
${ccarm} main.cpp -o dupd_ar71xx -lrt ${cross_cc} main.cpp common.cpp log.cpp -I. -o speeder_ar71xx -lrt -std=c++11 ${FLAGS} ${FLAGS2}
tar -zcvf udp_speeder_binaries.tar.gz speeder_amd64 speeder_x86 speeder_ar71xx
cross:
${cross_cc} main.cpp common.cpp log.cpp -I. -o speeder_cross -lrt -std=c++11 ${FLAGS} ${FLAGS2}
debug: debug:
g++ main.cpp common.cpp log.cpp -I. -o dupd -static -lrt -std=c++11 ${FLAGS} -Wformat-nonliteral -D MY_DEBUG g++ main.cpp common.cpp log.cpp -I. -o speeder -static -lrt -std=c++11 ${FLAGS} -Wformat-nonliteral -D MY_DEBUG
#g++ forward.cpp aes.c -o forward -static #g++ forward.cpp aes.c -o forward -static
# ${ccarm} forward.cpp aes.c -o forwardarm -static -lgcc_eh # ${ccarm} forward.cpp aes.c -o forwardarm -static -lgcc_eh