Computer Science and IT‹›⌂ 0:00 studied

Module 11 · 14 min read · Free chapter

Layering, OSI and TCP/IP, and switching

In short

A network splits its work into layers. OSI has seven: physical, data link, network, transport, session, presentation and application, while TCP/IP has four. Each layer adds a header, so data becomes a segment, packet, frame and bits. Transmission delay is L/R and propagation delay is d/s.

See it in 3DPacket journey through the layers: laptop, switch, router, fibre, server. Turn it, cut it open, or just press Watch.
What are you preparing for? We show the practice and previous year questions of your exam.

Start from zero: how a letter crosses India

Suppose your aunt in Patna writes a letter to you in Pune. She does not need to know which train carries mail, or how the sorting office works. She writes the letter, puts it in an envelope with the address, and drops it in the post box.

Now look at what happens next. The local post office bundles letters by city, the sorting office puts the Pune bundle on a train, and the train crew only cares about bags, not about what is written inside. In Pune the same steps happen in reverse, and the postman finally hands you the envelope.

Each person in this chain does one job and talks only to the matching person at the other end. Your aunt "talks" to you, the Patna sorting office "talks" to the Pune sorting office, and so on. A computer network works in exactly this way, and each such level of work is called a layer.

Why it matters. Without layers, every program would have to know about cables, radio waves and routes. With layers, a WhatsApp developer writes only the top part, while cable engineers and router makers work on their own parts. That is why the Internet could grow from wires to fibre to 5G without rewriting every application.

Why layers, and the OSI and TCP/IP stacks

A layer is a group of related jobs. Each layer gives a service to the layer above it and uses the service of the layer below it. It also follows a protocol with its peer, the same layer on the other machine, which is a set of rules about message format and order.

The OSI reference model has seven layers. It is mostly used for teaching and for naming things, because the real Internet runs on the simpler TCP/IP stack. From bottom to top the seven layers are as follows.

No. Layer Main job Example
7 Application Gives network services to user programs HTTP, SMTP, DNS
6 Presentation Data format, encryption, compression Character code conversion
5 Session Starts and ends dialogues, adds checkpoints Resuming a long transfer
4 Transport Process-to-process delivery, reliability, ports TCP, UDP
3 Network Logical addressing and routing across networks IP, ICMP
2 Data link Framing, error detection, access to one link Ethernet, Wi-Fi
1 Physical Sends raw bits as signals on the medium Cable, fibre, radio

A common way to remember the order from layer 1 upward is "Please Do Not Throw Sausage Pizza Away". The bottom three layers are present in every router, while the top four run only in the end hosts. That is why transport is called the first end-to-end layer.

The TCP/IP model has four layers: application, transport, internet and link. Many exam papers use a five-layer version in which link is split into data link and physical. There is no separate session or presentation layer, because those jobs, such as encryption, are done by the application itself.

Why it matters. Questions on "which layer does what" appear in almost every RRB JE, IT officer and GATE paper. The real skill is to place a job or a device on the right layer, which the next sections build on.

Encapsulation, PDUs and devices

When you open a web page, the browser creates an HTTP request, which is the message. The transport layer adds a TCP header with port numbers, and the result is a segment. The network layer adds an IP header with source and destination IP addresses, giving a packet (also called an IP datagram).

The data link layer then adds a header with MAC addresses and a trailer with an error check, giving a frame. Finally the physical layer sends the frame as bits, as voltage levels, light pulses or radio waves. This wrapping of data inside headers, layer by layer, is called encapsulation.

At the receiver each layer reads and removes its own header and passes the rest upward, which is decapsulation. The name of the data unit at each layer is its protocol data unit (PDU). So the PDUs are message, segment, packet, frame and bits, from top to bottom.

Network devices are classed by the highest layer they understand. A hub or repeater only copies bits, so it is a physical-layer device, and every machine on a hub shares one collision domain. A switch reads MAC addresses in frames and sends each frame only to the right port, so it is a data-link device that gives each port its own collision domain.

