aboutsummaryrefslogtreecommitdiff
path: root/src/iperf_udp.c
diff options
context:
space:
mode:
authorsethdelliott <devnull@localhost>2010-07-15 20:05:43 +0000
committersethdelliott <devnull@localhost>2010-07-15 20:05:43 +0000
commitaa89cda29f234f8e1f7041846887466602047206 (patch)
treebbd434cc070c2fc25d829628db1c74cb904db10f /src/iperf_udp.c
parent86afd62bfe7fad824f551e13971770add1ce73e4 (diff)
downloadiperf3-aa89cda29f234f8e1f7041846887466602047206.tar.gz
Added bandwidth mode (-b) support for UDP.
Diffstat (limited to 'src/iperf_udp.c')
-rw-r--r--src/iperf_udp.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/src/iperf_udp.c b/src/iperf_udp.c
index eb33eda..ad7a936 100644
--- a/src/iperf_udp.c
+++ b/src/iperf_udp.c
@@ -59,11 +59,6 @@ iperf_udp_recv(struct iperf_stream *sp)
double transit = 0, d = 0;
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
do {
result = recv(sp->socket, sp->buffer, size, 0);
@@ -127,18 +122,13 @@ iperf_udp_send(struct iperf_stream *sp)
int size = sp->settings->blksize;
struct timeval before, after;
- /*
- * 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) {
+ if (timer_expired(sp->send_timer)) {
-/*
dtargus = (int64_t) (sp->settings->blksize) * SEC_TO_US * 8;
dtargus /= sp->settings->rate;
assert(dtargus != 0);
-*/
+
if (gettimeofday(&before, 0) < 0)
perror("gettimeofday");
++sp->packet_count;
@@ -161,17 +151,10 @@ iperf_udp_send(struct iperf_stream *sp)
sp->result->bytes_sent += result;
sp->result->bytes_sent_this_interval += result;
-/*
+
if (gettimeofday(&after, 0) < 0)
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 += (before.tv_sec - after.tv_sec) * SEC_TO_US;
adjustus += (before.tv_usec - after.tv_usec);
@@ -179,10 +162,10 @@ iperf_udp_send(struct iperf_stream *sp)
if (adjustus > 0) {
dtargus = adjustus;
}
- // RESET THE TIMER
+
update_timer(sp->send_timer, 0, dtargus);
-// } // timer_expired_micro
-*/
+ }
+
return result;
}