CS Atlas GATE 2027
Computer Networks course
0 / 90 complete

Computer Networks/Phase 5 · Application Layer

Lesson 5.1 · Item 76 of 90

The client-server model and application protocols

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

  1. Order of server socket calls?
    Stuck? Peek at 4.4 The Socket API: system calls, client-server order & blocking calls
    • TCP Server order: socket() → bind() → listen() → accept() → recv()/send() → close().
    • TCP Client order: socket() → connect() → send()/recv() → close() (OS auto-binds ephemeral port).
    • UDP Server / Client: no listen() or accept(); uses recvfrom() / sendto() on a single bound socket.
    • Blocking calls: connect(), accept(), and recv() block by default; listen() does NOT block.

    Read lesson 4.4

  2. How many RTTs does the TCP 3-way handshake take before the client may send data?
    Stuck? Peek at 4.3.2 TCP 3-way handshake, connection termination & state machine
    • 3-way handshake: SYN(seq=x) → SYN+ACK(seq=y, ack=x+1) → ACK(seq=x+1, ack=y+1).
    • Seq consumption: SYN = +1, FIN = +1, Pure ACK = 0, Data(L) = +L (full connection advances by D + 2).
    • Teardown states: Active closer goes FIN-WAIT-1 → FIN-WAIT-2 → TIME-WAIT (2·MSL) → CLOSED; Passive closer goes CLOSE-WAIT (half-close) → LAST-ACK → CLOSED.

    Read lesson 4.3.2

  3. Which OSI layers does TCP/IP merge into its application layer?
    Stuck? Peek at 1.1.2 The OSI 7 layers and the TCP/IP model
    • OSI bottom-up: Physical, Data link, Network, Transport, Session, Presentation, Application.
    • Scope: link → hop → host-to-host → process-to-process.
    • Routers: layers 1–3; hosts: 1–7.
    • TCP/IP (5): application (= OSI 5–7), transport, network, data link, physical.
    • Encryption/compression = presentation; dialogue control = session.

    Read lesson 1.1.2

The Hook

Every layer below has been a delivery service. Now, at the top of the stack, our story finally asks why the message is sent: you want a web page. Your browser (a client program) asks a server program on another machine. The rules for what they say to each other — the format of the questions and answers — form an application protocol. This phase covers the two you use before every page loads: the name lookup (5.2) and the page fetch (5.3).

Predict First

A popular server has 1000 users connected at the same time, each over TCP. How many sockets does the server process hold open?

,

1001 or more: one listening (welcome) socket plus one connected socket per client connection (Lesson 4.4). If each client opens two connections, 2001.

Core Concept

Client and server

A server is a program that runs continuously at a well-known address and port, waits for requests and answers them. A client is a program that starts the conversation when a user needs something. The same machine can run both.
Client (browser)Serverrequestprocess the requestresponse
The client always speaks first; the server listens on a well-known port.

What an application protocol defines

  • The message types (request, response, …).
  • The syntax: fields and how they are written (text lines or binary).
  • The semantics: what each field means.
  • The rules: when and how to send and respond.
  • Which transport it uses (TCP for reliability, UDP for small fast exchanges) and which well-known port the server listens on.
Application needTransport usually chosenWhy
Every byte must arrive (web pages, mail, files)TCPreliable, ordered byte stream
One small question, one small answer (name lookups)UDPno handshake → faster; the app retries itself
Live voice/videoUDP (or special protocols)late data is useless; avoid retransmission delay
Applications pick the transport that suits them (UDP is the best-effort service of Lesson 4.1).

Peer-to-peer (brief)

In peer-to-peer (P2P) systems every machine is both client and server: peers download pieces from each other. The server's upload capacity stops being a bottleneck because every new peer also uploads.

Client-server
one always-on server; server upload limits scale
P2P
peers serve each other; capacity grows with users
Two ways to organise applications.

Putting it together

  • Clients ask, servers answer at well-known ports.
  • An application protocol fixes message types, syntax, meaning and timing.
  • P2P makes every user also a server, removing the upload bottleneck.

Visual

