Email and File Transfer: SMTP, POP3, IMAP and FTP

Application Layer and Security · 25 min

Core CS · Computer Networks

One protocol pushes. Another has to pull.

Email and FTP are the two oldest application protocols you will be asked about, and both split their job in a way that surprises people. Every answer here comes down to one question: which side opens the connection?

Run the same transfer in active and passive mode, and watch the router decide
SMTP pushes a message toward a mailbox: port 25 between servers, port 587 when a client submits one. It has no command that reads a mailbox, so POP3 on 110 or IMAP on 143 exists purely to fetch. FTP splits along a different seam: commands on port 21, and a whole separate connection for every file.

01 The idea

Sending mail and reading mail are two different jobs

Start with what actually moves. When you send mail, the message travels away from you and toward a machine you have never logged into. When you read mail, it travels toward you from a machine you own an account on. Those are opposite directions, and in a client-server protocol the direction of travel is decided by whichever side dialled. That single asymmetry is why email needs two protocols rather than one, and it is the thing a well-answered interview question turns on.

Three programs are involved, and they have names worth using. The mail user agent is what you type in: Thunderbird, Outlook, the Gmail app. The mail transfer agent is the server-side relay that carries a message from one organisation to another: Postfix, Exim, Sendmail. The mail delivery agent is the last step, the program that takes an accepted message and writes it into the right person’s mailbox on disk. Mail moves from agent to agent, and SMTP, the Simple Mail Transfer Protocol, is the protocol for every hop between agents, from your app all the way to the server that owns the recipient’s mailbox. The final handover from that server to the delivery agent happens inside one machine and is the only part of the journey SMTP does not have to carry.

Then it stops. SMTP is a push protocol in the strict sense: the sender opens the connection, announces who the message is from and who it is for, and hands the bytes over. There is no command in SMTP that means show me what is in that mailbox, and there could not usefully be one, because your phone is not a server. It has no fixed address, it is asleep half the day, and it sits behind a network that refuses unsolicited inbound connections. A mailbox on a server cannot dial your phone. Your phone has to dial the server. So a second, pulling protocol is required, and there are two of them: POP3 and IMAP, which differ on one question, namely where does the real copy of your mail live.

FTP, the File Transfer Protocol, splits its job along a completely different seam and is asked about for exactly that reason. It uses two TCP connections at once. One is the control connection, opened at login and held open for the whole session, and it carries nothing but short text commands and three-digit reply codes. The other is a data connection, opened fresh for every single file or directory listing and closed when that transfer ends. Keeping commands out of the data stream is a genuinely good design, and it also creates the one problem this lesson spends its console on: in the original scheme, it is the server that opens the data connection, back toward the client, and modern client networks drop exactly that kind of connection.

Ask who dials. SMTP’s sender dials, so SMTP can only ever push mail toward a mailbox, which is why POP3 or IMAP must exist to pull it out again. FTP’s client dials for commands, but in active mode the server dials for data, and that reversal is the whole reason passive mode was invented and is now the default.
The three agentsThe MUA is the app you compose in. The MTA is the server that relays a message onward, and it speaks SMTP to other MTAs. The MDA is what finally writes the message into the recipient’s mailbox. Retrieval is a fourth conversation, between the recipient’s MUA and the mailbox, and it is not SMTP.
Push and pullIn a push, the side holding the data opens the connection and sends it onward. In a pull, the side that wants the data opens the connection and asks for it. SMTP is push only. POP3 and IMAP are pull only. A protocol cannot be run backwards, because the side that has to listen must be reachable.
Control and data connectionsFTP holds one control connection to server port 21 for the entire session, carrying commands and replies, and opens a separate data connection for each transfer. Because they are separate, you can send a command while a file is still moving, and the end of the file is signalled by the data connection closing.

02 Worked example

One message from Asha to Ravi, hop by hop

Asha, at asha@examate.in, sends one message to Ravi at ravi@nitk.ac.in. Follow it left to right and watch which side opens each connection, because that is the only detail that changes between the boxes. The highlighted box is the one SMTP structurally cannot perform, and it is where every "why do we need POP3 or IMAP at all" question lands.

