Changeset 5ee0701 in network-demos for ttcp/ttcp_orig/ttcp.c


Ignore:
Timestamp:
Aug 16, 2007, 5:27:52 PM (13 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master, network-demos-4-10-branch, network-demos-4-8-branch, network-demos-4-9-branch
Children:
0cbc6db
Parents:
13bcedb
Message:

2007-08-16 Joel Sherrill <joel.sherrill@…>

  • init.c: Change clock tick to 1 millisecond.
  • rtems_ttcp.c: Add CPU usage reporting.
  • ttcp_orig/ttcp.c: Add -m option for delaying between writes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ttcp/ttcp_orig/ttcp.c

    r13bcedb r5ee0701  
    4848/* #define SYSV */      /* required on SGI IRIX releases before 3.3 */
    4949
     50#define ENABLE_NANOSLEEP_DELAY
     51
    5052#include <stdio.h>
    5153#include <signal.h>
     
    5860#include <arpa/inet.h>
    5961#include <netdb.h>
     62#include <string.h>
    6063#include <sys/time.h>           /* struct timeval */
     64
     65#include <unistd.h>
     66#include <stdlib.h>
    6167
    6268#if defined(SYSV)
     
    107113                                 *  g = gigabits, G = gigabytes */
    108114int touchdata = 0;              /* access data after reading */
     115long milliseconds = 0;          /* delay in milliseconds */
    109116
    110117struct hostent *addr;
     
    134141        -B      for -s, only output full blocks as specified by -l (for TAR)\n\
    135142        -T      \"touch\": access each byte as it's read\n\
     143        -m ##   delay for specified milliseconds between each write\n\
    136144";     
    137145
     
    157165}
    158166
     167void millisleep(long msec)
     168{
     169#if defined(ENABLE_NANOSLEEP_DELAY)
     170  struct timespec req;
     171
     172  req.tv_sec = msec / 1000;
     173  req.tv_nsec = (msec % 1000) * 1000000;
     174
     175  nanosleep( &req, NULL );
     176#endif
     177}
    159178int main(argc,argv)
    160179int argc;
     
    166185        if (argc < 2) goto usage;
    167186
    168         while ((c = getopt(argc, argv, "drstuvBDTb:f:l:n:p:A:O:")) != -1) {
     187        while ((c = getopt(argc, argv, "drstuvBDTb:f:l:m:n:p:A:O:")) != -1) {
    169188                switch (c) {
    170189
     
    188207        "ttcp: -D option ignored: TCP_NODELAY socket option not supported\n");
    189208#endif
     209                        break;
     210                case 'm':
     211                        milliseconds = atoi(optarg);
     212                        #if !defined(ENABLE_NANOSLEEP_DELAY)
     213                                fprintf(stderr, "millisecond delay disabled\n");
     214                        #endif
    190215                        break;
    191216                case 'n':
     
    380405                        pattern( buf, buflen );
    381406                        if(udp)  (void)Nwrite( fd, buf, 4 ); /* rcvr start */
    382                         while (nbuf-- && Nwrite(fd,buf,buflen) == buflen)
     407                        while (nbuf-- && Nwrite(fd,buf,buflen) == buflen) {
    383408                                nbytes += buflen;
     409                                millisleep( milliseconds );
     410                        }
    384411                        if(udp)  (void)Nwrite( fd, buf, 4 ); /* rcvr end */
    385412                } else {
Note: See TracChangeset for help on using the changeset viewer.