
! Common formats for (Moose) INet process, GDMR, Jan. 1988

%include "Moose:Mouse.Inc"

! Ether address format

%recordformat ether address fm(%bytearray x(0 : 5))
%recordformat ether addresses fm(%record(ether address fm) destination,
                                 %record(ether address fm) source,
                                 %short protocol type)


! Counters, etc that aren't held on a per-peer basis.  Includes ether I/O
! and errors, and mailbox I/O and errors

%ownstring(31) non peer name = "INET__NON-PEER_TABLE"

%recordformat non peer info fm(%integer ether packets in, ether bytes in,
                               %integer ether m packets in, ether m bytes in,
                               %integer ether errors in,
                               %integer ether packets out, ether bytes out,
                               %integer ether errors out,
                               %integer ARP in, ARP errors in,
                               %integer ARP out, ARP errors out,
                               %integer ARP responses, ARP timeouts,
                               %integer IP checksum errors,
                               %integer mailbox packets in, mailbox bytes in,
                               %integer mailbox errors in,
                               %integer mailbox packets out, mailbox bytes out,
                               %integer mailbox errors out,
                               %integer mailbox attaches, mailbox duplicate attaches,
                               %integer mailbox detaches, mailbox redundant detaches,
                               %integer mailbox no slots, mailbox unknown user,
                               %integer mailbox gone away,
                               %integer buffer high water, buffers in use)

%constinteger non peer size = 32 {ether}     + %c
                              24 {ARP}       + %c
                               4 {IP}        + %c
                              52 {mailboxes} + %c
                               8 {buffers}


! Peer information tables: constants and formats

%conststring(31) peer table name = "INET__PEER_TABLE"

%constinteger peer slots = 64

%constinteger peer statistics = 54

%recordformat peer info fm(%integer address,
                           %record(ether address fm) ether address,
                           %record(peer info fm)%name gateway,
                           %integer flags,
                           ((%integer ARP in, ARP for us,
                             %integer ARP for old broadcast, ARP for new broadcast,
                             %integer ARP out,
                             %integer IP packets in, IP bytes in,
                             %integer IP old broadcasts, IP new broadcasts,
                             %integer IP fragmented packets, IP dud lengths,
                             %integer IP dud protocols, IP other errors,
                             %integer IP packets out, IP bytes out,
                             %integer ICMP in, ICMP errors in,
                             %integer ICMP broadcasts,
                             %integer ICMP out, ICMP errors out,
                             %integer TCP packets in, TCP bytes in,
                             %integer TCP packets out, TCP bytes out,
                             %integer TCP bogus addresses,
                             %integer TCP checksum errors, TCP for closed,
                             %integer TCP resets received, TCP junk received,
                             %integer TCP SYNs received, TCP FINs received,
                             %integer TCP good ACKs received,
                             %integer TCP old ACKs received, TCP dud ACKs received,
                             %integer TCP window updates,
                             %integer TCP connections established,
                             %integer TCP connections reset,
                             %integer TCP connections closed,
                             %integer TCP acceptable segments,
                             %integer TCP unacceptable segments,
                             %integer TCP ahead segments,
                             %integer TCP duplicate bytes,
                             %integer TCP data bytes received,
                             %integer TCP data bytes sent,
                             %integer TCP retransmits, TCP retransmit timeouts,
                             %integer UDP packets in, UDP bytes in,
                             %integer UDP checksum errors, UDP no checksums,
                             %integer UDP bogus checksums, UDP other errors,
                             %integer UDP packets out, UDP bytes out) %or %c
                            %integerarray x(1 : peer statistics)))
! Ether removed to non-peer stats page.  Some "duplicate" ARP logging
! there too...

%constinteger peer info size = 14 {addresses}   + %c
                                4 {flags}       + %c
                               20 {ARP}         + %c
                               40 {IP}          + %c
                               20 {ICMP}        + %c
                              104 {TCP}         + %c
                               32 {UDP}

%constinteger peer ether address known = 1
%constinteger peer gated               = 2

%recordformat peer table fm(%integer slots used,
                            %record(peer info fm)%array slot(1 : peer slots))
%constinteger peer table size = peer info size * peer slots + 4


! IP/ICMP/UDP/TCP/ARP header formats and constants

%recordformat IP header fm(%byte IHL,                { includes version }
                           %byte type of service,
                           %short total length,
                           %short identification,
                           %short fragment offset,   { includes flags }
                           %byte TTL,
                           %byte protocol,
                           %short checksum,
                           %integer source,
                           %integer destination,
                           %bytearray options(1 : 8))
%constinteger IP header size = 20;  ! Not including options

%constintegerarray new broadcast mask('@' : 'C') =
      16_00000000, 16_00FFFFFF, 16_0000FFFF, 16_000000FF

%constinteger IP ICMP protocol = 1
%constinteger IP TCP  protocol = 6
%constinteger IP UDP  protocol = 17

%recordformat TCP header fm(%short source, destination,
                            %integer seq,
                            %integer ack,
                            %byte data offset,
                            %byte flags,
                            %short window,
                            %short checksum,
                            %short urgent,
                            %integer options)
%constinteger TCP header size = 20;  ! Not including options

%constinteger FIN bit = 2_000001
%constinteger SYN bit = 2_000010
%constinteger RST bit = 2_000100
%constinteger PSH bit = 2_001000
%constinteger ACK bit = 2_010000
%constinteger URG bit = 2_100000

%constinteger TCP define max segment = 2

%recordformat UDP header fm(%short source,
                            %short destination,
                            %short length,
                            %short checksum)

