%include "inc:util.imp"
%include "inc:fs.imp"
%begin
%recordformat pf(%byte ds,dp,%integer dn,
                 %byte ss,sp,%integer sn,
                 %byte type,seq,%bytearray b(1:999))
%record(pf)p
%integer multi=0,data=0,acks=0,other=0,t
%constinteger dtype=16_01,atype=16_81

  t = cputime+1000; %cycle; %repeatuntil cputime>t
  twait; ethc = 7
  twait; ethd = 16_80
  twait; ethc = 2

  %cycle
    %if dtx&1#0 %start
      t = etherread(0,p_ds,999)
      %if p_type=dtype %start
        phex2(p_ds); space; phex2(p_ss)
        write(t,3); newline
      %finish
      multi = multi+1 %if p_ds=0
      %if p_type=dtype %then data = data+1 %else-
      %if p_type=atype %then acks = acks+1 %else-
                             other = other+1
    %finish
  %repeatuntil testsymbol>=0

  printstring("Data="); write(data,0)
  printstring(", Acks="); write(acks,0)
  printstring(", Other="); write(other,0)
  printstring(", Multi="); write(multi,0); newline

  eths = 16_40
  eths = 6
  etheropen(lsap,rdte<<8+rsap)
%end
