클라이언트와 서버 간의 RTT (왕복 시간)를 계산하거나 어떻게 계산합니까?SUN RPC (ONC/RPC) : C에서 null 프로 시저를 사용하여 왕복 시간 (또는 핑) 계산
튜토리얼 또는 샘플 주소로도 도움이 될 수 있습니다. 여기
클라이언트와 서버 간의 RTT (왕복 시간)를 계산하거나 어떻게 계산합니까?SUN RPC (ONC/RPC) : C에서 null 프로 시저를 사용하여 왕복 시간 (또는 핑) 계산
튜토리얼 또는 샘플 주소로도 도움이 될 수 있습니다. 여기
내가 무엇을 :
#include <rpc/rpc.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/times.h>
#include <fcntl.h>
#include <time.h>
int main(int argc, char *argv[]) {
enum clnt_stat status;
CLIENT *handle;
struct timeval t;
clock_t rtime;
struct tms dumm;
int count = 100000;
int i;
time_t now;
char stamp[27];
int programm;
int version;
if (argc != 4) {
printf("Usage: rpcping <host> <program> <version>\n");
exit(1);
}
/*
* Create Client Handle
*/
programm = atoi(argv[2]);
version = atoi(argv[3]);
handle = clnt_create(argv[1], programm, version, "tcp");
if (handle == NULL) {
printf("clnt failed\n");
exit(1);
}
/*
* use 30 seconds timeout
*/
t.tv_sec = 30;
t.tv_usec = 0;
while (1) {
rtime = times(&dumm);
for (i = 0; i < count; i++) {
status = clnt_call(handle, 0, (xdrproc_t) xdr_void,
NULL, (xdrproc_t) xdr_void, NULL, t);
if (status == RPC_SUCCESS) { /* NOP */ }
}
now = time(NULL);
ctime_r(&now, stamp);
stamp[strlen(stamp) - 1] = '\0';
fprintf(stdout, "[%s]: Speed: %2.4fs.\n", stamp,
count/((double) (times(&dumm) - rtime)/(double) sysconf(_SC_CLK_TCK)));
fflush(stdout);
}
clnt_destroy(handle);
}
내가뿐만 아니라
https://gist.github.com/2401404
티그 다중 스레드 버전.
http://mattgemmell.com/2008/12/08/what-have-you-tried/ –
요아킴 안녕하세요. 무례한 방법으로 도움을 주셔서 감사합니다. 여기에 내가 질문을 할 때 초보자로서 한 일이있다. (나는 여전히 초보자이다.) 웹에서 제목 키워드 (SUN + RPC + ONC + RTT + 왕복 여행 + 왕복 시간 + 핑 + null 프로 시저 + C + 추정 + 클라이언트 + 서버). RPC에 대해 발견 한 모든 문서를 읽었습니다. 나는 심지어 몇 가지 RFC 표준 시트를 읽었다. (나는 그들이 내 마음을 부는 것을 기억한다.) 나는 아무것도 얻지 않았다. 그래서 아래의 해답은 제가 발견 할 수있는 유일한 해결책입니다. 그건 ... – duru
... 왜 귀중한가요? 어쨌든 당신의 귀중하지만 무례한 기여에 감사드립니다. – duru