00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef TEST_RCP_H
00022 #define TEST_RCP_H
00023
00024 #include <netdb.h>
00025 #include <sys/select.h>
00026 #include <sys/stat.h>
00027 #include <fcntl.h>
00028 #include <getopt.h>
00029 #include <strings.h>
00030 #include <pwd.h>
00031 #include <sys/stat.h>
00032 #include <signal.h>
00033 #include <dirent.h>
00034
00035 #include "vfer_tests.h"
00036 #include "vfer_api.h"
00037
00038 inline void vfer_rcp_print_stats(vfer_stats* stats);
00039
00040
00041 #define MAX_PATH 128
00042 #define MAX_USER 16
00043 #define MAX_HOST 64
00044 #define DEFAULT_PORT 2046
00045
00046
00047
00048
00049 typedef struct client_msg {
00050 char local_name [MAX_PATH];
00051 char remote_path[MAX_PATH];
00052 char user [MAX_USER];
00053 char from_remote;
00054 uint32_t file_size;
00055 } client_msg_t;
00056
00057 typedef enum status_t {RCP_READY=0,
00058 RCP_ENOENT,
00059 RCP_EOPEN,
00060 RCP_ENOFILE,
00061 RCP_EUSER,
00062 RCP_EOTHER
00063 } status_t;
00064
00065
00066
00067
00068 typedef struct server_msg {
00069 uint32_t status;
00070 uint32_t file_size;
00071 } server_msg_t;
00072
00073
00074
00075
00076
00077
00078 inline void vfer_rcp_print_stats(vfer_stats* stats) {
00079 double duration;
00080 struct timeval tv_end;
00081 uint32_t data_retransmitted;
00082
00083 if (stats->tv_end.tv_sec == 0 && stats->tv_end.tv_usec == 0) {
00084 GET_TIME_OF_DAY(&(tv_end));
00085 printf("-- real time stats --\n");
00086 } else {
00087 bcopy(&(stats->tv_end), &(tv_end), sizeof(struct timeval));
00088 }
00089
00090
00091
00092
00093 duration = (tv_end.tv_sec - stats->tv_start.tv_sec);
00094 duration += 0.000000001 * (tv_end.tv_usec - stats->tv_start.tv_usec);
00095
00096 data_retransmitted = (stats->data_bytes_sent - stats->data_bytes_sender_sent);
00097
00098 printf("\n");
00099 printf("VFER transfer statistics:\n");
00100 printf("\n");
00101 printf("Duration (s) conn %f\n", duration);
00102 printf("Avg rate (Mb/s) sending %-16.2f recving %.2f\n", ((stats->bytes_sent * 8.0) / (duration * 1000000)), ((stats->bytes_recvd * 8.0) / (duration * 1000000)));
00103 printf("Total (packets) sent %-14u recvd %u\n", stats->packets_sent, stats->packets_recvd);
00104 printf("Total (bytes) sent %-14u recvd %u\n", stats->bytes_sent, stats->bytes_recvd);
00105 printf("Total data (bytes) sent %-14u recvd %-16u retrans %u\n", stats->data_bytes_sent, stats->data_bytes_recvd, data_retransmitted);
00106 printf("Avg data rate (Mb/s) sending %-16.2f recving %-16.2f eff. sending %.2f\n",
00107 ((stats->data_bytes_sent * 8.0) / (duration * 1000000)),
00108 ((stats->data_bytes_recvd * 8.0) / (duration * 1000000)),
00109 (((stats->data_bytes_sent - data_retransmitted) * 8.0) / (duration * 1000000)));
00110 printf("RTT (us) avg %-16.2f max %-16.2f min %.2f\n", stats->avg_rtt, (double)(stats->max_rtt), (double)(stats->min_rtt));
00111 printf("\n");
00112 }
00113
00114
00115 #endif