1. Introduction to Computer Networks
A computer network is a collection of interconnected computers and devices that communicate with each other and share resources.
Main objectives of networking
- Resource sharing
- Data sharing
- Communication
- Centralized management
- Reliability
- Scalability
- Cost reduction
Important network components
- Sender – Device that sends data.
- Receiver – Device that receives data.
- Transmission Medium – Path through which data travels.
- Network Interface Card (NIC) – Connects a device to a network.
- Switch – Connects devices within a LAN.
- Router – Connects different networks.
- Gateway – Connects networks using different protocols.
- Modem – Converts digital and analog signals.
2. OSI Reference Model
The OSI (Open Systems Interconnection) model was developed by the International Organization for Standardization (ISO).
It consists of 7 layers.
OSI Layers
From top to bottom:
- Application
- Presentation
- Session
- Transport
- Network
- Data Link
- Physical
Mnemonic
All People Seem To Need Data Processing
- A – Application
- P – Presentation
- S – Session
- T – Transport
- N – Network
- D – Data Link
- P – Physical
Layer 7 – Application Layer
Provides network services directly to applications.
Examples
- HTTP/HTTPS
- FTP
- SMTP
- DNS
- Telnet
It is the layer closest to the end user.
Layer 6 – Presentation Layer
Responsible for data representation.
Functions:
- Translation
- Encryption/decryption
- Compression/decompression
Examples:
- ASCII
- JPEG
- MPEG
- Encryption formats
Layer 5 – Session Layer
Responsible for establishing, managing and terminating sessions between applications.
Functions:
- Session establishment
- Session management
- Synchronization
- Session termination
Layer 4 – Transport Layer
Provides end-to-end communication.
Major protocols:
- TCP
- UDP
Functions:
- Segmentation
- Flow control
- Error control
- Reliability
- Port addressing
TCP
TCP is:
- Connection-oriented
- Reliable
- Ordered
- Error-controlled
UDP
UDP is:
- Connectionless
- Faster
- Unreliable
- No guarantee of delivery
Layer 3 – Network Layer
Responsible for logical addressing and routing.
Main device:
Router
Important protocol:
IP
Functions:
- Routing
- Logical addressing
- Packet forwarding
- Path determination
Layer 2 – Data Link Layer
Responsible for reliable node-to-node delivery.
Functions:
- Framing
- MAC addressing
- Error detection
- Flow control
Devices:
- Switch
- Bridge
The Data Link Layer has two sublayers:
LLC
Logical Link Control
MAC
Media Access Control
Layer 1 – Physical Layer
Deals with transmission of raw bits.
Functions:
- Bit transmission
- Cable specifications
- Voltage
- Connectors
- Data rates
- Physical topology
Examples:
- Ethernet cables
- Fiber optic cable
- Radio signals
3. OSI Layer – PDU
| Layer | PDU |
|---|---|
| Application | Data |
| Presentation | Data |
| Session | Data |
| Transport | Segment |
| Network | Packet |
| Data Link | Frame |
| Physical | Bits |
Important: TCP uses Segment, IP uses Packet/Datagram, and Data Link uses Frame.
4. TCP/IP Model
The TCP/IP model is the practical networking model used on the Internet.
The commonly taught TCP/IP model has 4 layers:
- Application
- Transport
- Internet
- Network Access
OSI vs TCP/IP
| OSI | TCP/IP |
|---|---|
| Application | Application |
| Presentation | Application |
| Session | Application |
| Transport | Transport |
| Network | Internet |
| Data Link | Network Access |
| Physical | Network Access |
Important TCP/IP protocols
Application Layer
- HTTP
- HTTPS
- FTP
- SMTP
- DNS
- DHCP
- SSH
Transport Layer
- TCP
- UDP
Internet Layer
- IP
- ICMP
- ARP is commonly associated with network access/link functions, though its placement varies by model.
Network Access
- Ethernet
- Wi-Fi
5. OSI vs TCP/IP
| Feature | OSI | TCP/IP |
|---|---|---|
| Developed by | ISO | DARPA/DoD |
| Layers | 7 | 4 |
| Nature | Reference model | Protocol suite/model |
| Session layer | Separate | Included in Application |
| Presentation layer | Separate | Included in Application |
| Practical use | Mainly conceptual | Internet networking |
6. LAN, MAN and WAN
LAN – Local Area Network
A network covering a small geographical area.
Examples:
- Home
- School
- Office
- Computer laboratory
Characteristics:
- High speed
- Limited geographical area
- Usually privately managed
Example:
Ethernet
MAN – Metropolitan Area Network
Covers a city or metropolitan area.
Example:
A network connecting multiple branches of an organization across a city.
WAN – Wide Area Network
Covers a large geographical area.
Examples:
- Internet
- Inter-city networks
- International networks
WAN generally has greater latency than LAN.
7. IP Addressing
An IP address identifies a device/interface logically on an IP network.
There are two major versions:
- IPv4
- IPv6
IPv4
IPv4 uses 32-bit addresses.
Example:
192.168.1.10
IPv4 consists of four octets.
Each octet contains 8 bits.
Therefore:
4 × 8 = 32 bits
IPv4 range
0.0.0.0 to 255.255.255.255
Total addresses:
2³² = 4,294,967,296
8. IPv4 Address Classes
Traditional classful addressing divides IPv4 into five classes.
| Class | First Octet | Default Mask |
|---|---|---|
| A | 1–126 | 255.0.0.0 |
| B | 128–191 | 255.255.0.0 |
| C | 192–223 | 255.255.255.0 |
| D | 224–239 | Multicast |
| E | 240–255 | Experimental |
Important
127.x.x.x is reserved for loopback.
Example:
127.0.0.1
9. Private IPv4 Addresses
Private addresses are commonly used inside local networks.
Class A private range
10.0.0.0 – 10.255.255.255
Class B private range
172.16.0.0 – 172.31.255.255
Class C private range
192.168.0.0 – 192.168.255.255
These addresses are not directly routable on the public Internet.
10. IPv6
IPv6 uses 128-bit addresses.
Example:
2001:db8::1
Advantages:
- Huge address space
- Better support for modern networking
- Simplified header
- Improved multicast support
- No traditional IPv4 broadcast
Total possible IPv6 addresses:
2¹²⁸
11. MAC Address
MAC stands for Media Access Control.
A MAC address is a hardware/link-layer address associated with a network interface.
A typical MAC address is 48 bits.
Example:
00:1A:2B:3C:4D:5E
IP vs MAC
| IP Address | MAC Address |
|---|---|
| Logical address | Link-layer/hardware address |
| Used for routing | Used for local network delivery |
| IPv4 = 32 bits | Usually 48 bits |
| Can change | Normally associated with NIC/interface |
12. Routing
Routing is the process of determining a path for packets from source to destination.
Routers maintain routing information in a routing table.
Routing types
- Static Routing
- Dynamic Routing
Static Routing
Routes are manually configured by a network administrator.
Advantages:
- Simple for small networks
- Predictable
- No routing protocol overhead
Disadvantages:
- Difficult to maintain in large networks
- Does not automatically adapt to topology changes
13. Dynamic Routing
Routes are learned and updated automatically.
Major categories:
Distance Vector
Routers determine paths using distance and direction information.
Example:
RIP
Link State
Routers maintain information about network topology.
Examples:
- OSPF
- IS-IS
Path Vector
Used for inter-domain routing.
Example:
BGP
14. Routing Algorithms
14.1 Distance Vector Algorithm
Each router maintains information about:
- Destination
- Distance/cost
- Next hop
Routers exchange routing information with neighboring routers.
A famous example is:
RIP
RIP uses hop count as its routing metric.
Maximum usable hop count:
15
A hop count of 16 represents unreachable in RIP.
15. Link State Routing
In link-state routing:
- Routers discover neighbors.
- Determine link costs.
- Distribute link-state information.
- Build a topology database.
- Calculate shortest paths.
A commonly used algorithm is:
Dijkstra's Shortest Path First algorithm
OSPF uses the SPF approach.
16. BGP
BGP = Border Gateway Protocol
It is the major routing protocol used for routing between autonomous systems on the Internet.
BGP is a path-vector protocol.
It uses TCP for communication.
BGP uses:
TCP port 179
17. LAN Technologies
Ethernet
Ethernet is one of the most widely used LAN technologies.
IEEE standard:
802.3
Wi-Fi
Wi-Fi is based on the IEEE 802.11 family of standards.
18. Network Topologies
Bus
All devices share a common communication medium.
Star
All devices connect to a central device.
Common in Ethernet LANs.
Ring
Devices form a circular structure.
Mesh
Devices have multiple interconnections.
Tree
Hierarchical combination of network segments.
19. Network Security
Network security protects:
- Data
- Devices
- Networks
- Services
- Users
from unauthorized access, attacks and misuse.
20. CIA Triad
The three fundamental principles of information security are:
Confidentiality
Only authorized people should access information.
Integrity
Information should not be improperly modified.
Availability
Authorized users should be able to access resources when required.
CIA = Confidentiality + Integrity + Availability
21. Firewall
A firewall monitors and controls network traffic according to security rules.
It can control:
- Incoming traffic
- Outgoing traffic
- Ports
- Protocols
- IP addresses
22. Encryption
Encryption converts plaintext into ciphertext.
Symmetric Encryption
Uses the same key for encryption and decryption.
Examples:
- AES
- DES
Asymmetric Encryption
Uses a pair of keys:
- Public key
- Private key
Example:
RSA
23. Hashing
Hashing converts data into a fixed-length digest.
Examples:
- SHA-256
- SHA-3
Hash functions are commonly used for:
- Integrity verification
- Password protection systems
- Digital signatures
24. Digital Signature
A digital signature helps provide:
- Authentication
- Integrity
- Non-repudiation
It uses asymmetric cryptographic techniques.
25. Common Network Attacks
DoS
Denial of Service
Attempts to make a service unavailable.
DDoS
Distributed Denial of Service
A DoS attack launched from multiple compromised systems.
Phishing
Attempts to trick users into revealing sensitive information.
Spoofing
Attacker disguises identity or source information.
Man-in-the-Middle
Attacker intercepts communication between two parties.
Malware
Malicious software such as:
- Virus
- Worm
- Trojan
- Ransomware
26. Important Network Protocols
| Protocol | Purpose |
|---|---|
| HTTP | Web communication |
| HTTPS | Secure web communication |
| FTP | File transfer |
| SMTP | Sending email |
| POP3 | Receiving email |
| IMAP | Email access/synchronization |
| DNS | Domain-name resolution |
| DHCP | Automatic IP configuration |
| SSH | Secure remote access |
| Telnet | Remote access, unencrypted |
| ICMP | Network diagnostics/control |
| TCP | Reliable transport |
| UDP | Connectionless transport |
| BGP | Inter-domain routing |
| OSPF | Link-state routing |
| RIP | Distance-vector routing |
50+ Important MCQs
MCQ 1
How many layers are present in the OSI model?
A. 4
B. 5
C. 7
D. 8
Answer: C. 7
MCQ 2
Which layer of the OSI model is responsible for routing?
A. Physical
B. Data Link
C. Network
D. Transport
Answer: C. Network
MCQ 3
Which OSI layer is responsible for logical addressing?
A. Physical
B. Network
C. Session
D. Presentation
Answer: B. Network
MCQ 4
Which device primarily operates at the Network Layer?
A. Hub
B. Switch
C. Router
D. Repeater
Answer: C. Router
MCQ 5
Which layer is responsible for framing?
A. Network
B. Transport
C. Data Link
D. Physical
Answer: C. Data Link
MCQ 6
Which OSI layer transmits raw bits?
A. Physical
B. Data Link
C. Network
D. Transport
Answer: A. Physical
MCQ 7
Which layer provides end-to-end delivery?
A. Network
B. Transport
C. Session
D. Data Link
Answer: B. Transport
MCQ 8
TCP is a:
A. Connectionless protocol
B. Connection-oriented protocol
C. Physical protocol
D. Routing algorithm
Answer: B. Connection-oriented protocol
MCQ 9
UDP is:
A. Connection-oriented
B. Connectionless
C. Circuit-switched
D. Hardware-based
Answer: B. Connectionless
MCQ 10
Which OSI layer is responsible for encryption and compression?
A. Application
B. Presentation
C. Session
D. Transport
Answer: B. Presentation
MCQ 11
Which layer establishes and manages sessions?
A. Session
B. Transport
C. Network
D. Application
Answer: A. Session
MCQ 12
How many layers are commonly defined in the TCP/IP model?
A. 3
B. 4
C. 5
D. 7
Answer: B. 4
MCQ 13
Which protocol is used for domain-name resolution?
A. FTP
B. DNS
C. SMTP
D. DHCP
Answer: B. DNS
MCQ 14
Which protocol automatically assigns IP configuration to hosts?
A. DNS
B. HTTP
C. DHCP
D. FTP
Answer: C. DHCP
MCQ 15
Which protocol is used to send email?
A. SMTP
B. FTP
C. DNS
D. ARP
Answer: A. SMTP
MCQ 16
IPv4 addresses are:
A. 16 bits
B. 32 bits
C. 64 bits
D. 128 bits
Answer: B. 32 bits
MCQ 17
IPv6 addresses are:
A. 32 bits
B. 64 bits
C. 128 bits
D. 256 bits
Answer: C. 128 bits
MCQ 18
Which is a valid private IPv4 address?
A. 8.8.8.8
B. 192.168.1.10
C. 1.1.1.1
D. 172.40.1.1
Answer: B. 192.168.1.10
MCQ 19
What is the loopback IPv4 address commonly used?
A. 127.0.0.1
B. 192.168.1.1
C. 10.0.0.1
D. 255.255.255.255
Answer: A. 127.0.0.1
MCQ 20
Which IPv4 class is used for multicast?
A. Class A
B. Class B
C. Class C
D. Class D
Answer: D. Class D
MCQ 21
Class C IPv4 addresses traditionally have which default subnet mask?
A. 255.0.0.0
B. 255.255.0.0
C. 255.255.255.0
D. 255.255.255.255
Answer: C. 255.255.255.0
MCQ 22
Which address is in the private Class A range?
A. 10.5.6.7
B. 11.5.6.7
C. 127.5.6.7
D. 172.40.1.1
Answer: A. 10.5.6.7
MCQ 23
A MAC address is generally:
A. 16 bits
B. 32 bits
C. 48 bits
D. 128 bits
Answer: C. 48 bits
MCQ 24
Which device forwards packets between different networks?
A. Hub
B. Router
C. Repeater
D. NIC
Answer: B. Router
MCQ 25
Which technology is associated with IEEE 802.3?
A. Bluetooth
B. Ethernet
C. Wi-Fi
D. Token Ring
Answer: B. Ethernet
MCQ 26
IEEE 802.11 is primarily associated with:
A. Ethernet
B. Wi-Fi
C. Bluetooth<br dat