A router opens the frame, reads the IP header, chooses the next hop and builds a new frame for the next link. So a router works at the network layer, and it also separates broadcast domains. A frame's MAC addresses change at every router, but the IP addresses stay the same from source to destination, unless address translation is in use.

Why it matters. Header overhead, MAC versus IP addresses and "what does a router look at" are classic exam questions. For example, if each of four layers adds a 20-byte header to 100 bytes of data, the bits on the wire carry 180 bytes, so only 100180\dfrac{100}{180}, about 56%, is useful data.

Circuit, packet and virtual-circuit switching

A network has many links and many users, so it must decide how to share them. There are three main ways, and the old telephone network uses the first.

In circuit switching, a path is set up before any data flows, and a fixed share of bandwidth on every link is reserved for that call. Once set up, data flows at a steady rate with no queuing, which suits voice. But the reserved capacity is wasted during silences, and a new call can be refused if no capacity is left.

In packet switching with datagrams, the data is cut into packets, and each packet carries the full destination address. Every router looks up its table separately for each packet, so two packets of the same message may take different paths and arrive out of order. Nothing is reserved, so links are shared well, but delay varies with queues.

Virtual-circuit (VC) switching is a middle path. A setup phase picks a route and stores a small VC number in each router on it. After that every packet carries only the VC number, follows the same route and arrives in order, but bandwidth is still shared, not reserved.

Feature Circuit Datagram Virtual circuit
Setup phase Yes No Yes
Address in each packet None needed Full destination address Short VC number
Path Fixed Each packet decides Fixed after setup
Order of arrival In order May be out of order In order
Bandwidth Reserved Shared on demand Shared on demand
Effect of a router failure Call drops Packets reroute Circuit must be set up again

The Internet's IP layer is a datagram network. Older networks such as X.25, Frame Relay and ATM used virtual circuits. There was also message switching, where a whole message was stored and forwarded at each node, but it is now only of historical interest.

Why it matters. Packet switching lets many bursty users share a link, which is why the Internet is cheap. For example, a 10 Mbps link can carry ten users who each need 1 Mbps under circuit switching. With packet switching it can serve far more than ten such users if each is active only part of the time, since they rarely all send together.

The four delays and store-and-forward numericals

A packet going through one router faces four delays. Processing delay is the time to check the header and look up the route, usually microseconds. Queuing delay is the wait behind other packets, which can be zero or very large.

Transmission delay is the time to push all bits of the packet onto the link, equal to LR\dfrac{L}{R} for L bits on a link of R bits per second. Propagation delay is the time for one bit to travel the length of the link, equal to ds\dfrac{d}{s} for distance d and signal speed s. In copper and fibre s is about 2 × 10⁸ m/s, two-thirds of the speed of light in vacuum.

Students often mix the last two, so think of a toll booth. The time for a whole bus convoy to pass the booth is transmission, and it depends on how many buses there are and how fast the booth works. The time for one bus to drive to the next town is propagation, and it depends only on the distance.

Worked example 1. A 1,000-byte packet is sent on a 1 Mbps link that is 2,000 km long.

  • The packet has 8,000 bits, so the transmission delay is 8000106\dfrac{8000}{10^6} s = 8 ms.
  • The propagation delay is 2×106 m2×108 m/s\dfrac{2 \times 10^6\ \text{m}}{2 \times 10^8\ \text{m/s}} = 10 ms.
  • With no processing or queuing, the last bit reaches the far end after 8+10=188 + 10 = 18 ms.

Store-and-forward. A router must receive the whole packet before it can send it on. So one packet over N equal links takes N⋅LRN \cdot \dfrac{L}{R} of transmission time, plus the propagation on each link.

