aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/tcpblast
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1994-09-08 21:59:31 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1994-09-08 21:59:31 +0000
commit9e5906dd61cd8527110fdbbbd84381a0497b90a7 (patch)
tree71814b47d3d77bea657afd16f015ef93e103bb58 /benchmarks/tcpblast
parent34037f3eec3a2d8513de0fde2bbb665a8bb7416a (diff)
downloadports-9e5906dd61cd8527110fdbbbd84381a0497b90a7.tar.gz
ports-9e5906dd61cd8527110fdbbbd84381a0497b90a7.zip
Bring in Michael Reifenberger's tcpblast port.
Reviewed by: jkh Submitted by: mr
Notes
Notes: svn path=/head/; revision=62
Diffstat (limited to 'benchmarks/tcpblast')
-rw-r--r--benchmarks/tcpblast/Makefile16
-rw-r--r--benchmarks/tcpblast/pkg-comment1
-rw-r--r--benchmarks/tcpblast/pkg-descr2
-rw-r--r--benchmarks/tcpblast/pkg-plist2
-rw-r--r--benchmarks/tcpblast/src/Makefile7
-rw-r--r--benchmarks/tcpblast/src/tcpblast.c116
6 files changed, 144 insertions, 0 deletions
diff --git a/benchmarks/tcpblast/Makefile b/benchmarks/tcpblast/Makefile
new file mode 100644
index 000000000000..c297dc68c46a
--- /dev/null
+++ b/benchmarks/tcpblast/Makefile
@@ -0,0 +1,16 @@
+# New ports collection makefile for: pkg_install
+# Version required: <own lineage>
+# Date created: 22 August 1994
+# Whom: jkh
+#
+# $Id: Makefile,v 1.4 1994/08/28 15:00:20 jkh Exp $
+#
+
+DISTNAME= tcpblast
+NO_EXTRACT= yes
+
+pre-clean:
+ @echo "===> Pre-clean for ${DISTNAME}"
+ @(cd ${.CURDIR}/src; make clean)
+
+.include <bsd.port.mk>
diff --git a/benchmarks/tcpblast/pkg-comment b/benchmarks/tcpblast/pkg-comment
new file mode 100644
index 000000000000..7dfb1b2c264e
--- /dev/null
+++ b/benchmarks/tcpblast/pkg-comment
@@ -0,0 +1 @@
+This is the TCPBLAST program.
diff --git a/benchmarks/tcpblast/pkg-descr b/benchmarks/tcpblast/pkg-descr
new file mode 100644
index 000000000000..340d7882e278
--- /dev/null
+++ b/benchmarks/tcpblast/pkg-descr
@@ -0,0 +1,2 @@
+TCPBLAST messures the throughput of a tcp connection
+It was written by Daniel Karrenberg <dfk@nic.eu.net>
diff --git a/benchmarks/tcpblast/pkg-plist b/benchmarks/tcpblast/pkg-plist
new file mode 100644
index 000000000000..3ef9a3bb7371
--- /dev/null
+++ b/benchmarks/tcpblast/pkg-plist
@@ -0,0 +1,2 @@
+@cwd /usr/local
+bin/tcpblast
diff --git a/benchmarks/tcpblast/src/Makefile b/benchmarks/tcpblast/src/Makefile
new file mode 100644
index 000000000000..42d678f5b6eb
--- /dev/null
+++ b/benchmarks/tcpblast/src/Makefile
@@ -0,0 +1,7 @@
+PROG=tcpblast
+SRCS=tcpblast.c
+NOMAN=noman
+DESTDIR?=/usr/local
+BINDIR=/bin
+
+.include<bsd.prog.mk>
diff --git a/benchmarks/tcpblast/src/tcpblast.c b/benchmarks/tcpblast/src/tcpblast.c
new file mode 100644
index 000000000000..3b8a914e1c4d
--- /dev/null
+++ b/benchmarks/tcpblast/src/tcpblast.c
@@ -0,0 +1,116 @@
+/*
+ * tcpblast - test and estimate TCP thruput
+ *
+ * Daniel Karrenberg <dfk@nic.eu.net>
+ */
+
+#include <sys/types.h>
+#include <machine/endian.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+
+#include <netdb.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define BLKSIZE 1024
+
+struct sockaddr_in sock_in;
+struct servent *sp;
+struct hostent *host;
+
+long starts, startms, stops, stopms, expms;
+struct timeval ti;
+struct timezone tiz;
+
+char greet[BLKSIZE] = "Hi!";
+int nblocks;
+int f;
+
+int main(argc, argv)
+int argc; char **argv;
+{
+ register int i;
+
+ if (argc!=3)
+ {
+ fprintf(stderr, "usage: tcpblast destination nblkocks\n");
+ fprintf(stderr, "blocksize: %d bytes\n", BLKSIZE);
+ exit(1);
+ }
+
+ nblocks = atoi(argv[2]);
+ if (nblocks<=1 || nblocks>=10000)
+ {
+ fprintf(stderr, "tcpblast: 1 < nblocks <= 10000 \n");
+ exit(1);
+ }
+
+ bzero((char *)&sock_in, sizeof (sock_in));
+ sock_in.sin_family = AF_INET;
+ f = socket(AF_INET, SOCK_STREAM, 0);
+ if (f < 0) {
+ perror("tcpblast: socket");
+ exit(3);
+ }
+ if (bind(f, (struct sockaddr*) &sock_in, sizeof (sock_in)) < 0) {
+ perror("tcpblast: bind");
+ exit(1);
+ }
+
+ host = gethostbyname(argv[1]);
+ if (host) {
+ sock_in.sin_family = host->h_addrtype;
+ bcopy(host->h_addr, &sock_in.sin_addr, host->h_length);
+ } else {
+ sock_in.sin_family = AF_INET;
+ sock_in.sin_addr.s_addr = inet_addr(argv[1]);
+ if (sock_in.sin_addr.s_addr == -1) {
+ fprintf(stderr, "tcpblast: %s unknown host\n", argv[1]);
+ exit(1);
+ }
+ }
+ sock_in.sin_port = htons(9);
+
+ if (connect(f, (struct sockaddr*) &sock_in, sizeof(sock_in)) <0)
+ {
+ perror("tcpblast connect:");
+ exit(1);
+ }
+
+ if (gettimeofday(&ti, &tiz) < 0)
+ {
+ perror("tcpblast time:");
+ exit(1);
+ }
+ starts = ti.tv_sec;
+ startms = ti.tv_usec / 1000L;
+
+
+ for (i=0; i<nblocks; i++)
+ {
+ if (write(f, greet, BLKSIZE) != BLKSIZE)
+ perror("tcpblast send:");
+ write(1, ".", 1);
+ }
+
+ if (gettimeofday(&ti, &tiz) < 0)
+ {
+ perror("tcpblast time:");
+ exit(1);
+ }
+ stops = ti.tv_sec;
+ stopms = ti.tv_usec / 1000L;
+
+ expms = (stops-starts)*1000 + (stopms-startms);
+ printf("\n%d KB in %ld msec", nblocks, expms);
+ printf(" = %.1f kbit/s", (double) (nblocks*BLKSIZE) / expms * 8000.0);
+ printf(" = %.1f kByte/s", (double) (nblocks*BLKSIZE) / expms * 1000);
+ printf(" = %.1f MByte/s\n", (double) (nblocks*BLKSIZE) / (double)(expms*1024.0));
+return(0);
+}