Added bandwidth mode (-b) support for UDP.
Этот коммит содержится в:
родитель
86afd62bfe
Коммит
aa89cda29f
@ -143,6 +143,8 @@ iperf_init_test(struct iperf_test *test)
|
|||||||
{
|
{
|
||||||
char *prot;
|
char *prot;
|
||||||
struct iperf_stream *sp;
|
struct iperf_stream *sp;
|
||||||
|
int64_t dtargus;
|
||||||
|
|
||||||
|
|
||||||
/* XXX: These variables were used in the old UDP code
|
/* XXX: These variables were used in the old UDP code
|
||||||
int64_t delayus, adjustus, dtargus;
|
int64_t delayus, adjustus, dtargus;
|
||||||
@ -150,8 +152,7 @@ iperf_init_test(struct iperf_test *test)
|
|||||||
|
|
||||||
if (test->protocol == Pudp) {
|
if (test->protocol == Pudp) {
|
||||||
prot = "UDP";
|
prot = "UDP";
|
||||||
|
/* XXX: Trying my own implementation
|
||||||
/* XXX: This code isn't currently used and will most likely be changed
|
|
||||||
dtargus = (int64_t) (test->default_settings->blksize) * SEC_TO_US * 8;
|
dtargus = (int64_t) (test->default_settings->blksize) * SEC_TO_US * 8;
|
||||||
dtargus /= test->default_settings->rate;
|
dtargus /= test->default_settings->rate;
|
||||||
|
|
||||||
@ -165,7 +166,13 @@ iperf_init_test(struct iperf_test *test)
|
|||||||
for (sp = test->streams; sp != NULL; sp = sp->next)
|
for (sp = test->streams; sp != NULL; sp = sp->next)
|
||||||
sp->send_timer = new_timer(0, dtargus);
|
sp->send_timer = new_timer(0, dtargus);
|
||||||
*/
|
*/
|
||||||
|
dtargus = (int64_t) test->default_settings->blksize * SEC_TO_US * 8;
|
||||||
|
dtargus /= test->default_settings->rate;
|
||||||
|
|
||||||
|
assert(dtargus != 0);
|
||||||
|
|
||||||
|
for (sp = test->streams; sp; sp = sp->next)
|
||||||
|
sp->send_timer = new_timer(dtargus / SEC_TO_US, dtargus % SEC_TO_US);
|
||||||
} else {
|
} else {
|
||||||
prot = "TCP";
|
prot = "TCP";
|
||||||
}
|
}
|
||||||
@ -219,6 +226,11 @@ package_parameters(struct iperf_test *test)
|
|||||||
strncat(pstring, optbuf, sizeof(pstring));
|
strncat(pstring, optbuf, sizeof(pstring));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (test->default_settings->rate) {
|
||||||
|
snprintf(optbuf, sizeof(optbuf), "-b %llu ", test->default_settings->rate);
|
||||||
|
strncat(pstring, optbuf, sizeof(pstring));
|
||||||
|
}
|
||||||
|
|
||||||
if (test->default_settings->mss) {
|
if (test->default_settings->mss) {
|
||||||
snprintf(optbuf, sizeof(optbuf), "-m %d ", test->default_settings->mss);
|
snprintf(optbuf, sizeof(optbuf), "-m %d ", test->default_settings->mss);
|
||||||
strncat(pstring, optbuf, sizeof(pstring));
|
strncat(pstring, optbuf, sizeof(pstring));
|
||||||
@ -284,7 +296,7 @@ parse_parameters(struct iperf_test *test)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((ch = getopt(n, params, "pt:n:m:uP:Rw:l:")) != -1) {
|
while ((ch = getopt(n, params, "pt:n:m:uP:Rw:l:b:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'p':
|
case 'p':
|
||||||
test->protocol = Ptcp;
|
test->protocol = Ptcp;
|
||||||
@ -314,6 +326,9 @@ parse_parameters(struct iperf_test *test)
|
|||||||
case 'l':
|
case 'l':
|
||||||
test->default_settings->blksize = atoi(optarg);
|
test->default_settings->blksize = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
test->default_settings->rate = atoll(optarg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -59,11 +59,6 @@ iperf_udp_recv(struct iperf_stream *sp)
|
|||||||
double transit = 0, d = 0;
|
double transit = 0, d = 0;
|
||||||
struct timeval sent_time, arrival_time;
|
struct timeval sent_time, arrival_time;
|
||||||
|
|
||||||
// XXX: Is this necessary? We've already checked the buffer to see if it's allocated.
|
|
||||||
if (!sp->buffer) {
|
|
||||||
fprintf(stderr, "receive buffer not allocated \n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
#ifdef USE_SEND
|
#ifdef USE_SEND
|
||||||
do {
|
do {
|
||||||
result = recv(sp->socket, sp->buffer, size, 0);
|
result = recv(sp->socket, sp->buffer, size, 0);
|
||||||
@ -127,18 +122,13 @@ iperf_udp_send(struct iperf_stream *sp)
|
|||||||
int size = sp->settings->blksize;
|
int size = sp->settings->blksize;
|
||||||
struct timeval before, after;
|
struct timeval before, after;
|
||||||
|
|
||||||
/*
|
if (timer_expired(sp->send_timer)) {
|
||||||
* the || part ensures that last packet is sent to server - the
|
|
||||||
* STREAM_END MESSAGE
|
|
||||||
*/
|
|
||||||
// if (sp->send_timer->expired(sp->send_timer) || sp->settings->state == STREAM_END) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
dtargus = (int64_t) (sp->settings->blksize) * SEC_TO_US * 8;
|
dtargus = (int64_t) (sp->settings->blksize) * SEC_TO_US * 8;
|
||||||
dtargus /= sp->settings->rate;
|
dtargus /= sp->settings->rate;
|
||||||
|
|
||||||
assert(dtargus != 0);
|
assert(dtargus != 0);
|
||||||
*/
|
|
||||||
if (gettimeofday(&before, 0) < 0)
|
if (gettimeofday(&before, 0) < 0)
|
||||||
perror("gettimeofday");
|
perror("gettimeofday");
|
||||||
++sp->packet_count;
|
++sp->packet_count;
|
||||||
@ -161,17 +151,10 @@ iperf_udp_send(struct iperf_stream *sp)
|
|||||||
|
|
||||||
sp->result->bytes_sent += result;
|
sp->result->bytes_sent += result;
|
||||||
sp->result->bytes_sent_this_interval += result;
|
sp->result->bytes_sent_this_interval += result;
|
||||||
/*
|
|
||||||
if (gettimeofday(&after, 0) < 0)
|
if (gettimeofday(&after, 0) < 0)
|
||||||
perror("gettimeofday");
|
perror("gettimeofday");
|
||||||
|
|
||||||
//
|
|
||||||
// CHECK: Packet length and ID if(sp->settings->state ==
|
|
||||||
// STREAM_RUNNING) printf("State = %d Outgoing packet = %d AND SP =
|
|
||||||
// %d\n",sp->settings->state, sp->packet_count, sp->socket);
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
adjustus = dtargus;
|
adjustus = dtargus;
|
||||||
adjustus += (before.tv_sec - after.tv_sec) * SEC_TO_US;
|
adjustus += (before.tv_sec - after.tv_sec) * SEC_TO_US;
|
||||||
adjustus += (before.tv_usec - after.tv_usec);
|
adjustus += (before.tv_usec - after.tv_usec);
|
||||||
@ -179,10 +162,10 @@ iperf_udp_send(struct iperf_stream *sp)
|
|||||||
if (adjustus > 0) {
|
if (adjustus > 0) {
|
||||||
dtargus = adjustus;
|
dtargus = adjustus;
|
||||||
}
|
}
|
||||||
// RESET THE TIMER
|
|
||||||
update_timer(sp->send_timer, 0, dtargus);
|
update_timer(sp->send_timer, 0, dtargus);
|
||||||
// } // timer_expired_micro
|
}
|
||||||
*/
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user