Protocol layers and the physical layer
The OSI and TCP/IP layer models, encapsulation and overhead calculation, and bandwidth, bit rate and baud with the Nyquist and Shannon limits at the physical layer.
This week we build the skeleton of the network. A network is a complex system in which dozens of protocols work together. The way to manage this complexity is layering: each layer provides a service, uses only the service of the layer below it, and “talks” only to the same layer on the other side. The exam has three types of questions: layer matching (which job belongs to which layer), encapsulation overhead, and physical-layer capacity calculation (Nyquist, Shannon).
Golden rules:
- Know the five layers and the PDU names by heart: message, segment, datagram, frame, bit.
- Encapsulation: each layer adds a header on the way down and strips it on the way up.
- Bandwidth is in Hz, bit rate is in bps. They are not the same thing.
- Noiseless channel: Nyquist. Noisy channel: Shannon. In Shannon the SNR must be a ratio; if dB is given, convert it.
Why layers?
Think of an airline trip: buy a ticket, check a bag, go through the gate, take off, fly, land, leave through the gate, collect the bag. Each step corresponds to the reverse step at the destination airport. The baggage handler doesn’t need to know how the pilot flies. The same holds in a network: a programmer writing HTTP doesn’t know whether the data goes over fiber or Wi-Fi.
Benefits of layering:
- Modularity: changing one layer (5G instead of Wi-Fi) doesn’t break the others.
- Clarity: each layer has a single responsibility.
The downside: some work is repeated at two layers (error checking at both the link and the transport layer), and one layer may need information from another.
The Internet (TCP/IP) model: 5 layers
| Layer | Job | Example protocols | PDU |
|---|---|---|---|
| Application | Network applications | HTTP, SMTP, DNS, SSH | message |
| Transport | Process-to-process delivery, ports | TCP, UDP | segment |
| Network | Host-to-host, routing | IP, ICMP, OSPF, BGP | datagram |
| Link | Between two neighbouring nodes | Ethernet, Wi-Fi (802.11), PPP | frame |
| Physical | Putting bits on the wire / into the air | copper, fiber, radio coding | bit |
The OSI model: 7 layers
ISO’s OSI (Open Systems Interconnection) model has two more layers:
| OSI layer | Job | Where in TCP/IP? |
|---|---|---|
| 7 Application | application protocol | Application |
| 6 Presentation | data format, encryption, compression | Inside Application |
| 5 Session | sessions, synchronization, checkpoints | Inside Application |
| 4 Transport | end-to-end delivery | Transport |
| 3 Network | routing | Network |
| 2 Data Link | framing, between neighbours | Link |
| 1 Physical | bit transmission | Physical |
TIP · memorizing the order. From bottom to top: “Please Do Not Throw Sausage Pizza Away” (Physical, Data Link, Network, Transport, Session, Presentation, Application).
Encapsulation
At the sending host, data moves from top to bottom. Each layer takes the packet from above as a payload and puts its own header in front of it:
Application : [ M ] message
Transport : [ Ht | M ] segment
Network : [ Hn | Ht | M ] datagram
Link : [ Hl | Hn | Ht | M | trailer ] frame
Physical : 0110101011... bit
At the receiver the reverse happens (decapsulation): each layer reads its own header, strips it, and hands the contents to the layer above. A router on the path looks only at the link and network headers; a switch only at the link header. End hosts process all five layers.
Worked example: overhead
1000 bytes of application data are sent with TCP (20 bytes), IPv4 (20 bytes) and Ethernet (14-byte header + 4-byte FCS = 18 bytes).
Frame = 1000 + 20 + 20 + 18 = 1058 bytes
Efficiency = 1000 / 1058 = 0.9452 -> 94.52%
Overhead = 58 / 1058 = 5.48%
For small messages the efficiency collapses: a 1-byte keystroke (SSH) becomes a 59-byte frame. This is why protocols try to combine small packets.
PITFALL · number of headers. Each layer adds one header; the physical layer adds no header (the preamble is a separate topic). Ethernet also puts a trailer (FCS, CRC) at the end. You will compute this as the CRC in week 3.
Physical layer basics
The physical layer turns bits into signals: voltage on copper, light in fiber, radio waves in the air.
Basic concepts
| Term | Meaning | Unit |
|---|---|---|
| Bandwidth | The range of frequencies the channel passes | Hz |
| Bit rate (data rate) | Bits transmitted per second | bps |
| Baud rate (symbol rate) | Signal elements (symbols) transmitted per second | baud |
| Signal level | Number of different values a symbol can take | count |
| SNR | Signal power / noise power | ratio or dB |
If a symbol can take different values, it carries bits:
Example: at 9600 bps and 2400 baud, each symbol carries bits, so levels.
PITFALL · “bandwidth” in everyday language. In marketing, people say “100 Mbps bandwidth”. In a physical-layer question in this course, bandwidth means Hz. If a question says “bandwidth of 3 kHz”, that is a frequency range, not a bit rate.
Nyquist: the noiseless channel
On a noiseless channel with bandwidth Hz, at most symbols per second can be sent. With levels:
B = 3000 Hz, V = 2 : 2 x 3000 x 1 = 6,000 bps
B = 3000 Hz, V = 4 : 2 x 3000 x 2 = 12,000 bps
According to Nyquist, you can raise the rate without limit by increasing the number of levels. In reality, noise does not allow this.
Shannon: the noisy channel
Noise makes levels that are close to each other indistinguishable. The Shannon capacity is an absolute upper limit, independent of the number of levels:
SNR is usually given in decibels:
| dB | Ratio |
|---|---|
| 10 dB | 10 |
| 20 dB | 100 |
| 30 dB | 1000 |
| 40 dB | 10,000 |
Worked example: a telephone line
Hz, SNR = 30 dB.
SNR ratio = 10^(30/10) = 1000
C = 3000 x log2(1 + 1000) = 3000 x 9.967 = 29,902 bps (approximately)
This limit is why classic dial-up modems got stuck at around 30 kbps.
Using the two formulas together
A common exam question: “How many levels are needed to reach the Shannon capacity?” First find from Shannon, then solve for in Nyquist.
B = 1 MHz, SNR = 255
Shannon: C = 10^6 x log2(256) = 8 Mbps
Nyquist: 8 x 10^6 = 2 x 10^6 x log2 V -> log2 V = 4 -> V = 16
Line coding
| Coding | Idea | Baud / bit rate |
|---|---|---|
| NRZ | 1 is high voltage, 0 is low voltage | 1 |
| NRZI | Change the level when a 1 arrives | 1 |
| Manchester | Transition in the middle of every bit (direction gives the bit) | 2 |
| 4B/5B | Send 4 data bits as a 5-bit code | 5/4 |
In long runs of 0s or 1s, the receiver’s clock drifts with NRZ. Because Manchester makes a transition in every bit, the clock comes from the signal itself (self-clocking), but it needs twice the signal rate: 10 Mbps Ethernet is 20 Mbaud.
Transmission media
| Medium | Type | Note |
|---|---|---|
| Twisted pair | guided, copper | Cat5e/6, 1-10 Gbps, short distance |
| Coaxial | guided, copper | cable TV, shared |
| Fiber optic | guided, light | very high speed, immune to noise, hard to eavesdrop on |
| Radio (Wi-Fi, cellular, satellite) | unguided | broadcasts, anyone can listen |
Security note: a wireless medium is a broadcast medium. Anyone within range can receive the signal. This is why encryption (WPA2/WPA3) is a must on Wi-Fi. Tapping fiber requires physical access and is much harder.
Common mistakes
| Wrong idea | Correct |
|---|---|
| Bandwidth = bit rate | At the physical layer, bandwidth is in Hz. You get to bit rate with Nyquist/Shannon. |
| Putting dB directly into Shannon | First convert to a ratio with . |
| in Nyquist | It is . Don’t forget the factor 2. |
| Adding levels raises the rate without limit | With noise present, you cannot exceed the Shannon limit. |
| Baud = bit rate always | Only when . In general bit rate baud . |
| A router processes the TCP header | A router has 3 layers: link + network. It normally doesn’t look at port information. |
| OSI and TCP/IP have the same number of layers | OSI has 7, the Internet model has 5. No Session and Presentation. |
| Segment = frame | A segment is the transport PDU, a frame is the link PDU. |
Test yourself
Exam-style questions. Solve them on paper first, then reveal the answer.
Which layer of the five-layer Internet (TCP/IP) model is responsible for delivering datagrams from the source host to the destination host across multiple networks?
- Application layer
- Transport layer
- Network layer
- Link layer
- Physical layer
Show answer
The network layer (IP) carries a datagram from host to host, across many routers.
The transport layer carries data from process to process (port), and the link layer carries it only between two neighbouring nodes.
What is the name of the protocol data unit (PDU) at the link layer?
- Message
- Segment
- Datagram
- Frame
Show answer
Application: message, transport: segment, network: datagram (packet), link: frame, physical: bit.
Memorize the order as "M-S-D-F-B".
Which two OSI layers have no separate counterpart in the five-layer Internet model?
- Transport and Network
- Session and Presentation
- Data Link and Physical
- Application and Session
Show answer
OSI has 7 layers: Application, Presentation, Session, Transport, Network, Data Link, Physical.
In the Internet model, Presentation (encryption, compression, data format) and Session (synchronization, sessions) are not separate layers. If needed, the application does them itself.
A noiseless channel has a bandwidth of 4000 Hz and the signal uses 8 discrete levels. What is the maximum data rate according to Nyquist?
Show answer
Nyquist: bps.
A channel has bandwidth 1 MHz and a signal-to-noise ratio of 63 (as a plain ratio, not dB). What is its Shannon capacity?
Show answer
Shannon: Mbps.
The SNR is given here as a ratio, so there is no dB conversion.
A telephone channel has bandwidth 2000 Hz and SNR = 20 dB. What is the Shannon capacity (round to the nearest bps)?
Show answer
First convert dB to a ratio: . bps.
Pitfall: if you put 20 directly into the formula you get , which is wrong.
An application sends a 500-byte message using UDP (8-byte header) over IPv4 (20-byte header) over Ethernet (18 bytes of header plus trailer). What fraction of the transmitted frame is application data?
Show answer
Encapsulation: each layer adds its own header.
Frame size bytes.
Efficiency .
A modem transmits 4800 symbols per second using 16-QAM (16 distinct symbols). What is the bit rate?
Show answer
Each symbol carries bits. Bit rate bps.
Baud (symbols/s) and bits/s are equal only for a 2-level signal.
You need 36 kbps over a noiseless channel with bandwidth 3 kHz. What is the minimum number of signal levels required?
Show answer
Nyquist: , so and levels.
With Manchester encoding, a 10 Mbps Ethernet link needs what signal (baud) rate?
- 5 Mbaud
- 10 Mbaud
- 20 Mbaud
- 40 Mbaud
Show answer
Manchester makes a transition in the middle of every bit, so there are 2 signal elements per bit. Baud Mbaud.
In return, the receiver can easily synchronize its clock (self-clocking).
A channel has bandwidth 1 MHz and SNR = 255. (a) What is the Shannon capacity? (b) How many signal levels are needed to reach that rate by Nyquist?
Show answer
(a) bps = 8 Mbps.
(b) , so and .
Shannon gives the upper limit; Nyquist tells you how many levels it takes to reach that limit.
A router forwards a packet. Which headers does it examine and possibly rewrite, and which does it normally leave untouched?
- It processes only the transport header
- It processes the link and network headers; it does not process transport or application headers
- It processes all five layers' headers
- It processes only the physical layer
Show answer
A router is a 3-layer device: physical, link, network. It strips the link header of the incoming frame, looks at the IP header and forwards (decrements TTL, updates the checksum), and sends it with a new link header.
A switch has only 2 layers (physical, link), and hosts process all 5 layers. From a security view: a device that looks at the TCP port (firewall, NAT) knowingly breaks this layer separation.
Verification: Numerical answers were computed with node (verify/SEN2008/02.mjs): encapsulation overhead and efficiency, Nyquist 2B·log2(V), Shannon B·log2(1+SNR), dB conversion, relation between baud and bit rate. Concept questions were checked against textbook definitions.