Computer Networks & Communication

Unit-I in full: from bits on a wire to frames on a LAN. Every concept below is paired with a live animation — press play, watch the packet move, and the theory sticks.

DARK-BLUEPRINT THEME · AMBER PACKETS · CYAN SIGNALS

01Data Communications & Network Types

A network moves data between devices. For communication to happen, five components must exist: message, sender, receiver, medium, protocol. Delivery must be on time, accurate, and error-free.

Three data-flow (duplex) modes

Simplex = one-way only · Half-duplex = both ways, one at a time · Full-duplex = both ways simultaneously.

Duplex modes — watch the direction of traffic↻ replay
Simplex: TV tower → screen. Half-duplex: walkie-talkie (press to talk, release to hear). Full-duplex: a phone call.
✦ Exam point The five components of data communication are message, sender, receiver, transmission medium, and protocol. "Protocol" is the set of rules governing exchange — remember it as the language both ends agree to speak.

02Network Types — LAN, MAN, WAN

Networks are classified by geographical span: LAN (a room/building), MAN (a city), WAN (a country / the world).

Zoom out from your desk to the planet↻ replay
A LAN connects nearby PCs through a switch; a MAN joins city LANs with routers on fibre; a WAN connects cities via the Internet backbone.

LAN

  • Small area: office, lab, building
  • High speed (Gbps), low error
  • Owned by one organisation

WAN

  • Connects cities/countries
  • Point-to-point leased lines + routers
  • Slower, higher error, expensive

03Connection-Oriented vs Connectionless

Is the path set up before the data flows, or is every packet on its own?

Three-way handshake (left) vs free datagrams (right)↻ replay
TCP: SYN → SYN-ACK → ACK reserves the channel, then data flows in order. UDP: each datagram is independent — fast, no guarantee of order.
PropertyConnection-oriented (TCP)Connectionless (UDP)
SetupNeeds handshake firstNone
OrderGuaranteedNot guaranteed
ReliabilityACKs + retransmissionBest effort
OverheadHighLow
Used byFile transfer, webStreaming, DNS, VoIP

04Network Devices

Modem, Hub, Switch, Router — the "physical chain" from your home to the internet. Each one works at a different layer.

Modem

MODulator–DEModulator. Converts digital ↔ analog so signals can travel over phone lines.

Hub

Physical-layer repeater. Broadcasts every frame to all ports — wasteful, collisions.

Switch

Data-link device. Learns MAC addresses, forwards only to the destination port.

Router

Network-layer device. Routes between networks using IP addresses.

Hub (broadcasts) vs Switch (learns & targets)↻ replay
Left: A sends to C — the hub sends a copy to everyone. Right: the switch already knows C lives on port 3, so only C receives it.
Router joins two LANs — a frame becomes a packet becomes a frame↻ replay
Host 192.168.1.5 sends to 10.0.0.8: the frame goes to the router, which strips the old frame, repackages the IP packet in a new frame, and sends it onward.

05Network Models — OSI & TCP/IP

Both are layered architectures. Each layer talks only to its neighbours and adds its own header — that's encapsulation.

OSI — 7 layers (reference model)

LayerWhat it does
7 ApplicationNetwork services to apps (HTTP, FTP)
6 PresentationEncoding, encryption, compression
5 SessionDialogue control, checkpoints
4 TransportSegments, end-to-end delivery, ports
3 NetworkPackets, logical (IP) addressing, routing
2 Data linkFrames, MAC addressing, error control
1 PhysicalBits, signals, media

TCP/IP — 5 layers (practical model)

LayerOSI equivalent
5 Application7 + 6 + 5 combined
4 Transport4
3 Network3
2 Data link2
1 Physical1
✓ Mnemonic OSI from bottom: Please Do Not Throw Sausage Pizza Away.
Encapsulation — headers stack up going down, peel off going up↻ replay
At the sender: data → +TCP header = segment → +IP header = packet → +MAC header/trailer = frame → bits. The receiver reverses the process, stripping headers layer by layer.
⚠ Common mistake OSI is a reference model; the Internet actually runs on TCP/IP. Don't say "OSI is the protocol" — it's a blueprint.

