Skip to Content.
Sympa Menu

thrulay-users - Re: thrulay 0.9 patch: change size of returned blocks

Subject: Discussion list for thrulay, a network testing tool

List archive

Re: thrulay 0.9 patch: change size of returned blocks


Chronological Thread 
  • From: Csaba Kiraly <>
  • To:
  • Subject: Re: thrulay 0.9 patch: change size of returned blocks
  • Date: Tue, 26 Feb 2008 17:06:52 +0100

The patch was missing from my earlier mail. See it attached.
Csaba

Csaba Kiraly wrote:
> Hi,
>
> First of all, thanks for thrulay, the only tool I've found that measures
> application level RTT, i.e. something useful when TCP level proxying is
> part of the system!
>
> I've made a small patch that changes the size of the data block returned
> from the server to the client. The option was already there in the code
> as a compile time constant, it becomes a configurable parameter after
> you apply the patch. Why is it useful:
> - better control over what do you measure
> - you can regulate the ratio of client->server and server->client traffic
>
> How it was before:
> -l parameter defines the block size sent from the client to the server.
> Default is 64 Kilobytes. It is enough to define it in the client.
> - after a block is received by the server, the first 16 bytes (the
> timestamp) is returned to the client.
>
> After the patch:
> -l works as before
> -r defines the size of the return block (I think it works only up to the
> amount of -l, in which case all the traffic is looped back to the
> client). Currently, -r should be specified at both sides, both when
> starting the client and when starting the server.
>
> Hope someone finds it useful
> Csaba
>
>

diff -aur thrulay-0.9/src/client.c thrulay-0.9-kiraly/src/client.c
--- thrulay-0.9/src/client.c 2006-08-20 20:06:19.000000000 +0200
+++ thrulay-0.9-kiraly/src/client.c 2008-02-17 23:57:07.000000000 +0100
@@ -1642,7 +1642,7 @@

/* Allocate memory for writing blocks. */
block = malloc((size_t)server_block_size +
- (thrulay_opt.num_streams -1) * BLOCK_HEADER);
+ (thrulay_opt.num_streams -1) * block_header);
if (block == NULL) {
return -4;
}
@@ -1688,7 +1688,7 @@
/* Non-blocking recv. */
rc = recv(stream[id].sock,
buf[id]+stream[id].rcount,
- BLOCK_HEADER-
+ block_header-
stream[id].rcount, 0);

