12. Computer Networks
12. Computer Networks
• Data Link Layer: Framing, Error control, Flow control, Error detection
and correction, Simplex protocol, Sliding Window protocols, go-back-N,
A protocol using selective repeat.
1. Framing
○ Purpose: To divide the stream of bits from the network layer into manageable
units called "frames" for transmission over the physical link. Frames allow the
receiver to identify the beginning and end of a message.
○ Methods:
■ Character Counting: Header specifies the number of characters in
the frame. (Less robust, susceptible to errors in the count).
■ Byte Stuffing (Character Stuffing): Special flag bytes mark the start
and end of a frame. If the flag byte appears in the data, an "escape
byte" is inserted before it.
■ Bit Stuffing: Similar to byte stuffing, but uses a bit pattern (e.g.,
01111110). If five consecutive 1s appear in the data, a 0 is "stuffed"
after them.
■ Physical Layer Coding Violations: Uses specific encoding schemes
(e.g., Manchester encoding) where a unique sequence not
representing data bits indicates frame boundaries.
2. Error Control
○ Error Detection:
■ Concept: Adding redundant bits to data (checksums, parity bits) so
that the receiver can detect if data has been corrupted during
transmission.
■ Methods:
■ Parity Check (Simple Parity): Adds one bit to make the total
number of 1s either even or odd. Detects single-bit errors.
■ Checksum: Sums up the data bits and appends the sum (or
its complement) to the data. Detects various errors but not
highly robust.
■ Cyclic Redundancy Check (CRC): Divides data by a
predetermined binary polynomial and uses the remainder as
the CRC code. Highly effective for detecting burst errors.
○ Error Correction:
■ Concept: Not only detects errors but also determines the original,
uncorrupted data, allowing recovery without retransmission.
■ Methods:
■ Forward Error Correction (FEC): Uses highly redundant
codes (e.g., Hamming codes, Reed-Solomon codes) to allow
the receiver to deduce the original data even with errors. More
complex and adds more overhead.
■ Automatic Repeat Request (ARQ): Combines error detection
with retransmission. If an error is detected, the receiver
requests the sender to retransmit the corrupted frame. This is
more common in data link layer.
5. Simplex Protocol (or Unidirectional Protocol)
○ Description: A very basic data link layer protocol where data flows in only
one direction (sender to receiver).
○ Characteristics:
■ No acknowledgments (ACKs) or retransmissions.
■ No flow control.
■ No error control.
○ Use Case: Only suitable for perfectly reliable, error-free, and infinite-capacity
channels, which do not exist in reality. It's primarily a theoretical starting point
to understand more complex protocols.
6. Sliding Window Protocols
○ Concept: A class of data link layer protocols that allow a sender to transmit
multiple frames (a "window" of frames) before receiving an acknowledgment.
This significantly improves efficiency, especially over links with high latency.
○ Key Components:
■ Send Window: A range of sequence numbers that the sender is
permitted to transmit.
■ Receive Window: A range of sequence numbers that the receiver is
permitted to accept.
■ Acknowledgments (ACKs): Used by the receiver to inform the
sender which frames have been successfully received.
■ Timers: Used by the sender to detect lost frames or ACKs.
○ Benefits: Increased throughput compared to Stop-and-Wait.
7. Go-Back-N (GBN) Protocol
○ Type: A sliding window protocol that retransmits only corrupted or lost frames.
○ Sender Behavior:
■ Maintains a send window of size N.
■ Sends frames up to N frames.
■ Sets a timer for each unacknowledged frame.
■ Receives individual ACKs for each frame.
■ If a timer expires for frame k, only frame k is retransmitted.
○ Receiver Behavior:
■ Maintains a receive window of size N (or typically N/2 for efficiency).
■ Accepts frames out of order if they fall within its receive window.
■ Buffers out-of-order frames until the missing frames are received.
■ Sends individual ACKs for each correctly received frame, whether in
order or out of order.
■ Once a sequence of frames becomes contiguous (e.g., missing frame
k arrives), it delivers the entire contiguous block to the network layer.
○ Advantage: Much more efficient than GBN in noisy channels as it minimizes
retransmissions.
○ Disadvantage: Requires more complex buffering and logic at both the sender
and receiver.
○ IEEE 802.11 (Wi-Fi): The most common standard for Wireless LANs.
■ Core MAC Protocol: CSMA/CA.
■ Operational Modes: Infrastructure mode (with Access Points),
Ad-hoc mode (direct device-to-device).
■ Frame Types: Data frames, Control frames (RTS, CTS, ACK),
Management frames (beacons, association requests).
■ Hidden Terminal Problem: Two stations are out of range of each
other but both within range of a central access point. They can't hear
each other, leading to collisions at the AP. CSMA/CA with RTS/CTS
helps mitigate this.
■ Exposed Terminal Problem: A station wants to transmit but hears
another station transmitting, even though the receiver of its intended
transmission is not within range of the interfering transmitter. This
leads to unnecessary deferral.
5. Collision-Free Protocols (Controlled Access Protocols)
○ Purpose: To determine the optimal (or a good) path for data packets to travel
from a source host to a destination host across a network of interconnected
routers.
○ Goal: Minimize metrics like hop count, delay, bandwidth, cost, etc.
○ Types:
■ Static Routing:
■ Concept: Routes are manually configured by a network
administrator and remain fixed unless manually changed.
■ Characteristics: Simple for small, stable networks. No
overhead for routing updates. Not adaptive to network changes
(failures, congestion).
■ Dynamic Routing (Adaptive Routing):
■ Concept: Routers use routing protocols to automatically
discover and update routes based on real-time network
conditions.
■ Characteristics: Adaptive to network changes. More complex
to configure and manage. Introduces routing overhead.
■ Categories:
■ Distance Vector Routing:
■ Concept: Each router maintains a "distance
vector" (table) to all known destinations, sharing
it with its directly connected neighbors.
Neighbors then update their tables based on the
received vectors.
■ Examples: RIP (Routing Information Protocol).
■ Issues: "Count-to-infinity" problem, slow
convergence.
■ Link State Routing:
■ Concept: Each router gathers information about
its directly connected links and their costs (link
states). It then broadcasts this information to all
other routers in the network. Each router
independently builds a complete map of the
network (graph) and runs an algorithm (e.g.,
Dijkstra's algorithm) to calculate the shortest
path to all destinations.
■ Examples: OSPF (Open Shortest Path First),
IS-IS (Intermediate System to Intermediate
System).
■ Benefits: Faster convergence, less prone to
loops.
■ Disadvantages: More complex to implement,
requires more computational resources.
2. Congestion Control Algorithms
○ Purpose: To prevent the entire network (not just the end hosts) from
becoming congested by excessive traffic.
○ Mechanism (TCP): TCP uses an end-to-end approach, inferring network
congestion and reacting to it. It doesn't rely on explicit signals from
intermediate routers (though ECN helps).
○ Key Algorithms/Phases (TCP):
■ Congestion Window (cwnd): A sender-side variable that limits the
amount of data a TCP sender can have in flight (unacknowledged) at
any given time.
■ Slow Start:
■ Concept: Starts with a small cwnd (e.g., 1 or 2 segments).
■ Growth: cwnd increases exponentially (e.g., doubles for every
ACK received) until it reaches ssthresh (slow start
threshold).
■ Purpose: To quickly probe the network capacity.
■ Congestion Avoidance:
■ Concept: After cwnd reaches ssthresh, growth becomes
linear.
■ Growth: cwnd increases by 1 segment for every Round Trip
Time (RTT).
■ Purpose: To probe for more bandwidth cautiously, avoiding
congestion.
■ Fast Retransmit:
■ Concept: If the sender receives three duplicate ACKs for a
segment, it assumes that segment is lost (without waiting for a
timeout) and immediately retransmits the missing segment.
■ Purpose: To recover from single packet losses quickly without
entering slow start.
■ Fast Recovery:
■ Concept: After Fast Retransmit, ssthresh is set to half of the
current cwnd, and cwnd is set to ssthresh plus three
segments. Then, cwnd continues to grow linearly.
■ Purpose: To recover from packet loss gracefully, avoiding the
full slow start phase, assuming the loss was not due to severe
congestion.
■ Timeout: If a timeout occurs (no ACK for a segment for a long time),
it's a strong indication of severe congestion. ssthresh is set to half
cwnd, and cwnd is reset to 1 (re-enters slow start).
○ Goal: To optimize network utilization and prevent congestion collapse by
dynamically adjusting the sending rate based on network conditions.
3. TCP (Transmission Control Protocol)
This section covers specific Application Layer protocols and a re-mention of the Presentation
Layer.
○ Purpose: The standard protocol for sending email across the Internet. It
defines the mechanism for sending emails from a mail client to a mail server,
and between mail servers.
○ Client-Server Interaction: Mail client (e.g., Outlook, Gmail web interface)
sends an email to its designated SMTP server. The SMTP server then relays
the email, potentially through other SMTP servers, until it reaches the
recipient's mail server.
○ Protocol: Uses TCP port 25 (for server-to-server and client-to-server without
authentication) or TCP port 587 (for client-to-server with authentication, often
referred to as Submission port).
○ Limitations: SMTP is only for sending emails. Other protocols (POP3, IMAP)
are used for retrieving emails.
3. HTTP (Hypertext Transfer Protocol)
○ Purpose: The foundation of the World Wide Web, used for retrieving
resources (e.g., HTML documents, images, videos) from web servers to web
browsers.
○ Client-Server Model: Web browser (client) sends an HTTP request to a web
server. The web server processes the request and sends back an HTTP
response containing the requested resource.
○ Protocol: Uses TCP port 80 (HTTP) or TCP port 443 (HTTPS - HTTP
Secure, with TLS/SSL encryption).
○ Characteristics:
■ Stateless: Each request from a client to a server is treated as an
independent transaction; the server does not retain information about
previous requests. Cookies are used to maintain state.
■ Request/Response Model: Client initiates request, server responds.
○ Methods: Common HTTP methods include GET (retrieve data), POST
(submit data), PUT (update resource), DELETE (delete resource).
4. FTP (File Transfer Protocol)
2. The Internet is the best example of a: a) LAN b) MAN c) WAN d) Wireless network
Answer: c) WAN
3. Which network type is designed to cover a city or a large metropolitan area? a) LAN
b) MAN c) WAN d) WLAN Answer: b) MAN
4. Devices in a wireless network communicate using: a) Optical fiber b) Copper cables
c) Electromagnetic waves d) Telephone lines Answer: c) Electromagnetic waves
5. How many layers are there in the OSI reference model? a) 4 b) 5 c) 7 d) 6 Answer:
c) 7
6. Which OSI layer is responsible for logical addressing and routing? a) Physical Layer
b) Data Link Layer c) Network Layer d) Transport Layer Answer: c) Network Layer
7. The Transport Layer of the OSI model is responsible for: a) Bit synchronization b)
End-to-end process-to-process communication c) Routing packets d) Data encryption
Answer: b) End-to-end process-to-process communication
8. Which OSI layer provides services like data encryption and compression? a) Session
Layer b) Presentation Layer c) Application Layer d) Data Link Layer Answer: b)
Presentation Layer
9. Which layer of the TCP/IP model combines the functions of the OSI Physical and
Data Link layers? a) Application Layer b) Transport Layer c) Internet Layer d)
Network Access Layer Answer: d) Network Access Layer
10.FTP, HTTP, and SMTP protocols operate at which layer of the TCP/IP model? a)
Transport Layer b) Internet Layer c) Application Layer d) Network Access Layer
Answer: c) Application Layer
11.A hub operates at which layer of the OSI model? a) Physical Layer b) Data Link
Layer c) Network Layer d) Transport Layer Answer: a) Physical Layer
12.A router operates at which layer of the OSI model? a) Data Link Layer b) Network
Layer c) Transport Layer d) Session Layer Answer: b) Network Layer
14.What is the primary difference between the OSI and TCP/IP models regarding the
Session and Presentation layers? a) TCP/IP has more layers. b) OSI combines them
into the Application layer. c) TCP/IP combines them into the Application layer. d)
TCP/IP has no equivalent for these layers. Answer: c) TCP/IP combines them into
the Application layer.
15.What is the unit of data at the Data Link Layer? a) Bits b) Segments c) Packets d)
Frames Answer: d) Frames
17.Which switching technique is more efficient for bursty data traffic? a) Circuit
Switching b) Packet Switching c) Message Switching d) Both a and b Answer: b)
Packet Switching
21.The process of dividing the stream of bits from the network layer into discrete,
manageable units for transmission is called: a) Error Control b) Flow Control c)
Framing d) Segmentation Answer: c) Framing
22.Which framing method inserts an "escape byte" if the flag byte appears in the data?
a) Bit Stuffing b) Character Counting c) Byte Stuffing d) Physical Layer Coding
Violations Answer: c) Byte Stuffing
23.The primary goal of flow control at the data link layer is to: a) Detect corrupted
frames. b) Prevent a fast sender from overwhelming a slow receiver. c) Determine
the best path for data. d) Translate logical addresses. Answer: b) Prevent a fast
sender from overwhelming a slow receiver.
24.What is the main purpose of error control at the data link layer? a) To manage shared
access to the medium. b) To ensure reliable transmission of data across the physical
link. c) To convert logical addresses to physical addresses. d) To synchronize bit
streams. Answer: b) To ensure reliable transmission of data across the physical
link.
26.Which error control method allows the receiver to correct errors without
retransmission? a) Checksum b) Parity Check c) Automatic Repeat Request (ARQ)
d) Forward Error Correction (FEC) Answer: d) Forward Error Correction (FEC)
28.Which protocol allows the sender to transmit multiple frames before waiting for an
acknowledgment? a) Simplex Protocol b) Stop-and-Wait Protocol c) Sliding Window
Protocol d) Pure ALOHA Answer: c) Sliding Window Protocol
29.In a Go-Back-N protocol, if frame 5 is lost, what does the sender retransmit upon
timeout or receiving duplicate ACKs for frame 4? a) Only frame 5 b) Frame 5 and all
subsequent frames in its window c) All frames from the beginning d) The receiver
retransmits frame 5 Answer: b) Frame 5 and all subsequent frames in its window
30.The receiver in a Go-Back-N protocol typically has a receive window size of: a) 0 b) 1
c) N d) N/2 Answer: b) 1
32.In Selective Repeat, the receiver can accept frames: a) Only in sequential order. b)
Only if they are corrupted. c) Out of order, within its receive window. d) Only one at a
time. Answer: c) Out of order, within its receive window.
33.What is the main disadvantage of the Stop-and-Wait protocol? a) High error rate b)
Low utilization for high-latency links c) Complex implementation d) Requires large
buffers Answer: b) Low utilization for high-latency links
34.A checksum is used for: a) Error correction b) Error detection c) Flow control d)
Framing Answer: b) Error detection
35.Parity checking can detect: a) Single-bit errors b) Burst errors c) Random errors only
d) All types of errors Answer: a) Single-bit errors
36.Which data link layer protocol is best suited for a perfectly reliable and error-free
channel? a) Go-Back-N b) Selective Repeat c) Simplex d) Stop-and-Wait Answer: c)
Simplex
37.What is the maximum number of unacknowledged frames a sender can have in flight
in a Go-Back-N protocol with a window size of N? a) 1 b) N-1 c) N d) N+1 Answer: c)
N
38.The use of sequence numbers in data link layer frames helps to: a) Detect errors. b)
Control the flow of data. c) Reorder out-of-order frames. d) Both b and c. Answer: d)
Both b and c. (Primarily reordering, but also implicitly assists flow control by
determining what can be sent next).
42.In Pure ALOHA, if a station transmits and does not receive an ACK, what does it do?
a) It assumes success and continues. b) It immediately retransmits. c) It retransmits
after a random backoff time. d) It gives up. Answer: c) It retransmits after a
random backoff time.
43.What is the "vulnerable period" for a Pure ALOHA frame? a) Half the frame
transmission time b) Equal to the frame transmission time c) Twice the frame
transmission time d) Four times the frame transmission time Answer: c) Twice the
frame transmission time
44.Slotted ALOHA improves upon Pure ALOHA by: a) Allowing transmission at any
time. b) Dividing time into discrete slots for transmission. c) Sensing the carrier
before transmitting. d) Detecting collisions during transmission. Answer: b) Dividing
time into discrete slots for transmission.
46.CSMA/CD is primarily used in: a) Wireless LANs (Wi-Fi) b) Traditional wired Ethernet
c) Satellite communication d) Bluetooth networks Answer: b) Traditional wired
Ethernet
53.Which protocol allows multiple users to transmit simultaneously over the same
frequency by using unique codes? a) TDMA b) FDMA c) CDMA d) CSMA Answer:
c) CDMA
56.The primary function of the Network Layer is: a) Framing and error control. b)
End-to-end process communication. c) Logical addressing and routing. d) Data
encryption. Answer: c) Logical addressing and routing.
58.What is the main advantage of dynamic routing over static routing? a) Simplicity of
configuration b) Lower overhead c) Adaptability to network changes d) Faster initial
setup Answer: c) Adaptability to network changes
60.Which routing algorithm requires each router to build a complete map of the network
topology? a) Distance Vector Routing b) Link State Routing c) Static Routing d)
Flooding Answer: b) Link State Routing
63.The primary goal of congestion control at the Network Layer is to: a) Prevent a single
host from sending too fast. b) Ensure reliable data transfer. c) Prevent the network
from becoming overloaded. d) Authenticate users. Answer: c) Prevent the network
from becoming overloaded.
64.Which congestion control technique involves preventing new connections from being
established when the network is overloaded? a) Backpressure b) Choke Packets c)
Admission Control d) Load Shedding Answer: c) Admission Control
66.What is the fundamental protocol used for internetworking that provides logical
addressing? a) TCP b) UDP c) IP d) ARP Answer: c) IP
67.What happens if a router receives a packet larger than the MTU of the next network
link? a) It discards the packet. b) It fragments the packet. c) It holds the packet until
the MTU increases. d) It sends an error message to the source. Answer: b) It
fragments the packet.
68.Routers are key devices for internetworking because they: a) Connect devices within
a single network. b) Manage physical connections between different networks. c)
Forward packets between different heterogeneous networks. d) Provide wireless
access. Answer: c) Forward packets between different heterogeneous
networks.
70.Which routing strategy is best suited for large, dynamic networks? a) Static Routing
b) Default Routing c) Dynamic Routing d) Policy-based Routing Answer: c)
Dynamic Routing
72.UDP is often preferred over TCP for applications like: a) Web Browse b) Email
transfer c) Online gaming and VoIP d) File transfer Answer: c) Online gaming and
VoIP
73.TCP's flow control mechanism uses a: a) Fixed window size. b) Sliding window
(receive window) advertised by the receiver. c) Token bucket algorithm. d)
Backpressure signal. Answer: b) Sliding window (receive window) advertised by
the receiver.
75.What is the primary purpose of TCP's congestion control? a) To prevent a fast sender
from overwhelming a slow receiver. b) To ensure data arrives in order. c) To prevent
the network from collapsing due to excessive traffic. d) To detect corrupted packets.
Answer: c) To prevent the network from collapsing due to excessive traffic.
76.In TCP's congestion control, the "slow start" phase causes the congestion window to
grow: a) Linearly b) Exponentially c) Statically d) Randomly Answer: b)
Exponentially
77.TCP infers network congestion primarily from: a) Explicit messages from routers. b)
Packet loss (timeouts or duplicate ACKs). c) Network Administrator warnings. d) High
CPU utilization. Answer: b) Packet loss (timeouts or duplicate ACKs).
79.What does TCP use to detect missing segments and ensure ordered delivery? a) IP
addresses b) Port numbers c) Sequence numbers d) MAC addresses Answer: c)
Sequence numbers
81.Which port number is typically used by TCP for HTTP traffic? a) 21 b) 25 c) 80 d) 443
Answer: c) 80
82.What is the typical default action of POP3 after downloading emails to a client? a)
Keep them on the server. b) Delete them from the server. c) Archive them on the
server. d) Mark them as unread. Answer: b) Delete them from the server.
84.If a TCP timeout occurs, what typically happens to the congestion window (cwnd)? a)
It doubles. b) It linearly increases. c) It is reset to 1. d) It remains unchanged.
Answer: c) It is reset to 1.
85.Why does TCP use port numbers? a) To identify specific network interfaces. b) To
identify specific applications or processes on a host. c) To provide unique IP
addresses. d) To ensure data reliability. Answer: b) To identify specific
applications or processes on a host.
86.Which OSI layer is responsible for dialog control and synchronization during a
communication session? a) Transport Layer b) Session Layer c) Presentation Layer
d) Application Layer Answer: b) Session Layer
87.The Presentation Layer's primary function is to: a) Establish and terminate sessions.
b) Provide logical addressing. c) Ensure data is in a readable format for the
application. d) Route packets between networks. Answer: c) Ensure data is in a
readable format for the application.
88.Data encryption and compression are functions primarily handled by which OSI
layer? a) Session Layer b) Presentation Layer c) Application Layer d) Transport
Layer Answer: b) Presentation Layer
89.Remote Procedure Call (RPC) allows a program to: a) Send email to a remote
server. b) Execute a procedure on a different machine as if it were local. c) Translate
domain names to IP addresses. d) Transfer files securely. Answer: b) Execute a
procedure on a different machine as if it were local.
90.The process of packaging parameters and results into a network-ready format for
RPC is called: a) Encryption b) Compressing c) Marshalling d) Routing Answer: c)
Marshalling
92.DNS queries primarily use which transport layer protocol for speed? a) TCP b) UDP
c) SCTP d) Both TCP and UDP equally Answer: b) UDP
93.Which protocol is used for sending email from a mail client to a mail server? a) POP3
b) IMAP c) HTTP d) SMTP Answer: d) SMTP
95.HTTPS uses which protocol for secure communication? a) FTP b) SMTP c) TLS/SSL
d) DNS Answer: c) TLS/SSL
96.Which protocol uses two TCP connections (one for control, one for data) for file
transfer? a) HTTP b) SMTP c) FTP d) DNS Answer: c) FTP
97.If you want to access your emails from multiple devices and keep them synchronized
on the server, which protocol is generally preferred? a) POP3 b) SMTP c) IMAP d)
HTTP Answer: c) IMAP
98.The World Wide Web is primarily based on which application layer protocol? a) FTP
b) SMTP c) HTTP d) Telnet Answer: c) HTTP
100. A mail user agent (MUA) is typically: a) A mail server. b) A client software for
sending and receiving emails. c) A protocol for transferring mail between servers. d)
A database for storing emails. Answer: b) A client software for sending and
receiving emails.