1 · Asha’s MUA submitsHer mail app opens a connection to her own provider’s server on port 587, upgrades it to TLS, and authenticates as Asha. This is submission, not relay. Her app dials out; nothing dials her.
2 · examate.in relaysThe MTA asks DNS on port 53 for the MX record of nitk.ac.in, gets the name of the receiving mail server, and opens SMTP to it on port 25. Server to server, no password, an outbound push.
3 · nitk.ac.in acceptsThe receiving MTA answers 250 OK and takes responsibility for the message. It hands it to the mail delivery agent, which appends it to Ravi’s mailbox on disk.
4 · SMTP’s job endsThe message is now at rest in a mailbox. Nothing has been sent to Ravi. His laptop was closed the whole time and no protocol has any way to know it exists.
5 · Ravi’s MUA pullsRavi’s phone opens IMAP on port 143 (or POP3 on 110) to his provider, authenticates, and fetches. The direction has reversed, so this cannot be SMTP. This is the second protocol, and this box is why it exists.

Now the dialogue on hop 2, because being able to recite it is worth marks and it makes the push visible line by line. The receiving server speaks first with 220, then every line is a command from the sender and a coded reply from the receiver: EHLO mail.examate.in answered with 250 and a list of extensions; MAIL FROM:<asha@examate.in> answered 250 OK; RCPT TO:<ravi@nitk.ac.in> answered 250 OK, once per recipient; DATA answered 354 Start mail input; then the headers and body, terminated by a line containing a single full stop, answered 250 Queued; then QUIT and 221. Every command is issued by the side that has the message. At no point does the receiver ask for anything.

That is the mechanical proof of the structural claim. There is nothing in that dialogue you could turn around. A command like RCPT TO announces a destination; there is no GIVE ME. If you wanted SMTP to deliver Ravi’s mail to his phone, his phone would have to be running an SMTP server, listening on a stable address, permanently reachable from the internet, so that his provider could dial it. That is exactly the arrangement organisations use for their mail servers, and exactly the arrangement no laptop or phone can offer.

Two details in box 1 that get asked about on their own. First, why 587 and not 25, when both are SMTP. They are the same protocol serving two different roles. Port 25 is for relay, MTA to MTA, and accepts mail from strangers without a password because that is what interconnecting the world’s mail requires. Port 587 is the submission port, where a server accepts mail only from its own authenticated users. Splitting them lets a network block outbound port 25 from ordinary machines to stop compromised laptops spraying spam directly at the world, while leaving 587 open so real mail clients still work. Nearly every residential ISP and cloud provider does block outbound 25 for that reason, so an application that tries to send mail by connecting to port 25 from a cloud VM usually hangs until it times out. Port 465 is the same submission job with TLS from the first byte instead of upgrading mid-session, and RFC 8314 brought it back as the recommended option after years of it being called deprecated.

Second, MIME, in the one clause it deserves. SMTP was defined to carry 7-bit US-ASCII text and nothing else, so a photograph cannot be put into a message as it stands. MIME is the set of headers that solves this without changing SMTP at all: Content-Type declares what a part actually is, and Content-Transfer-Encoding declares how it was rewritten into printable characters for the journey, almost always base64 for binary and quoted-printable for text that is mostly ASCII. The receiving client reads those headers and reverses the encoding. That is the whole trick, and it is why attachments arrive larger than the file on disk.

03 Mechanics

The retrieval table, the two connections, and the three names

Three tables, in the order the questions come. The first is the one to be able to reproduce from memory, because "POP3 or IMAP, and why" is the single most asked question in the application layer. Read it as one decision repeated down the rows: where does the authoritative copy live. Every other difference follows from that answer.

