diff options
author | brian <brian@FreeBSD.org> | 1997-11-18 14:52:08 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-11-18 14:52:08 +0000 |
commit | 7a358d8b024e6ebd90807720438c539bcac14855 (patch) | |
tree | baa2a2ef6ea91adf2c59b11bbffbd706f85ced30 /usr.sbin/ppp | |
parent | 907dcc5c043baddb164e2c76f04097ea096b9c3a (diff) | |
download | FreeBSD-src-7a358d8b024e6ebd90807720438c539bcac14855.zip FreeBSD-src-7a358d8b024e6ebd90807720438c539bcac14855.tar.gz |
Add throughput logging (disabled by default).
Use "enable throughput" to see modem & IPCP throughput.
Removed an extraneous prompt()
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/Makefile | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/ip.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/ipcp.c | 76 | ||||
-rw-r--r-- | usr.sbin/ppp/ipcp.h | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/lcp.c | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 148 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp.8 | 78 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp.8.m4 | 78 | ||||
-rw-r--r-- | usr.sbin/ppp/throughput.c | 126 | ||||
-rw-r--r-- | usr.sbin/ppp/throughput.h | 24 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.c | 5 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.h | 5 |
12 files changed, 329 insertions, 234 deletions
diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile index 7562f21..7736260 100644 --- a/usr.sbin/ppp/Makefile +++ b/usr.sbin/ppp/Makefile @@ -1,11 +1,11 @@ -# $Id: Makefile,v 1.29 1997/11/09 06:22:37 brian Exp $ +# $Id: Makefile,v 1.30 1997/11/16 22:15:02 brian Exp $ PROG= ppp SRCS= alias_cmd.c arp.c async.c auth.c ccp.c chap.c chat.c \ command.c defs.c filter.c fsm.c hdlc.c id.c ip.c ipcp.c lcp.c \ loadalias.c log.c lqr.c main.c mbuf.c modem.c os.c pap.c phase.c \ - pred.c route.c server.c sig.c slcompress.c systems.c timer.c tun.c \ - vars.c vjcomp.c + pred.c route.c server.c sig.c slcompress.c systems.c throughput.c \ + timer.c tun.c vars.c vjcomp.c CFLAGS+=-Wall -Wmissing-prototypes LDADD+= -lmd -lcrypt -lutil DPADD+= ${LIBMD} ${LIBCRYPT} ${LIBUTIL} diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index 26cee11..ed27692 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.29 1997/11/12 21:04:21 brian Exp $ + * $Id: ip.c,v 1.30 1997/11/16 22:15:03 brian Exp $ * * TODO: * o Return ICMP message for filterd packet @@ -251,7 +251,7 @@ IcmpError(struct ip * pip, int code) memcpy(MBUF_CTOP(bp), ptr, cnt); SendPppFrame(bp); RestartIdleTimer(); - ipOutOctets += cnt; + IpcpAddOutOctets(cnt); } #endif } @@ -405,7 +405,7 @@ IpInput(struct mbuf * bp) pfree(bp); return; } - ipInOctets += nb; + IpcpAddInOctets(nb); nb = ntohs(((struct ip *) tun.data)->ip_len); nb += sizeof(tun)-sizeof(tun.data); @@ -450,7 +450,7 @@ IpInput(struct mbuf * bp) pfree(bp); return; } - ipInOctets += nb; + IpcpAddInOctets(nb); nb += sizeof(tun)-sizeof(tun.data); nw = write(tun_out, &tun, nb); if (nw != nb) @@ -509,7 +509,7 @@ IpStartOutput() cnt = plength(bp); SendPppFrame(bp); RestartIdleTimer(); - ipOutOctets += cnt; + IpcpAddOutOctets(cnt); break; } } diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index eaa5788..7f93f14 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.35 1997/11/11 22:58:11 brian Exp $ + * $Id: ipcp.c,v 1.36 1997/11/14 15:39:14 brian Exp $ * * TODO: * o More RFC1772 backwoard compatibility @@ -33,6 +33,7 @@ #include <limits.h> #include <stdio.h> #include <string.h> +#include <time.h> #include <unistd.h> #include "mbuf.h" @@ -51,6 +52,7 @@ #include "vars.h" #include "vjcomp.h" #include "ip.h" +#include "throughput.h" #ifndef NOMSEXT struct in_addr ns_entries[2]; @@ -62,7 +64,6 @@ struct in_range DefMyAddress; struct in_range DefHisAddress; struct in_addr TriggerAddress; int HaveTriggerAddress; -struct pppTimer IpcpReportTimer; static void IpcpSendConfigReq(struct fsm *); static void IpcpSendTerminateAck(struct fsm *); @@ -73,11 +74,6 @@ static void IpcpLayerFinish(struct fsm *); static void IpcpLayerUp(struct fsm *); static void IpcpLayerDown(struct fsm *); static void IpcpInitRestartCounter(struct fsm *); -static int IpcpOctetsIn(void); -static int IpcpOctetsOut(void); - -static int lastInOctets, lastOutOctets; -static int StartingIpIn, StartingIpOut; #define REJECTED(p, x) (p->his_reject & (1<<x)) @@ -126,32 +122,18 @@ static char *cftypes128[] = { #define NCFTYPES128 (sizeof(cftypes)/sizeof(char *)) -/* - * Function called every second. Updates connection period and idle period, - * also update LQR information. - */ -static void -IpcpReportFunc() +struct pppThroughput throughput; + +void +IpcpAddInOctets(int n) { - ipConnectSecs++; - if (lastInOctets == ipInOctets && lastOutOctets == ipOutOctets) - ipIdleSecs++; - lastInOctets = ipInOctets; - lastOutOctets = ipOutOctets; - StopTimer(&IpcpReportTimer); - IpcpReportTimer.state = TIMER_STOPPED; - StartTimer(&IpcpReportTimer); + throughput_addin(&throughput, n); } -static void -IpcpStartReport() +void +IpcpAddOutOctets(int n) { - ipIdleSecs = ipConnectSecs = 0; - StopTimer(&IpcpReportTimer); - IpcpReportTimer.state = TIMER_STOPPED; - IpcpReportTimer.load = SECTICKS; - IpcpReportTimer.func = IpcpReportFunc; - StartTimer(&IpcpReportTimer); + throughput_addout(&throughput, n); } int @@ -167,10 +149,6 @@ ReportIpcpStatus() inet_ntoa(icp->his_ipaddr), icp->his_compproto); fprintf(VarTerm, " my side: %s, %lx\n", inet_ntoa(icp->want_ipaddr), icp->want_compproto); - fprintf(VarTerm, "Connected: %d secs, idle: %d secs\n\n", - ipConnectSecs, ipIdleSecs); - fprintf(VarTerm, " %d octets in, %d octets out\n", - IpcpOctetsIn(), IpcpOctetsOut()); fprintf(VarTerm, "Defaults:\n"); fprintf(VarTerm, " My Address: %s/%d\n", @@ -182,6 +160,9 @@ ReportIpcpStatus() else fprintf(VarTerm, " Negotiation(trigger): MYADDR\n"); + fprintf(VarTerm, "\n"); + throughput_disp(&throughput, VarTerm); + return 0; } @@ -232,8 +213,7 @@ IpcpInit() icp->want_compproto = 0; icp->heis1172 = 0; IpcpFsm.maxconfig = 10; - StartingIpIn = ipInOctets; - StartingIpOut = ipOutOctets; + throughput_init(&throughput); } static void @@ -292,30 +272,12 @@ IpcpLayerFinish(struct fsm * fp) NewPhase(PHASE_TERMINATE); } -static int -IpcpOctetsIn() -{ - return ipInOctets < StartingIpIn ? - INT_MAX - StartingIpIn + ipInOctets - INT_MIN + 1 : - ipInOctets - StartingIpIn; -} - -static int -IpcpOctetsOut() -{ - return ipOutOctets < StartingIpOut ? - INT_MAX - StartingIpOut + ipOutOctets - INT_MIN + 1 : - ipOutOctets - StartingIpOut; -} - static void IpcpLayerDown(struct fsm * fp) { LogPrintf(LogIPCP, "IpcpLayerDown.\n"); - LogPrintf(LogIPCP, "%d octets in, %d octets out\n", - IpcpOctetsIn(), IpcpOctetsOut()); - StopTimer(&IpcpReportTimer); - Prompt(); + throughput_stop(&throughput); + throughput_log(&throughput, LogIPCP, NULL); } /* @@ -344,9 +306,7 @@ IpcpLayerUp(struct fsm * fp) if (mode & MODE_ALIAS) VarPacketAliasSetAddress(IpcpInfo.want_ipaddr); OsLinkup(); - StartingIpIn = ipInOctets; - StartingIpOut = ipOutOctets; - IpcpStartReport(); + throughput_start(&throughput); StartIdleTimer(); } diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h index 1b83bfc..598566c 100644 --- a/usr.sbin/ppp/ipcp.h +++ b/usr.sbin/ppp/ipcp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.h,v 1.11 1997/10/26 01:02:55 brian Exp $ + * $Id: ipcp.h,v 1.12 1997/10/26 12:42:11 brian Exp $ * * TODO: */ @@ -76,3 +76,5 @@ extern void IpcpUp(void); extern void IpcpOpen(void); extern int ReportIpcpStatus(void); extern void IpcpInput(struct mbuf *); +extern void IpcpAddInOctets(int); +extern void IpcpAddOutOctets(int); diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index c23c8dd..513dbfc 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.45 1997/11/14 15:39:15 brian Exp $ + * $Id: lcp.c,v 1.46 1997/11/16 22:15:04 brian Exp $ * * TODO: * o Validate magic number received from peer. @@ -332,7 +332,6 @@ static void StopAllTimers() { StopTimer(&LcpReportTimer); - StopTimer(&IpcpReportTimer); StopIdleTimer(); StopTimer(&AuthPapInfo.authtimer); StopTimer(&AuthChapInfo.authtimer); diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 585728b..67d0ee0 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.64 1997/11/09 14:18:48 brian Exp $ + * $Id: modem.c,v 1.65 1997/11/18 08:49:03 brian Exp $ * * TODO: */ @@ -55,6 +55,7 @@ #include "vars.h" #include "main.h" #include "chat.h" +#include "throughput.h" #ifdef __OpenBSD__ #include <util.h> #else @@ -76,6 +77,7 @@ static struct pppTimer ModemTimer; static struct mbuf *modemout; static struct mqueue OutputQueues[PRI_LINK + 1]; static int dev_is_modem; +static struct pppThroughput throughput; static void CloseLogicalModem(void); @@ -116,130 +118,80 @@ static struct speeds { } speeds[] = { #ifdef B50 - { - 50, B50, - }, + { 50, B50, }, #endif #ifdef B75 - { - 75, B75, - }, + { 75, B75, }, #endif #ifdef B110 - { - 110, B110, - }, + { 110, B110, }, #endif #ifdef B134 - { - 134, B134, - }, + { 134, B134, }, #endif #ifdef B150 - { - 150, B150, - }, + { 150, B150, }, #endif #ifdef B200 - { - 200, B200, - }, + { 200, B200, }, #endif #ifdef B300 - { - 300, B300, - }, + { 300, B300, }, #endif #ifdef B600 - { - 600, B600, - }, + { 600, B600, }, #endif #ifdef B1200 - { - 1200, B1200, - }, + { 1200, B1200, }, #endif #ifdef B1800 - { - 1800, B1800, - }, + { 1800, B1800, }, #endif #ifdef B2400 - { - 2400, B2400, - }, + { 2400, B2400, }, #endif #ifdef B4800 - { - 4800, B4800, - }, + { 4800, B4800, }, #endif #ifdef B9600 - { - 9600, B9600, - }, + { 9600, B9600, }, #endif #ifdef B19200 - { - 19200, B19200, - }, + { 19200, B19200, }, #endif #ifdef B38400 - { - 38400, B38400, - }, + { 38400, B38400, }, #endif #ifndef _POSIX_SOURCE #ifdef B7200 - { - 7200, B7200, - }, + { 7200, B7200, }, #endif #ifdef B14400 - { - 14400, B14400, - }, + { 14400, B14400, }, #endif #ifdef B28800 - { - 28800, B28800, - }, + { 28800, B28800, }, #endif #ifdef B57600 - { - 57600, B57600, - }, + { 57600, B57600, }, #endif #ifdef B76800 - { - 76800, B76800, - }, + { 76800, B76800, }, #endif #ifdef B115200 - { - 115200, B115200, - }, + { 115200, B115200, }, #endif #ifdef B230400 - { - 230400, B230400, - }, + { 230400, B230400, }, #endif #ifdef EXTA - { - 19200, EXTA, - }, + { 19200, EXTA, }, #endif #ifdef EXTB - { - 38400, EXTB, - }, + { 38400, EXTB, }, #endif #endif /* _POSIX_SOURCE */ - { - 0, 0 - } + { 0, 0 } }; static int @@ -268,9 +220,6 @@ IntToSpeed(int nspeed) return B0; } -static time_t uptime; -u_long OctetsIn, OctetsOut; - void DownConnection() { @@ -478,8 +427,7 @@ UnlockModem() static void HaveModem() { - time(&uptime); - OctetsIn = OctetsOut = 0; + throughput_start(&throughput); connect_count++; LogPrintf(LogPHASE, "Connected!\n"); } @@ -497,7 +445,6 @@ OpenModem() LogPrintf(LogDEBUG, "OpenModem: Modem is already open!\n"); /* We're going back into "term" mode */ else if (mode & MODE_DIRECT) { - HaveModem(); if (isatty(0)) { LogPrintf(LogDEBUG, "OpenModem(direct): Modem is a tty\n"); cp = ttyname(0); @@ -507,10 +454,12 @@ OpenModem() return -1; } modem = 0; + HaveModem(); } else { LogPrintf(LogDEBUG, "OpenModem(direct): Modem is not a tty\n"); SetVariable(0, 0, 0, VAR_DEVICE); /* We don't call ModemTimeout() with this type of connection */ + HaveModem(); return modem = 0; } } else { @@ -599,7 +548,6 @@ OpenModem() if (ioctl(modem, TIOCMGET, &mbits)) { LogPrintf(LogERROR, "OpenModem: Cannot get modem status: %s\n", strerror(errno)); - uptime = 0; CloseLogicalModem(); return (-1); } @@ -609,7 +557,6 @@ OpenModem() if (oldflag < 0) { LogPrintf(LogERROR, "OpenModem: Cannot get modem flags: %s\n", strerror(errno)); - uptime = 0; CloseLogicalModem(); return (-1); } @@ -674,28 +621,25 @@ UnrawModem() } } -void ModemAddInOctets(int n) +void +ModemAddInOctets(int n) { - OctetsIn += n; + throughput_addin(&throughput, n); } -void ModemAddOutOctets(int n) +void +ModemAddOutOctets(int n) { - OctetsOut += n; + throughput_addout(&throughput, n); } static void ClosePhysicalModem() { + LogPrintf(LogDEBUG, "ClosePhysicalModem\n"); close(modem); - if (uptime) { - LogPrintf(LogPHASE, "Connect time: %d secs\n", time(NULL) - uptime); - LogPrintf(LogPHASE, "Modem: %d octets in, %d octets out\n", - OctetsIn, OctetsOut); - OctetsIn = OctetsOut = 0; - uptime = 0; - } - modem = -1; /* Mark modem as closed */ + modem = -1; + throughput_log(&throughput, LogPHASE, "Modem"); } void @@ -703,13 +647,14 @@ HangupModem(int flag) { struct termios tio; - LogPrintf(LogDEBUG, "Hangup modem (%s), uptime %ld\n", - modem >= 0 ? "open" : "closed", (long)uptime); - StopTimer(&ModemTimer); + LogPrintf(LogDEBUG, "Hangup modem (%s)\n", modem >= 0 ? "open" : "closed"); if (modem < 0) return; + StopTimer(&ModemTimer); + throughput_stop(&throughput); + if (TermMode) { LogPrintf(LogDEBUG, "HangupModem: Not in 'term' mode\n"); return; @@ -735,6 +680,7 @@ HangupModem(int flag) char ScriptBuffer[SCRIPT_LEN]; strcpy(ScriptBuffer, VarHangupScript); /* arrays are the same size */ + LogPrintf(LogDEBUG, "HangupModem: Script: %s\n", ScriptBuffer); if (flag || !(mode & MODE_DEDICATED)) { DoChat(ScriptBuffer); tcflush(modem, TCIOFLUSH); @@ -755,6 +701,7 @@ HangupModem(int flag) static void CloseLogicalModem() { + LogPrintf(LogDEBUG, "CloseLogicalModem\n"); if (modem >= 0) { ClosePhysicalModem(); if (Utmp) { @@ -958,5 +905,8 @@ ShowModemStatus() fprintf(VarTerm, "LoginScript = %s\n", VarLoginScript); fprintf(VarTerm, "PhoneNumber(s) = %s\n", VarPhoneList); + fprintf(VarTerm, "\n"); + throughput_disp(&throughput, VarTerm); + return 0; } diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 1561680..949e5df 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.78 1997/11/11 22:58:12 brian Exp $ +.\" $Id: ppp.8,v 1.79 1997/11/14 20:07:39 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -1548,16 +1548,10 @@ means that the option will not be requested by us. may be one of the following: .Bl -tag -width 20 -.It vjcomp -Default: Enabled and Accepted. This option decides if Van Jacobson -header compression will be used. - -.It lqr -Default: Disabled and Accepted. This option decides if Link Quality -Requests will be sent. LQR is a protocol that allows -.Nm -to determine that the link is down without relying on the modems -carrier detect. +.It acfcomp +Default: Enabled and Accepted. ACFComp stands for Address and Control +Field Compression. Non LCP packets usually have very similar address +and control fields - making them easily compressible. .It chap Default: Disabled and Accepted. CHAP stands for Challenge Handshake @@ -1593,6 +1587,20 @@ challenge. Refer to the description of the .Dq set encrypt command for further details. +.It lqr +Default: Disabled and Accepted. This option decides if Link Quality +Requests will be sent. LQR is a protocol that allows +.Nm +to determine that the link is down without relying on the modems +carrier detect. + +.It msext +Default: Disabled. This option allows the use of Microsoft's +.Em PPP +extensions, supporting the negotiation of the DNS and the NetBIOS NS. +Enabling this allows us to pass back the values given in "set ns" +and "set nbns". + .It pap Default: Disabled and Accepted. PAP stands for Password Authentication Protocol. Only one of PAP and CHAP (above) may be negotiated. With @@ -1619,37 +1627,25 @@ in .Pa /etc/ppp/ppp.conf . PAP is accepted by default. -.It acfcomp -Default: Enabled and Accepted. ACFComp stands for Address and Control -Field Compression. Non LCP packets usually have very similar address -and control fields - making them easily compressible. +.It pred1 +Default: Enabled and Accepted. This option decides if Predictor 1 +compression will be used. .It protocomp Default: Enabled and Accepted. This option is used to negotiate PFC (Protocol Field Compression), a mechanism where the protocol field number is reduced to one octet rather than two. -.It pred1 -Default: Enabled and Accepted. This option decides if Predictor 1 -compression will be used. - -.It msext -Default: Disabled. This option allows the use of Microsoft's -.Em PPP -extensions, supporting the negotiation of the DNS and the NetBIOS NS. -Enabling this allows us to pass back the values given in "set ns" -and "set nbns". - +.It vjcomp +Default: Enabled and Accepted. This option decides if Van Jacobson +header compression will be used. .El + +.Pp The following options are not actually negotiated with the peer. Therefore, accepting or denying them makes no sense. .Bl -tag -width 20 -.It proxy -Default: Disabled. Enabling this option will tell -.Nm -to proxy ARP for the peer. - .It passwdauth Default: Disabled. Enabling this option will tell the PAP authentication code to use the password file (see @@ -1658,6 +1654,26 @@ to authenticate the caller rather than the .Pa /etc/ppp/ppp.secret file. +.It proxy +Default: Disabled. Enabling this option will tell +.Nm +to proxy ARP for the peer. + +.It throughput +Default: Disabled. Enabling this option will tell +.Nm +to gather thoroughput statistics. Input and output is sampled over +a rolling 5 second window, and current, best and total figures are +retained. This data is output when the relevent +.Em PPP +layer shuts down, and is also available using the +.Dq show +command. Troughput statistics are available at the +.Dq IPCP +and +.Dq modem +levels. + .It utmp Default: Enabled. Normally, when a user is authenticated using PAP or CHAP, and when diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index 1561680..949e5df 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.78 1997/11/11 22:58:12 brian Exp $ +.\" $Id: ppp.8,v 1.79 1997/11/14 20:07:39 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -1548,16 +1548,10 @@ means that the option will not be requested by us. may be one of the following: .Bl -tag -width 20 -.It vjcomp -Default: Enabled and Accepted. This option decides if Van Jacobson -header compression will be used. - -.It lqr -Default: Disabled and Accepted. This option decides if Link Quality -Requests will be sent. LQR is a protocol that allows -.Nm -to determine that the link is down without relying on the modems -carrier detect. +.It acfcomp +Default: Enabled and Accepted. ACFComp stands for Address and Control +Field Compression. Non LCP packets usually have very similar address +and control fields - making them easily compressible. .It chap Default: Disabled and Accepted. CHAP stands for Challenge Handshake @@ -1593,6 +1587,20 @@ challenge. Refer to the description of the .Dq set encrypt command for further details. +.It lqr +Default: Disabled and Accepted. This option decides if Link Quality +Requests will be sent. LQR is a protocol that allows +.Nm +to determine that the link is down without relying on the modems +carrier detect. + +.It msext +Default: Disabled. This option allows the use of Microsoft's +.Em PPP +extensions, supporting the negotiation of the DNS and the NetBIOS NS. +Enabling this allows us to pass back the values given in "set ns" +and "set nbns". + .It pap Default: Disabled and Accepted. PAP stands for Password Authentication Protocol. Only one of PAP and CHAP (above) may be negotiated. With @@ -1619,37 +1627,25 @@ in .Pa /etc/ppp/ppp.conf . PAP is accepted by default. -.It acfcomp -Default: Enabled and Accepted. ACFComp stands for Address and Control -Field Compression. Non LCP packets usually have very similar address -and control fields - making them easily compressible. +.It pred1 +Default: Enabled and Accepted. This option decides if Predictor 1 +compression will be used. .It protocomp Default: Enabled and Accepted. This option is used to negotiate PFC (Protocol Field Compression), a mechanism where the protocol field number is reduced to one octet rather than two. -.It pred1 -Default: Enabled and Accepted. This option decides if Predictor 1 -compression will be used. - -.It msext -Default: Disabled. This option allows the use of Microsoft's -.Em PPP -extensions, supporting the negotiation of the DNS and the NetBIOS NS. -Enabling this allows us to pass back the values given in "set ns" -and "set nbns". - +.It vjcomp +Default: Enabled and Accepted. This option decides if Van Jacobson +header compression will be used. .El + +.Pp The following options are not actually negotiated with the peer. Therefore, accepting or denying them makes no sense. .Bl -tag -width 20 -.It proxy -Default: Disabled. Enabling this option will tell -.Nm -to proxy ARP for the peer. - .It passwdauth Default: Disabled. Enabling this option will tell the PAP authentication code to use the password file (see @@ -1658,6 +1654,26 @@ to authenticate the caller rather than the .Pa /etc/ppp/ppp.secret file. +.It proxy +Default: Disabled. Enabling this option will tell +.Nm +to proxy ARP for the peer. + +.It throughput +Default: Disabled. Enabling this option will tell +.Nm +to gather thoroughput statistics. Input and output is sampled over +a rolling 5 second window, and current, best and total figures are +retained. This data is output when the relevent +.Em PPP +layer shuts down, and is also available using the +.Dq show +command. Troughput statistics are available at the +.Dq IPCP +and +.Dq modem +levels. + .It utmp Default: Enabled. Normally, when a user is authenticated using PAP or CHAP, and when diff --git a/usr.sbin/ppp/throughput.c b/usr.sbin/ppp/throughput.c new file mode 100644 index 0000000..d356709 --- /dev/null +++ b/usr.sbin/ppp/throughput.c @@ -0,0 +1,126 @@ +/* + * $Id$ + */ + +#include <sys/param.h> + +#include <stdio.h> +#include <time.h> +#include <netinet/in.h> + +#include "timer.h" +#include "throughput.h" +#include "defs.h" +#include "loadalias.h" +#include "command.h" +#include "vars.h" +#include "mbuf.h" +#include "log.h" + +void +throughput_init(struct pppThroughput *t) +{ + int f; + + t->OctetsIn = t->OctetsOut = 0; + for (f = 0; f < SAMPLE_PERIOD; f++) + t->SampleOctets[f] = 0; + t->OctetsPerSecond = t->BestOctetsPerSecond = t->nSample = 0; + throughput_stop(t); +} + +void +throughput_disp(struct pppThroughput *t, FILE *f) +{ + int secs_up; + + secs_up = time(NULL) - t->uptime; + fprintf(f, "Connect time: %d secs\n", secs_up); + if (secs_up == 0) + secs_up = 1; + fprintf(f, "%ld octets in, %ld octets out\n", t->OctetsIn, t->OctetsOut); + if (Enabled(ConfThroughput)) { + fprintf(f, " overall %5ld bytes/sec\n", + (t->OctetsIn+t->OctetsOut)/secs_up); + fprintf(f, " currently %5d bytes/sec\n", t->OctetsPerSecond); + fprintf(f, " peak %5d bytes/sec\n", t->BestOctetsPerSecond); + } else + fprintf(f, "Overall %ld bytes/sec\n", (t->OctetsIn+t->OctetsOut)/secs_up); +} + + +void +throughput_log(struct pppThroughput *t, int level, const char *title) +{ + if (t->uptime) { + int secs_up; + + secs_up = time(NULL) - t->uptime; + if (title) + LogPrintf(level, "%s: Connect time: %d secs: %ld octets in, %ld octets" + " out\n", title, secs_up, t->OctetsIn, t->OctetsOut); + else + LogPrintf(level, "Connect time: %d secs: %ld octets in, %ld octets out\n", + secs_up, t->OctetsIn, t->OctetsOut); + if (secs_up == 0) + secs_up = 1; + if (Enabled(ConfThroughput)) + LogPrintf(level, " total %ld bytes/sec, peak %d bytes/sec\n", + (t->OctetsIn+t->OctetsOut)/secs_up, t->BestOctetsPerSecond); + else + LogPrintf(level, " total %ld bytes/sec\n", + (t->OctetsIn+t->OctetsOut)/secs_up); + } +} + +static void +throughput_sampler(struct pppThroughput *t) +{ + u_long old; + + StopTimer(&t->Timer); + t->Timer.state = TIMER_STOPPED; + + old = t->SampleOctets[t->nSample]; + t->SampleOctets[t->nSample] = t->OctetsIn + t->OctetsOut; + t->OctetsPerSecond = (t->SampleOctets[t->nSample] - old) / SAMPLE_PERIOD; + if (t->BestOctetsPerSecond < t->OctetsPerSecond) + t->BestOctetsPerSecond = t->OctetsPerSecond; + if (++t->nSample == SAMPLE_PERIOD) + t->nSample = 0; + + StartTimer(&t->Timer); +} + +void +throughput_start(struct pppThroughput *t) +{ + throughput_init(t); + time(&t->uptime); + if (Enabled(ConfThroughput)) { + t->Timer.state = TIMER_STOPPED; + t->Timer.load = SECTICKS; + t->Timer.func = throughput_sampler; + t->Timer.arg = t; + StartTimer(&t->Timer); + } +} + +void +throughput_stop(struct pppThroughput *t) +{ + if (Enabled(ConfThroughput)) + StopTimer(&t->Timer); +} + +void +throughput_addin(struct pppThroughput *t, int n) +{ + t->OctetsIn += n; +} + +void +throughput_addout(struct pppThroughput *t, int n) +{ + t->OctetsOut += n; +} diff --git a/usr.sbin/ppp/throughput.h b/usr.sbin/ppp/throughput.h new file mode 100644 index 0000000..907f224 --- /dev/null +++ b/usr.sbin/ppp/throughput.h @@ -0,0 +1,24 @@ +/* + * $Id$ + */ + +#define SAMPLE_PERIOD 5 + +struct pppThroughput { + time_t uptime; + u_long OctetsIn; + u_long OctetsOut; + u_long SampleOctets[SAMPLE_PERIOD]; + int OctetsPerSecond; + int BestOctetsPerSecond; + int nSample; + struct pppTimer Timer; +}; + +extern void throughput_init(struct pppThroughput *); +extern void throughput_disp(struct pppThroughput *, FILE *); +extern void throughput_log(struct pppThroughput *, int, const char *); +extern void throughput_start(struct pppThroughput *); +extern void throughput_stop(struct pppThroughput *); +extern void throughput_addin(struct pppThroughput *, int); +extern void throughput_addout(struct pppThroughput *, int); diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 35c5287..7b6953a 100644 --- a/usr.sbin/ppp/vars.c +++ b/usr.sbin/ppp/vars.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.c,v 1.33 1997/11/09 22:07:29 brian Exp $ + * $Id: vars.c,v 1.34 1997/11/11 22:58:14 brian Exp $ * */ #include <sys/param.h> @@ -40,7 +40,7 @@ #include "defs.h" char VarVersion[] = "PPP Version 1.4"; -char VarLocalVersion[] = "$Date: 1997/11/09 22:07:29 $"; +char VarLocalVersion[] = "$Date: 1997/11/11 22:58:14 $"; int Utmp = 0; int ipInOctets = 0; int ipOutOctets = 0; @@ -65,6 +65,7 @@ struct confdesc pppConfs[] = { {"msext", CONF_DISABLE, CONF_NONE}, {"passwdauth", CONF_DISABLE, CONF_NONE}, {"utmp", CONF_ENABLE, CONF_NONE}, + {"throughput", CONF_DISABLE, CONF_NONE}, {NULL}, }; diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index 3e205da..26f3910 100644 --- a/usr.sbin/ppp/vars.h +++ b/usr.sbin/ppp/vars.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.h,v 1.32 1997/11/09 14:18:55 brian Exp $ + * $Id: vars.h,v 1.33 1997/11/09 22:07:29 brian Exp $ * * TODO: */ @@ -43,7 +43,8 @@ struct confdesc { #define ConfMSExt 8 #define ConfPasswdAuth 9 #define ConfUtmp 10 -#define MAXCONFS 11 +#define ConfThroughput 11 +#define MAXCONFS 12 #define Enabled(x) (pppConfs[x].myside & CONF_ENABLE) #define Acceptable(x) (pppConfs[x].hisside & CONF_ACCEPT) |