The Application Layer’s Role

The Application Layer (Layer 7) is the layer the user interacts with. Its job is to provide specific services and translate user input into the structures required by the Transport Layer (Part 66).

Protocol 1: DNS (Domain Name Service)

Users prefer typing names (google.com) rather than IP addresses. DNS is the protocol that translates these human-readable names into the 4-byte IP addresses required by the Network Layer.

The DNS Client Routine:

  1. Form Query: Build a DNS request packet containing the desired domain name.
  2. Send: Send the packet to a known DNS Server Address via the UDP transport protocol (unreliable but fast).
  3. Wait for Response: Poll the network buffer for the response packet.
  4. Extract: Parse the response to find the IP Address and return it to the application.

Implementation Challenge: The Z80 routine must convert the ASCII domain name (e.g., “labby.co.uk”) into the length-prefixed binary format required by the DNS packet structure (e.g., 5labby2co3uk0).

Protocol 2: Telnet (Terminal Emulation)

Telnet is a simple application protocol used to establish a remote command-line session. It is the network version of a basic text terminal.

The Principle:

  1. Input: When the user types a key on the Z80 keyboard, the Telnet client reads the character.
  2. Transmission: The client wraps the character in the necessary TCP (reliable) header and sends the packet across the network to the remote server (port 23).
  3. Output: When the client receives a packet from the remote server, it reads the data and prints the characters to the Z80 screen using the `PutChar′ routine (Part 59).

Telnet Protocol Commands

Telnet also defines a set of negotiation commands (e.g., `IAC WILL ECHO′) to determine how the remote host handles data.

The Z80 Client’s Job: The Z80 client must constantly check the incoming TCP stream for the `IAC′ (Interpret As Command) byte and then jump to a subroutine to handle the negotiation sequence before continuing to display text.

The Final Network Structure: When your user sends the letter ‘A’ via Telnet: $$\text{‘A’} \xrightarrow{\text{Telnet}} \xrightarrow{\text{TCP}} \xrightarrow{\text{IP}} \xrightarrow{\text{Link Layer (SIO)}} \xrightarrow{\text{Physical Wire}}$$ The entire chain, from application (Telnet) to hardware (SIO), must be functional for the communication to succeed.