PropertyPOP3 · port 110IMAP · port 143
Storage locationon the client deviceon the server
Default after downloadthe server copy is deletednothing is removed
Multiple deviceseach device sees a different subset — whichever one collected a message has it, and the others never willevery device sees one mailbox, because there is only one mailbox and all of them are looking at it
Working with no networkcomplete — the mail is already on disk, and this is the first of the two things POP3 is genuinely better atonly what the client cached — the protocol itself needs the server for every operation
Server storage usedclose to none — and this is the secondgrows with the mailbox — this is why providers quote a quota in gigabytes
Folder supportnone — POP3 knows exactly one mailbox and has no command to create or list anotherserver-side folders, created, renamed and moved between over the protocol itself
Message flagsnot carried — read and unread is a note your one client keeps to itselfkept on the server\Seen, \Answered, \Flagged, \Deleted, shared by every client
Fetching part of a messagealmost noneRETR takes the whole message; TOP n gets the headers plus the first n body lines, and that is the limityes — fetch headers alone, one MIME part alone, or a byte range, so a phone can list 500 subjects without downloading one attachment
Searchingon the client only, over what it happens to holdon the serverSEARCH runs across the whole mailbox
Over TLS995993

Read the first two rows together, because that is the exam answer in one line. POP3 moves mail from the server to one device. IMAP mirrors a mailbox that stays on the server. Everything else in the table is a consequence: if the mail is on one device, there are no folders to synchronise and no flags to share and nothing to search remotely, and equally there is no quota to hit and no network needed to read what you already have. POP3 was designed in an era of one computer per person and a dial-up link paid for by the minute, and for that era it was the right answer.

The detail that catches people out about POP3’s deletion. A POP3 session moves through three states: AUTHORIZATION while you log in, TRANSACTION while you list and retrieve, and UPDATE at the end. DELE during a session does not delete anything; it only marks the message. The deletion actually happens in the UPDATE state, when the client sends QUIT. Drop the connection without a clean QUIT and every mark is discarded and nothing is removed. Note also that "by default it deletes" is the protocol’s design, not an unchangeable law: every real client offers a setting that skips the delete and leaves the server copy in place.

Now FTP, and the shape that makes it worth teaching. One session, two connections, doing two different jobs.

Control connectionData connection
Server port21, always20 in active mode only — in passive mode it is a high port the server chooses and announces
How manyexactly one per sessionone per transfer or listing, opened and closed each time
Lifetimeopened at login, held for the whole sessionseconds — it exists only while bytes are moving
Carriescommands and 3-digit replies — USER, PASS, PASV, RETR, STOR, LIST, QUITfile bytes and directory listings, and nothing else, ever
Who opens italways the clientthe server in active mode, the client in passive mode — this row is the entire lesson
End of file marked bynot applicablethe connection closing — there is no length field, so the close is the delimiter

Active mode, and the exact packet that dies. In active mode the client picks a port, starts listening on it, and sends PORT h1,h2,h3,h4,p1,p2 over the control connection: four bytes of IP address and two bytes of port, so PORT 192,168,1,7,156,64 means connect to 192.168.1.7 on port 156 × 256 + 64 = 40000. The server then opens the data connection inbound, from its own port 20 to that address and port. Put a NAT router in front of the client and that connection is dead twice over. The address in the PORT command is the client’s private RFC 1918 address, which no router on the internet will forward to; and even if the client wrote the router’s public address instead, the arriving SYN matches no translation entry, because NAT builds its table from packets going out. The router has no way to know which machine behind it the packet is for, so it drops it. Unsolicited inbound is precisely what NAT is unable to deliver.

Passive mode, and why it is the default today. The client sends PASV. The server picks a port, starts listening, and replies 227 Entering Passive Mode (203,0,113,10,195,80) — the same six bytes, so port 195 × 256 + 80 = 50000. Now the client opens the data connection outbound, exactly as it opened the control connection. The router creates a translation entry on the way out and happily translates the replies coming back, because they now match something. Note carefully that only the direction of connection setup changed: the file bytes still travel from server to client on a download. Reversing who dialled fixed the problem without reversing who sends. Many routers and firewalls ship an FTP application-layer gateway that reads the control connection in plaintext, spots a PORT command or a 227 reply, and opens a temporary pinhole for the port it names. That is a middlebox reading and rewriting an application’s text to keep a protocol working, and it stops working the moment the control connection is encrypted. Treat it as a workaround, not as a reason to use active mode.

