EtherTesterStatsImpl.mesa
Last Edited by: Willie-Sue, January 10, 1986 4:18:36 pm PST
lifted from EtherTesterStats.mesa, HGM, 19-Dec-81 12:45:31
DIRECTORY
BasicTime USING [Pulses, GetClockPulses, PulsesToMicroseconds],
EtherTesterOps USING [tsOut, Stats, counter],
IO,  -- using lots;
Rope USING [ROPE];
EtherTesterStatsImpl: MONITOR
IMPORTS BasicTime, EtherTesterOps, IO
EXPORTS EtherTesterOps =
BEGIN
Global Data
stats: PUBLIC EtherTesterOps.Stats;
realBackground: PUBLIC LONG CARDINAL;
Private Data
oldPulses: BasicTime.Pulses;
elapsedTime, recentTime: LONG CARDINAL; -- in mili seconds
leftoverMicroseconds: LONG CARDINAL;
StatsInit: PUBLIC PROC =
BEGIN
stats ← [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0];
oldPulses ← BasicTime.GetClockPulses[];
elapsedTime ← recentTime ← leftoverMicroseconds ← 0;
realBackground ← EtherTesterOps.counter[7] ← 1;
END;
StatsPeek: PUBLIC PROC =
BEGIN
StatsUpdateClock[];
IF recentTime > 3600000 THEN
BEGIN StatsPrint[TRUE]; recentTime ← recentTime - 3600000; END;
END;
StatsUpdateClock: ENTRY PROC = { StatsClock[] };
StatsClock: INTERNAL PROC =
BEGIN
now: BasicTime.Pulses ← BasicTime.GetClockPulses[];
microSec, milliSec: LONG CARDINAL;
EtherTesterOps.counter[7] ← realBackground ← realBackground + 1;
microSec ←
leftoverMicroseconds + BasicTime.PulsesToMicroseconds[now - oldPulses];
IF microSec < 1000000 THEN RETURN;
oldPulses ← now;
milliSec ← microSec/1000;
elapsedTime ← elapsedTime + milliSec;
recentTime ← recentTime + milliSec;
leftoverMicroseconds ← microSec - (milliSec*1000);
END;
StatsPrint: PUBLIC ENTRY PROC[partial: BOOL] =
BEGIN OPEN IO;
log: STREAM← EtherTesterOps.tsOut;
StatsClock[];
log.PutF[NIL, time[]];
log.PutRope[
IF partial THEN " The time so far is " ELSE " This run lasted "];
log.PutF[NIL, card[elapsedTime/1000]];
log.PutRope[" seconds.\nIt took "];
log.PutF[NIL, card[elapsedTime/realBackground]];
log.PutRope[" ms/background cycle.\n"];
IF PrintLine[stats.pktsOut, "Packets Sent OK"] THEN stats.pktsOut ← 0;
IF PrintLine[stats.wdsOut, "Words Sent"] THEN stats.wdsOut ← 0;
IF PrintLine[stats.collisions, "Collisions"] THEN stats.collisions ← 0;
IF PrintLine[stats.coll1, "Packets with 1 collision"] THEN stats.coll1 ← 0;
IF PrintLine[stats.coll2, "Packets with 2 collisions"] THEN stats.coll2 ← 0;
IF PrintLine[stats.coll3, "Packets with 3 collisions"] THEN stats.coll3 ← 0;
IF PrintLine[stats.coll4, "Packets with 4 collisions"] THEN stats.coll4 ← 0;
IF PrintLine[stats.coll5, "Packets with 5 collisions"] THEN stats.coll5 ← 0;
IF PrintLine[stats.coll6, "Packets with 6 collisions"] THEN stats.coll6 ← 0;
IF PrintLine[stats.coll7, "Packets with 7 collisions"] THEN stats.coll7 ← 0;
IF PrintLine[stats.coll8, "Packets with 8 collisions"] THEN stats.coll8 ← 0;
IF PrintLine[stats.coll9, "Packets with 9 collisions"] THEN stats.coll9 ← 0;
IF PrintLine[stats.coll10, "Packets with 10 collisions"] THEN stats.coll10 ← 0;
IF PrintLine[stats.coll11, "Packets with 11 collisions"] THEN stats.coll11 ← 0;
IF PrintLine[stats.coll12, "Packets with 12 collisions"] THEN stats.coll12 ← 0;
IF PrintLine[stats.coll13, "Packets with 13 collisions"] THEN stats.coll13 ← 0;
IF PrintLine[stats.coll14, "Packets with 14 collisions"] THEN stats.coll14 ← 0;
IF PrintLine[stats.coll15, "Packets with 15 collisions"] THEN stats.coll15 ← 0;
IF PrintLine[stats.collx, "Packets with funny collision mask ******"] THEN stats.collx ← 0;
IF PrintLine[stats.loadOverflow, "Packets with too many collisions"]
THEN stats.loadOverflow ← 0;
IF PrintLine[stats.lateCollisions, "Late collisions ******"] THEN stats.lateCollisions ← 0;
IF PrintLine[stats.errsOut, "Errors from Transmitter"] THEN stats.errsOut ← 0;
IF PrintLine[stats.funnyOut, "Funny Output Errors ******"] THEN stats.funnyOut ← 0;
IF PrintLine[stats.overrunOut, "Output overruns"] THEN stats.overrunOut ← 0;
[] ← PrintLine[Mpp[stats.pktsOut], "Microsec/Pkt Sent"];
[] ← PrintLine[BitsPerSecond[stats.wdsOut], "Bits/Sec Sent"];
IF PrintLine[stats.pktsIn, "Packets Received OK"] THEN stats.pktsIn ← 0;
IF PrintLine[stats.wdsIn, "Words Received"] THEN stats.wdsIn ← 0;
IF PrintLine[stats.wrongLength, "Packets received with wrong length **"]
THEN stats.wrongLength ← 0;
IF PrintLine[stats.wrongPackets, "Packets received with at least one wrong word **"]
THEN stats.wrongPackets ← 0;
IF PrintLine[stats.wrongWords, "Wrong words received **"] THEN stats.wrongWords ← 0;
IF PrintLine[stats.missed, "Input packets missed (no buffer)"] THEN stats.missed ← 0;
IF PrintLine[stats.errsIn, "Errors from Receiver"] THEN stats.errsIn ← 0;
IF PrintLine[stats.funnyIn, "Funny Input Errors ******"] THEN stats.funnyIn ← 0;
IF PrintLine[stats.shortIn, "Short Packets ******"] THEN stats.shortIn ← 0;
IF PrintLine[stats.longIn, "Long Packets ******"] THEN stats.longIn ← 0;
IF PrintLine[stats.shortBuffer, "Buffer Overflow ******"] THEN stats.shortBuffer ← 0;
IF PrintLine[stats.itIn, "Input IT only errors ******"] THEN stats.itIn ← 0;
IF PrintLine[stats.crcIn, "Input CRC errors"] THEN stats.crcIn ← 0;
IF PrintLine[stats.crcItIn, "Input CRC+IT errors"] THEN stats.crcItIn ← 0;
IF PrintLine[stats.overrunIn, "Input overruns"] THEN stats.overrunIn ← 0;
IF PrintLine[stats.bc, "Broadcast packets Received"] THEN stats.bc ← 0;
IF PrintLine[stats.bcWords, "Words in Broadcast packets"] THEN stats.bcWords ← 0;
IF PrintLine[stats.toMe, "Packets to ME"] THEN stats.toMe ← 0;
IF PrintLine[stats.toOther, "Packets to somebody else"] THEN stats.toOther ← 0;
IF PrintLine[stats.fromMe, "Packets from ME"] THEN stats.fromMe ← 0;
IF PrintLine[stats.packetsEchoed, "Packets Echoed"] THEN stats.packetsEchoed ← 0;
IF PrintLine[stats.packetsNotEchoed, "Packets Not Echoed (no output buffer)"]
THEN stats.packetsNotEchoed ← 0;
IF PrintLine[stats.lateEchos, "Late Echo Packets ****"] THEN stats.lateEchos ← 0;
IF PrintLine[stats.packetsTooLongToEcho, "Packets Too Long To Echo ****"]
THEN stats.packetsTooLongToEcho ← 0;
IF PrintLine[stats.echosMissed, "Echos Missed"] THEN stats.echosMissed ← 0;
IF PrintLine[stats.dallyForEcho, "Dallys for Echo"] THEN stats.dallyForEcho ← 0;
IF PrintLine[stats.runts, "Runts"] THEN stats.runts ← 0;
IF PrintLine[stats.runtsMarkedOk, "Runts marked OK *****"]
THEN stats.runtsMarkedOk ← 0;
IF PrintLine[stats.multicastRunts, "Runts via mullticast"] THEN stats.multicastRunts ← 0;
[] ← PrintLine[Mpp[stats.pktsIn], "Microsec/Pkt Received"];
[] ← PrintLine[BitsPerSecond[stats.wdsIn], "Bits/Sec Received"];
log.PutChar['\n];
END;
PrintLine: PROC[one: LONG CARDINAL, name: Rope.ROPE] RETURNS[nonZero: BOOL] =
BEGIN
IF one = 0 THEN RETURN[FALSE];
EtherTesterOps.tsOut.PutF[" %g %g\n", IO.card[one], IO.rope[name]];
RETURN[TRUE];
END;
BitsPerSecond: PROC[wd: LONG CARDINAL] RETURNS [LONG CARDINAL] =
BEGIN
t: LONG CARDINAL;
IF elapsedTime < 1000 THEN RETURN[0];
SELECT wd FROM
< 100000000 => { t ← 16*wd; RETURN[t/(elapsedTime/1000)] };
ENDCASE => { t ← wd/(elapsedTime/1000); RETURN[16*t] };
END;
Mpp: PROC[packets: LONG CARDINAL] RETURNS [LONG CARDINAL] =
BEGIN
t, p: LONG CARDINAL;
IF packets = 0 THEN RETURN[0];
SELECT elapsedTime FROM
< 2000000 => { t ← elapsedTime*1000; p ← packets };
ENDCASE => { t ← elapsedTime; p ← packets/1000; IF p = 0 THEN RETURN[0] };
RETURN[t/p];
END;
END.