5 ms·
Personally I find how/why FTP uses two ports, 20 and 21, to be more interesting: So the first thing to know is the FTP is 'old', in that it predates TCP and or
by throw0101a 7y ago
Personally I find how/why FTP uses two ports, 20 and 21, to be more interesting:
So the first thing to know is the FTP is 'old', in that it predates TCP and originally ran on NCP:
> The original specification for the File Transfer Protocol was written by Abhay Bhushan and published as RFC 114 on 16 April 1971. Until 1980, FTP ran on NCP, the predecessor of TCP/IP.[2] The protocol was later replaced by a TCP/IP version, RFC 765 (June 1980) and RFC 959 (October 1985), the current specification.
* https://en.wikipedia.org/wiki/File_Transfer_Protocol https://en.wikipedia.org/wiki/File_Transfer_Protocol
The second thing to know is that, unlike TCP or UDP, NCP was not duplex:
> NCP preceded the Transmission Control Protocol (TCP) as a transport layer protocol used during the early ARPANET. NCP was a simplex protocol that utilized two port addresses, establishing two connections, for two-way communications. An odd and an even port were reserved for each application layer application or protocol. The standardization of TCP and UDP reduced the need for the use of two simplex ports for each application down to one duplex port.[1]
* https://en.wikipedia.org/wiki/Network_Control_Program https://en.wikipedia.org/wiki/Network_Control_Program
So the original transport layer that FTP relied on necessitated two ports, and when the move to a newer transport layer occurred the use of two ports was carried over for simplicity's sake. And several decades later that design still exists.
- ghelmer 7y agoI've written a lot of TCP deep-packet inspection code, including parsing FTP control protocol. So I was surprised by this post by Robert Graham: https://blog.erratasec.com/2019/08/hacker-jeopardy-wrong-answers-only.html https://blog.erratasec.com/2019/08/hacker-jeopardy-wrong-ans... - FTP control protocol follows the specification for Telnet.
- crooked-v 7y agoYou might find the MUD community interesting in this regard, as they've built de facto standards for 16-bit color encoding, text compression, hidden sideband metadata communication usable by clients, and even simple embedded HTML and image rendering all on top of telnet. On top of that, because of the wildly varying capabilities of MUD clients, every single feature has to be totally backwards-compatible with a plain text terminal.
- pmiller2 7y agoSome MUDs even have sound!
- Twisol 7y agoI can vouch for this wholeheartedly! However, be aware that these are all ad-hoc in some fascinating yet depressing ways. I can't help but mention a few names and fun facts... > 16-bit color encoding I think the xterm-256 escape codes came from somewhere other than MUDs, but it is forever frustrating to me that whoever designed them used the parameter separator `;` instead of the subparameter separator `:`. For SGR (`\e[m`-type escapes), each parameter is an individual change to the graphic state, so you can combine multiple settings into a single SGR. (For instance, `\e[1;32m` means "bold" followed by "green foreground".) But the 256-color extensions use a pattern "\e[38;5;<n>m", which makes itself into a fresh edge case you have to handle specially instead of treating "38", "5", and the chosen <n> as individual commands. `:` is perfectly well defined as binding more tightly than `;`, so "38:5:<n>" would have worked perfectly well as a definition for the otherwise-undefined "38" code, but no... > text compression The MCCP (Mud Client Compression Protocol) is very cool, but its first version called to signal the start of compression with the byte sequence `IAC SB MCCP SE`. The intent was to send an empty MCCP subnegotiation frame and immediately return to the main Telnet channel, but they left off an `IAC` to preceed the `SE`, meaning that this just starts a subnegotion frame, sends `SE` as the first byte, and then forgets to close the frame. Ever. So if you want to support MCCPv1, you have to add a little hack to detect this situation and pretend the frame was actually closed as intended. (Please don't support MCCPv1.) > hidden sideband metadata communication usable by clients Yes! One of my favorite topics. Iron Realms-published MUDs introduced "ATCP", another subnegotiation-based protocol that would provide additional information about your character, which directions you can move, your inventory, etc., so that your client could provide graphical representations of this information in the UI. They replaced it with "GMCP" later on -- the "standardization" process behind that was memorable -- which used JSON as the payload format. Fun fact about ATCP: It was originally designed with a lightweight handshake mechanism so that only Iron Realms clients ("Nexus") could utilize this information. Before my time, someone seems to have reverse engineered this algorithm, so it pretty quickly spread to custom plugins for third-party clients. They never seemed openly upset about this development, and GMCP dropped this mechanism. And none of this is even getting into MXP, which embedded XML-inspired tags directly into the main data channel instead of using a subnegotiation. The presence of tags is controlled by using a non-standard ANSI-style escape sequence. I never ended up implementing MXP, because ATCP and GMCP were so much simpler to work with, but it's still a very cool piece of tech. > every single feature has to be totally backwards-compatible with a plain text terminal. Telnet is actually a shockingly cool little protocol. Sure, there are some anachronisms, like the "Network Virtual Terminal" (NVT) defining a variety of special text editing commands to provide a common representation for the many terminals sold by many vendors and their incompatible command representations. But Telnet at its core is a data multiplexer with 1 primary data channel and 256 negotiable framed channels ("options"). The mechanism for negotiating the use of a channel is symmetric, meaning that the client and server are on equal footing -- both have to agree, and either one can advertise its willingness to use a channel. It's a really cool protocol to study -- and small enough that you really can understand the whole thing! Source for all this: I was a MUD enthusiast for several years as a teenager, and wrote my own Telnet stack, ANSI escape parser (referencing the ECMA spec!), and started on my own web-based MUD client. I did a heck of a lot of digging back then on these topics. It's still one of my favorite esoteric technology stacks to play around with.
- bbanyc 7y agoAlso, Telnet was originally port 1 and FTP was port 3 (RFC 433, December 1972). On an incompatible protocol change (mentioned in RFC 542, August 1973), they were "temporarily" moved to 23 and 21 respectively until the old versions were taken down. Of course, the move back to 1 and 3 never happened. Wouldn't FTP need three simplex connections - commands to server, responses from server, data transfer?
- sedatk 7y agoPerhaps it received command responses from the data port too.
- azernik 7y agoFTP puts data and commands on the same socket. This is perfectly doable in NCP.
- bbanyc 7y ago> FTP puts data and commands on the same socket. Not on TCP it doesn't. And some of the Arpanet FTP RFCs refer to separate connections as well, e.g. for the MAIL and MLFL commands which send email over the command and data connections, respectively. (SMTP didn't exist yet so mail was sent over FTP.)
- throw0101a 7y ago> Wouldn't FTP need three simplex connections - commands to server, responses from server, data transfer? AFAICT, per RFC 114, responses from the server are considered a data type: when a user sends a command to the server, sometimes the response is a status update ('MKDIR successful'†) and sometimes the response is the requested file. The data structure of the response has fields to say what's coming back on the data channel for the requested transaction. † MKDIR was not a command, just using it as an modern example.
- zaphirplane 7y agoAnd till fairly recently a gotcha for firewalls and when the firewall team is different from the requesting team oh the jokes
- DonHopkins 7y ago>... was carried over for simplicity's sake. Or for simplexity's sake! From the previous discussion of SSH port 22: https://news.ycombinator.com/item?id=14178993 https://news.ycombinator.com/item?id=14178993 Back in the "bad old days" of the simplex NCP protocol, before the full duplex TCP/IP protocol legalized same-sex network connections, connect and listen sockets had gender defined by their parity, and all connections were required to use sockets with different parity gender (one even and the other odd -- I can't remember which was which, or if it even mattered -- they just had to be different). The act of trying to connect an even socket to another even socket, or an odd socket to another odd socket, was considered a "peculiar error" called "homosocketuality", which was strictly forbidden by internet protocols, and mandatory "heterosocketuality" was called the "Anita Bryant feature". https://en.wikipedia.org/wiki/Network_Control_Program https://en.wikipedia.org/wiki/Network_Control_Program http://www.saildart.org/IMPSER.DOC[SS,SYS] http://www.saildart.org/IMPSER.DOC[SS,SYS] When the error code is zero, the next 8 bit byte is the Stanford peculiar error code, followed by 72 bits of the ailing command returned. Here are the Stanford error codes. [...] IGN 3 Illegal Gender (Anita Bryant feature--sockets must be heterosocketual, ie. odd to even and even to odd) [...] Illegal gender in RFC, host hhh/iii, link 0 The host is trying to engage us in homosocketuality. Since this is against the laws of God and ARPA, we naturally refuse to consent to it. http://www.saildart.org/FTP.NCP[S,NET] http://www.saildart.org/FTP.NCP[S,NET] ; Try to initiate connection loginj: init log,17 sixbit /IMP/ 0 jrst noinit setzm conecb setom conecb+lsloc move ac3,hostno movem ac3,conecb+hloc setom conecb+wfloc movei ac3,40 movem ac3,conecb+bsloc move ac3,consck trnn ac3,1 jrst gayskt ; only heterosocketuals can win! movem ac3,conecb+fsloc mtape log,[ =15 byte (6) 2,24,0,7,7 ] ; Time out CLS, RFNM, RFC, and INPut [...] gayskt: outstr [asciz/Homosocketuality is prohibited (the Anita Bryant feature) /] ife rsexec,<jrst rstart;>exit 1, (The PDP-10 code above adds the connect and listen socket numbers together, which results in bit 0 being 0 if they are the same gender, then TRNN is "test bits right, no change, skip if non zero", which skips the next instruction (jrst gayskt) if they different sex.)
- 7y ago
- gumby 7y agoFTP was also how mail was transported in the NCP days (and you'll notice that RFC 733 still refers to FTP mail for back compatibility).
- glandium 7y agoWasn't UUCP more popular, or was it after?
- gumby 7y agoUUCP wasn't written until '78 which was much later than we're talking about, though the Internet transition to TCP (and thus, for this conversation, SMTP) didn't happen until (my memory is hazy) '82 or '83. Also UUCP was for unix machines only (at least back then) which were a small proportion of machines on the net. Most of them were 36-bit machines plus a few IBM machines. You can still see the old 36-bit influence in some contemporary protocols (e.g. a high level protocol like FTP has a commend to set byte size), big-endian traffic etc.