if (-1 == rc && EAGAIN != errno) {
@@ -1699,7 +1699,7 @@
break;
} else if (0 < rc) {
stream[id].rcount += rc;
- if ( BLOCK_HEADER ==
+ if ( block_header ==
stream[id].rcount ) {
/* Whole block read */
memcpy(&tv, buf[id],
@@ -1720,13 +1720,13 @@

perror("gettimeofday");
return -1;
}
- memcpy(block +
id*BLOCK_HEADER,
+ memcpy(block +
id*block_header,
&tv, sizeof(tv));
}

/* Non-blocking send */
rc = send(stream[id].sock,
- block + id*BLOCK_HEADER +
+ block + id*block_header +
stream[id].wcount,
(size_t)server_block_size-
stream[id].wcount, 0);
@@ -1808,7 +1808,7 @@
return -5;
}

- memset(block + id*BLOCK_HEADER, '2', (size_t)server_block_size);
+ memset(block + id*block_header, '2', (size_t)server_block_size);

return 0;
}
diff -aur thrulay-0.9/src/server.c thrulay-0.9-kiraly/src/server.c
--- thrulay-0.9/src/server.c 2006-08-20 21:30:19.000000000 +0200
+++ thrulay-0.9-kiraly/src/server.c 2008-02-17 23:56:39.000000000 +0100
@@ -1592,7 +1592,7 @@
rcount += rc;
if (rcount == (size_t)b) {
blocks++;
- if (BLOCK_HEADER == wcount) {
+ if (block_header == wcount) {
rcount = wcount = 0;
}
}
@@ -1610,8 +1610,8 @@
}

/* Bytes ready for sending back to client? */
- wready = (rcount < BLOCK_HEADER - wcount)? rcount :
- BLOCK_HEADER - wcount;
+ wready = (rcount < block_header - wcount)? rcount :
+ block_header - wcount;
/* Send header. We don't care about FD_ISSET(fd,&wfds).
If it was false, can be outdated. Also, having
FS_SET(fd,&wfds_orig) generally leads to unnecessary calls
@@ -1620,7 +1620,7 @@
rc = send(fd, block + wcount, wready, 0);
if (-1 != rc) {
wcount += rc;
- if (BLOCK_HEADER == wcount &&
+ if (block_header == wcount &&
rcount == (size_t)b) {
wcount = rcount = 0;
}
diff -aur thrulay-0.9/src/thrulay.c thrulay-0.9-kiraly/src/thrulay.c
--- thrulay-0.9/src/thrulay.c 2006-08-20 20:06:19.000000000 +0200
+++ thrulay-0.9-kiraly/src/thrulay.c 2008-02-18 00:05:58.000000000 +0100
@@ -129,7 +129,10 @@
"\t\t\treporting interval is ignored.\n");
fprintf(stderr, "\t-T#\t\tTTL field for multicast (default: 1)\n");
fprintf(stderr, "\t-g group\tmulticast group to send data to\n");
+ fprintf(stderr, "\t-r#\t\tblock header size (at least/default: %d)\n",
+ THRULAY_DEFAULT_BLOCK_HEADER);
fprintf(stderr, "\thost\t\tserver to connect to (no default)\n");
+
}

static void __attribute__((noreturn))
@@ -153,13 +156,14 @@
main(int argc, char *argv[])
{
char *endptr = NULL;
+ block_header=THRULAY_DEFAULT_BLOCK_HEADER;
uint32_t tlng;
int rc, ch;
thrulay_opt_t thrulay_opt;

thrulay_client_options_init(&thrulay_opt);

- while ((ch = getopt(argc, argv, "hVvbD:m:t:i:w:l:p:u:T:g:")) != -1)
+ while ((ch = getopt(argc, argv, "hVvbD:m:t:i:w:l:p:u:T:g:r:")) != -1)
switch (ch) {
case 'h':
print_usage();
@@ -264,6 +268,14 @@
fprintf(stderr,"multicast is disabled, continuing\n");
#endif
break;
+ case 'r':
+ block_header = atoi(optarg);
+ if (block_header <= 0) {
+ fprintf(stderr, "block_header size should be"
+ "at least 16 bytes\n");
+ usage();
+ }
+ break;
default:
usage();
}
@@ -295,7 +307,7 @@
}
#endif /* ifdef SIGPIPE */

- assert(sizeof(struct timeval) <= BLOCK_HEADER);
+ assert(sizeof(struct timeval) <= block_header);

rc = thrulay_client_init(thrulay_opt);
if (rc < 0) {
diff -aur thrulay-0.9/src/thrulayd.c thrulay-0.9-kiraly/src/thrulayd.c
--- thrulay-0.9/src/thrulayd.c 2006-08-20 20:06:19.000000000 +0200
+++ thrulay-0.9-kiraly/src/thrulayd.c 2008-02-18 00:05:31.000000000 +0100
@@ -47,6 +47,8 @@
THRULAY_DEFAULT_SERVER_TCP_PORT);
fprintf(stderr, "\t-d \t\tdebug (no daemon, log to stderr)\n");
fprintf(stderr, "\t-j group\tjoin a multicast group\n");
+ fprintf(stderr, "\t-r#\t\tblock header size (at least/default: %d)\n",
+ THRULAY_DEFAULT_BLOCK_HEADER);
}

void __attribute__((noreturn))
@@ -75,9 +77,10 @@
int argcorig = argc;
int log_type = LOGTYPE_SYSLOG; /* default is syslog */
int reporting_verbosity = 0;
+ block_header=THRULAY_DEFAULT_BLOCK_HEADER;
int ch, rc;

- while ((ch = getopt(argc, argv, "hVva:w:p:dj:")) != -1) {
+ while ((ch = getopt(argc, argv, "hVva:w:p:dj:r:")) != -1) {
switch (ch) {
case 'h':
print_usage();
@@ -121,6 +124,14 @@
fprintf(stderr,"multicast is disabled, continuing\n");
#endif
break;
+ case 'r':
+ block_header = atoi(optarg);
+ if (block_header <= 0) {
+ fprintf(stderr, "block_header size should be"
+ "at least 16 bytes\n");
+ usage();
+ }
+ break;
default:
usage();
}
diff -aur thrulay-0.9/src/util.h thrulay-0.9-kiraly/src/util.h
--- thrulay-0.9/src/util.h 2006-08-20 20:06:19.000000000 +0200
+++ thrulay-0.9-kiraly/src/util.h 2008-02-18 00:01:44.000000000 +0100
@@ -42,8 +42,9 @@

#include <unistd.h>

-#define BLOCK_HEADER 16
-#define MIN_BLOCK BLOCK_HEADER
+int block_header;
+#define THRULAY_DEFAULT_BLOCK_HEADER 16
+#define MIN_BLOCK THRULAY_DEFAULT_BLOCK_HEADER
#define MAX_BLOCK 1048576

#define ERR_FATAL 0



Archive powered by MHonArc 2.6.16.

Top of Page