From:	ADVAX::"mcnc!VM1.NoDak.EDU!fac2%DAYTON.SAIC.COM" "Earle Ake" 16-FEB-1991 07:50:33.55
To:	Multiple recipients of list ANU-NEWS <ANU-NEWS@NDSUVM1>
CC:	
Subj:	Patch to NNTP_XMIT.C to get transfer stats

Received: by ADVAX.DECnet (utk-mail11 v1.5) ; Sat, 16 Feb 91 07:49:50 EST
Received:  from mcnc by ge-dab.GE.COM (5.61/GE-DAB 1.15) with UUCP
	id AA16943 for ; Sat, 16 Feb 91 07:45:43 -0500
Received: from VM1.NoDak.EDU by mcnc.mcnc.org (5.59/MCNC/6-11-90)
	id AA28877; Thu, 14 Feb 91 23:52:16 -0500
	for ARISIA.DNET.ge.com!EVERHART
Message-Id: <9102150452.AA28877@mcnc.mcnc.org>
Received: from NDSUVM1.BITNET by VM1.NoDak.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 4725; Thu, 14 Feb 91 22:51:08 CST
Received: from NDSUVM1.BITNET by NDSUVM1.BITNET (Mailer R2.07) with BSMTP id
 8778; Thu, 14 Feb 91 22:51:04 CST
Date:         Thu, 14 Feb 91 01:02:11 GMT
Reply-To: Earle Ake <mcnc!VM1.NoDak.EDU!fac2%DAYTON.SAIC.COM>
Sender: ANU-NEWS Discussion <ANU-NEWS@VM1.NoDak.EDU>
From: Earle Ake <mcnc!VM1.NoDak.EDU!fac2%DAYTON.SAIC.COM>
Subject:      Patch to NNTP_XMIT.C to get transfer stats
To: Multiple recipients of list ANU-NEWS <ANU-NEWS@NDSUVM1>
 
        I wanted to see what kind of throughput I was getting on NNTP news
batch transfers to other sites.  I modified NNTP_XMIT.C to print some
statistics after the transfer.  Here is what the output now looks like along
with the patch to make it work.
 
 
$ nntp_xmit kahuna.asd-yf.wpafb.af.mil cmutcp kahuna.ids tt: tt:
        Connecting to NEWS SERVER on node kahuna.asd-yf.wpafb.af.mil ...
X> Try open channel to remote node
X> IHAVE <9491.27b96e3b@ohstpy.mps.ohio-state.edu>< 335> 235
X> IHAVE <1991Feb13.201727.1503@dayton.saic.com>< 335> 235
X> IHAVE <1991Feb13.201807.1504@dayton.saic.com>< 335> 235
X> IHAVE <1E2D4AC884A00155@HMCVAX.CLAREMONT.EDU>< 335> 235
13 Feb 91 20:45:04  dayton.saic.com: nntpxmit: kahuna.asd-yf.wpafb.af.mil
  4 offered 4 accepted 0 rejected 0 failed 0 expired
Transferred 58419 bytes in 117 seconds = 499 bytes/Second
 
 
*** [-.old_src]nntp_xmit.c
--- nntp_xmit.c
**************
*** 903,908
    unsigned short len, qual_len;
    FILE *fpr, *fpi, *fpl, *fpw;
    $DESCRIPTOR(qual_dsc,qual);
 
    *taskstr = '\0';
    *node = *proto = *idfile = *logfile = *dbgfile = '\0';
--- 903,910 -----
    unsigned short len, qual_len;
    FILE *fpr, *fpi, *fpl, *fpw;
    $DESCRIPTOR(qual_dsc,qual);
+   long bytes_sent = 0, total_bytes_sent = 0;
+   int start_time, stop_time, elapsed_time = 0;
 
    *taskstr = '\0';
    *node = *proto = *idfile = *logfile = *dbgfile = '\0';
**************
*** 1190,1195
        if (debugging) fprintf(fpd,"\n");
        continue;
        }
      while (fgets(inpline0,512,fpi)) {
        char *t;
        if (*inpline0 == '.') memmove(inpline0 + 1,inpline0,strlen(inpline0) + 1
);
--- 1192,1199 -----
        if (debugging) fprintf(fpd,"\n");
        continue;
        }
