Mercurial > flash_v2
changeset 936:c77314a3f0fd
* tests/linux_echo.c: Renamed to....
* tests/host_echo.c: this new file. Change comment to indicate this.
* tests/make.linux: Renamed to....
* tests/make.host: this new file. Change comment to indicate this.
Also linux_echo -> host_echo, and add clean target.
* doc/tcpip.sgml: Reflect above.
| author | jlarmour |
|---|---|
| date | Fri, 11 Apr 2003 21:01:09 +0000 |
| parents | aa074daf1f12 |
| children | 249dd9889974 |
| files | packages/net/common/current/ChangeLog packages/net/common/current/doc/tcpip.sgml packages/net/common/current/tests/host_echo.c packages/net/common/current/tests/linux_echo.c packages/net/common/current/tests/make.host packages/net/common/current/tests/make.linux |
| diffstat | 6 files changed, 331 insertions(+), 317 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/net/common/current/ChangeLog +++ b/packages/net/common/current/ChangeLog @@ -1,3 +1,14 @@ +2003-04-11 Jonathan Larmour <jifl@eCosCentric.com> + + * tests/linux_echo.c: Renamed to.... + * tests/host_echo.c: this new file. Change comment to indicate this. + + * tests/make.linux: Renamed to.... + * tests/make.host: this new file. Change comment to indicate this. + Also linux_echo -> host_echo, and add clean target. + + * doc/tcpip.sgml: Reflect above. + 2003-04-11 Michael Checky <Michael_Checky@Thermoking.com> * tests/nc_test_framework.h: deleted '#include <net/route.h>'.
--- a/packages/net/common/current/doc/tcpip.sgml +++ b/packages/net/common/current/doc/tcpip.sgml @@ -246,26 +246,26 @@ purpose networks unless protected by a s <PARA><command>tcp_echo</command> is one part of the standard performance test we use. The other parts are host programs <LITERAL>tcp_source</LITERAL> and <LITERAL>tcp_sink</LITERAL>. - To make these (under LINUX) cd to the tests source directory in -the eCos repository and type “<LITERAL>make -f make.linux</LITERAL>” - + To make these (under your <emphasis>HOST</emphasis> system) cd to the tests source directory in +the eCos repository and type “<LITERAL>make -f make.host</LITERAL>” - this should build <LITERAL>tcp_source</LITERAL> and <LITERAL>tcp_sink</LITERAL>.</PARA> -<PARA>The LINUX program “<LITERAL>tcp_source</LITERAL>” sends +<PARA>The host program “<LITERAL>tcp_source</LITERAL>” sends data to the target. On the target, “<LITERAL>tcp_echo</LITERAL>” sends it onwards to “<LITERAL>tcp_sink</LITERAL>” running -on LINUX. So the target must receive and send on all the data that <LITERAL>tcp_source</LITERAL> sends +on your host. So the target must receive and send on all the data that <LITERAL>tcp_source</LITERAL> sends it; the time taken for this is measured and the data rate is calculated.</PARA> <PARA>To invoke the test, first start <LITERAL>tcp_echo</LITERAL> on the target board and wait for it to become quiescent - it will report work to calibrate a CPU load which can be used to simulate real operating conditions for the stack.</PARA> -<PARA>Then on your LINUX machine, in one terminal window, invoke <LITERAL>tcp_sink</LITERAL> giving +<PARA>Then on your host machine, in one terminal window, invoke <LITERAL>tcp_sink</LITERAL> giving it the IP address (or hostname) of one interface of the target board. For example “<LITERAL>tcp_sink 10.130.39.66</LITERAL>”. <LITERAL>tcp_echo</LITERAL> on the target will print something like “<LITERAL>SINK connection from 10.130.39.13:1143</LITERAL>” when <LITERAL>tcp_sink</LITERAL> is correctly invoked.</PARA> -<PARA>Next, in another LINUX terminal window, invoke <LITERAL>tcp_source</LITERAL>, +<PARA>Next, in another host terminal window, invoke <LITERAL>tcp_source</LITERAL>, giving it the IP address (or hostname) of an interface of the target board, and optionally a background load to apply to the target while the test runs. For example, “<LITERAL>tcp_source @@ -279,15 +279,15 @@ tcp_source is correctly invoked.</PARA> <PARA>You can connect tcp_sink to one target interface and tcp_source to another, or both to the same interface. Similarly, you can run <LITERAL>tcp_sink</LITERAL> and <LITERAL>tcp_source</LITERAL> on -the same LINUX machine or different ones. TCP/IP and ARP +the same host machine or different ones. TCP/IP and ARP look after them finding one another, as intended.</PARA> <PROGRAMLISTING><EMPHASIS>nc_test_master</EMPHASIS> - network characterization master <EMPHASIS>nc_test_slave</EMPHASIS> - network characterization slave</PROGRAMLISTING> <PARA>These tests talk to each other to measure network performance. -They can each run on either a test target or a LINUX host computer +They can each run on either a test target or a host computer given some customization to your local environment. As provided, <literal>nc_test_slave</literal> must run on the test target, and <literal>nc_test_master</literal> must -be run on a LINUX host, and be given the test target's +be run on a host computer, and be given the test target's IP address or hostname.</PARA> <PARA>The tests print network performance for various packet sizes over UDP and TCP, versus various additional CPU loads on the target.</PARA>
new file mode 100644 --- /dev/null +++ b/packages/net/common/current/tests/host_echo.c @@ -0,0 +1,281 @@ +//========================================================================== +// +// tests/host_echo.c +// +// Simple TCP throughput test - echo component FOR *HOST* +// * CAUTION: host, i.e. non eCos, only * +// +//========================================================================== +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: This is the middle part of a three part test. The idea is +// to test the throughput of box in a configuration like this: +// +// +------+ port +----+ port +----+ +// |SOURCE|=========>|ECHO|============>|SINK| +// +------+ 9990 +----+ 9991 +----+ +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#undef _KERNEL +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#include <sys/param.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/errno.h> +#include <sys/time.h> + +#include <net/if.h> +#include <netinet/in_systm.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#include <netinet/ip_icmp.h> + +#include <netdb.h> + +#define true 1 +#define false 1 + +#define TNR_ON() +#define TNR_OFF() + +#define diag_printf printf + +void +pexit(char *s) +{ + perror(s); + exit(1); +} + + +#define SOURCE_PORT 9990 +#define SINK_PORT 9991 + +#define MAX_BUF 8192 +static unsigned char data_buf[MAX_BUF]; + +struct test_params { + long nbufs; + long bufsize; + long load; +}; + +struct test_status { + long ok; +}; + +int max( int a, int b ) { return (a>b)?a:b; } +int min( int a, int b ) { return (a<b)?a:b; } + + +int +do_read(int s, void *_buf, int len) +{ + int total, slen, rlen; + unsigned char *buf = (unsigned char *)_buf; + total = 0; + rlen = len; + while (total < len) { + slen = read(s, buf, rlen); + if (slen != rlen) { + if (slen < 0) { + diag_printf("Error after reading %d bytes\n", total); + return -1; + } + rlen -= slen; + buf += slen; + } + total += slen; + } + return total; +} + +int +do_write(int s, void *_buf, int len) +{ + int total, slen, rlen; + unsigned char *buf = (unsigned char *)_buf; + total = 0; + rlen = len; + while (total < len) { + slen = write(s, buf, rlen); + if (slen != rlen) { + if (slen < 0) { + diag_printf("Error after writing %d bytes\n", total); + return -1; + } + rlen -= slen; + buf += slen; + } + total += slen; + } + return total; +} + +static void +echo_test(void * p) +{ + int s_source, s_sink, e_source, e_sink; + struct sockaddr_in e_source_addr, e_sink_addr, local; + int one = 1; + fd_set in_fds; + int i, num, len; + struct test_params params,nparams; + struct test_status status,nstatus; + + s_source = socket(AF_INET, SOCK_STREAM, 0); + if (s_source < 0) { + pexit("stream socket"); + } + if (setsockopt(s_source, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) { + pexit("setsockopt /source/ SO_REUSEADDR"); + } + memset(&local, 0, sizeof(local)); + local.sin_family = AF_INET; +// local.sin_len = sizeof(local); + local.sin_port = ntohs(SOURCE_PORT); + local.sin_addr.s_addr = INADDR_ANY; + if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) { + pexit("bind /source/ error"); + } + listen(s_source, SOMAXCONN); + + s_sink = socket(AF_INET, SOCK_STREAM, 0); + if (s_sink < 0) { + pexit("stream socket"); + } + memset(&local, 0, sizeof(local)); + local.sin_family = AF_INET; +// local.sin_len = sizeof(local); + local.sin_port = ntohs(SINK_PORT); + local.sin_addr.s_addr = INADDR_ANY; + if(bind(s_sink, (struct sockaddr *) &local, sizeof(local)) < 0) { + pexit("bind /sink/ error"); + } + if (setsockopt(s_sink, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) { + pexit("setsockopt /sink/ SO_REUSEADDR"); + } + listen(s_sink, SOMAXCONN); + + e_source = 0; e_sink = 0; + while (true) { + // Wait for a connection on either of the ports + FD_ZERO(&in_fds); + FD_SET(s_source, &in_fds); + FD_SET(s_sink, &in_fds); + num = select(max(s_sink,s_source)+1, &in_fds, 0, 0, 0); + if (FD_ISSET(s_source, &in_fds)) { + len = sizeof(e_source_addr); + if ((e_source = accept(s_source, (struct sockaddr *)&e_source_addr, &len)) < 0) { + pexit("accept /source/"); + } + diag_printf("SOURCE connection from %s:%d\n", + inet_ntoa(e_source_addr.sin_addr), ntohs(e_source_addr.sin_port)); + } + if (FD_ISSET(s_sink, &in_fds)) { + len = sizeof(e_sink_addr); + if ((e_sink = accept(s_sink, (struct sockaddr *)&e_sink_addr, &len)) < 0) { + pexit("accept /sink/"); + } + diag_printf("SINK connection from %s:%d\n", + inet_ntoa(e_sink_addr.sin_addr), ntohs(e_sink_addr.sin_port)); + } + // Continue with test once a connection is established in both directions + if ((e_source != 0) && (e_sink != 0)) { + break; + } + } + + // Wait for "source" to tell us the testing paramters + if (do_read(e_source, &nparams, sizeof(nparams)) != sizeof(nparams)) { + pexit("Can't read initialization parameters"); + } + + params.nbufs = ntohl(nparams.nbufs); + params.bufsize = ntohl(nparams.bufsize); + params.load = ntohl(nparams.load); + + diag_printf("Using %d buffers of %d bytes each, %d%% background load\n", + params.nbufs, params.bufsize, params.load); + + // Tell the sink what the parameters are + if (do_write(e_sink, &nparams, sizeof(nparams)) != sizeof(nparams)) { + pexit("Can't write initialization parameters"); + } + + status.ok = 1; + nstatus.ok = htonl(status.ok); + + // Tell the "source" to start - we're all connected and ready to go! + if (do_write(e_source, &nstatus, sizeof(nstatus)) != sizeof(nstatus)) { + pexit("Can't send ACK to 'source' host"); + } + + TNR_ON(); + + // Echo the data from the source to the sink hosts + for (i = 0; i < params.nbufs; i++) { + if ((len = do_read(e_source, data_buf, params.bufsize)) != params.bufsize) { + TNR_OFF(); + diag_printf("Can't read buf #%d: ", i+1); + if (len < 0) { + perror("I/O error"); + } else { + diag_printf("short read - only %d bytes\n", len); + } + TNR_ON(); + } + if ((len = do_write(e_sink, data_buf, params.bufsize)) != params.bufsize) { + TNR_OFF(); + diag_printf("Can't write buf #%d: ", i+1); + if (len < 0) { + perror("I/O error"); + } else { + diag_printf("short write - only %d bytes\n", len); + } + TNR_ON(); + } + } + + TNR_OFF(); + + // Wait for the data to drain and the "sink" to tell us all is OK. + if (do_read(e_sink, &status, sizeof(status)) != sizeof(status)) { + pexit("Can't receive ACK from 'sink' host"); + } + +} + + +int +main(int argc, char *argv[]) +{ + echo_test(argv[1]); + return 0; +} + + +// EOF +
deleted file mode 100644 --- a/packages/net/common/current/tests/linux_echo.c +++ /dev/null @@ -1,281 +0,0 @@ -//========================================================================== -// -// tests/linux_echo.c -// -// Simple TCP throughput test - echo component FOR LINUX HOST -// * CAUTION: host, i.e. non eCos, only * -// -//========================================================================== -//####BSDCOPYRIGHTBEGIN#### -// -// ------------------------------------------- -// -// Portions of this software may have been derived from OpenBSD or other sources, -// and are covered by the appropriate copyright disclaimers included herein. -// -// ------------------------------------------- -// -//####BSDCOPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): gthomas -// Contributors: gthomas -// Date: 2000-01-10 -// Purpose: -// Description: This is the middle part of a three part test. The idea is -// to test the throughput of box in a configuration like this: -// -// +------+ port +----+ port +----+ -// |SOURCE|=========>|ECHO|============>|SINK| -// +------+ 9990 +----+ 9991 +----+ -// -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#undef _KERNEL -#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> - -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <sys/errno.h> -#include <sys/time.h> - -#include <net/if.h> -#include <netinet/in_systm.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <netinet/ip_icmp.h> - -#include <netdb.h> - -#define true 1 -#define false 1 - -#define TNR_ON() -#define TNR_OFF() - -#define diag_printf printf - -void -pexit(char *s) -{ - perror(s); - exit(1); -} - - -#define SOURCE_PORT 9990 -#define SINK_PORT 9991 - -#define MAX_BUF 8192 -static unsigned char data_buf[MAX_BUF]; - -struct test_params { - long nbufs; - long bufsize; - long load; -}; - -struct test_status { - long ok; -}; - -int max( int a, int b ) { return (a>b)?a:b; } -int min( int a, int b ) { return (a<b)?a:b; } - - -int -do_read(int s, void *_buf, int len) -{ - int total, slen, rlen; - unsigned char *buf = (unsigned char *)_buf; - total = 0; - rlen = len; - while (total < len) { - slen = read(s, buf, rlen); - if (slen != rlen) { - if (slen < 0) { - diag_printf("Error after reading %d bytes\n", total); - return -1; - } - rlen -= slen; - buf += slen; - } - total += slen; - } - return total; -} - -int -do_write(int s, void *_buf, int len) -{ - int total, slen, rlen; - unsigned char *buf = (unsigned char *)_buf; - total = 0; - rlen = len; - while (total < len) { - slen = write(s, buf, rlen); - if (slen != rlen) { - if (slen < 0) { - diag_printf("Error after writing %d bytes\n", total); - return -1; - } - rlen -= slen; - buf += slen; - } - total += slen; - } - return total; -} - -static void -echo_test(void * p) -{ - int s_source, s_sink, e_source, e_sink; - struct sockaddr_in e_source_addr, e_sink_addr, local; - int one = 1; - fd_set in_fds; - int i, num, len; - struct test_params params,nparams; - struct test_status status,nstatus; - - s_source = socket(AF_INET, SOCK_STREAM, 0); - if (s_source < 0) { - pexit("stream socket"); - } - if (setsockopt(s_source, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) { - pexit("setsockopt /source/ SO_REUSEADDR"); - } - memset(&local, 0, sizeof(local)); - local.sin_family = AF_INET; -// local.sin_len = sizeof(local); - local.sin_port = ntohs(SOURCE_PORT); - local.sin_addr.s_addr = INADDR_ANY; - if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) { - pexit("bind /source/ error"); - } - listen(s_source, SOMAXCONN); - - s_sink = socket(AF_INET, SOCK_STREAM, 0); - if (s_sink < 0) { - pexit("stream socket"); - } - memset(&local, 0, sizeof(local)); - local.sin_family = AF_INET; -// local.sin_len = sizeof(local); - local.sin_port = ntohs(SINK_PORT); - local.sin_addr.s_addr = INADDR_ANY; - if(bind(s_sink, (struct sockaddr *) &local, sizeof(local)) < 0) { - pexit("bind /sink/ error"); - } - if (setsockopt(s_sink, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) { - pexit("setsockopt /sink/ SO_REUSEADDR"); - } - listen(s_sink, SOMAXCONN); - - e_source = 0; e_sink = 0; - while (true) { - // Wait for a connection on either of the ports - FD_ZERO(&in_fds); - FD_SET(s_source, &in_fds); - FD_SET(s_sink, &in_fds); - num = select(max(s_sink,s_source)+1, &in_fds, 0, 0, 0); - if (FD_ISSET(s_source, &in_fds)) { - len = sizeof(e_source_addr); - if ((e_source = accept(s_source, (struct sockaddr *)&e_source_addr, &len)) < 0) { - pexit("accept /source/"); - } - diag_printf("SOURCE connection from %s:%d\n", - inet_ntoa(e_source_addr.sin_addr), ntohs(e_source_addr.sin_port)); - } - if (FD_ISSET(s_sink, &in_fds)) { - len = sizeof(e_sink_addr); - if ((e_sink = accept(s_sink, (struct sockaddr *)&e_sink_addr, &len)) < 0) { - pexit("accept /sink/"); - } - diag_printf("SINK connection from %s:%d\n", - inet_ntoa(e_sink_addr.sin_addr), ntohs(e_sink_addr.sin_port)); - } - // Continue with test once a connection is established in both directions - if ((e_source != 0) && (e_sink != 0)) { - break; - } - } - - // Wait for "source" to tell us the testing paramters - if (do_read(e_source, &nparams, sizeof(nparams)) != sizeof(nparams)) { - pexit("Can't read initialization parameters"); - } - - params.nbufs = ntohl(nparams.nbufs); - params.bufsize = ntohl(nparams.bufsize); - params.load = ntohl(nparams.load); - - diag_printf("Using %d buffers of %d bytes each, %d%% background load\n", - params.nbufs, params.bufsize, params.load); - - // Tell the sink what the parameters are - if (do_write(e_sink, &nparams, sizeof(nparams)) != sizeof(nparams)) { - pexit("Can't write initialization parameters"); - } - - status.ok = 1; - nstatus.ok = htonl(status.ok); - - // Tell the "source" to start - we're all connected and ready to go! - if (do_write(e_source, &nstatus, sizeof(nstatus)) != sizeof(nstatus)) { - pexit("Can't send ACK to 'source' host"); - } - - TNR_ON(); - - // Echo the data from the source to the sink hosts - for (i = 0; i < params.nbufs; i++) { - if ((len = do_read(e_source, data_buf, params.bufsize)) != params.bufsize) { - TNR_OFF(); - diag_printf("Can't read buf #%d: ", i+1); - if (len < 0) { - perror("I/O error"); - } else { - diag_printf("short read - only %d bytes\n", len); - } - TNR_ON(); - } - if ((len = do_write(e_sink, data_buf, params.bufsize)) != params.bufsize) { - TNR_OFF(); - diag_printf("Can't write buf #%d: ", i+1); - if (len < 0) { - perror("I/O error"); - } else { - diag_printf("short write - only %d bytes\n", len); - } - TNR_ON(); - } - } - - TNR_OFF(); - - // Wait for the data to drain and the "sink" to tell us all is OK. - if (do_read(e_sink, &status, sizeof(status)) != sizeof(status)) { - pexit("Can't receive ACK from 'sink' host"); - } - -} - - -int -main(int argc, char *argv[]) -{ - echo_test(argv[1]); - return 0; -} - - -// EOF -
new file mode 100644 --- /dev/null +++ b/packages/net/common/current/tests/make.host @@ -0,0 +1,30 @@ +# +# Simple *HOST SIDE* makefile for network tests +# + +CC = cc +CFLAGS = -O2 -g + +ALL = nc_test_master nc_test_slave tcp_source tcp_sink host_echo +ALL += nc6_test_master nc6_test_slave + +all: ${ALL} + +clean: + rm -f $(ALL) + +nc_test_master: nc_test_framework.h nc_test_master.c + $(CC) -o $@ ${CFLAGS} nc_test_master.c + +nc_test_slave: nc_test_framework.h nc_test_slave.c + $(CC) -o $@ ${CFLAGS} nc_test_slave.c + +tcp_source: tcp_source.c + $(CC) -o $@ ${CFLAGS} tcp_source.c + +tcp_sink: tcp_sink.c + $(CC) -o $@ ${CFLAGS} tcp_sink.c + +host_echo: host_echo.c + $(CC) -o $@ ${CFLAGS} host_echo.c +
deleted file mode 100644 --- a/packages/net/common/current/tests/make.linux +++ /dev/null @@ -1,27 +0,0 @@ -# -# Simple Linux makefile for network tests (host side) -# - -CC = cc -CFLAGS = -O2 -g - -ALL = nc_test_master nc_test_slave tcp_source tcp_sink linux_echo -ALL += nc6_test_master nc6_test_slave - -all: ${ALL} - -nc_test_master: nc_test_framework.h nc_test_master.c - $(CC) -o $@ ${CFLAGS} nc_test_master.c - -nc_test_slave: nc_test_framework.h nc_test_slave.c - $(CC) -o $@ ${CFLAGS} nc_test_slave.c - -tcp_source: tcp_source.c - $(CC) -o $@ ${CFLAGS} tcp_source.c - -tcp_sink: tcp_sink.c - $(CC) -o $@ ${CFLAGS} tcp_sink.c - -linux_echo: linux_echo.c - $(CC) -o $@ ${CFLAGS} linux_echo.c -