%recordformat ICMP header fm(%byte type,
                             %byte code,
                             %short checksum,
                             ((%short identifier,
                               %short sequence number) %c
                          %or %integer gateway address),
                             (%integer originate timestamp,
                              %integer receive timestamp,
                              %integer transmit timestamp))

%recordformat ARP fm(%short format,
                     %short protocol,
                     %byte hardware length,
                     %byte protocol length,
                     %short op,
                     %record(ether address fm) source hardware,
                     %integer source protocol,
                     %record(ether address fm) target hardware,
                     %integer target protocol,
                     %string(47) padding)

%constinteger ARP ether protocol = 1
%constinteger ARP IP type        = 16_0800
%constinteger ARP request code   = 1
%constinteger ARP reply   code   = 2


! TCP TCB format & constants

%constinteger max TCB table = 128;  ! Upper bound only
%ownstring(31) TCB table name = "INET__TCB_TABLE"

%constinteger time wait timeout = 12000;  ! msecs

%constinteger TCP initial receive window  = 2048
%constinteger TCP unspecified mrss        = 1023;  ! For compatibility
%constinteger TCP default mrss            = 1023

%recordformat TCB fm(%integer remote address, remote port, local port,
                     %integer slot,
                     %record(peer info fm)%name peer info,
                     %integer ISS, IRS, FIN seq,
                     %integer snd una, snd nxt, snd up,
                     %integer snd wnd, snd wl1, snd wl2,
                     %integer rcv nxt, rcv wnd, rcv up,
                     %integer state, previous state, state change stamp,
                     %integer ack pending, blocked send,
                     %record(queue fm) blocked send queue,
                     %record(queue fm) retransmit queue,
                     %record(queue fm) Xpending retransmit queue,
                     %record(queue fm) reordering queue,
                     %record(queue fm) state change queue,
                     %integer retransmit timer, retransmit timeout,
                     %integer round trip timer,
                     %integer mrss, mtss)
! retransmit timer    contains stamp when packet was sent
! retransmit timeout  contains offset for when retransmission is required
%constinteger TCB size = 12 + 4 + 4 + 12 + 24 + 12 + 12 + 8 + 5 * 16 + 8 + 4 + 8

%recordformat TCB table fm(%record(TCB fm)%array TCB(1 : max TCB table))

! TCP states (**NB order important**)
%constinteger TCP closed         = 0
%constinteger TCP listen         = 1
%constinteger TCP syn sent       = 2
%constinteger TCP syn received   = 3
%constinteger TCP established    = 4
%constinteger TCP fin wait 1     = 5
%constinteger TCP fin wait 2     = 6
%constinteger TCP close wait     = 7
! States from here on are ignored for (implied) ABORT requests
%constinteger TCP closing        = 8
%constinteger TCP last ack       = 9
%constinteger TCP time wait      = 10

%conststring(15)%array TCP state name(TCP closed : TCP time wait) =
   "closed",
   "listen",
   "syn sent",
   "syn received",
   "established",
   "fin wait 1",
   "fin wait 2",
   "close wait",
   "closing",
   "last ack",
   "time wait"

%constinteger RTT a = 800, RTT a denominator = 1000
%constinteger RTT b = 130, RTT b denominator = 100

%constinteger TCP initial RTT =  150;  ! msecs

%constinteger TCP reTX lbound =  100;  ! msecs
%constinteger TCP reTX ubound = 1500;  ! msecs


! UDP tables: format and constants

%constinteger UDP table entries = 64

%ownstring(31) UDP table name = "INET__UDP_TABLES"

%recordformat UDP entry fm(%integer slot,
                           %record(peer info fm)%name peer info,
                           %integer remote address, remote port, local port)
%constinteger UDP entry size = 4 + 4 + 12

%recordformat UDP table fm(%c
   %record(UDP entry fm)%array UDP(1 : UDP table entries))
%constinteger UDP table size = UDP entry size * UDP table entries


! <<<<<<<<<<<<<<<<<<

%recordformat IOSB fm(%integer a, b);  !<<<<<<<<<<<<<<<<<<<<<


! Internal buffer format and constants

%recordformat buffer fm(%record(queue fm) q,
                        %record(IOSB fm) IOSB,
                        %record(ether addresses fm) ether addrs,
                        %integer IP peer, protocol, ARP lives, seq, flags,
                        %integer stamp, life, interval,
                        %record(peer info fm)%name p,
                        %integer privilege,
                        %record(queue fm)%name next queue,
                        (%record(TCB fm)%name TCB %c
                         %or %record(UDP entry fm)%name UDP entry),
                        %integer tag, acceptable,
                        %integer code, bytes, IP bytes, data bytes,
                        (%record(IP header fm)%name IP header %or %c
                         %record(ARP fm)%name ARP packet),
                        (%record(*)%name header2 %or %c
                         %record(TCP header fm)%name TCP header %or %c
                         %record(UDP header fm)%name UDP header %or %c
                         %record(ICMP header fm)%name ICMP header),
                        %bytename data start,
                        %bytearray data(0 : 1499))
%constinteger buffer size = 16 + 8 + 14 + 20 + 12 + 4 + 4 + 4 + 4 + 8 + %c
                            16 + 4 + 4 + 4 + 1500
%constinteger copy or clear = buffer size - 1500 + 128

%constinteger ignore seq   = 1
%constinteger ignore SYN   = 2
%constinteger ignore ACK   = 4
%constinteger requeue flag = 8

%end %of %file