06Physical Layer — Digital Signals

Computers speak in digital signals — discrete voltage pulses (0/1). A periodic digital signal has amplitude, period/frequency, and phase.

One period, three knobs — drag and watch the wave change
Amplitude = strength (volts), frequency = cycles/sec (Hz), phase = starting angle. The screen shows one period; T = 1/f.

Transmission impairment

Signals weaken and deform as they travel: attenuation (loss of energy), distortion (components arrive out of sync), noise (unwanted signals added on top).

Attenuation, distortion, noise — three ways a signal gets hurt↻ replay
Left: amplitude fades with distance. Middle: a square wave becomes a rounded, lagging mess. Right: random noise rides on the signal.
✓ Worked — dB cascade Signal is amplified +30 dB, then +20 dB, then a cable loses 10 dB. Net gain = 30 + 20 − 10 = 40 dB. As a ratio that is 1040/10 = 10,000×. dB = 10·log₁₀(P2/P1) — always add dB, multiply ratios.

07Data-Rate Limits & Performance

Two hard ceilings govern any channel: Nyquist (noiseless) and Shannon (noisy). Performance is judged by throughput, latency, and bandwidth.

Nyquist & Shannon calculators
Nyquist:
Shannon:
Latency = propagation + transmission
Propagation:
Transmission:
Total latency:
⚠ Common mistake Bit rate ≠ baud rate. Bit rate = baud × log₂(L). With 4 levels (L=4), each signal element carries 2 bits, so bit rate is double the baud rate. Nyquist is 2B·log₂L — many students forget the factor of 2.

08Line Coding — Digital-to-Digital

Converting a bit stream into voltage signals. Unipolar = one polarity; polar = positive/negative. Watch all six schemes draw themselves on the bits 0 1 0 0 1 1 1 0.

Comparing the schemes

SchemeSelf-clocking?DC component?Used for
Unipolar NRZNoYesRare (baseline wander)
NRZ-LNoYes (long runs)Simple digital links
NRZ-INoReducedUSB, 100Base-FX
ManchesterYesNoEthernet (10Base-T)
Differential ManchesterYesNoToken Ring
✦ Exam point Manchester is self-clocking because there is always a transition at the middle of every bit — the receiver extracts its clock from the signal. Unipolar NRZ has a DC component because it never goes below zero.

09Transmission Media (Guided)

Guided media = the signal is contained in a conductor: twisted-pair, coaxial cable, or optical fibre.

Three guided media, three ways to carry a signal↻ replay
Twisted pair: two insulated copper wires, twisted to cancel interference. Coax: centre conductor + braided shield. Fibre: light pulses bounce down the core by total internal reflection.
MediumSpeed classTypical use
Twisted pair (STP/UTP)10 Mbps – 10 GbpsTelephone, Ethernet
Coaxial cable10–100 MbpsCATV, older Ethernet
Optical fibreGbps–TbpsBackbones, WAN, submarine cables

10Switching — Packet Switching

In packet switching, data is chopped into packets that travel independently. Two flavours: datagram (each packet routed on its own) and virtual circuit (path reserved first).

Datagram vs Virtual Circuit across three routers↻ replay
Datagram: packets 1, 2, 3 take different routes and may arrive out of order. VC: a setup packet reserves the path, then all data follows it in order — then it's torn down.
DatagramVirtual circuit
SetupNoneNeeded (setup phase)
Routing decisionPer packetOnce, at setup
OrderingMay be lost/reorderedIn order
Best forEmail, webVoice, video

11Data-Link Layer — Addressing & ARP

Four levels of addressing exist on the internet. At the link layer we use MAC (physical) addresses, and ARP translates an IP address into a MAC address.