Worked example 2. A 10⁶-bit file goes over 3 links of 1 Mbps each, through 2 routers, ignoring propagation.

  • Sent as one message, each link needs 1 s, so the total is 3×1=33 \times 1 = 3 s.
  • Cut into 1,000 packets of 1,000 bits, each packet needs 1 ms per link.
  • The first packet arrives after 3 ms, and then one packet arrives every 1 ms, so the total is (3+1000−1)×1 ms=1002 ms(3 + 1000 - 1) \times 1\ \text{ms} = 1002\ \text{ms}, about 1 s.

Small packets win because all links work at the same time, like an assembly line. The general rule is (N+P−1)⋅LR(N + P - 1) \cdot \dfrac{L}{R} for P packets over N links. In practice each packet also carries a header, so packets that are too small waste bandwidth on headers.

Queuing and traffic intensity. If packets of L bits arrive at an average rate of a packets per second, the traffic intensity is L⋅aR\dfrac{L \cdot a}{R}. If it is above 1, bits arrive faster than they can leave and the queue grows without limit. Even below 1, the average queuing delay rises very sharply as the intensity gets close to 1.

Why it matters. GATE often asks for total delay over several hops, or the best packet size for a file. Every such question is solved by writing transmission and propagation separately for each link and then adding carefully.

Bandwidth-delay product, RTT and throughput

Imagine the link as a water pipe. Its width is the bandwidth R and its length, in time, is the propagation delay. The amount of water that fills the pipe is the bandwidth-delay product, R × propagation delay, measured in bits.

Worked example 3. A 100 Mbps link has a one-way propagation delay of 20 ms.

  • The bandwidth-delay product is 108×0.02=2×10610^8 \times 0.02 = 2 \times 10^6 bits, which is 250 KB.
  • So when the first bit reaches the receiver, 2×1062 \times 10^6 bits are already on the wire behind it.
  • If the sender must wait for a reply before sending more, it should be allowed to send about twice this amount, one RTT's worth, to keep the pipe full.

The round-trip time (RTT) is the time for a small packet to reach the other end and for the reply to come back. When transmission and queuing are small, RTT is about twice the one-way propagation delay. In the example above, RTT is about 40 ms.

Throughput is the rate at which useful data actually reaches the receiver. On a path of several links it is limited by the slowest link, called the bottleneck. For example, a file going through links of 100 Mbps, 10 Mbps and 50 Mbps gets at most 10 Mbps.

This product explains why fast long-distance links are hard to use well. A sender that sends one frame and then waits for an acknowledgement wastes most of the pipe, and sliding-window protocols fix this by keeping many frames in flight. The same idea sets the TCP window size needed on a fast path.

Why it matters. The bandwidth-delay product is the hidden link between this chapter and the efficiency numericals of the data link and transport layers. If you can find it quickly, window-size and efficiency questions become one-liners.

Descriptive lens: how written papers ask this

Written papers for IT officer posts, state Assistant Programmer exams and university-level tests ask about layering and switching in four ways:

  1. Explain the OSI model layer by layer, with the job and one protocol or device for each layer.
  2. Compare the OSI and TCP/IP models, usually in a table, and say why TCP/IP won in practice.
  3. Contrast circuit, datagram and virtual-circuit switching with their advantages and drawbacks.
  4. Calculate end-to-end delay for a given path and packet size, and comment on the result.

Practice questions (our own, not previous-year questions).

  1. What is layering in computer networks? Explain the seven layers of the OSI model with one example for each layer. (10 marks)
  2. Compare circuit switching and packet switching, and explain why the Internet uses packet switching. (10 marks)
  3. A 4 MB file is sent over 4 links of 10 Mbps each, using packets of 10,000 bits. Find the total transfer time ignoring propagation, and explain what would happen with much smaller packets. (15 marks)

Answer plan for question 2.

  • Begin by defining circuit switching as reserving a path and bandwidth for the whole call after a setup phase.
  • Then define packet switching as sending independent packets that share links on demand without any reservation.
  • Draw a comparison table covering setup, use of bandwidth, delay, order of arrival and the effect of failures.
  • Explain that circuit switching wastes reserved capacity during silences, which is costly for bursty computer traffic.
  • Show with a small example that packet switching lets many more bursty users share one link.
  • Conclude that the Internet chose packet switching because data traffic is bursty and robustness matters more than fixed delay.

