Computer Networks - 7
Computer Networks - 7
LAN (Local Area Network), MAN (Metropolitan Area Network), and WAN (Wide Area
Network) are three types of networks that differ in terms of their size, range, and usage.
Covers a small
Covers a city or a large
geographic area Covers a vast geographic area,
Scope campus, typically within a
(within a building or potentially global in scale.
range of up to 50 km.
campus).
Devices Used Switches, routers, Routers, bridges, leased Routers, modems, satellite
LAN (Local Area MAN (Metropolitan Area
Feature WAN (Wide Area Network)
Network) Network)
Manchester Encoding and Differential Manchester Encoding are both types of line coding
schemes used to encode data in the form of electrical signals for transmission over a
communication channel.
Manchester Encoding:
In Manchester Encoding, the signal level transitions at the middle of the bit period.
This encoding ensures that there is always a transition in every bit period, which helps in
synchronization and reduces the possibility of long periods of no activity (thus
minimizing the risk of signal loss).
Advantages:
In Differential Manchester Encoding, the signal transitions at the beginning of the bit
period, and the interpretation of the transition depends on the data bit.
Advantages:
o More resilient to errors, as the signal is interpreted relative to the previous state.
Comparison:
Manchester Encoding has a transition in the middle of each bit period, making it easier
to synchronize clocks.
Differential Manchester uses a transition at the beginning of each bit period for "1" and
at the middle for "0", making it more robust against noise.
Topology refers to the arrangement of different elements (like nodes, links, etc.) in a network. It
defines the way devices are connected and how data flows within the network. There are
several types of network topologies.
Types of Topologies:
1. Bus Topology:
o In bus topology, all devices are connected to a single central cable (the "bus").
o Advantages:
o Disadvantages:
A failure in the central cable affects the whole network.
2. Star Topology:
o Advantages:
o Disadvantages:
3. Ring Topology:
o In ring topology, each device is connected to exactly two other devices, forming
a ring.
o Advantages:
Data transfer is fast because each device passes the data in one direction.
o Disadvantages:
4. Mesh Topology:
o Advantages:
o Disadvantages:
5. Hybrid Topology:
o Hybrid topology combines two or more basic topologies (like star and bus).
o Advantages:
o Disadvantages:
1. Router:
o Role: A router connects multiple networks (such as LANs, WANs) and directs data
packets between them. It operates at the Network Layer (Layer 3) of the OSI
model.
o Functions:
o Example: A home router that connects your home network to the internet.
2. Switch:
o Role: A switch is used to connect devices within a single network (LAN) and
operates at the Data Link Layer (Layer 2). It forwards data based on MAC
addresses.
o Functions:
3. Hub:
o Functions:
Does not have the intelligence to determine the destination of the data.
Hamming Code is a method of error detection and correction used to detect and correct single-
bit errors in transmitted data.
2r≥m+r+12^r \geq m + r + 1
Where m is the number of data bits and r is the number of parity bits.
o Parity bits are placed at positions that are powers of 2 (1, 2, 4, 8, etc.). The data
bits are placed in all other positions.
3. Calculate Parity Bits:
o Each parity bit checks specific positions in the bit stream (including its own
position). The parity bit ensures that the total number of 1s in the positions it
checks (including the parity bit itself) is even.
2), it checks bits 2, 3, 6, 7, 10, etc. - For P4 (bit at position 4), it checks bits 4, 5, 6, 7, 12, etc.
4. Transmit Data:
o Once the parity bits are calculated, the complete code (data bits + parity bits) is
transmitted.
o On the receiver side, the receiver recalculates the parity bits. If any of the
recalculated parity bits don't match the received parity bits, an error is detected.
o The position of the error is identified by the binary number formed by the
positions where the parity checks failed.
Example:
If we are sending the 4-bit data 1011, we will add 3 parity bits to form a 7-bit code: p1 p2 1 p4 0
1 1. After calculation and transmission, the receiver checks for errors and corrects them if
necessary.
The Link Layer is the second layer in the OSI model and is responsible for data transfer between
two directly connected nodes. It provides several essential services to ensure reliable
communication over a physical medium.
1. Framing:
o The link layer divides data from the Network Layer into smaller units called
frames. Each frame contains data and control information necessary for the
reliable transmission of the data.
o The link layer uses techniques such as cyclic redundancy check (CRC) and parity
bits to detect errors in the transmitted frames. It may also provide mechanisms
for error correction, depending on the protocol.
3. Flow Control:
o The link layer manages the flow of data to ensure that the sender does not
overwhelm the receiver. Flow control prevents congestion by regulating data
transmission based on the receiver's buffer capacity.
o The link layer defines protocols that control access to the shared transmission
medium, ensuring that only one device transmits at a time to avoid collisions.
5. Addressing:
o The link layer uses MAC addresses (hardware addresses) to identify devices on
the same local network. This allows data to be directed to specific devices in a
network segment.
6. Link Management:
Flow control is a mechanism to control the rate of data transmission between two devices to
prevent the receiver from being overwhelmed. Below are two common flow control techniques
used in the link layer:
1. Stop-and-Wait Protocol:
In the Stop-and-Wait Protocol, the sender sends one frame and then stops and waits for
an acknowledgment (ACK) from the receiver before sending the next frame.
Process:
o Once the acknowledgment is received, the sender sends the next frame.
Advantages:
o Simple to implement.
Disadvantages:
o Inefficient in high-speed networks because the sender spends much time waiting
for an acknowledgment.
In the Sliding Window Protocol, the sender can send multiple frames without waiting
for an acknowledgment for each frame. However, the receiver will acknowledge each
frame in order.
Process:
o The sender can send several frames at once, but the number of unacknowledged
frames is restricted by the size of the window.
Advantages:
PPP (Point-to-Point Protocol) is a data link layer communication protocol used to establish a
direct connection between two nodes (devices) over a serial link, such as a phone line, fiber, or
a dedicated leased line. It is commonly used in dial-up connections, DSL, and VPNs.
1. Framing:
o PPP encapsulates the data link layer frame in a standard format for transmission
over a point-to-point link. The frame includes a flag (to indicate the beginning
and end of the frame) and a checksum for error detection.
2. Error Detection:
o PPP uses Cyclic Redundancy Check (CRC) for error detection. If an error is
detected in the received frame, the data is discarded, and the sender is asked to
retransmit the frame.
3. Authentication:
5. Multi-Protocol Support:
o PPP can carry multiple network layer protocols, including IP, IPv6, and others,
making it a flexible choice for point-to-point connections.
Data: Variable length (contains the actual data from the upper layer).
Channel Allocation refers to the process of assigning communication channels to different users
or devices in a network. It ensures efficient use of the available bandwidth and minimizes
interference and collision. There are two main types of channel allocation: Static Channel
Allocation and Dynamic Channel Allocation.
Examples:
o Time Division Multiple Access (TDMA): Each user is assigned a specific time slot
for transmission.
Advantages:
Disadvantages:
o Inefficient, as some channels may remain idle while others are overloaded.
Examples:
o Code Division Multiple Access (CDMA): Users are assigned unique codes for
communication, allowing them to share the same frequency spectrum.
o Dynamic TDMA: Users are assigned time slots dynamically based on the current
network load.
Advantages:
Disadvantages:
1. Pure ALOHA:
In Pure ALOHA, a device transmits data whenever it has data to send, without
synchronization. If a collision occurs (i.e., another device transmits at the same time),
the device waits for a random period before retransmitting the data.
Working:
o Collisions can happen if two devices transmit at the same time or overlap.
Advantages:
o Simple to implement.
Disadvantages:
2. Slotted ALOHA:
In Slotted ALOHA, time is divided into discrete slots, and devices are synchronized to
transmit only at the beginning of each time slot.
Working:
o A device waits for the start of a time slot and then sends its data frame.
o If a collision occurs, the device waits for a random period (based on the slot
duration) and then retransmits.
Advantages:
o Collisions are less frequent than in Pure ALOHA because devices are synchronized
to transmission slots.
Disadvantages:
o Slightly more complex than Pure ALOHA because of the time slot
synchronization.
Comparison:
Efficiency: Slotted ALOHA is more efficient than Pure ALOHA because the time
synchronization reduces the probability of collisions.
Throughput: Slotted ALOHA can achieve a maximum throughput of about 36.8%, while
Pure ALOHA can only achieve about 18.4% due to the increased chances of collisions.
11. Draw and Explain the Working of CSMA/CD in Detail
CSMA/CD (Carrier Sense Multiple Access with Collision Detection) is a network protocol used
in Ethernet networks to manage access to a shared communication channel. It helps to avoid
and resolve collisions that occur when two devices attempt to send data simultaneously.
Working of CSMA/CD:
1. Carrier Sensing:
o A device first listens to the channel (Carrier Sense) to check if it is free or busy. If
the channel is idle, the device can transmit.
o If the channel is busy (another device is transmitting), the device waits for the
channel to become free.
2. Transmission:
o Once the channel is idle, the device starts transmitting data. However, it
continues to monitor the channel during transmission.
3. Collision Detection:
o While transmitting, the device continues to check if another device has also
started transmitting at the same time. This results in a collision.
4. Collision Resolution:
o After a collision is detected, each device waits for a random period (called
backoff time) before attempting to resend the data.
o This random waiting helps to avoid repeated collisions, which could occur if both
devices try to transmit at the same time again.
5. Retransmission:
o Once the random backoff time has elapsed, the devices sense the channel again
and, if it's idle, they retransmit their data.
Diagram of CSMA/CD:
+-----------+ +-----------+
| Device A | | Device B |
+-----------+ +-----------+
| |
| |
/ \ / \
Yes No Yes No
| | | |
Wait for free Send data Wait for free Send data
| | | |
+-------------+ +-------------+
| |
| |
/ \ / \
Yes No Yes No
| | | |
| | | |
| | | |
The Ethernet frame is the basic data unit used in Ethernet networks. It consists of several fields,
each serving a different purpose in ensuring reliable data transmission.
Ethernet Frame Format:
1. Preamble (7 bytes):
o A sequence of 7 bytes that helps the receiver synchronize with the incoming
frame. It is used to alert the receiving device about the incoming frame.
o The MAC address of the destination device on the network. It identifies the
receiver.
o The MAC address of the source device that is sending the frame.
o Indicates either the type of protocol being carried (e.g., IPv4, ARP) or the length
of the data field.
o The actual data being transmitted. This can be an IP packet or another higher-
layer protocol data unit (PDU).
o A CRC (Cyclic Redundancy Check) value used for error detection. The receiver
calculates the CRC and compares it to this field to detect errors.
+---------+---------+------------+------------+-----------+----------+------------------+-----------+
+---------+---------+------------+------------+-----------+----------+------------------+-----------+
Decimal dotted
Hexadecimal colon notation (e.g.,
Address Format notation (e.g.,
2001:0db8:85a3:0000:0000:8a2e:0370:7334)
192.168.1.1)
Approximately 4.3
Address Space Approximately 340 undecillion addresses
billion addresses
Header
Complex (more fields) Simplified (many fields are dropped)
Complexity
Security optional
Security Security mandatory (IPsec is mandatory)
(IPsec is optional)
NAT (Network Address Translation) is a technique used to modify the IP address information in
packet headers while they are in transit across a router or firewall. It enables devices in a private
network to communicate with external networks (such as the internet) using a single public IP
address.
Role of NAT:
1. IP Address Conservation:
o NAT allows multiple devices within a private network to share a single public IP
address. This helps conserve public IP addresses.
2. Security:
3. Address Translation:
4. Types of NAT:
Link-State Routing is a type of routing protocol in which routers maintain a complete map of the
network topology. Each router exchanges information about its directly connected links
(interfaces) with all other routers. This allows every router to independently calculate the best
path to each destination using algorithms like Dijkstra's Algorithm.
o LSAs contain the router's state (e.g., up/down status, link cost) and the state of
its links to other routers.
2. Flooding:
o LSAs are flooded throughout the network so that all routers have the same
topology information.
3. Shortest Path Calculation:
o After receiving the LSAs, each router builds a complete topology map of the
network.
o Using algorithms like Dijkstra's algorithm, routers calculate the shortest path to
each destination based on the link-state database.
o Once the shortest paths are calculated, each router updates its routing table and
uses it to forward packets.
If Router A is connected to Routers B and C, it sends LSAs to all other routers, including
information about its connection to B and C. Other routers like B and C will then
calculate the shortest path based on the complete network topology and adjust their
routing tables accordingly.
RIP is a distance-vector routing protocol used in both IPv4 and IPv6 networks. It helps routers
determine the best path for data to travel across a network. RIP uses hop count as the metric to
determine the shortest path. It’s considered one of the oldest and simplest routing protocols.
Metric: Hop count (maximum of 15 hops, making it unsuitable for large networks).
Operation: RIP routers periodically exchange routing information with their neighbors.
Each router maintains a table of destination networks and the number of hops to reach
them. The router updates its table based on the information received from its neighbors.
Advantages: Simple to configure, widely supported, and easy to use in small networks.
Disadvantages: Slow convergence, limited scalability, and uses a maximum hop count of
15, which limits its usefulness in large networks.
ii) BGP (Border Gateway Protocol)
BGP is the protocol used to exchange routing information between different networks
(autonomous systems, AS) on the internet. It is a path vector protocol and plays a critical role in
determining how data is routed across the internet.
Operation: BGP exchanges routing and reachability information among routers within
different autonomous systems. It uses AS numbers to identify different networks.
Key Characteristics:
o Path Selection: BGP uses various attributes (AS path, next hop, prefix length) to
choose the best path for routing traffic.
o Policy-Based Routing: Network operators can apply routing policies based on the
path, AS path, or other criteria.
o Scalability: BGP can handle a large number of routes and is designed for
scalability, making it suitable for large networks such as the internet.
Advantages: Flexible routing policies, scalable, and provides control over traffic flow.
TCP is a connection-oriented transport layer protocol that ensures reliable data transmission
between devices over a network. It is used in applications where reliable data delivery is
required, such as web browsing (HTTP), email (SMTP), and file transfer (FTP).
Reliability: TCP ensures data is delivered in order and without errors. It uses sequence
numbers, acknowledgments, and retransmission to ensure data integrity.
Flow Control: TCP uses flow control mechanisms to prevent the sender from
overwhelming the receiver with data.
Congestion Control: TCP adjusts the rate of data transmission based on network
congestion, using algorithms like slow start, congestion avoidance, and fast retransmit.
Features:
Message-Oriented: Unlike TCP, which deals with streams of data, SCTP transmits data in
discrete messages.
Reliable: SCTP ensures reliable delivery of messages, like TCP, using acknowledgments,
retransmission, and sequencing.
Features:
o Ordered and Unordered Delivery: SCTP supports both ordered and unordered
message delivery.
The Transport Layer is the fourth layer of the OSI model and plays a critical role in end-to-end
communication between devices. It ensures reliable data transfer across the network by
providing error control, flow control, and proper sequencing of data.
Segmentation and Reassembly: The transport layer divides large data from the
application layer into smaller segments and ensures they are properly reassembled at
the destination.
Error Detection and Correction: The transport layer adds error-checking mechanisms
(like checksums) to ensure data integrity and requests retransmission if errors are
detected.
Flow Control: It manages the rate of data transmission between sender and receiver to
prevent congestion and ensure the receiver can handle the incoming data.
Order of Data Maintains order of data Does not guarantee order of data
TCP Congestion Control is a mechanism that prevents network congestion by adjusting the rate
of data transmission. The goal is to avoid overwhelming the network and ensure fair sharing of
network resources among all devices.
1. Slow Start:
2. Congestion Avoidance:
o Once the CWND reaches the threshold (ssthresh), the growth of the window
becomes linear instead of exponential.
o The CWND is increased by 1 segment for each round-trip time (RTT) until packet
loss occurs.
3. Fast Retransmit:
o When a packet is lost (indicated by duplicate ACKs), TCP performs fast retransmit,
immediately retransmitting the lost packet without waiting for a timeout.
4. Fast Recovery:
o After detecting packet loss, TCP reduces the congestion window and enters the
fast recovery phase. It avoids starting from scratch (like in slow start) and
continues to send data using a reduced window size.
5. Timeout:
These mechanisms help manage congestion and ensure reliable data transmission in networks
with varying load conditions.
DNS (Domain Name System) is a distributed hierarchical naming system that translates human-
readable domain names (e.g., www.example.com) into machine-readable IP addresses (e.g.,
192.0.2.1). It plays a crucial role in the functionality of the internet by allowing users to access
websites using easily memorable names instead of numeric IP addresses.
DNS Structure: The DNS system consists of a series of servers and databases that work
together to resolve domain names. It includes DNS clients (resolvers), DNS servers, and
zones.
o DNS Resolver: The DNS resolver is responsible for querying the DNS servers to
resolve domain names into IP addresses.
o DNS Server: DNS servers hold records of domain names and their corresponding
IP addresses. Types of DNS records include A records (IPv4 addresses), AAAA
records (IPv6 addresses), MX records (Mail Exchange), etc.
o Zones: Zones are parts of the DNS namespace that are managed by DNS servers.
Each zone contains information about specific domain names and subdomains.
o When a user enters a domain name in the browser, the browser sends a query to
the DNS resolver to obtain the corresponding IP address.
o The resolver queries DNS servers until it finds the authoritative server for the
domain, which provides the IP address.
o The IP address is then returned to the browser, allowing the user to access the
website.
Caching: DNS records are often cached by DNS resolvers to reduce lookup times and
improve performance.
HTTP (Hypertext Transfer Protocol) is the protocol used for transferring hypertext (web page)
data across the World Wide Web. It is an application layer protocol that defines how messages
are formatted and transmitted between a client (such as a web browser) and a web server.
HTTP Basics:
o HTTP operates on the client-server model where the client sends HTTP requests,
and the server sends HTTP responses.
1. Request Line: Includes the HTTP method (e.g., GET, POST), the requested
resource (URL), and the HTTP version. Example: GET /index.html HTTP/1.1
2. Headers: Contain additional information about the request, such as the client
type (User-Agent), accepted content types (Accept), and cookies (Cookie).
3. Body (Optional): Some HTTP requests (e.g., POST requests) contain a body with
data being sent to the server.
1. Status Line: Includes the HTTP version, a status code (e.g., 200 OK, 404 Not
Found), and a reason phrase describing the status. Example: HTTP/1.1 200 OK
2. Headers: Provide additional information about the server, content type, content
length, etc.
3. Body: Contains the requested data, such as an HTML page, image, or other
resources.
HTTP Methods:
Stateless: HTTP is stateless, meaning that each request is independent, and the server
does not retain any memory of previous requests. This is why cookies or sessions are
often used to maintain state.
Secure Version: HTTPS (Hypertext Transfer Protocol Secure) is the encrypted version of
HTTP, which uses SSL/TLS to secure communication between the client and the server,
ensuring data privacy and integrity.
SMTP is a protocol used for sending and receiving emails between email clients and servers, as
well as between email servers.
Purpose: SMTP is used primarily to send outgoing emails from a client to a server and
from one server to another. It cannot retrieve or store emails; for that, other protocols
like IMAP or POP3 are used.
Operation:
2. The client sends the email's contents (recipient, subject, body, and attachments)
to the SMTP server.
3. The SMTP server forwards the email to the recipient’s email server if the
recipient’s email address is valid.
Ports: SMTP uses port 25 for unencrypted communication, and port 587 is used for
secure email transmission (with encryption).
Commands:
As mentioned earlier, DNS is responsible for resolving human-readable domain names into IP
addresses that computers can understand. It allows users to access websites using domain
names instead of IP addresses.
Purpose: DNS translates domain names like www.example.com into IP addresses such as
192.0.2.1, which enables users to connect to websites.
Operation:
1. When a user types a domain name in the browser, the browser sends a query to
a DNS resolver to obtain the corresponding IP address.
2. The DNS resolver then queries DNS servers (such as root servers, authoritative
servers, and caching servers) to find the IP address.
3. Once the IP address is found, it is sent back to the browser to initiate the
connection to the web server.
DNS Records:
SNMP is an application-layer protocol used for managing and monitoring network devices (such
as routers, switches, servers) in an IP network.
Purpose: SNMP is used to collect information from network devices, monitor their
health, and perform administrative tasks remotely. It helps administrators to manage
and monitor network performance.
Components:
2. SNMP Agent: Software that runs on network devices and collects data about the
device's performance (CPU usage, memory usage, etc.).
3. MIB (Management Information Base): A virtual database where data about the
device is stored in an organized manner, enabling easy querying and
manipulation.
Operations:
Versions:
Use Cases: SNMP is used for network monitoring, device management, and
troubleshooting.