Summary
- Under
STRU RwithMODE S, FTP placed two-byte control codes inside the data stream: an all-ones escape followed by 1 meant end-of-record, 2 meant end-of-file, and 3 meant both at the same point. - A literal all-ones data byte had to be sent twice. The receiver therefore needed negotiated context and a sliver of parser memory to tell doubled data from a structural boundary.
- The design kept portable record meaning separate from host storage and from TCP delivery chunks. Later host requirements narrowed the mandate, but still demanded honest, preferably invertible treatment whenever record structure was accepted.
The byte that had to be said twice
A receiver has been swallowing ordinary data for a while. Then a byte arrives with every bit set to one. It cannot hand that byte to the file. Not yet. It has to hold it, remember it, and wait for the next byte to explain it.
If the next byte is also all ones, the pair means one literal data byte — the escape quoting itself. If the next value is 1, the pair closes a record. Value 2 closes the file. Value 3 says the final record boundary and the end of the file land on the same point, so nobody has to invent an empty record just to say so.
That compact grammar, set down by Jon Postel in RFC 765 and carried forward into RFC 959, made a single octet do two jobs without leaving an ambiguous literal value behind. The first all-ones byte was never intrinsically a control character. Its meaning was finished by its neighbour and by the transfer parameters already agreed on the control connection.
The doubling is the tell. An in-band sentinel borrows a value from the data alphabet, so the sender has to pay that value back with a second copy. The receiver reverses the bookkeeping. Raw transfer length and reconstructed file length can therefore differ even when nothing was compressed and nothing was lost.
A stream was never a record service
FTP kept structure and transmission mode as separate dials. STRU F said the file was one continuous run of data bytes. STRU R said it was a sequence of records. MODE S picked a largely unframed byte stream to carry it.
The combination is where the trouble lives. A stream connection promises order and delivery. It says nothing about where one source record stopped. FTP wrote that missing sentence itself, and wrote it for every record, including the last one.
The standards are explicit about why a local convention could not simply hitch a ride. A record-oriented host might store a count field or some private marker of its own. The next host along would have no idea what that field meant. So the sender translated its local record notation into FTP's negotiated representation before the transfer, and the receiver translated back into whatever its own system could use afterwards.
That was an interoperability contract, not a claim that two file systems were cousins. The shared part was the boundary declaration. Storage stayed local.
Four things that could follow the escape
The STREAM grammar was deliberately small:
- escape plus 1: end of record;
- escape plus 2: end of file;
- escape plus 3: end of record and end of file at the same position;
- escape plus another escape: one literal all-ones data byte.
The combined code avoided inventing an empty record merely to announce that the last record and the file ended together. The literal form guaranteed that every possible transfer byte could still appear in the reconstructed data.
An implementation could not safely scan for the sentinel and immediately declare a boundary. Nor could it keep both bytes of a doubled literal pair. Correct decoding required one step of look-ahead, exact unquoting, and a clean distinction between transfer bytes and file bytes.
It also required memory that outlives a single read. RFC 9293 defines TCP as an ordered byte-stream service, not an application-record service. The escape may be the last byte returned by one receive operation while its discriminator arrives in the next. That split changes neither the FTP code nor the record map. Treating receive calls or TCP segments as records adds boundaries the sender never declared.
The same byte was plain data under another structure
The sharpest evidence of negotiated meaning sits in FTP's rule for file structure. With STRU F in STREAM mode, every byte is data and EOF is signalled by closing the data connection. The all-ones byte has no escape role there at all.
With STRU R, the parser switches on the two-byte grammar. A capture of the data connection without the matching STRU and MODE state is therefore incomplete. The octets alone do not settle whether a doubled pair reconstructs one byte or stays two, or whether a particular pair ends a record.
Connection closure changes job too. Under file structure it supplies the ordinary EOF signal. Under record structure, EOR markers remain explicit and the STREAM representation can state EOF inside the stream. A monitor that records only "connection closed normally" can miss whether the final structural declaration ever arrived.
Other modes moved the boundary out of the payload
FTP never bound record meaning to this one escape scheme. In BLOCK mode, each data block carried a count and descriptor flags. One descriptor bit said the block ended at EOR; another said it ended at EOF; both could be set together. Other bits flagged suspect data or a restart marker.
COMPRESSED mode likewise used descriptor forms for EOR and EOF while adding encodings for replicated data and filler. The boundary semantics survived intact. Their on-wire representation depended on MODE.
Which is why "same payload" is too weak a claim for a structured transfer. Two captures can hold the same reconstructed data bytes while using different boundary encodings. Conversely, the same raw octets can mean different things under different parameter tuples. Reliable evidence joins control-plane negotiation, data-stream bytes and decoded structure.
A line ending was not a record ending
FTP also kept end-of-line strictly separate from end-of-record. ASCII text without record structure could use CRLF to divide printing lines; EBCDIC text could use NL. A record-structured file carried explicit EOR markers instead.
Visible text makes those boundaries coincide often enough to tempt a shortcut. The shortcut turns destructive the moment a record contains an embedded line ending, spans several lines, or has no textual representation at all. Swapping EOR for newline guesses rewrites the source structure while producing a file that still looks readable.
RFC 959 required ASCII and EBCDIC text implementations to accept record structure. It also insisted on useful, invertible transformations between record-oriented and file-oriented hosts. When an identical pair of systems moved non-record text, a binary representation could avoid the pointless conversion. Every one of those rules enforces the same discipline: do not infer structure from presentation when the protocol can simply state it.
The later minimum got narrower
RFC 1123 redrew the implementation boundary. Record structure became required only for hosts whose file systems actually supported it. A host without native records could still accept STRU R and record the byte stream literally.
That concession deserves precise wording. Literal preservation protects the encoded evidence for later retrieval, but it does not prove that local applications ever received a native record map. A system can preserve transfer syntax, reconstruct records, flatten records, or reject the request outright. Those four outcomes should not share one undifferentiated success claim.
The host requirements kept the preference for transformations that were useful and invertible where possible. If retrieval under the same structure cannot reproduce the original records, the receiver should not imply full semantic preservation merely because every raw byte reached storage.
A registry entry is not a parser test
RFC 5797 keeps STRU and MODE among FTP's mandatory base commands. The IANA FTP Commands and Extensions registry preserves their parameter-setting role and their RFC 959 reference.
A registry coordinates vocabulary. It does not prove that a server accepts the R argument, supports every mode combination, retains escape state across reads, handles every legal control pair, reconstructs records, or preserves them through a storage round trip.
The distinction mirrors the byte itself. A known name creates a place for meaning. Only the surrounding state and the observed behaviour establish which meaning was actually realised.
Evidence has to include the decoder
A defensible transfer record therefore holds more than a file hash. It retains TYPE, STRU, MODE, the raw stream hash, the decoded data hash, raw and decoded lengths, every EOR and EOF position, the final parser state, connection-close status and the target reconstruction result.
Canaries should place a literal doubled sentinel before and after each legal control pair, split the pair across receive calls, and compare STREAM and BLOCK encodings of the same record map. A dangling escape at close, an unknown discriminator, a missing final EOR, or a changed parameter set with no parser reset is evidence of a failed interpretation — even when the connection itself completed cleanly.
The byte had to appear twice because the protocol refused to sacrifice it. The record boundary lived inside the stream, but only as a reversible agreement between two machines that had already agreed on what the words meant.
Sources
Member Briefing
Read the full trend briefing
Members read the full briefing with the source notes behind every finding.
Strategic Circle
A daily briefing in your language, built from changes we have verified.
Join for USD 20/monthCancel anytime.
Members also get the full research library, a daily briefing on the networks they follow and the private forum.






