ArpaTCPBuf.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Demers, July 24, 1987 7:41:42 pm PDT
Doug Terry, August 28, 1987 11:38:55 am PDT
Format for Arpa TCP packets.
DIRECTORY
ArpaBuf USING[Hdr, maxBodyBytes],
Basics USING [FWORD, HWORD],
CommBuffer USING [Overhead];
ArpaTCPBuf: CEDAR DEFINITIONS ~ {
HWORD: TYPE ~ Basics.HWORD;
FWORD: TYPE ~ Basics.FWORD;
maxBytes: CARDINAL ~ ArpaBuf.maxBodyBytes;
Header
Port: TYPE ~ HWORD;
nullPort: Port ~ [0, 0];
Pair: TYPE = MACHINE DEPENDENT RECORD [a, b: CARDINAL]; -- used for word swap
Hdr: TYPE ~ TCPHeader;
TCPHeader: TYPE = MACHINE DEPENDENT RECORD [
sourcePort (0): Port, -- source port number
dstnPort (1): Port, -- destination port number
seqNumber (2): Pair, -- sequence number
ackNumber (4): Pair, -- acknowledgement number
dataWordOffset (6: 0..3): INT [0..15], -- size of header in 32-bit words
unused (6: 4..9): INT [0..63] ← 0,
urg (6: 10..10): BOOLFALSE, -- control flags, urgent
ack (6: 11..11): BOOLFALSE, -- acknowledgement
psh (6: 12..12): BOOLFALSE, -- push
rst (6: 13..13): BOOLFALSE, -- reset
syn (6: 14..14): BOOLFALSE, -- syn (first packet on connection)
fin (6: 15..15): BOOLFALSE, -- fin (last packet on connection)
window (7): Basics.HWORD, -- window of packets to send
checksum (8): Basics.HWORD, -- for header and pseudo header
urgentPtr (9): Basics.HWORD ← [0,0] -- ptr to byte following urgent data
];
options are in CommDriver.BufferObject.spaceForOptions.
hdrBytes: CARDINAL ~ BYTES[Hdr];
Body
Body: TYPE ~ MACHINE DEPENDENT RECORD [
SELECT OVERLAID * FROM
bytes => [bytes: PACKED ARRAY [0..maxBodyBytes) OF BYTE],
chars => [chars: PACKED ARRAY [0..maxBodyChars) OF CHAR],
hWords => [hWords: PACKED ARRAY [0..maxBodyHWords) OF HWORD],
fWords => [fWords: PACKED ARRAY [0..maxBodyFWords) OF FWORD]
ENDCASE
];
maxBodyBytes: CARDINAL ~ maxBytes - hdrBytes;
maxBodyChars: CARDINAL ~ maxBodyBytes;
maxBodyHWords: CARDINAL ~ maxBodyBytes/BYTES[HWORD];
maxBodyFWords: CARDINAL ~ maxBodyBytes/BYTES[FWORD];
Packet
Packet: TYPE ~ REF PacketObject;
PacketObject: TYPE ~ MACHINE DEPENDENT RECORD [
hdr: Hdr,
body: Body];
Buffer
All buffers start out as Driver.Buffer's. Clients may SmashType between Driver.Buffer and ArpaBuf.Buffer, so the "right" module gets to do finalization. This is VERY delicate.
Buffer: TYPE ~ REF BufferObject;
BufferObject: TYPE ~ MACHINE DEPENDENT RECORD [
ovh: CommBuffer.Overhead,
hdr1: ArpaBuf.Hdr,
hdr2: Hdr,
body: Body];
}.