Introduction and Layering

What a network is, the OSI and TCP/IP models, encapsulation, which device works at which layer, and the four kinds of delay.

A computer network is a set of devices (hosts, switches, routers) connected by links that carry data between them. The Internet is a network of networks, all speaking the same protocols.

Why layers

Sending a web page involves many separate problems: turning bits into signals, getting a frame to the next machine, finding a route across the world, recovering lost data, and understanding HTTP. Layering gives each problem to one layer. Each layer:

  • offers a service to the layer above it,
  • uses the service of the layer below it, and
  • talks to the same layer on the other machine using a protocol.

A layer can change its implementation (for example, Wi-Fi instead of Ethernet) without the others noticing.

The OSI and TCP/IP models

#OSI layerJobUnit of data (PDU)TCP/IP model
7ApplicationServices for applications (HTTP, DNS, SMTP)MessageApplication
6PresentationData format, encryption, compressionMessageApplication
5SessionDialogue control, checkpointsMessageApplication
4TransportProcess-to-process delivery, reliability, flow and congestion controlSegment (TCP) / datagram (UDP)Transport
3NetworkHost-to-host delivery across networks: addressing and routingPacket (datagram)Internet
2Data linkNode-to-node delivery on one link: framing, MAC addresses, error detectionFrameLink
1PhysicalBits as signals on the mediumBitLink

The TCP/IP model merges OSI layers 5–7 into one application layer, and layers 1–2 into the link layer (some books count physical separately and call it a five-layer model).

A mnemonic for OSI from the bottom: Please Do Not Throw Sausage Pizza Away.

Encapsulation

On the way down, each layer adds its own header (and the data link layer also a trailer) to what it gets from above. The receiver strips them in reverse order.

ApplicationHTTP messageTransportTCP header + message = segmentNetworkIP header + segment = packetData linkEthernet header + packet + trailer = framePhysicalbits on the wire
Encapsulation of an HTTP request on the sender

Addresses at each layer

LayerAddressExampleIdentifies
TransportPort number (16 bits)443A process on a host
NetworkIP address (32 bits in IPv4)192.168.1.10A host interface, globally
Data linkMAC address (48 bits)3c:22:fb:1a:09:7eA network card, on the local link

Devices and layers

DeviceHighest layer it understandsWhat it does
Repeater, hubPhysical (1)Regenerates bits; a hub repeats them to every port
Bridge, switchData link (2)Forwards frames using MAC addresses
RouterNetwork (3)Forwards packets between networks using IP addresses
Gateway, firewall, proxyUp to application (7)Translates or filters at higher layers

A hub forms one collision domain and one broadcast domain. A switch splits collision domains (one per port) but keeps one broadcast domain. A router splits broadcast domains too.

Delays

The time for one packet to cross one link is the sum of four delays:

DelayFormulaDepends on
Transmission delayTt = L / R (packet length / bandwidth)Packet size and link speed
Propagation delayTp = d / v (distance / signal speed)Link length (v ≈ 2 × 10⁸ m/s in copper or fibre)
Queuing delayWaiting in the router's bufferTraffic load
Processing delayChecking headers, looking up routesRouter speed

Transmission delay is the time to push all bits onto the link; propagation delay is the time for one bit to travel to the other end. A wide motorway (high bandwidth) gets the cars on faster, but does not make the journey shorter.

The bandwidth–delay product R × Tp is the number of bits "in flight" on the link at once: the link's capacity as a pipe.

L = 1000 * 8          # packet: 1000 bytes, in bits
R = 1_000_000         # bandwidth: 1 Mbps
d = 2_000_000         # distance: 2000 km, in metres
v = 2e8               # signal speed in m/s

Tt = L / R
Tp = d / v
print(f"transmission delay = {Tt * 1000:.1f} ms")
print(f"propagation delay  = {Tp * 1000:.1f} ms")
print(f"total (no queuing) = {(Tt + Tp) * 1000:.1f} ms")
print(f"bandwidth-delay product = {R * Tp:.0f} bits")
Output
transmission delay = 8.0 ms
propagation delay  = 10.0 ms
total (no queuing) = 18.0 ms
bandwidth-delay product = 10000 bits

Practice questions

GATE-styleNAT · numerical answer

A 1500-byte packet is sent over a 10 Mbps link that is 3000 km long, with a signal speed of 2 × 10⁸ m/s. Ignoring queuing and processing, how many milliseconds does it take from the first bit leaving the sender to the last bit arriving?

Show answer and explanationAnswer: 16.2

Transmission delay = 12,000 bits / 10⁷ bps = 1.2 ms. Propagation delay = 3 × 10⁶ m / 2 × 10⁸ m/s = 15 ms. The last bit leaves after 1.2 ms and arrives 15 ms later: 16.2 ms.

GATE-styleNAT · numerical answer

A 100 Mbps link has a round-trip time of 40 ms. How many bytes can the sender transmit during one round-trip time?

Show answer and explanationAnswer: 500000

Bits in one RTT = 10⁸ × 0.04 = 4 × 10⁶ bits = 500,000 bytes. This is why TCP needs large windows on fast long-distance links.

GATE-styleMCQ · one correct answer

Which layer is responsible for process-to-process delivery?

Show answer and explanationAnswer: B

The network layer delivers packets from host to host; the transport layer uses port numbers to deliver data to the right process on that host.

GATE-styleMSQ · one or more correct answers

Which statements are true? (Select all that apply.)

Show answer and explanationAnswer: A, B, D

Each switch port is its own collision domain, but broadcasts still reach every port. A router does not forward link-layer broadcasts. A hub repeats every bit to every port, so all its ports share one collision domain.

GATE-styleMCQ · one correct answer

Doubling the bandwidth of a link changes which delay?

Show answer and explanationAnswer: A

Transmission delay is L / R, so doubling R halves it. Propagation delay d / v depends only on distance and the medium.