FTP, DNS and Telnet Explained: Ports, Protocol Flows and Worked Numericals
Learn how DNS resolution, FTP control and data connections, and Telnet negotiation fit together. Then solve port, TTL and transfer-time calculations step by step.
KnowledgeGate Team
Exam prep & CS education

Port-number lists make FTP, DNS and Telnet look similar. Exams test who opens each connection, whether TCP or UDP is involved, and what happens before data moves. A DNS lookup, an FTP passive-mode transfer and the exact Telnet negotiation bytes show how these protocols differ.
FTP, DNS and Telnet at the application layer
Protocol | Job | Server-side well-known port | Transport | Exam-critical distinction |
|---|---|---|---|---|
DNS | Resolves names | 53 | Usually UDP for ordinary queries, with TCP in defined cases | A client can ask recursively while its resolver queries upstream iteratively |
FTP | Transfers files | 21 for control | TCP | A separately negotiated TCP data connection carries listings and file bytes |
Telnet | Provides a remote terminal | 23 | TCP | Network Virtual Terminal data shares the stream with option negotiation |
Servers listen on well-known ports, while clients normally use ephemeral source ports. A port identifies one transport endpoint, not an entire conversation. FTP port 20 belongs to the traditional active-mode data path, not a universal second port.
GATE CS Exam Preparation places these protocols inside the wider Computer Networks syllabus.
DNS resolution, records, caching and a worked RTT example
The stub resolver at 192.0.2.25 asks recursive resolver 203.0.113.53 for files.example.net. On a cache miss, the resolver follows referrals from a root server to a .net TLD server and then to the authoritative server. The answer is A files.example.net = 198.51.100.40 with TTL 300 s.
The client requests a completed answer recursively. Its resolver commonly follows referrals through iterative upstream queries. Distinguish A for IPv4, AAAA for IPv6, CNAME for an alias, NS for an authoritative name server, MX for mail routing and PTR for reverse lookup. The Application Layer Protocols: DNS, HTTP, and email, with a DNS walk-through traces the full DNS hierarchy into HTTP. Caching becomes a different problem when its saved RTT is one term inside an FTP transfer total, while Telnet questions instead decode negotiation bytes.
Assume sequential exchanges and ignore processing delay. The client-to-resolver RTT is 8 ms; resolver-to-root, resolver-to-TLD and resolver-to-authoritative RTTs are 22 ms, 28 ms and 34 ms.
Cold resolution time =
8 + 22 + 28 + 34 = 92 ms.At
t = 200 s, remaining TTL =300 - 200 = 100 s. The cached answer needs only the8 msclient-to-resolver RTT.At
t = 301 s, the cached record is stale, so the resolver must refresh it.

Caching removes upstream work until TTL expiry, but does not change the authoritative server.
FTP control and data connections in active and passive mode
FTP uses two channels. The client opens a persistent TCP control connection from 192.0.2.25:53000 to 198.51.100.40:21. Commands and replies use it, while each listing or transfer gets a separate TCP data connection.
In passive mode, the server replies with (198,51,100,40,195,80). The final two values encode the data port in base 256:
195 × 256 + 80 = 49,920 + 80 = 50,000
The client opens 192.0.2.25:53001 -> 198.51.100.40:50000. Passive mode suits typical client-side NAT and firewall arrangements because the client initiates both connections.
In a traditional active-mode example, the client sends PORT 192,0,2,25,207,49. Its listening data port is:
207 × 256 + 49 = 52,992 + 49 = 53,041
The server initiates data from 198.51.100.40:20 to 192.0.2.25:53041. Port 20 is qualified traditional active behaviour. FTP also distinguishes ASCII representation from binary or image transfer. Never demonstrate real credentials over insecure FTP.

