2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
// keep track of the network performance of this host,
|
|
|
|
// namely exponentially weighted averages of upload and download speeds
|
|
|
|
//
|
|
|
|
|
2005-06-07 19:22:50 +00:00
|
|
|
#ifndef _NET_STATS_
|
|
|
|
#define _NET_STATS_
|
|
|
|
|
2004-03-04 11:41:43 +00:00
|
|
|
#ifndef _WIN32
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdio>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
|
|
|
|
2003-02-26 00:47:57 +00:00
|
|
|
#include "net_xfer.h"
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "miofile.h"
|
2003-02-26 00:47:57 +00:00
|
|
|
|
|
|
|
// there's one of these each for upload and download
|
|
|
|
//
|
|
|
|
struct NET_INFO {
|
|
|
|
double delta_t; // elapsed time of file transfer activity
|
|
|
|
// in this session of client
|
|
|
|
double delta_nbytes; // bytes transferred in this session
|
|
|
|
double last_bytes;
|
|
|
|
double starting_throughput; // throughput at start of session
|
|
|
|
|
|
|
|
void update(double dt, double nb, bool active);
|
|
|
|
double throughput();
|
|
|
|
};
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
class NET_STATS {
|
|
|
|
public:
|
2003-02-26 00:47:57 +00:00
|
|
|
double last_time;
|
|
|
|
NET_INFO up;
|
|
|
|
NET_INFO down;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
NET_STATS();
|
2003-02-26 00:47:57 +00:00
|
|
|
void poll(NET_XFER_SET&);
|
2004-07-13 13:54:09 +00:00
|
|
|
|
2004-09-22 21:08:26 +00:00
|
|
|
int write(MIOFILE&);
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
2005-06-07 19:22:50 +00:00
|
|
|
|
|
|
|
#endif
|