Quick revision

  • A layer gives a service to the layer above and talks to its peer layer through a protocol.
  • The OSI layers from the bottom are physical, data link, network, transport, session, presentation and application.
  • In practice the Internet's TCP/IP model has four layers, application, transport, internet and link, and five in the teaching version.
  • The PDUs from the top are message, segment, packet, frame and bits.
  • A hub works at layer 1, a switch at layer 2 and a router at layer 3.
  • Circuit switching reserves bandwidth, datagrams carry full addresses, and virtual circuits fix the path without reserving bandwidth.
  • Transmission delay is LR\dfrac{L}{R} and propagation delay is ds\dfrac{d}{s}.
  • P packets over N store-and-forward links take (N+P−1)⋅LR(N + P - 1) \cdot \dfrac{L}{R} plus propagation.
  • The bandwidth-delay product R × propagation delay is the number of bits in flight on a link.
  • The slowest link on a path sets its throughput.

Check yourself

Exam-style questions on this chapter. Pick an answer to see the explanation. 0 of 15 answered

  1. In a layered network design, each layer talks to its peer layer on the other machine through:

  2. Which OSI layer is responsible for routing packets across networks?

  3. Encryption and compression belong to which OSI layer?

  4. Which OSI layers have no separate layer in the TCP/IP model?

  5. The PDU at the data link layer is called a:

  6. As a packet passes through several routers, which addresses change at every hop?

  7. A switch with 8 ports, each connected to one computer, has how many collision domains and broadcast domains?

  8. Which statement about virtual-circuit switching is TRUE?

  9. Reserving a fixed path and bandwidth for the whole call is a feature of:

  10. A 1,000-byte packet is sent on a 1 Mbps link 2,000 km long (signal speed 2 × 10⁸ m/s). The time until the last bit arrives is:

  11. Doubling the bandwidth of a link changes which delay?

  12. A file of 10⁶ bits is cut into 1,000 packets and sent over 3 store-and-forward links of 1 Mbps each. Ignoring propagation and headers, the total time is:

  13. Packets of 1,000 bits arrive at a router at 1,200 packets per second on average, and the output link is 1 Mbps. What happens to the queue?

  14. The bandwidth-delay product of a 100 Mbps link with 20 ms one-way propagation delay is:

  15. Which topic is listed under Computer Networks in the GATE 2026 CS syllabus?

Previous year questions

Previous year questions for UPSC CSE will appear here once each one is checked word for word against the official question paper.

Learn with AI

A tutor that asks instead of telling, a partner that argues the other side, and this chapter told through your own district.

Tell the tutor what you are stuck on. It will guide you with questions and give the answer after a few tries.

🙋 Raise a doubt or feedback

Stuck somewhere, or spotted a mistake? Write to the ExamHike team. We usually reply within a day, and you will see the reply on My progress.

Log in to ask a doubt or send feedback →

Frequently asked questions

What are the seven layers of the OSI model?

From the bottom they are physical, data link, network, transport, session, presentation and application.

How is TCP/IP different from OSI?

TCP/IP has four layers and no separate session or presentation layer; those jobs are done by the application.

What is the difference between transmission and propagation delay?

Transmission delay L/R is the time to put all bits on the link; propagation delay d/s is the travel time of one bit.

Does virtual-circuit switching reserve bandwidth?

No. It fixes one path and keeps packets in order, but bandwidth is shared, unlike circuit switching.

More in this module: Computer networks

Official sources

Facts in this chapter were checked against these official sources.

  1. GATE 2026 Computer Science and Information Technology (CS) syllabus, IIT Guwahati
  2. NPTEL Computer Networks and Internet Protocol (IIT Kharagpur, 106105183): layering, switching and delay