---
title: "Stub, skeleton and NFS architecture"
subject: "Distributed System"
chapter: 2
key: "semester_7/distributed_system:stub-skeleton-nfs"
source: https://www.bctengineer.com/q/semester_7/distributed_system/stub-skeleton-nfs
site: BCT Engineering
---

# Stub, skeleton and NFS architecture

Distributed System · Chapter 2: Distributed Objects and File System

- Asked in: 2074 Chaitra, 2+6 marks
- Video: [RMI architecture | Distributed Systems | Lec-23 | Bhanu Priya](https://www.youtube.com/watch?v=ZXnuMY-C1so) — Education 4u
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/stub-skeleton-nfs
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-2

## Question

Mention the role of stub and skeleton in distributed system. Explain the architectural details of the Network File System (NFS).

## Short answer

Stubs marshal parameters and unmarshal replies, providing access transparency; skeletons unmarshal requests, invoke the server method, and marshal results. NFS architecture uses a VFS layer, an NFS client that translates file operations to RPCs, and a stateless NFS server that identifies files by file handles, with a mount service for location transparency.

## Answer

#### Role of stub and skeleton
- **Stub (client side proxy):** a local piece of code that stands in for the remote procedure or object. The client calls it like a local procedure. It **marshals** the parameters into a message, sends the request, waits, then **unmarshals** the reply and returns it. It provides access transparency.
- **Skeleton (server side stub):** receives the request, **unmarshals** the arguments, calls the actual procedure or method of the server object, and marshals the result into the reply. In RMI, a dispatcher first selects the right method of the skeleton.
- Both are generated automatically from the interface definition (IDL), so the programmer need not write network code, and they hide heterogeneity.

#### Network File System (NFS) architecture
**SUN NFS** (Network File System) is the most widely used distributed file service, developed by Sun Microsystems. It lets a client access remote files as if they were local, over an RPC-based protocol that is independent of the operating system, hardware and network.

**Architecture**

```text
 Client computer                       Server computer
 +-----------------------------+       +-----------------------------+
 | Application programs        |       |                             |
 |-------- UNIX kernel --------|       |-------- UNIX kernel --------|
 |    Virtual file system      |       |    Virtual file system      |
 |      |              |       |       |       |              |      |
 | +----v-----+  +-----v-----+ |       | +-----v-----+  +-----v----+ |
 | | UNIX     |  | NFS       | |       | | NFS       |  | UNIX     | |
 | | file     |  | client    | |       | | server    |  | file     | |
 | | system   |  |           | |       | |           |  | system   | |
 | +----------+  +-----+-----+ |       | +-----+-----+  +----------+ |
 +---------------------|-------+       +-------|---------------------+
                       |                       |
                       +<---- NFS protocol --->+
                              (RPC over UDP/TCP)
```

- **Virtual file system (VFS):** a layer in the kernel that decides whether a request is for a local file or a remote file and passes it to the UNIX file system or to the NFS client. It keeps a *v-node* for each open file; the v-node holds an i-node reference for a local file or a *file handle* for a remote file.
- **NFS client:** translates VFS operations into RPC requests to the server.
- **NFS server:** receives requests, identifies the file by its **file handle** (file system id, i-node number, i-node generation number), and calls the local file system.
- **Mount service:** a client mounts a remote directory into its local file tree. The server lists the file systems it exports in /etc/exports, and the client records each mounted remote directory in its mount table.
- **Automounter:** mounts a remote directory on first use.

**Operation**

1. The application issues a system call (for example read).
2. The VFS finds that the file is remote and calls the NFS client.
3. The NFS client sends an RPC (lookup, read, write, getattr, create, remove, mkdir, readdir...) over UDP/TCP using XDR encoding.
4. The NFS server's VFS finds the local file by the file handle, runs the operation on the local file system and returns the result.
5. The client caches the data (block cache) and attributes. Cache validity is checked by comparing timestamps; a cached entry is trusted for a freshness interval of about 3–30 seconds for files and 30–60 seconds for directories.

**Features / properties**

- **Access and location transparency** through mounting.
- **Stateless server:** each request carries all the information needed, so a crashed server restarts without recovery work; operations are idempotent.
- **Heterogeneity:** works with any OS that implements the protocol.
- **Caching:** read-ahead and delayed write for performance, with approximate (not strict one-copy) consistency.
- **Security:** the original version trusted the user id sent in the RPC; later versions use Kerberos.
- **Limited replication and migration support.**

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does the client stub do?
   A. Marshals parameters into a message, sends the request, then unmarshals the reply
   B. Unmarshals arguments and calls the server procedure
   C. Maintains the file system on the server
   D. Chooses the nearest replica
   Answer: A. The stub stands in for the remote procedure and provides access transparency. (Key point: Client stub)

2. What does the skeleton do on the server?
   A. Marshals arguments for sending
   B. Unmarshals arguments, calls the actual procedure or method, and marshals the result
   C. Generates the IDL
   D. Mounts remote directories
   Answer: B. In RMI it also dispatches to the right method. (Key point: Skeleton)

3. How are stubs and skeletons usually produced?
   A. Written by hand for every call
   B. Copied from the client OS
   C. Automatically from the interface definition (IDL)
   D. Downloaded at run time from DNS
   Answer: C. Generation hides network code and heterogeneity from the programmer. (Key point: Generation)

4. What does the Virtual File System (VFS) layer do in NFS?
   A. Decides whether a request is for a local or a remote file and passes it to the UNIX file system or the NFS client
   B. Stores the file data of remote clients on the server
   C. Encrypts all RPC messages between client and server
   D. Mounts remote directories automatically on first use
   Answer: A. The VFS sits in the kernel and routes each request, using v-nodes for local and file handles for remote files. (Key point: Role of VFS)

## Related in Distributed System

- [SUN NFS architecture and operation](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Asun-nfs-architecture) — Distributed System, chapter 2, asked 3×
- [Stateful vs stateless; NFS architecture](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Anfs-stateful-stateless) — Distributed System, chapter 2
- [DFS requirements and file service architecture](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adfs-requirements-architecture) — Distributed System, chapter 2
- [Need of naming; Sun NFS](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Anaming-nfs) — Distributed System, chapter 2
- [Context switching; distributed vs network OS](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Acontext-switch-dos) — Distributed System, chapter 3
- [Network OS vs distributed OS](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Anos-vs-dos-diff) — Distributed System, chapter 3

## Related in other subjects

- [Google File System architecture](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Agfs-architecture) — Big Data Technologies, chapter 2, asked 2×
- [Architectural design and multiprocessor architecture](https://www.bctengineer.com/question.md?key=semester_5%2Fsoftware_engineering%3Aarchitectural-design-multiprocessor) — Software Engineering, chapter 3
- [Double-stub microstrip network and its S-matrix](https://www.bctengineer.com/question.md?key=semester_7%2Frf_and_microwave_engineering%3Adouble-stub-microstrip-smatrix) — RF and Microwave Engineering, chapter 2
- [Distributed object versus multiprocessor architecture](https://www.bctengineer.com/question.md?key=semester_5%2Fsoftware_engineering%3Adistributed-object-vs-multiprocessor) — Software Engineering, chapter 3
