Computer Network
Midterm Revision Notes
MARR | CSE-325 / Networking
1. Network Topology
Topology means the arrangement/layout of devices in a network.
1.1 Categories of Networks
● PAN (Personal Area Network)
● LAN (Local Area Network)
● MAN (Metropolitan Area Network)
● WAN (Wide Area Network)
1.2 Types of Topology
● Bus
● Ring
● Star
● Tree
● Mesh
● Hybrid
1.2.1 Bus Topology
Advantages:
● Used for small connections
● Cost is low
Disadvantages:
● Uses a common cable
● When the cable is broken, the entire network stops working
● Less secured
1.2.2 Ring Topology
Characteristics:
● Less security
● Low quality
1.2.3 Star Topology
Advantages:
● Uses Hub or Switch
● One connection failure does not affect another connection between Hub/Switch
● Secured when a switch is used
Disadvantages:
● If the Hub/Switch crashes, the entire system stops working
● When a Hub is used, there is a chance the data will remain broadcast (less secure) — security concern; using a Switch
is preferred
1.2.4 Tree Topology
Characteristics:
● Well structured
● High secured
● Most preferred
1.2.5 Mesh Topology
Characteristics:
● High cost
Each PC's connections = n - 1 = 4 - 1 = 3
Whole connections = n(n-1)/2 = 4(4-1)/2 = 6
1.2.6 Hybrid Topology
Combination of two or more topologies.
2. Networking Devices
2.1 Repeater
A repeater regenerates a weak/degraded signal back to its original strength so it can travel further along the transmission
medium.
2.2 Hub vs Switch
Hub Switch
Data remains broadcast while using Hub Data remains secured when using Switch
Less used nowadays More widely used
Doesn't use MAC address Uses MAC address (Media Access Control)
Low cost High cost
2.3 Modem
Modem = Modulator + Demodulator. Converts digital signal to analog (modulation) at the sender side and analog back to
digital (demodulation) at the receiver side.
2.4 Other Devices
● Router
● Switch
● Hub
● NIC (Network Interface Card)
3. Address Types: IP, Port, MAC
Address Type Purpose
IP address Identifies the area/network (logical address)
Port address Unique address for a specific process/application
MAC address Specific hardware (physical) address of a device
4. Types of Network Architecture
4.1 Peer to Peer
● Examples: Bluetooth file share, Torrent
● Client ↔ Client (direct communication)
● No specific/dedicated server is needed
● Client itself acts as both user and server
4.2 Client - Server
● Examples: Facebook, YouTube, Google
● Client → sends request → Server
● Server → sends response → Client
5. OSI Model vs TCP/IP Model
OSI = Open System Interconnection TCP = Transmission Control Protocol
5.1 Data Flow Example Through OSI Layers (PC sends “HI”)
Layer What is added / done
Application HI
Presentation encoded data e.g. 001101
Session connection set up
Transport adds sender port number + receiver port number
Network adds sender IP + receiver IP
Data Link adds MAC address
Physical sent as bits to receiver
6. Data Link Layer
6.1 Functions of Data Link Layer
● Framing
● Error Control
● Flow Control
● Access Control
● Physical Addressing
6.2 Framing
Header → set of information (start of frame). Trailer → set of information (end of frame).
Types of Frame:
● Fixed size frame
● Variable size frame
6.2.1 Byte Count Method
The byte-count field at the start of a frame tells the receiver how many bytes belong to that frame (F1, F2, F3...). If the count
value itself gets corrupted (as shown by the error), the receiver loses synchronization for the following frames too.
6.2.2 Character-Oriented Protocol (Byte Stuffing)
Flag byte =
Flag byte = xE -> Frame start / end marker
ESC = xD
Original data:
[ xE | Hello | xE ]
If the data itself contains a byte identical to the Flag (xE), an ESC (xD) byte is stuffed right before it so the receiver does not
mistake it for a real frame delimiter:
[ xE | Hel xESC xE lo | xE ] -> Receiver removes the stuffed ESC and recovers: [ xE | Hello
| xE ]
6.2.3 Bit Stuffing
Flag byte -> xE -> 01111110
Sender data (before stuffing):
0110 1111111 111111 0111
After stuffing (a 0 is inserted after every five consecutive 1's):
0110 [11111]0 [11111]0 111 0 1111
Receiver removes the stuffed 0's and recovers the original data:
0110 1111111 111111 0111
7. Transmission (Duplex) Modes
● Simplex — one-way communication only
● Half Duplex — both directions possible, but one at a time
● Full Duplex — both directions simultaneously
8. Error Types
● Single Bit Error — only one bit in the data unit changes
● Burst Error — two or more bits in the data unit change
9. Error Detecting Techniques
● Single Parity Check (Vertical Redundancy Check – VRC)
● Two-Dimensional Parity Check (Longitudinal Redundancy Check – LRC)
● Checksum
● Cyclic Redundancy Check (CRC)
9.1 Single Parity Check (VRC)
Rules:
● If the number of 1's in the original data is even → parity bit = 0
● Else → parity bit = 1
Example: Data = 1100 1
Data: 1 1 0 0 1
Even parity bit: 1 (appended)
Transmitted: 1 1 0 0 0 1
At the receiver (Even Parity Checker):
If received bits (with parity) are all-zero on the parity check -> Accepted
If an error occurs, e.g. received byte = 1101011 with the 6th bit flipped, the parity checker will not balance to zero and the
frame is rejected.
9.2 Two-Dimensional Parity Check (LRC)
Example data blocks:
11100111 11011101 00110100 10101001
1 1 1 0 0 1 1 1
1 1 0 1 1 1 0 1
0 0 1 1 0 1 0 0
1 0 1 0 1 0 0 1
LRC bit: 1 0 1 0 1 0 1 0 <- appended as a 5th row
Rules:
● If the number of 1's in a column is even → LRC bit of that column = 0
● Else → LRC bit = 1
At the receiver, if all recomputed bits come out as 0, the data is Accepted; otherwise it is rejected.
9.3 Checksum
Sender side — data blocks:
10011001 11100010 00100100 10000100
Step 1: Add all blocks (with end-around carry), then take the 1's complement to get the checksum:
10011001
+ 11100010
+ 00100100
+ 10000100
-----------------
sum (with carry wrapped around) = 00100101
1's complement (checksum) = 11011010
Receiver side — add the 4 data blocks + received checksum:
10011001 + 11100010 + 00100100 + 10000100 + 11011010
Result = 11111111 -> all bits 1 -> Accepted (no error)
9.4 Cyclic Redundancy Check (CRC)
Example:
Data : 1101011011
Generator : 10011 (n = 5, so n-1 = 4 zero bits appended)
Sender side — binary (modulo-2) division of Data+0000 by the Generator using XOR (same = 0, different = 1):
1101011011 0000 ÷ 10011 -> Remainder (CRC bits) is appended to the data and transmitted
Receiver side — the received codeword is divided by the same generator (10011). Since all resulting bits are 0, the result is
Accepted — no error is expected.
10. Flow Control Protocols
● Noiseless Channel Protocols
● → Simplest Protocol
● → Stop-and-Wait Protocol
● Noisy Channel Protocols
● → Stop-and-Wait ARQ Protocol
● → Go-Back-N ARQ
● → Selective Repeat ARQ
10.1 Simplest Protocol (Noiseless Channel)
Sender simply keeps sending frames one after another; the receiver just receives them — no acknowledgement or flow control
needed since the channel is assumed error-free and the receiver is assumed always ready.
10.2 Stop-and-Wait Protocol (Noiseless Channel)
The sender sends one frame and waits for an acknowledgement (ACK) before sending the next frame.
ACK = Acknowledgement ARQ = Automatic Repeat Request
10.3 Stop-and-Wait ARQ (Noisy Channel)
Adds a timer to handle lost frames/ACKs and sequence numbers (0/1) to detect duplicates. Four important cases:
● Case 1: Normal operation — frame and ACK both arrive safely
● Case 2: ACK is lost → sender times out → resends the same frame → receiver discards duplicate but resends ACK
● Case 3: Frame is lost → sender times out (no ACK arrives) → resends the frame
● Case 4: ACK is delayed → sender times out and resends before the original ACK arrives → duplicate handled using
sequence numbers
10.4 Go-Back-N ARQ vs Selective Repeat ARQ
Both use a sliding window (example window size = 4) to send multiple frames before waiting for acknowledgements, but they
differ in how they recover from a lost frame:
● Go-Back-N ARQ — if a frame is lost, the sender re-transmits that frame and every frame sent after it.
● Selective Repeat ARQ — if a frame is lost, only that specific frame is re-transmitted; correctly received frames are
buffered at the receiver.
11. Hamming Code
Example: Data = 1011
Formula to find the number of redundancy bits (r):
2^r ≥ m + r + 1 (m = number of data bits)
Here, m = 4
r = 0 : 2^0 = 1 ≥ 4+0+1 = 5 -> False
r = 1 : 2^1 = 2 ≥ 4+1+1 = 6 -> False
r = 2 : 2^2 = 4 ≥ 4+2+1 = 7 -> False
r = 3 : 2^3 = 8 ≥ 4+3+1 = 8 -> True
So, r = 3 redundancy bits are needed.
Total bits = data bits (4) + redundancy bits (3) = 7 bits, positioned as:
Position: 7 6 5 4 3 2 1
Bit: 1 0 1 R3 1 R2 R1
11.1 Finding Redundancy Bit Values
R1 covers bit positions: 1, 3, 5, 7
R2 covers bit positions: 2, 3, 6, 7
R3 covers bit positions: 4, 5, 6, 7
Using even parity for each group:
R1 = (1,1,1,1) = 0
R2 = (0,1,0,1) = 0
R3 = (0,1,0,1) = 0
Final 7-bit message sent by the sender:
Position: 7 6 5 4 3 2 1
Bit: 1 0 1 0 1 0 0
11.2 Error Detection at the Receiver
Suppose an error occurs and the received bit pattern (positions 7→1) is: 1 1 1 0 1 0 1
R1 = (1,1,1,1) = 0
R2 = (0,1,1,1) = 1
R3 = (1,0,1,1) = 0
Combine as R3 R2 R1 -> 010 (binary) = position 2 -> the error is in bit position 2, which the receiver can now correct by
flipping that bit.
12. Physical Layer
12.1 Functions of the Physical Layer
● Bit-by-Bit Transmission
● Encoding – Decoding
● Signal Transmission
● Modulation and Demodulation
● Transmission Modes
12.1.1 Bit-by-Bit Transmission
Bits received from the Data Link layer are sent one by one across the transmission medium and reassembled at the other end
before being passed back up to the Data Link layer.
From Data Link layer: 0100111010 0 --[ Transmission Media ]--> To Data Link layer:
0100111010 0
12.1.2 Encoding / Decoding
Binary data (0s and 1s) is converted into an electrical/optical signal pattern for transmission, and converted back into bits at the
receiver.
12.1.3 Signal Transmission
A digital signal (square wave) can be converted into an analog signal (sine-like wave) for transmission over analog media.
12.1.4 Modulation
A message signal is combined with a higher-frequency carrier signal to produce a modulated signal suitable for transmission
over long distances.
12.1.5 Transmission Modes
● Simplex Mode — one-way only (sender → receiver)
● Duplex Mode
● Full Duplex Mode — both directions at the same time
12.2 Transmission Media (Cables)
12.2.1 Twisted Pair Cable
Pairs of insulated copper wires twisted together to reduce electromagnetic interference/noise.
12.2.2 Co-axial Cable
● Copper core → carries the signal transmission
● Insulator → prevents leakage
● Shield → reduces noise
● Plastic cover → overall protection
12.2.3 Optical Fiber
● Core → carries the light signal
● Cladding → keeps the light confined inside the core
● Coating → protects the fiber from physical damage
12.3 Networking Devices (Physical Layer)
● Modem → Modulation + Demodulation (Digital ↔ Analog)
● Router
● Repeater
● Switch
● Hub
● NIC (Network Interface Card)