Finally, three names that students blur together, and they are not three versions of one thing.

NameWhat it actually isPortsConnectionsCredentials on the wire
FTPRFC 959, the original, entirely in plaintext21 control, 20 or a negotiated port for datatworeadable by anyone on the path
FTPSThe same FTP with TLS wrapped around it. Explicit FTPS starts on 21 and upgrades with AUTH TLS; implicit FTPS is TLS from the first byte.21 explicit, 990 implicit, plus datatwoencrypted
SFTPnot FTP at all — a different protocol that runs as a subsystem inside an SSH session, sharing nothing with RFC 95922, the SSH portoneencrypted

The honest closing sentence on plain FTP. It sends the username and the password as readable text on the control connection, and every byte of every file unencrypted on the data connection. Anyone able to see the traffic reads both, and can rewrite either. It should not be used for anything that matters, and if you are asked to move files today the answer is SFTP over SSH, or HTTPS, or a cloud object store, with FTPS as the option when a counterparty specifically requires FTP semantics. Say that out loud in an interview; being able to name what is wrong with a protocol is worth more than being able to recite it.

05 Cheat sheet

The answers that get asked, and the wrong ones that get given

Every row is something you should be able to state in under ten seconds. The right-hand column is the specific wrong answer that gets written down, not a general caution.

What they askThe answerThe trap
SMTP port, server to server25giving 25 for a mail client sending — that is 587
SMTP port, client submitting587 · 465 for TLS from the first byteCalling 587 "secure SMTP". It is the submission port; the encryption is a separate matter.
POP3 and IMAP ports110 and 143 · 995 and 993 over TLSassuming the TLS pair keeps the same order — in plaintext POP3 is the lower number, 110 against 143, but over TLS it flips: POP3S is 995 and IMAPS is 993
Why a second protocol at allSMTP can only push toward a mailboxSaying "because POP3 is for receiving". Name the direction and who dials.
POP3 versus IMAP in one linePOP3 moves mail to one device; IMAP keeps it on the server and syncs stateListing features without naming where the authoritative copy lives.
What POP3 is genuinely better atoffline use, and near-zero server storageClaiming POP3 has no advantages. It has those two, and both are real.
What MIME addsContent-Type and Content-Transfer-EncodingSaying "MIME sends attachments". It re-encodes them so a 7-bit text protocol can carry them.
FTP ports21 control, 20 data in active modesaying data is always 20 — in passive mode the server picks a high port
Who opens the data connectionactive: the server · passive: the clientmemorising the two words with no direction attached
Why passive is the defaultthe client dials out, so NAT and client firewalls pass itSaying passive is "more secure". It is not; it is more reachable.
What ends a file transfer in FTPthe data connection closingLooking for a length field. There is none.
FTPS versus SFTPFTPS is FTP plus TLS · SFTP is an SSH subsystem on 22calling SFTP "secure FTP" — it shares no code and no design with FTP
FTP reply codes worth knowing220 ready · 230 logged in · 227 passive · 150 opening data · 226 complete · 425 cannot open dataQuoting HTTP codes. FTP has its own, and 425 is the one active mode behind NAT produces.
A push cannot be run backwardsSMTP’s sender always opens the connection, so mail can only travel toward a mailbox. Retrieval reverses the direction of travel, and the side that wants the data has to dial. That is the whole reason POP3 and IMAP exist, and it is a better answer than any feature list.
Where the real copy lives decides everythingPOP3 puts it on your device, so there are no shared folders, no shared flags and no server search, but also no quota and no network needed. IMAP puts it on the server, so every device agrees, at the price of depending on that server.
Two connections, and only one is yours to openFTP’s control connection is always opened by the client. The data connection is opened by the server in active mode and by the client in passive mode, and since NAT can only deliver replies to connections that started inside it, passive is the one that survives.

06 Where & why

These are configuration lines you will actually edit

None of this is a teaching abstraction. The port numbers and mode names in this lesson are literal values in configuration files and command-line flags on systems you will meet, and each of the four below is somewhere you can watch this lesson’s one question — who dials — decide how software is built.

