/*---------------------------------------------------------------
* Copyright (c) 1999,2000,2001,2002,2003
* The Board of Trustees of the University of Illinois
* All Rights Reserved.
*---------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software (Iperf) and associated
* documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
*
* Redistributions of source code must retain the above
* copyright notice, this list of conditions and
* the following disclaimers.
*
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimers in the documentation and/or other materials
* provided with the distribution.
*
*
* Neither the names of the University of Illinois, NCSA,
* nor the names of its contributors may be used to endorse
* or promote products derived from this Software without
* specific prior written permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ________________________________________________________________
* National Laboratory for Applied Network Research
* National Center for Supercomputing Applications
* University of Illinois at Urbana-Champaign
* http://www.ncsa.uiuc.edu
* ________________________________________________________________
*
* Reporter.c
* by Kevin Gibbs <kgibbs@nlanr.net>
*
* ________________________________________________________________ */
#include "headers.h"
#include "Settings.hpp"
#include "util.h"
#include "Reporter.h"
#include "Thread.h"
#include "Locale.h"
#include "PerfSocket.hpp"
#include "SocketAddr.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
The following 4 functions are provided for Reporting
styles that do not have all the reporting formats. For
instance the provided CSV format does not have a settings
report so it uses settings_notimpl.
*/
void* connection_notimpl( Connection_Info * nused, int nuse ) {
return NULL;
}
void settings_notimpl( ReporterData * nused ) { }
void statistics_notimpl( Transfer_Info * nused ) { }
void serverstatistics_notimpl( Connection_Info *nused1, Transfer_Info *nused2 ) { }
// To add a reporting style include its header here.
#include "report_default.h"
#include "report_CSV.h"
// The following array of report structs contains the
// pointers required for reporting in different reporting
// styles. To add a reporting style add a report struct
// below.
report_connection connection_reports[kReport_MAXIMUM] = {
reporter_reportpeer,
CSV_peer
};
report_settings settings_reports[kReport_MAXIMUM] = {
reporter_reportsettings,
settings_notimpl
};
report_statistics statistics_reports[kReport_MAXIMUM] = {
reporter_printstats,
CSV_stats
};
report_serverstatistics serverstatistics_reports[kReport_MAXIMUM] = {
reporter_serverstats,
CSV_serverstats
};
report_statistics multiple_reports[kReport_MAXIMUM] = {
reporter_multistats,
CSV_stats
};
char buffer[64]; // Buffer for printing
ReportHeader *ReportRoot = NULL;
extern Condition ReportCond;
extern Condition ReportDoneCond;
int reporter_process_report ( ReportHeader *report );
void process_report ( ReportHeader *report );
int reporter_handle_packet( ReportHeader *report );
int reporter_condprintstats( ReporterData *stats, MultiHeader *multireport, int force );
int reporter_print( ReporterData *stats, int type, int end );
void PrintMSS( ReporterData *stats );
MultiHeader* InitMulti( thread_Settings *agent, int inID ) {
MultiHeader *multihdr = NULL;
if ( agent->mThreads > 1 || agent->mThreadMode == kMode_Server ) {
if ( isMultipleReport( agent ) ) {
multihdr = malloc(sizeof(MultiHeader) + sizeof(ReporterData) +
NUM_MULTI_SLOTS * sizeof(Transfer_Info));
} else {
multihdr = malloc(sizeof(MultiHeader));
}
if ( multihdr != NULL ) {
memset( multihdr, 0, sizeof(MultiHeader) );
Condition_Initialize( &multihdr->barrier );
multihdr->groupID = inID;
multihdr->threads = agent->mThreads;
if ( isMultipleReport( agent ) ) {
int i;
ReporterData *data = NULL;
multihdr->report = (ReporterData*)(multihdr + 1);
memset(multihdr->report, 0, sizeof(ReporterData));
multihdr->data = (Transfer_Info*)(multihdr->report + 1);
data = multihdr->report;
for ( i = 0; i < NUM_MULTI_SLOTS; i++ ) {
multihdr->data[i].startTime = -1;
multihdr->data[i].transferID = inID;
multihdr->data[i].groupID = -2;
}
data->type = TRANSFER_REPORT;
if ( agent->mInterval != 0.0 ) {
struct timeval *interval = &data->intervalTime;
interval->tv_sec = (long) agent->mInterval;
interval->tv_usec = (long) ((agent->mInterval - interval->tv_sec)
* rMillion);
}
data->mHost = agent->mHost;
data->mLocalhost = agent->mLocalhost;
data->mBufLen = agent->mBufLen;
data->mMSS = agent->mMSS;
data->mTCPWin = agent->mTCPWin;
data->flags = agent->flags;
data->mThreadMode = agent->mThreadMode;
data->mode = agent->mReportMode;
data->info.mFormat = agent->mFormat;
data->info.mTTL = agent->mTTL;
if ( isUDP( agent ) ) {
multihdr->report->info.mUDP = (char)agent->mThreadMode;
}
if ( isConnectionReport( agent ) ) {
data->type |= CONNECTION_REPORT;
data->connection.peer = agent->peer;
data->connection.size_peer = agent->size_peer;
SockAddr_setPortAny( &data->connection.peer );
data->connection.local = agent->local;
data->connection.size_local = agent->size_local;
SockAddr_setPortAny( &data->connection.local );
}
}
} else {
FAIL(1, "Out of Memory!!\n", agent);
}
}
return multihdr;
}
/*
* BarrierClient allows for multiple stream clients to be syncronized
*/
void BarrierClient( ReportHeader *agent ) {
Condition_Lock(agent->multireport->barrier);
agent->multireport->threads--;
if ( agent->multireport->threads == 0 ) {
// last one set time and wake up everyone
gettimeofday( &(agent->multireport->startTime), NULL );
Condition_Broadcast( &agent->multireport->barrier );
} else {
Condition_Wait( &agent->multireport->barrier );
}
agent->multireport->threads++;
Condition_Unlock( agent->multireport->barrier );
agent->report.startTime = agent->multireport->startTime;
agent->report.nextTime = agent->report.star
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
iperf-2.0.5.tar.gz (90个子文件)
iperf-2.0.5
missing 11KB
man
Makefile.in 10KB
iperf.1 4KB
Makefile.am 47B
COPYING 2KB
aclocal.m4 30KB
m4
acx_pthread.m4 7KB
dast.m4 5KB
ax_create_stdint_h.m4 23KB
compat
signal.c 6KB
delay.cpp 3KB
headers_slim.h 1KB
string.c 3KB
snprintf.c 3KB
inet_ntop.c 5KB
Makefile.in 14KB
gettimeofday.c 3KB
error.c 8KB
Thread.c 15KB
Makefile.am 421B
inet_pton.c 6KB
INSTALL 304B
config.h.in 7KB
include
version.h 71B
gnu_getopt.h 5KB
Client.hpp 3KB
Reporter.h 7KB
inet_aton.h 4KB
headers.h 6KB
util.h 7KB
report_CSV.h 3KB
Locale.h 5KB
delay.hpp 3KB
Mutex.h 4KB
gettimeofday.h 3KB
Thread.h 5KB
Settings.hpp 16KB
Makefile.in 9KB
Server.hpp 3KB
Condition.h 7KB
config.win32.h 2KB
Timestamp.hpp 10KB
List.h 3KB
Listener.hpp 3KB
service.h 5KB
snprintf.h 1KB
Extractor.h 4KB
PerfSocket.hpp 3KB
report_default.h 3KB
Makefile.am 379B
SocketAddr.h 4KB
configure 265KB
ChangeLog 3KB
install-sh 9KB
Makefile.in 19KB
depcomp 15KB
AUTHORS 815B
src
gnu_getopt_long.c 4KB
main.cpp 10KB
Extractor.c 5KB
SocketAddr.c 15KB
Locale.c 12KB
service.c 17KB
ReportDefault.c 11KB
List.cpp 4KB
stdio.c 9KB
Settings.cpp 32KB
ReportCSV.c 6KB
Listener.cpp 26KB
Makefile.in 16KB
gnu_getopt.c 29KB
Client.cpp 16KB
sockets.c 6KB
Launch.cpp 6KB
PerfSocket.cpp 6KB
Server.cpp 9KB
Makefile.am 713B
Reporter.c 34KB
tcp_window_size.c 6KB
autogen.sh 467B
configure.ac 8KB
config.guess 43KB
README 693B
config.sub 31KB
doc
ui_license.html 3KB
dast.gif 5KB
Makefile.in 8KB
index.html 41KB
Makefile.am 49B
Makefile.am 220B
共 90 条
- 1
flyingefox
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页