FTP transfer time from DNS lookup to the last file bit
Consider an idealised transfer that begins with the uncached 92 ms DNS lookup. The server RTT is 40 ms. Count one RTT for the FTP control TCP handshake, one for the passive-mode command and reply, and one for the data TCP handshake. Login is already complete, and processing, headers, slow start, teardown and other overheads are excluded. The file is 12 MiB, and the constant payload rate is 24 Mbit/s.
Convert every unit before adding the times:
12 MiB = 12 × 1,048,576 bytes = 12,582,912 bytes.Payload =
12,582,912 × 8 = 100,663,296 bits.Transmission time =
100,663,296 / 24,000,000 = 4.194304 s = 4,194.304 ms.Cold total =
92 + 40 + 40 + 40 + 4,194.304 = 4,406.304 ms, approximately4.406 s.
At t = 200 s, the DNS answer is cached, so replace 92 ms with 8 ms:
8 + 40 + 40 + 40 + 4,194.304 = 4,322.304 ms, approximately 4.322 s.
The cache saves 4,406.304 - 4,322.304 = 84 ms. It does not alter the file-transmission term. Mixing binary MiB with decimal MB would silently change the answer.
Telnet, Network Virtual Terminal and option negotiation
Telnet is a TCP remote-terminal protocol on server port 23. Its Network Virtual Terminal gives different hosts a common byte-oriented interface. Commands begin with IAC, decimal 255 or hex FF.
Decode this exchange byte by byte. Server bytes 255, 251, 1 mean IAC WILL ECHO: 251 is WILL, and option 1 is ECHO. Client bytes 255, 253, 1 mean IAC DO ECHO: 253 is DO. A typed capital A is data byte decimal 65, or hex 41. A literal data byte 255 must be sent as 255, 255 so that it is not mistaken for a command introducer.
Telnet does not encrypt the terminal session. SSH on TCP port 22 is the normal secure alternative. Do not connect to a public Telnet service.
FTP, DNS and Telnet traps that cost marks
Claim | Correction | Reason |
|---|---|---|
DNS uses only UDP | DNS can use UDP or TCP | TCP is used for zone transfers and when a response requires TCP handling |
FTP always uses ports 20 and 21 | Port 21 is the control listener; the data endpoint is negotiated | Passive and active modes create different data paths |
FTP sends commands and file bytes on one connection | Control and data use separate TCP connections | The two-channel design is fundamental to FTP |
Telnet is encrypted remote login | Telnet carries plaintext terminal traffic | SSH supplies the normal secure alternative |
A client connects from port 53, 21 or 23 | Those are normally server-side well-known ports | The client usually chooses an ephemeral source port |
Two finer traps matter. Recursive and iterative DNS queries describe different resolver responsibilities. An FTP p1,p2 pair means p1 × 256 + p2, not decimal concatenation. Test these corrections with Application Layer MCQs: 12 Solved DNS, HTTP, Email.
How exams test FTP, DNS and Telnet
Questions usually take four forms: port and transport matching, connection direction or message ordering, assertion-reason traps, and short numericals on DNS RTT, TTL or FTP port tuples.
Try these answer-first checks:
(192,168,1,10,200,25)advertises port200 × 256 + 25 = 51,225.A DNS entry with TTL
120 s, cached75 sago, has120 - 75 = 45 sleft.DNS can use UDP or TCP, while FTP and Telnet use TCP.
With no usable cached address, resolve the hostname before opening the application TCP connection.
After understanding the flows, use this 30-second recall grid: FTP = files, control plus data, 21 plus negotiated data endpoint; DNS = names, 53, UDP and TCP; Telnet = remote terminal, 23, TCP, plaintext.
The short version and the next practice step
DNS finds the endpoint. FTP separates control from transferred data. Telnet carries terminal bytes and negotiations without encryption.
Redraw the DNS and FTP figures, then recompute 50,000, 53,041 and 4.406 s without looking. Application Layer in Computer Networks: Protocols, Worked Examples, and How GATE Tests It connects DNS to HTTP, email and layer-wide RTT problems. FTP active and passive port arithmetic instead turns on negotiated data endpoints, while Telnet requires byte-level IAC decoding. Once you can reproduce both calculations independently, use the GATE Test Series for timed practice.
Keep learning
FTP, DNS & Telnet MCQs: 12 Solved Questions with Explanations
Solve 12 application-layer MCQs on DNS lookups, FTP connections and Telnet. Each answer explains the tested concept and rejects the distractors.
Internet Protocols and Web Services: DNS, HTTP, Email and FTP with Worked Examples
Trace a browser request through DNS, TCP and HTTP, then separate email from FTP.
Go-Back-N Protocol Explained: Sliding Windows, Worked Numericals and Exam Traps
Trace Go-Back-N through a lost frame, calculate its legal window and link utilisation, and avoid the ACK and wrap-around traps that spoil numericals.
TCP/UDP Services and Ports MCQs: 12 Solved Questions with Explanations
Solve 12 transport-layer MCQs on port and socket addressing, socket operations, TCP and UDP guarantees, application choices and TCP state.