Postfix and Dovecot
The MTA and the retrieval server are two separate programs

Postfix is the MTA. Its master.cf has one entry for smtp on port 25, taking relay from other servers, and a separate submission entry on 587 that switches on smtpd_tls_security_level = encrypt and demands SASL authentication. Postfix hands accepted mail to Dovecot, which is the delivery agent and also the POP3 and IMAP server, listening on 110, 143, 995 and 993. Seeing them as two programs makes the split in this lesson concrete: nothing in Postfix can read a mailbox, and nothing in Dovecot can relay a message.

Gmail
The IMAP and POP settings page is this table

Under Forwarding and POP/IMAP, "Enable POP" comes with a menu reading keep Gmail’s copy, archive it, or delete it — that menu exists purely because of POP3’s default. IMAP is what the phone apps use, and Gmail maps its labels onto IMAP folders, which is why a message with two labels appears in two folders in Thunderbird and why [Gmail]/All Mail looks like a duplicate of everything. The read and starred state you set on the phone appears on the laptop because those are IMAP flags held on the server.

curl and FileZilla
Passive is the default, and you can prove it in one flag

curl ftp://host/file uses passive mode unless you tell it otherwise; curl -P - switches it into active mode and asks curl to work out the address to put in the PORT command. Run the second one from a laptop on home Wi-Fi and it hangs and then fails, which is this lesson’s console reproduced in one command. FileZilla makes the same choice in Settings under Transfer Mode, defaulting to passive, and its "server sent passive reply with unroutable address" warning is a NATed server announcing its own private address in the 227 reply.

OpenSSH sftp-server
One connection, one port, and no PORT command at all

SFTP is not a daemon you install. It is a subsystem of the SSH server, switched on by the line Subsystem sftp /usr/lib/openssh/sftp-server in sshd_config, and it runs entirely inside an existing SSH session on port 22. There is no control connection, no data connection, no active or passive choice, and nothing for a NAT device to rewrite, because there is only ever one TCP connection and the client opened it. Firewall rules become one line, which is most of why file transfer moved here.

Both halves of this lesson are the same question asked twice. Mail needs two protocols because the message travels one way and the reader is on the other side of a network that cannot be dialled. FTP needed passive mode for the same reason: the moment the client stopped being reachable from outside, any design where the server dials back stopped working. Ask who dials, and the rest of the application layer gets easier.

07 Interview questions

What they ask, and what they follow up with

Two of these come up in almost every application-layer interview: "POP3 or IMAP" and "why does FTP need two connections". Neither is asked once. The follow-up to the first is usually about multiple devices or offline use, and the follow-up to the second is always active versus passive. Name the port number and the direction in your first sentence, every time.

