00001 // This file is part of BOINC. 00002 // http://boinc.berkeley.edu 00003 // Copyright (C) 2008 University of California 00004 // 00005 // BOINC is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation, 00008 // either version 3 of the License, or (at your option) any later version. 00009 // 00010 // BOINC is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 // See the GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 00017 00018 // keep track of the network performance of this host, 00019 // namely exponentially weighted averages of upload and download speeds 00020 // 00021 00022 #ifndef _NET_STATS_ 00023 #define _NET_STATS_ 00024 00025 #ifndef _WIN32 00026 #include <cstdio> 00027 #endif 00028 00029 #include "miofile.h" 00030 00031 class FILE_XFER_SET; 00032 class HTTP_OP_SET; 00033 00035 00036 struct NET_INFO { 00040 double max_rate; 00042 double avg_rate; 00044 double avg_time; 00046 void update(double nbytes, double dt); 00047 00048 }; 00049 00050 class NET_STATS { 00051 public: 00052 NET_INFO up; 00053 NET_INFO down; 00054 00055 NET_STATS(); 00056 00057 int write(MIOFILE&); 00058 int parse(MIOFILE&); 00059 }; 00060 00061 class NET_STATUS { 00062 public: 00065 bool need_to_contact_reference_site; 00066 void contact_reference_site(); 00067 bool show_ref_message; 00069 00076 bool need_physical_connection; 00080 bool have_sporadic_connection; 00081 double last_comm_time; 00082 00083 int network_status(); 00084 void network_available(); 00085 void got_http_error(); 00086 NET_STATUS() { 00087 need_physical_connection = false; 00088 have_sporadic_connection = false; 00089 need_to_contact_reference_site = false; 00090 show_ref_message = false; 00091 last_comm_time = 0; 00092 } 00093 void poll(); 00094 }; 00095 00099 00100 struct LOOKUP_WEBSITE_OP: public GUI_HTTP_OP { 00101 int error_num; 00102 00103 virtual ~LOOKUP_WEBSITE_OP(){} 00104 int do_rpc(std::string&); 00105 virtual void handle_reply(int http_op_retval); 00106 LOOKUP_WEBSITE_OP(GUI_HTTP* p){ 00107 error_num = BOINC_SUCCESS; 00108 gui_http = p; 00109 } 00110 }; 00111 00112 extern NET_STATUS net_status; 00113 00114 #endif
1.5.6