Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

FTP, TELNET, DHCP and SNMP

Notes on FTP, TELNET, DHCP and SNMP: their purpose, operation, message formats, example traces, common exam errors and practice questions.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

These four protocols are fundamental application-layer services used by network engineers: FTP (file transfer) and TELNET (remote terminal) are tools for accessing and managing remote systems; DHCP (dynamic host configuration protocol) automates IP address and configuration assignment; SNMP (simple network management protocol) monitors and controls network devices. An engineer uses them for configuration, remote troubleshooting, automation of address management, and device monitoring.

Key ideas

Start from first principles: the Application layer uses transport layer services (TCP or UDP). For each protocol below, I first define it, state its transport mapping, core message model, and describe the control-data separation or PDU structure.

  • FTP: a protocol to transfer files between systems. It uses two separate TCP connections: a control connection (commands and responses) and a data connection (file or directory data). Default TCP ports: control on port 21 (server) and data either initiated by server-to-client (active mode) or client-to-server (passive mode). Assumption: both peers are TCP-capable and can open the required ports through firewalls/NAT.

    • Control channel semantics: ASCII text commands (e.g., USER, PASS, LIST, RETR, STOR) and numeric 3-digit responses (e.g., 200, 226). Commands are sent over the established TCP control connection; data transfers open a separate TCP data connection whose endpoints and roles depend on mode.
    • Active vs Passive modes: in active mode the client listens on a TCP port and tells the server which port to connect to (PORT command); in passive mode the server listens on a port and tells the client which port to connect to (PASV response). Passive mode is typically required through NAT/firewalls; active mode requires the server to initiate an inbound connection to the client.
  • TELNET: a protocol to provide a remote terminal connection. Define Telnet as an application-layer protocol providing bidirectional interactive text-based communication. Telnet normally uses TCP port 23. It defines an option negotiation mechanism using the special byte sequence IAC (Interpret As Command, 255) followed by command bytes: WILL, WONT, DO, DONT and option codes. Assumption: Telnet is unencrypted (cleartext), so it is insecure for sensitive logins; SSH is preferred for secure remote shells. Telnet uses the Network Virtual Terminal (NVT) model with CR LF line endings; a literal data byte 255 must be sent as IAC IAC to escape it in the data stream.

    • Option negotiation: exact behavior: when one side sends IAC WILL <option>, it proposes to enable an option; the other side responds with IAC DO <option> to accept or IAC DONT <option> to refuse. Similarly IAC DO <option> proposes the other side to enable it, and the other replies IAC WILL or IAC WONT.
  • DHCP: define DHCP as the dynamic protocol that assigns IP addresses and related configuration to hosts. DHCP is based on BOOTP and uses UDP transport: client uses UDP source port 68, server uses UDP destination port 67. Core transactions: DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, DHCPACK (and DHCPNAK). Assumptions: client may not have an IP address initially (boots with 0.0.0.0 source), therefore messages may be sent as link-layer broadcasts and DHCP uses the chaddr (client hardware address) and xid (transaction id) to match exchanges.

    • Lease semantics: a server grants a lease with a lease time — client must renew before expiry. In DHCPv4, renewal (T1) and rebinding (T2) timers are delivered as options (58 and 59), typically T1 ≈ 0.5 × lease and T2 ≈ 0.875 × lease.
    • Message fields: DHCP messages reuse BOOTP header fields: op, htype, hlen, hops, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr, chaddr, sname, file, options.
  • SNMP: define SNMP as an application-layer protocol for network management using a manager-agent model. It operates over UDP (default port 161 for agent, 162 for traps). SNMP messages carry PDUs containing operations such as GetRequest, GetNextRequest, GetResponse, SetRequest, Trap; SNMPv2/v3 also add GetBulkRequest, InformRequest, and SNMPv2-Trap. The managed objects are identified by OIDs (Object Identifiers), a tree-like dotted numeric path (e.g., 1.3.6.1.2.1.1.1 for sysDescr). SNMP versions: v1 (community-string based), v2c (improved PDUs), v3 (adds security: authentication and encryption). SNMP PDUs are encoded using ASN.1 BER; MIB modules define the object structure. Assumptions: agents implement MIB objects as specified; community strings in v1/v2c act like weak passwords.

Diagrams to draw (describe exactly):

  • FTP Active vs Passive: draw two boxes labelled Client and Server. Draw a TCP connection from Client ephemeral port (e.g., 49152) to Server port 21 labeled "Control (TCP 21)". For active mode: draw arrow from Server TCP port 20 to Client chosen ephemeral port (client-listening port, as specified in the PORT command) labeled "Data (TCP 20 -> client)" and annotate that the client issued PORT command. For passive: draw arrow from Client ephemeral port to Server ephemeral passive port advertised in PASV response labeled "Data (client -> server)".
  • DHCP four-message exchange: draw Client, DHCP Server, with arrows: DHCPDISCOVER (broadcast), DHCPOFFER (broadcast or unicast), DHCPREQUEST (broadcast), DHCPACK (unicast/broadcast). Label fields: xid, chaddr, offered yiaddr.
  • SNMP manager-agent: manager sends GetRequest UDP src ephemeral -> agent UDP dst 161; agent replies GetResponse UDP src 161 -> manager UDP dst ephemeral; agent may send Trap UDP src ephemeral -> manager UDP dst 162.