Applicationname lookup, web pages (this phase)
TransportTCP / UDP · ports
NetworkIP addresses, routing
Data linkframes, MAC
Physicalbits
We are at the top of the stack: the application protocols ride on everything learned so far.

Worked Examples

Easy

A server has 1000 clients, each holding 2 TCP connections to it. How many sockets does the server keep open?

Show the full solution

2 × 1000 connected sockets + 1 listening socket = 2001.

Medium

Client-server distribution: a 20 MB file (1 MB = 10⁶ bytes as stated) must reach 50 clients. The server uploads at 100 Mbps. Ignoring other limits, how long does the server need to send all copies?

Show the full solution

Total bits = 50 × 20 × 10⁶ × 8 = 8 × 10⁹. Time = 8 × 10⁹ / 10⁸ = 80 s.

GATE

Same file and 50 users, but P2P: server upload 100 Mbps, every peer uploads 2 Mbps and downloads at most 10 Mbps. Lower bound on distribution time = max(F/us, F/dmin, N·F/(us + Σui)). Compute it.

Show the full solution

F = 1.6 × 10⁸ bits. F/us = 1.6 s. F/dmin = 16 s. N·F/(us + 50 × 2 Mbps) = 8 × 10⁹ / 2 × 10⁸ = 40 s. Maximum = 40 s — half the client-server time, and the gap grows with N.

GATE Traps

  • A server listens on a well-known port; the client usually uses an ephemeral port chosen by its OS.
  • "Server" is a program role, not a kind of hardware.
  • Application protocols choose TCP or UDP — the choice is part of the protocol.

Memory Hook

"The client knocks, the server answers — and the protocol is the language at the door."

Connect the Dots

Before your browser can knock, it needs the server's IP address — but you typed a name. Next (5.2): how is a name turned into an address, quickly and for billions of users?

Self-Test

  1. MCQ

    Which statement about a server process is correct?

    1. It starts the conversation.
    2. It listens at a well-known port and answers requests.
    3. It must run on special hardware.
    4. It always uses UDP.
  2. NAT

    A server has 300 clients with one TCP connection each. Sockets open at the server?

    Write your answer before opening the key.

  3. MSQ

    An application protocol defines:

    1. message types
    2. message syntax and meaning
    3. the routing algorithm
    4. when to send which message
  4. NAT

    Client-server: 10 copies of an 8 × 10⁸-bit file, server upload 200 Mbps. Minimum seconds for the server to upload all copies?

    Write your answer before opening the key.

Rule Card

  • Client initiates; server listens at a well-known port and answers.
  • Application protocol = message types + syntax + semantics + rules + transport/port choice.
  • Server sockets = 1 listening + 1 per connection.
  • P2P: peers serve each other; client-server distribution ≥ N·F/u_s.

Concept Ledger

  • client-server model
  • server, client
  • application protocol (types, syntax, semantics, rules)
  • peer-to-peer (P2P, brief)

Answer Vault

Try the questions first. Open when you are ready to check.

Warm-up answers

  1. socket → bind → listen → accept → recv/send → close.
  2. One RTT (SYN, SYN-ACK), then the client sends ACK with or before its data.
  3. Application, presentation and session.

Self-test answers

  1. B — Servers wait and answer; clients initiate.
    • A: Clients initiate.
    • C: Any machine can run a server.
    • D: Many servers use TCP.
  2. 301 — 300 connected + 1 listening.
  3. ABD — Types, syntax, semantics, rules.
    • C: Routing is the network layer's job.
  4. 40 — 8 × 10⁹ / 2 × 10⁸ = 40 s.

Flashcards

  1. Who initiates in client-server?
    Reveal answerThe client.
  2. What does an application protocol define?
    Reveal answerMessage types, syntax, semantics, rules (and transport/port).
  3. Sockets at a server with n connections?
    Reveal answern + 1.

Exam shortcuts

  • Server sockets = 1 listening + 1 per connection. — TCP servers using the standard socket API.
  • Client-server distribution ≥ N·F / u_s. — server upload is the bottleneck (many clients).

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.