LevelAddressLengthExample
ApplicationPort number16 bits443 (HTTPS)
NetworkIP address32 bits (v4)141.23.56.23
Data linkMAC address48 bitsAA:BB:CC:11:22:33
Physical
ARP in action — broadcast the question, unicast the answer↻ replay
A (IP .2, MAC AA) needs to send to IP .23 (MAC BB). A broadcasts: "who has .23? tell .2". Only B answers (unicast): "BB is at .23". A stores it in its ARP cache — next time, no broadcast needed.
⚠ Common mistake ARP works within one LAN only — it never crosses a router. MAC addresses are not routable; IP addresses are. The MAC of a host is set at manufacture (or by the OS) — not leased like IP.

12Block Coding & Error Detection — CRC

Block coding adds redundancy by mapping m data bits to n codeword bits (e.g. 4B/5B). CRC (Cyclic Redundancy Check) appends a checksum so the receiver can detect corrupted frames.

CRC in one sentence

Append (divisor_len − 1) zeros to the data, divide the whole thing by the divisor using XOR, and attach the remainder. The receiver re-divides; a non-zero remainder means the frame is corrupt.

✓ Worked — CRC-3 Data 1011001, divisor 1011 (x³+x+1). Append 3 zeros → 1011001000. Divide by 1011 → remainder 011. Transmit 1011001 011.
Shift-register division — each step shifts and XORs↻ replay
The 3-bit register shifts in the next data bit; if a 1 falls out the left, the register is XORed with the divisor (without its leading 1). The final register content is the CRC remainder.
✦ Exam point CRC detects errors, it does not correct them. A single error in the data is caught because the remainder comes out non-zero. The minimum Hamming distance dmin decides what a code can detect/correct.

13CSMA / CSMA-CD

Carrier Sense Multiple Access: listen before you talk. In Ethernet (CSMA/CD), if two stations transmit at once → collision → both stop, wait a random backoff, and retry.

CSMA/CD — sense, collide, back off, retry↻ replay
A and B both sense idle and transmit. Their frames collide mid-cable, both send a jam signal, then each waits a random time before retransmitting — this time they succeed one after the other.
Persistence methodBehaviour
1-persistentIf busy, keep listening; send immediately when free (aggressive — collisions)
Non-persistentIf busy, wait a random time then listen again (calmer)
p-persistentIf free, send with probability p; else wait for the next slot

14Formula Sheet & 5 Near-Certain Questions

Formulas you must own

QuantityFormula
Data rate (Nyquist)C = 2B·log₂L bps
Data rate (Shannon)C = B·log₂(1 + SNR) bps
dBdB = 10·log₁₀(P₂/P₁)
Bit rate ↔ baudbit rate = baud × log₂L
Transmission timeT = frame size / rate
Propagation timeT = distance / speed
Total latencyT = propagation + transmission + queueing
CRC remainderdata·2^(n−1) mod divisor (XOR division)
ThroughputTh = actual bits delivered / time
Q1 · A channel has B = 1 MHz, L = 4 levels. Max data rate? answer
Nyquist: C = 2(1×10⁶)·log₂4 = 2×10⁶ × 2 = 4 Mbps.
Q2 · B = 3000 Hz, SNR = 35 dB. Max rate?
SNR = 10^3.5 = 3162. Shannon: C = 3000·log₂(3163) ≈ 3000 × 11.63 ≈ 34.9 kbps.
Q3 · Draw NRZ-I for 01001110. Level starts low.
Low, High, High, High, Low, High, Low, Low — transition only on 1 (start Low). Check the line-coding widget above for the visual.
Q4 · When does a hub differ from a switch?
Hub = physical layer, broadcasts to all ports, can't filter → collisions & waste. Switch = data-link layer, learns MAC→port and forwards only to the destination.
Q5 · Explain the ARP exchange when A (.2) talks to B (.23) on the same LAN.
A broadcasts "Who has .23? Tell .2". B (and only B) replies unicast "BB is at .23". A caches it. Later sends are direct — no more broadcast.