Formulas

FTP control: TCP port 21 — control connection endpoint on server. FTP data (active): server TCP port 20 -> client-specified port — server initiates data TCP from port 20. FTP data (passive): client -> server ephemeral port (PASV response) — client initiates data connection. TELNET: TCP port 23 — default service port. Telnet option negotiation: IAC (255) + {WILL(251)|WONT(252)|DO(253)|DONT(254)} + <option-code> — byte-level command sequence. DHCP client port 68, server port 67 (UDP) — transport ports. DHCP messages fields: op, htype, hlen, hops, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr, chaddr, sname, file, options — header layout to memorize. DHCP handshake sequence: DISCOVER -> OFFER -> REQUEST -> ACK/NAK — four-message sequence. SNMP agent port 161, trap port 162 (UDP) — transport ports. SNMP PDU types: GetRequest, GetNextRequest, GetResponse, SetRequest, Trap; (v2c/v3 also: GetBulkRequest, InformRequest, SNMPv2-Trap) — basic operations. OID notation: dot-separated integers (e.g., 1.3.6.1.2.1) — hierarchical identifier.

Worked examples

  1. DHCP: Client with MAC 00:11:22:33:44:55 boots and needs an IP. Step 1: Client broadcasts DHCPDISCOVER: UDP src=0.0.0.0:68 dst=255.255.255.255:67, includes chaddr=00:11:22:33:44:55 and xid=0x3903F326. Step 2: DHCP server replies DHCPOFFER: UDP src=192.0.2.1:67 dst=255.255.255.255:68 (or unicast), offers yiaddr=192.0.2.100, includes same xid and server id in options. Step 3: Client sends DHCPREQUEST: broadcast with chosen yiaddr and xid to request that offer, including the Server Identifier and Requested IP Address options; ciaddr remains 0.0.0.0 at this stage. Step 4: Server sends DHCPACK assigning 192.0.2.100 with lease time (e.g., 3600 s). Client configures IP and may use ARP to detect duplicates. Final: IP 192.0.2.100 assigned. Bold final: Client assigned 192.0.2.100 for lease 3600 s.

  2. FTP active vs passive trace (control on TCP 21): Given: Client IP 10.0.0.2 ephemeral port 49152; Server IP 10.0.0.1. Control: Client -> Server TCP 49152 -> 21: send USER alice, PASS ****. Active mode: Client sends PORT 10,0,0,2,192,7 meaning port = 192256+7 = 49159 and then server connects from its port 20 to client 10.0.0.2:49159 for data transfer. Passive mode: Client sends PASV. Server replies 227 Entering Passive Mode (10,0,0,1,195,85) meaning passive port = 195256+85 = 50005. Client then opens TCP from a new ephemeral port (e.g., 49160) -> 50005 to fetch data. Bold: Active: server opens data TCP from port 20 -> client-port; Passive: client opens data TCP -> server passive-port.

  3. SNMP GetRequest example: Manager wants sysName OID 1.3.6.1.2.1.1.5.0. Manager sends GetRequest (UDP src random -> dst agent 161) with that OID. Agent replies GetResponse with value e.g., "router1". If using SNMPv2c, community string included. Bold: Manager received sysName = router1.

Common mistakes

  • In DHCP, forgetting that initial client source IP is 0.0.0.0 and that broadcast is used because client lacks an IP; also mixing up UDP ports 67/68.
  • For SNMP, treating community string as a secure credential — it is plaintext in v1/v2c; also confusing agent port (161) and trap destination (162).
  • Mislabeling IAC/command bytes for Telnet negotiation or not showing the negotiation handshakes when asked for byte-level traces.

For your exam

Kinds of questions:

  • Definitions: define each protocol, transport mapping, and basic operation.
  • Short notes: active vs passive FTP; DHCP four-message flow; Telnet option negotiation; SNMP manager-agent model and MIB/OID.
  • Derivations/diagrams: draw FTP active/passive port flow; draw DHCPDISCOVER/OFFER/REQUEST/ACK arrows and label fields; show Telnet IAC negotiation sequence diagram.
  • Numericals/traces: given IPs and ports, trace FTP control and data TCP connections; given MAC and xid, trace DHCP messages; given OID write GetRequest/GetResponse.
  • Programs/byte-level: small pseudocode to open a TCP control socket to FTP server and parse numeric replies (show command sequences).

What full-marks answers include:

  • Clear definitions with bolded protocol roles and transport ports.
  • Correct diagrams with endpoints, port numbers, and arrow directions for control and data flows.
  • For DHCP, mention xid, chaddr, broadcasting behavior and ports 67/68; include lease time semantics.
  • For SNMP, list PDU types, OID example, and mention SNMPv1/v2c/v3 security differences.
  • Exact byte sequences for Telnet option negotiation when requested (IAC + command + option).

Quick check

  1. Which UDP ports do DHCP clients and servers use?
  2. In FTP passive mode who opens the TCP data connection?
  3. What are the four main DHCP messages in the normal allocation sequence? Answers: DHCP client UDP port 68 and server UDP port 67; the client opens the TCP data connection to the server passive port in passive FTP; DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, DHCPACK.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?