src/vsl_rcp.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2005, 2006, Internet2
00003  * Legal conditions are in file LICENSE
00004  * (MD5 = c434f2e53b8089d8b4d0172c7ce07360).
00005  */
00006 
00007 /**
00008  * @file   vsl_rcp.h
00009  * @author Nikolaus Rath
00010  * @brief  Headers for VSL file transfer tools
00011  */
00012 
00013 #ifndef VSL_RCP_H
00014 #define VSL_RCP_H
00015 
00016 #include "vsl_api.h"
00017 
00018 /* constants controlling the max buffer sizes for paths, usernames, etc */
00019 #define MAX_PATH        128
00020 #define MAX_USER        16
00021 #define MAX_HOST        64
00022 
00023 //! default file for server debug output
00024 #define DEBUGLOG        "./vsl_rcp.log"
00025 
00026 //! parameter that indicates when vsl_rcpd is called from vsl_rcp
00027 #define MAGIC_PARM      "234958oehtedu"
00028 
00029 //! structure used as a client message from the client rcp program
00030 typedef struct vsl_client_msg {
00031     char local_name[MAX_PATH];  /* filename of the file on the local system */
00032     char remote_path[MAX_PATH]; /* path on the remote host specified on the cmd line */
00033     char from_remote;           /* 0: yes (get remote file to local sys), 1: no (put local file to remote sys)*/
00034     uint32_t file_size;         /* file size to transfer if from_remote = 1, ow. set to 0 */
00035 } vsl_client_msg_t;
00036 
00037 
00038 //! server return codes
00039 typedef enum status_t {RCP_READY=0,     /* success, ready/OK */
00040                        RCP_ENOENT,      /* error, component of the path does not exist, or the path is an empty string */
00041                        RCP_EOPEN,       /* error, can't open file for reading or writing */
00042                        RCP_ENOFILE,     /* error, file doesn't exist (if from_remote==0) */
00043                        RCP_EUSER,       /* error, user name does not match for authentication purposes */
00044                        RCP_EOTHER       /* error, some other error occured */
00045 } status_t;
00046 
00047 /**
00048  * @brief structure used as a server message reply from the server rcpd program to the client msg
00049  */
00050 typedef struct vsl_server_msg {
00051     uint32_t status;            /* status of the server rcpd proccess (actually of status_t type) */
00052     uint32_t file_size;         /* file size the client should expect (if from_remote set to 0 in client msg (see above)) */
00053 } vsl_server_msg_t;
00054 
00055 /**
00056  * This function prints the final transfer statistics after file transfer
00057  *
00058  * @param stats vfer stats structure pointer
00059  */
00060 inline void vfer_rcp_print_stats(vfer_stats* stats) {
00061     double duration;    /* in seconds */
00062     struct timeval tv_end;
00063     uint32_t data_retransmitted;
00064 
00065     if (stats->tv_end.tv_sec == 0 && stats->tv_end.tv_usec == 0) {
00066         GET_TIME_OF_DAY(&(tv_end));
00067         printf("-- real time stats --\n");
00068     } else {
00069         bcopy(&(stats->tv_end), &(tv_end), sizeof(struct timeval));
00070     }
00071 
00072     /* printf("start: %d %d\n", (int)stats->tv_start.tv_sec, (int)stats->tv_start.tv_usec);
00073        printf("end: %d %d\n", (int)tv_end.tv_sec, (int)tv_end.tv_usec);  */
00074 
00075     duration = (tv_end.tv_sec - stats->tv_start.tv_sec);
00076     duration += 0.000000001 * (tv_end.tv_usec - stats->tv_start.tv_usec);
00077     /* retransmit traffic (data payload only) in bytes */
00078     data_retransmitted = (stats->data_bytes_sent - stats->data_bytes_sender_sent);
00079 
00080     printf("\n");
00081     printf("VFER transfer statistics:\n");
00082     printf("\n");
00083     printf("Duration      (s)   conn    %f\n", duration);
00084     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)));
00085     printf("Total             (packets) sent    %-14u   recvd   %u\n", stats->packets_sent, stats->packets_recvd);
00086     printf("Total         (bytes)       sent    %-14u   recvd   %u\n", stats->bytes_sent, stats->bytes_recvd);
00087     printf("Total data    (bytes)       sent    %-14u   recvd   %-16u retrans      %u\n", stats->data_bytes_sent, stats->data_bytes_recvd, data_retransmitted);
00088     printf("Avg data rate (Mb/s)        sending %-16.2f recving %-16.2f eff. sending %.2f\n",
00089            ((stats->data_bytes_sent * 8.0) / (duration * 1000000)),
00090            ((stats->data_bytes_recvd * 8.0) / (duration * 1000000)),
00091            (((stats->data_bytes_sent - data_retransmitted) * 8.0) / (duration * 1000000)));
00092     printf("RTT           (ms)  avg     %-16.2f max     %-16.2f min          %.2f\n", stats->avg_rtt, (double)(stats->max_rtt), (double)(stats->min_rtt));
00093     printf("\n");
00094 } /* vfer_rcp_print_stats() */
00095 
00096 #endif
00097 
00098 
00099 /*
00100  * Local Variables:
00101  * compile-command: "cd ..; make file_xfer"
00102  * compilation-search-path: ("..")
00103  * End:
00104  */

Generated on Tue Aug 8 16:07:20 2006 for VFER by  doxygen 1.4.7