+     bytes_sent = 0;
+     time(&start_time);
      while (fgets(inpline0,512,fpi)) {
        char *t;
        if (*inpline0 == '.') memmove(inpline0 + 1,inpline0,strlen(inpline0) + 1
);
**************
*** 1195,1200
        if (*inpline0 == '.') memmove(inpline0 + 1,inpline0,strlen(inpline0) + 1
);
        if (t = strchr(inpline0,'\n')) *t = '\0';
        if (!nntp_write(inpline0)) GO_DIE(ERROR)
        }
      fclose(fpi);
      if (!nntp_write(".") || (!(reply = wait_net_response(CLIENT_TIMER,1)))) GO
_DIE(ERROR)
--- 1199,1205 -----
        if (*inpline0 == '.') memmove(inpline0 + 1,inpline0,strlen(inpline0) + 1
);
        if (t = strchr(inpline0,'\n')) *t = '\0';
        if (!nntp_write(inpline0)) GO_DIE(ERROR)
+       bytes_sent += strlen(inpline0);
        }
      fclose(fpi);
      if (!nntp_write(".") || (!(reply = wait_net_response(CLIENT_TIMER,1)))) GO
_DIE(ERROR)
**************
*** 1198,1203
        }
      fclose(fpi);
      if (!nntp_write(".") || (!(reply = wait_net_response(CLIENT_TIMER,1)))) GO
_DIE(ERROR)
      if (debugging) fprintf(fpd," %d\n",reply);
      if (reply == 435  || reply == 437) {
        rejected++;
--- 1203,1211 -----
        }
      fclose(fpi);
      if (!nntp_write(".") || (!(reply = wait_net_response(CLIENT_TIMER,1)))) GO
_DIE(ERROR)
+     total_bytes_sent += bytes_sent;
+     time(&stop_time);
+     elapsed_time += (stop_time - start_time);
      if (debugging) fprintf(fpd," %d\n",reply);
      if (reply == 435  || reply == 437) {
        rejected++;
**************
*** 1228,1234
    if (logging){
      dat();
      fpl = fopen(logfile,"a+");
!     fprintf(fpl,"%s %s: nntpxmit: %s %d offered %d accepted %d rejected %d fai
led %d expired\n",
                datum, lhost, node, offered, accepted, rejected, failed, expired
);
      fclose(fpl);
      }
--- 1236,1242 -----
    if (logging){
      dat();
      fpl = fopen(logfile,"a+");
!     fprintf(fpl,"%s %s: nntpxmit: %s\n  %d offered %d accepted %d rejected %d
failed %d expired\n",
                datum, lhost, node, offered, accepted, rejected, failed, expired
);
      fprintf(fpl,"Transferred %d bytes in %d seconds",
                total_bytes_sent, elapsed_time);
**************
*** 1230,1235
      fpl = fopen(logfile,"a+");
      fprintf(fpl,"%s %s: nntpxmit: %s %d offered %d accepted %d rejected %d fai
led %d expired\n",
                datum, lhost, node, offered, accepted, rejected, failed, expired
);
      fclose(fpl);
      }
    if (debugging) fclose(fpd);
--- 1238,1247 -----
      fpl = fopen(logfile,"a+");
      fprintf(fpl,"%s %s: nntpxmit: %s\n  %d offered %d accepted %d rejected %d
failed %d expired\n",
                datum, lhost, node, offered, accepted, rejected, failed, expired
);
+     fprintf(fpl,"Transferred %d bytes in %d seconds",
+               total_bytes_sent, elapsed_time);
+     fprintf(fpl," = %d bytes/Second\n",
+               total_bytes_sent/elapsed_time);
      fclose(fpl);
      }
    if (debugging) fclose(fpd);
 
 
Earle
_____________________________________________________________________________
             ____ ____    ___
Earle Ake   /___ /___/ / /     Science Applications International Corporation
           ____//   / / /__                 Dayton, Ohio
-----------------------------------------------------------------------------
Internet: fac2@dayton.saic.com             uucp: dayvb!fac2