Take me through what happens between Asha pressing send and Ravi seeing the message on his phone.
Her mail client submits the message over SMTP to her own provider on port 587, authenticated and over TLS. That server looks up the MX record for the recipient’s domain in DNS and opens SMTP on port 25 to the receiving mail server, which accepts it with 250 OK and hands it to a delivery agent that writes it into Ravi’s mailbox. At that point SMTP is finished and the message is sitting at rest on a disk. Ravi’s phone then opens a completely separate connection, IMAP on 143 or POP3 on 110, and fetches it.
Why can SMTP not be used to read your mail?
Because SMTP only pushes. In every SMTP exchange the side holding the message opens the connection and announces a destination; there is no command that means "show me what is in that mailbox", and the protocol offers no way to ask for one. For SMTP to deliver mail to your phone, your phone would have to be running a permanently reachable SMTP server that the provider could dial, which no phone or laptop can offer. So the direction has to reverse, the client has to dial, and that requires a different protocol.
SMTP is one protocol. Why does it have two port numbers?
Because it does two different jobs. Port 25 is for relay between mail servers and accepts mail from strangers without a password, which is what interconnecting the world’s mail requires. Port 587 is the submission port, where a server takes mail only from its own authenticated users. Splitting them means a network can block outbound 25 from ordinary machines, which stops a compromised laptop spraying spam straight at the world, while leaving 587 open so real clients still work. Most ISPs and cloud providers do block outbound 25 for exactly that reason. Port 465 is the same submission job with TLS from the first byte.
POP3 or IMAP: what actually differs?
Where the authoritative copy of your mail lives. POP3 downloads messages to the client device and by default removes them from the server, so the mail ends up on one machine. IMAP leaves messages on the server and the client works against them there, so the server holds the real mailbox and the client is a view of it. Everything else follows from that: IMAP carries server-side folders and shared flags like \Seen and \Flagged, and can fetch the headers alone or a single MIME part, while POP3 has one mailbox, no flags, and RETR pulls whole messages.
When you press delete in a POP3 client, what has actually happened on the server?
Nothing yet. A POP3 session runs through three states, AUTHORIZATION while you log in, TRANSACTION while you list and retrieve, and UPDATE at the end. DELE during TRANSACTION only marks the message; the server carries out the deletions in the UPDATE state, which it enters when the client sends QUIT. If the connection drops before a clean QUIT, every mark is discarded and nothing is deleted. It is a small point, but it is the difference between knowing POP3 and having read a summary of it.
What is MIME, and why did email need it?
SMTP was defined to carry 7-bit US-ASCII text, so a message could not contain arbitrary bytes and could not carry an image. MIME solves that without touching SMTP: it adds headers, principally Content-Type to declare what a part is and Content-Transfer-Encoding to declare how it was rewritten into printable characters, together with a multipart structure so one message can hold a body and several attachments. Binary usually travels as base64 and mostly-ASCII text as quoted-printable. The receiving client reads the headers and reverses the encoding.
Why does FTP use two connections instead of one?
To keep the command channel out of the data stream. The control connection to port 21 is opened at login and held for the whole session, carrying only short commands and three-digit replies. A data connection is opened fresh for each file or directory listing and closed when it finishes. Because the control channel stays free, the client can send a command while a transfer is still running, and because the data channel carries nothing but the file, no escaping or framing is needed at all: the end of the file is signalled by the connection closing.
Active mode versus passive mode: which side does what?
In active mode the client opens a listening port and sends PORT h1,h2,h3,h4,p1,p2 naming it, and the server then opens the data connection inbound, from its own port 20, to the client. In passive mode the client sends PASV, the server replies 227 naming a port it is listening on, and the client opens the data connection outbound. In both, the six bytes are four of address and two of port, high byte first. Passive is the default in every modern client because a client behind NAT or a firewall cannot accept the inbound connection active mode requires.
Somebody tells you they are using SFTP because it is the secure version of FTP. What do you say?
That they are two unrelated protocols that happen to share four letters. FTPS is the secure version of FTP: the same RFC 959 commands with TLS wrapped around them, still two connections, on port 21 with AUTH TLS or on 990 for implicit TLS. SFTP is the SSH File Transfer Protocol, a subsystem that runs inside an SSH session on port 22, with one connection, no PORT or PASV, and none of FTP’s design. They share no code, no commands and no port. Which one you are running matters the moment somebody has to write a firewall rule.
Is plain FTP acceptable for anything today?
No, and say so plainly. The username and password cross the network as readable text and every byte of every file crosses it unencrypted, so anyone on the path reads all three. There is a second problem in that firewalls have to do awkward things to cope with the second connection. For a new system the answer is SFTP over SSH, or HTTPS, or a cloud object store; FTPS is what you use when a counterparty insists on FTP semantics. The only honest reason to still see plain FTP is anonymous read-only public mirrors, and even those have largely moved to HTTPS.
Why do modern services move files over HTTPS instead of any of these?
Because one client-initiated connection on port 443 passes through every network in the world, and that turns out to matter more than protocol elegance. HTTPS gets authentication, encryption, resumable ranged requests, caching and proxying from machinery that already exists, and it needs no second connection, no mode choice and no special handling in any firewall. An S3-style upload is a single PUT. FTP survives where it does mainly because a counterparty’s system was built around it, and SFTP survives because scheduled batch transfers between organisations are genuinely convenient over SSH.

