| | |
| | | #include "usg_common.h" |
| | | #include <getopt.h> |
| | | |
| | | #define SCALE 100000 |
| | | |
| | | typedef struct Targ { |
| | | char *nodelist; |
| | | int id; |
| | |
| | | void usage(char *name); |
| | | int parse_node_list(char *str, net_node_t *node_arr_addr[]) ; |
| | | void print_node_list(net_node_t *node_arr, int len); |
| | | |
| | | |
| | | |
| | | void * client; |
| | | |
| | | void start_net_proxy(int port) { |
| | | printf("Start net proxy\n"); |
| | |
| | | } |
| | | |
| | | void start_net_client(char *sendlist, char*publist ){ |
| | | void * client = net_mod_socket_open(); |
| | | client = net_mod_socket_open(); |
| | | char content[MAXLINE]; |
| | | char action[512]; |
| | | char topic[512]; |
| | |
| | | int rv; |
| | | int remote_port; |
| | | while ( (rv = net_mod_socket_recvfrom(socket, &recvbuf, &size, &remote_port) ) == 0) { |
| | | printf( "server: RECEIVED REQUEST FROM PORT %d NAME %s\n", remote_port, recvbuf); |
| | | // printf( "server: RECEIVED REQUEST FROM PORT %d NAME %s\n", remote_port, recvbuf); |
| | | sprintf(sendbuf, "RECEIVED PORT %d NAME %s", remote_port, recvbuf); |
| | | net_mod_socket_sendto(socket, sendbuf, strlen(sendbuf) + 1, remote_port); |
| | | free(recvbuf); |
| | |
| | | |
| | | |
| | | |
| | | #define SCALE 100000 |
| | | |
| | | |
| | | void *_run_sendandrecv_(void *arg) { |
| | | Targ *targ = (Targ *)arg; |
| | |
| | | int node_arr_size = parse_node_list(targ->nodelist, &node_arr); |
| | | |
| | | |
| | | void * client = net_mod_socket_open(); |
| | | |
| | | char filename[512]; |
| | | sprintf(filename, "test%d.tmp", targ->id); |
| | | FILE *fp = NULL; |
| | |
| | | total += n; |
| | | } |
| | | fclose(fp); |
| | | net_mod_socket_close(client); |
| | | |
| | | return (void *)total; |
| | | } |
| | | |
| | |
| | | struct timeval start, end; |
| | | long total = 0; |
| | | |
| | | client = net_mod_socket_open(); |
| | | printf("开始测试...\n"); |
| | | gettimeofday(&start, NULL); |
| | | for (i = 0; i < processors; i++) { |
| | |
| | | long diffusec = difftime - diffsec*1000000; |
| | | fprintf(stderr,"发送数目: %ld, 用时: (%ld sec %ld usec), 平均: %f\n", total, diffsec, diffusec, difftime/total ); |
| | | // fflush(stdout); |
| | | net_mod_socket_close(client); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | char *topic = "news"; |
| | | |
| | | void * client = net_mod_socket_open(); |
| | | |
| | | |
| | | // char filename[512]; |
| | | // sprintf(filename, "test%d.tmp", targ->id); |
| | |
| | | total += n; |
| | | } |
| | | // fclose(fp); |
| | | net_mod_socket_close(client); |
| | | |
| | | return (void *)total; |
| | | } |
| | | |
| | |
| | | char sendbuf[512]; |
| | | struct timeval start, end; |
| | | long total = 0; |
| | | client = net_mod_socket_open(); |
| | | |
| | | printf("开始测试...\n"); |
| | | gettimeofday(&start, NULL); |
| | |
| | | long diffusec = difftime - diffsec*1000000; |
| | | fprintf(stderr,"发送数目: %ld, 用时: (%ld sec %ld usec), 平均: %f\n", total, diffsec, diffusec, difftime/total ); |
| | | // fflush(stdout); |
| | | net_mod_socket_close(client); |
| | | } |
| | | |
| | | |
| | |
| | | net_node_t *node_arr = (net_node_t *) calloc(entry_arr_len, sizeof(net_node_t)); |
| | | for(i = 0; i < entry_arr_len; i++) { |
| | | property_arr_len = str_split(entry_arr[i], ":", &property_arr); |
| | | printf("%s, %s, %s\n", property_arr[0], property_arr[1], property_arr[2]); |
| | | // printf("%s, %s, %s\n", property_arr[0], property_arr[1], property_arr[2]); |
| | | node_arr[i] = {trim(property_arr[0], 0), atoi(property_arr[1]), atoi(property_arr[2])}; |
| | | free(entry_arr[i]); |
| | | free(property_arr[1]); |