📝 TELNET protocol in computer networks (13 MCQs)
TELNET for Text-Based Remote Terminal Access
TELNET is an application-layer protocol that provides interactive text-based access to a remote host. It carries terminal input and output across a TCP connection and uses a Network Virtual Terminal representation to support communication between different terminal types. Traditional TELNET does not encrypt session data, making it unsuitable for sensitive remote administration on untrusted networks. Its simple terminal model made remote access possible across systems with different interfaces.
Network Virtual Terminal and Option Negotiation
The protocol defines a Network Virtual Terminal and option-negotiation commands that allow client and server to agree on terminal behavior. Data and control sequences share the TCP byte stream. The server usually listens on TCP port 23, while the remote operating system handles the user's account and shell after login succeeds.
Establishing a Remote Terminal Session
The client opens a TCP connection to the remote host, negotiates applicable TELNET options, and exchanges terminal characters. The server presents a login prompt or service interface, processes the input and sends display output back. TCP preserves byte order, but TELNET itself does not secure the user's credentials or terminal data.
Logging In to a Remote Host with TELNET
An administrator connects to a legacy device at 192.0.2.40 using TELNET. The client establishes TCP port 23, receives a login prompt and sends the username and password as ordinary session data. The device accepts the credentials and returns a command prompt, but a traffic observer could capture the exchange.
TELNET over TCP and Its Modern Replacement
TELNET provides a remote terminal interface rather than transferring files or resolving domain names. It uses TCP for a reliable stream and supports terminal option negotiation. SSH replaced it for secure administration by adding authenticated, encrypted communication; TELNET may remain in isolated labs or legacy environments where risk is controlled.
Security Errors Associated with TELNET
'TELNET encrypts passwords because it has a login prompt' is false because traditional TELNET sends session data unencrypted. 'TELNET is a terminal emulator inside the remote computer' confuses client behavior with the remote service. 'TCP makes the session confidential' is wrong because TCP provides ordered delivery, not encryption or peer authentication.
Identifying TELNET Commands, Port and Risks
Identify TCP port 23, the Network Virtual Terminal concept and the option-negotiation role. Trace a connection from TCP setup to character exchange and remote output. Explain why SSH is preferred for administration and distinguish TELNET's remote terminal service from local login, FTP file transfer and HTTP web access. Focus on the endpoint running the commands and the channel carrying the terminal data.
TELNET Terminal and Session Terms
- TELNET - Provides text-based remote terminal access.
- NVT - Defines a common terminal representation.
- TCP port 23 - Receives traditional TELNET connections.
- Option negotiation - Agrees on terminal operating features.
- Remote login - Accesses another host over a network.
- SSH - Provides secure remote terminal access.
📝 All TELNET protocol in computer networks MCQs
Q1. If a program requires guaranteed delivery of data, which Java class should be chosen and why?
📖 Explanation: Socket uses TCP, which ensures ordered, loss‑free delivery through acknowledgments and retransmissions. DatagramSocket relies on UDP, which offers no such guarantees, so the correct choice for reliability is the Socket class.
Q2. When a client creates a DatagramSocket using the no‑argument constructor, how does the socket become bound to a local address?
📖 Explanation: The no‑arg constructor creates an unbound socket; the first call to send() triggers the OS to allocate an available local port and bind the socket to the appropriate local IP, satisfying the requirement that a socket be bound before communication.
Q3. Explain the mechanism by which the UDP client in Table 25.13 blocks execution until the server’s response arrives.
📖 Explanation: DatagramSocket.receive(Packet) is a blocking operation; the thread halts until a datagram arrives or a timeout occurs. This design lets the client pause execution without consuming CPU cycles, effectively “sleeping” until the server’s reply is placed in the packet buffer.
Q4. Which of the following statements correctly compares the two DatagramPacket constructors regarding their suitability for sending data?
📖 Explanation: To send a datagram, the packet must contain the destination address and port, which are supplied by the constructor that accepts those parameters. The simpler constructor lacks this information and is intended for receiving packets, where the source is filled by the system.
Q5. In what fundamental way does ServerSocket differ from Socket in Java network programming?
📖 Explanation: A ServerSocket binds to a local port and invokes accept() to create a new Socket for each client, establishing a dedicated two‑way channel. A Socket, by contrast, represents one end of an already‑established TCP connection and is used for data exchange, not for listening.
Q6. Given two methods that convert an IPv4 address string to a 32‑bit integer, which approach is more efficient and why?
📖 Explanation: InetAddress.getByName parses the textual address once and returns a byte array; converting that array to an integer is straightforward and avoids repeated string manipulation. The other methods involve multiple allocations or regex processing, which are slower and consume more memory.
Q7. To modify the client in Figure 25.16 so that it can transmit a picture instead of a text string, which changes are required?
📖 Explanation: Binary data must be read from the file system and written directly to the socket’s OutputStream. BufferedReader works with characters, so it must be replaced by a FileInputStream (or BufferedInputStream) and the raw byte array sent, ensuring the image bytes are transmitted unchanged.
Q8. When the request in Figure 25.15 is a URL pointing to an image, how is the URL represented inside the recvBuff array?
📖 Explanation: The client receives the request as a byte stream; the URL is transmitted as its textual representation, typically encoded in UTF‑8 and terminated by a newline or null byte to signal the end of the string. The buffer therefore holds the character bytes, not the image data.
Q9. How does the TCP client in Figure 25.18 obtain its input and output streams after the Socket object is created?
📖 Explanation: Once the Socket is connected, the getInputStream() and getOutputStream() methods return raw byte streams linked to the underlying TCP channel. Wrapping these streams with higher‑level classes (e.g., BufferedReader, PrintWriter) allows convenient text processing while preserving the connection.
Q10. Why does the TCP client program avoid using high‑level input stream classes such as Scanner directly on the socket?
📖 Explanation: Scanner parses input based on delimiters (whitespace, line breaks) and assumes a character encoding, which can cause it to block or misinterpret binary protocols. Directly using InputStreamReader and BufferedReader gives precise control over encoding and avoids unintended waiting for delimiters that may never appear.
Q11. Which Java statement correctly extracts the InetAddress from an InetSocketAddress variable named sockAd?
📖 Explanation: InetSocketAddress provides the method getAddress() that returns the associated InetAddress object. The other listed methods either do not exist for this class or return different types (e.g., a string), making option A the correct way to retrieve the address.
Q12. Consider the two methods getPort() and getLocalPort() of a Socket object. Which statement best evaluates their differences in the context of a client connecting to a server?
📖 Explanation: When a client socket connects, getPort() yields the destination (server) port number, whereas getLocalPort() reveals the automatically assigned local (ephemeral) port on the client side. This distinction is crucial for logging, firewall rules, or when multiple connections share the same remote endpoint.
Q13. Write a Java method that converts a 32‑bit unsigned integer to a dotted‑decimal IP string; which of the following implementations is correct?
📖 Explanation: The first option extracts each octet by shifting the integer right by 24, 16, and 8 bits and masking with 0xFF, then concatenates them with periods. This yields the standard dotted‑decimal notation. The second option reverses the order, the third produces binary groups, and the fourth requires handling signedness, making option A the correct implementation.