08 Practice problems

Six to work on paper

For each one, write down which side opens each connection before you write anything else; three of the six turn entirely on that, and two more turn on where the authoritative copy of a mailbox lives. Two of them need arithmetic rather than recall, and neither is arithmetic you can do in your head on the first try.

Whose mailbox is the real one

Easy
Two users each hold about 5 GB of mail going back years. Asha’s provider reports her account at 4.8 GB used. Ravi’s provider reports 40 MB used, yet his laptop holds every message he has ever received. Name the retrieval protocol each of them is using, and say which of the two loses their entire mail history if a laptop drive fails on Monday morning.
Follow-up
Neither user has misconfigured anything and neither provider has lost data. The one whose provider reports almost no usage is the one who is a single hardware failure away from having nothing.
Show the hint
Ask, for each user, what a complete backup taken on the provider’s server that night would actually contain.

Reading a reply out loud

Easy
A packet capture of an FTP control connection contains the line 227 Entering Passive Mode (203,0,113,10,131,7). State which side sent that line, state which side must open the next TCP connection and in which direction, and compute the exact port number that connection will be opened to.
Follow-up
The port is not a number you can read off the line. It is split across the last two fields, and multiplying the wrong one by 256 lands you more than thirty thousand ports away from the right answer.
Show the hint
The last two fields are the high byte and the low byte of one 16-bit value; the first four are something else entirely.

The one that worked perfectly in 1994

Medium
Active mode was the default for FTP for years and it worked. Describe the change in how end-user networks are built that broke it. Then explain why that same change did not break the FTP control connection, an HTTPS page load, or SMTP submission to port 587, and state the single property those three share that active mode’s data connection does not.
Follow-up
Nothing in FTP changed. The protocol that stopped working is byte for byte the protocol that used to work, so the answer cannot be anything about FTP itself.
Show the hint
For each of the four connections named, write down only one thing: which end sent the very first packet. Then look at your list.

The attachment that grew on the way

Medium
A user attaches a 3,000,000-byte image to a message. Because SMTP was defined for 7-bit text, the client base64-encodes it before sending. Compute the encoded size in bytes, give the percentage overhead, and then work the ratio the other way: if a provider advertises a 25 MB attachment limit and means 25,000,000 bytes of encoded message, give the largest raw file a user can actually attach.
Follow-up
The limit the provider advertises and the limit the user experiences are two different numbers, and the gap is not rounding or protocol overhead. It is the encoding, applied in reverse.
Show the hint
Base64 maps every 3 input bytes onto 4 output characters. Do that division first, then invert the same ratio for the second half.

Nine hours with no network

Medium
A user boards a nine-hour flight with a 400-message mailbox. They want to read all of it in the air, write replies in the air, and on landing have the replies sent and their read markers visible on the office desktop. Take POP3 and IMAP in turn and say, for each, which of those three requirements it meets and which it fails and why. Then say which protocol handles the replies, and why that part of the answer is the same either way.
Follow-up
One protocol wins the offline half by design and loses the sync half outright. The other wins the sync half by design, but wins any part of the offline half only because of something mail clients choose to do, which the protocol itself does not require of them.
Show the hint
Split the three requirements and ask of each one whether it is satisfied by the protocol or by a decision the mail client made about its local disk.

One control connection, two firewalls

Hard
An FTP server sits behind a stateful firewall that permits inbound TCP only to port 21. A client behind NAT connects and uses passive mode. Identify the exact point at which the transfer fails and why, name what the administrator must configure on the FTP server and on the firewall to fix it, and then explain in one sentence each why wrapping the control connection in TLS makes that fix harder, and why SFTP reduces the firewall rule to a single line.
Follow-up
Passive mode did not remove the problem, it moved it from the client’s network to the server’s. And encrypting the control connection takes away the one thing a firewall was quietly using to cope with FTP at all.
Show the hint
Passive mode still needs a port on the server to be reachable from outside, and it is not port 21. Ask what a firewall would have had to read, and where, in order to know which port to open.