Protocol stack and switching is the foundation for every network topic in the PSC Computer Engineer syllabus. If you understand layers, encapsulation and forwarding decisions, later topics like Ethernet, IP, TCP, DNS and routing become connected instead of memorized fragments.
Engineering Definitions
Protocol stack
Standard definition: A layered collection of protocols where each layer offers services to the layer above and uses services of the layer below.
Exam meaning: Layer अनुसार काम बाँडेर communication reliable, modular and interoperable बनाउने structure।
Encapsulation
Standard definition: The process of wrapping data with protocol headers/trailers as it moves down the stack.
Exam meaning: Application data तल layer झर्दा TCP header, IP header, frame header जस्ता metadata थपिँदै जानु।
Switching
Standard definition: A forwarding technique that moves data through intermediate nodes toward a destination.
Exam meaning: Network मा data कुन path/interface बाट पठाउने भन्ने forwarding mechanism।
Concept Teaching
A network is easier to understand if you follow one message. Application creates data, transport adds process-to-process delivery information, network adds host-to-host addressing, link layer adds local network delivery information and physical layer transmits bits. Switching decides where the unit of data goes next.
OSI Model vs TCP/IP Model
OSI is a teaching/reference model with seven layers; TCP/IP is the practical internet model. PSC questions may ask either model, but engineering answers should map both and explain what each layer contributes.
| OSI Layer | TCP/IP Equivalent | Main work | PDU / Data unit | Address or identifier |
|---|---|---|---|---|
| Application | Application | User-facing network services such as HTTP, FTP, SMTP, DNS | Data / message | URL, domain name, application command |
| Presentation | Application | Data format, encryption, compression, character encoding | Data | Encoding/format such as TLS, JPEG, UTF-8 |
| Session | Application | Dialog/session control, checkpoints, connection management concept | Data | Session identifier/context |
| Transport | Transport | Process-to-process delivery, reliability, flow control, multiplexing | Segment/datagram | Port number |
| Network | Internet | Logical addressing and routing across networks | Packet/datagram | IP address |
| Data Link | Link | Framing and local-hop delivery inside one link/LAN | Frame | MAC address |
| Physical | Link/Physical medium | Transmission of raw bits as electrical/optical/radio signals | Bits | Signal properties, medium |
Physical Layer: Bits, Signals and Medium
Physical layer is not about files, IP or applications. It converts bits into signals and defines transmission medium behavior.
- Deals with voltage, light pulses, radio waves, connectors, modulation, bit rate and synchronization.
- Engineering concern: attenuation, noise, bandwidth, interference, encoding and physical topology.
- Exam trap: physical layer does not understand frames, MAC address, IP address or ports.
Data Link Layer: Frames, MAC and Local Delivery
Data link layer takes packets and wraps them into frames for one-hop delivery over a local link.
- Sublayers: LLC provides logical link control; MAC controls access to the medium.
- Important services: framing, error detection using CRC/FCS, MAC addressing, media access.
- Devices/concepts: switches, bridges, Ethernet, Wi-Fi MAC, PPP, ARP support for IP-to-MAC resolution.
- Engineering trap: switches forward frames using MAC table; routers forward packets using IP routing table.
Network Layer: IP, Routing and Logical Addressing
Network layer allows communication across multiple networks. Its central job is host-to-host delivery using logical addresses.
- Main protocols/concepts: IPv4, IPv6, ICMP, routing, fragmentation, TTL/hop limit.
- Router operation: receive frame, extract IP packet, check destination IP, longest-prefix match, forward to next hop.
- Engineering concern: addressing plan, subnetting, routing convergence, MTU, fragmentation and path selection.
- Exam trap: IP provides best-effort delivery; reliability is normally handled by transport layer protocols such as TCP.
Transport Layer: Ports, Reliability and Congestion
Transport layer connects processes, not just hosts. It uses port numbers so many applications can share one network connection.
- TCP provides connection-oriented reliable byte stream using sequence number, acknowledgement, retransmission and flow/congestion control.
- UDP provides connectionless datagram service with low overhead and no built-in reliability.
- Multiplexing/demultiplexing means mapping data to the correct process using port numbers.
- Engineering trap: TCP reliability is end-to-end; Ethernet FCS only detects local frame errors.
Session, Presentation and Application Layers
In TCP/IP, these OSI upper layers are usually grouped into the application layer, but OSI separates their responsibilities for clarity.
- Session layer: manages dialog, checkpoints and session recovery conceptually.
- Presentation layer: handles data representation, compression, encryption and encoding.
- Application layer: provides services such as HTTP, DNS, FTP, SMTP, POP/IMAP and remote login.
- Exam trap: DNS is application layer but it supports other applications by resolving names to IP addresses.
End-to-End Flow Example
When a user opens a website, every layer participates. This is the best way to write an engineering answer.
- Application: browser creates HTTP/HTTPS request; DNS resolves domain to IP if needed.
- Transport: TCP creates connection using source/destination ports; TLS may secure data above TCP.
- Network: IP packet is addressed to destination server IP and routed hop by hop.
- Data link: each hop uses a new frame with local source/destination MAC.
- Physical: bits are transmitted over cable, fiber or wireless signal.
Engineering Mechanism
- Application data is created by a program such as browser, mail client or FTP client.
- Transport layer segments data and adds port numbers; TCP may add sequence and acknowledgement logic.
- Network layer creates IP packet with source/destination IP and routing information.
- Link layer creates frame with source/destination MAC for local hop.
- Switching/forwarding device reads relevant header and sends frame/packet to correct outgoing interface.
Diagrams / Models To Draw
- Draw TCP/IP stack: Application, Transport, Internet, Link, Physical.
- Draw encapsulation: Data -> Segment -> Packet -> Frame -> Bits.
- Draw packet switching path with routers and independent packets.
- Draw circuit switching path with reserved circuit.
Formulas, Fields and Algorithms
- Layer PDU names: data, segment/datagram, packet, frame, bits.
- Switching decision depends on table lookup: MAC table for switch, routing table for router.
- Delay components: processing delay + queuing delay + transmission delay + propagation delay.
| Concept | Engineering meaning | Exam trap |
|---|---|---|
| Layering | Separates responsibilities and hides implementation detail | Do not mix MAC, IP and port at same layer |
| Packet switching | Packets share network dynamically | No dedicated path is guaranteed |
| Circuit switching | Dedicated path/resources reserved | Efficient for constant stream, not bursty data |
| Encapsulation | Headers/trailers added per layer | Header changes at each hop for link layer |
Exam Point
- Use layer-wise language in answers: service, interface, protocol, encapsulation.
- For 10-mark answer, draw stack and encapsulation diagram.
- Compare packet vs circuit switching with resource use, delay and reliability.
Worked Example
When a browser sends a request, HTTP data becomes a TCP segment, then an IP packet, then an Ethernet/Wi-Fi frame. A switch forwards using MAC address inside a LAN, while a router forwards using destination IP between networks.
Subjective Answer Pattern
- Define protocol stack and switching.
- Explain why layering is used: modularity, interoperability and abstraction.
- Show encapsulation with PDU names.
- Compare packet and circuit switching.
- Conclude with web request example.
Common Engineering Mistakes
- Writing OSI layer names without explaining services.
- Saying switch and router do the same forwarding.
- Forgetting that link-layer header changes hop by hop while IP header generally remains end-to-end.
MCQ Revision
- Which layer uses port numbers?
- What is encapsulation?
- Which device uses MAC table?
- Packet switching reserves a dedicated path: true or false?
Final Summary
- Protocol stack is the mental model for networks.
- Encapsulation explains how data carries control information.
- Switching is forwarding based on table and header fields.