0% found this document useful (0 votes)
7 views116 pages

Computer NetworkS - Hamza

Uploaded by

hamzazahoor182
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views116 pages

Computer NetworkS - Hamza

Uploaded by

hamzazahoor182
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 116

Hamza Zahoor What's App 0341-8377-917

NOTES

SUBJECT :
Computer Networks
CLASS :
BSCS 3rd Semester
WRITTEN BY :
Hamza Zahoor

Computer Networks - BS 3rd Semester Notes

Week 1: Introduction to Data Communication and Networks

1. Introduction of the Course and Outline

 Definition: This section typically covers the scope of the "Computer


Networks" course, its objectives, and the learning outcomes. It
introduces students to what they will learn over the semester,
including fundamental concepts, network models, protocols, and
various networking technologies.

 Examples:

o Course Objectives: To understand the principles of data


communication, to learn about different network models (OSI,
TCP/IP), to study various network protocols and their
functionalities, to explore different networking devices and
technologies, and to gain practical knowledge of network design
and troubleshooting.
Hamza Zahoor What's App 0341-8377-917

o Course Outline: A chronological list of topics to be covered


throughout the semester, often broken down by week, similar to
the list you provided.

 Key Takeaway: Sets the stage for the entire course, providing a
roadmap of the learning journey.

2. Data Communication

 Definition: Data communication refers to the exchange of data


between two devices via some form of transmission medium. This
exchange can occur between a sender and a receiver, with the data
being in various forms such as text, images, audio, or video. The
primary goal is reliable and efficient transfer of information.

 Key Concepts:

o Effectiveness of Data Communication: Depends on four


fundamental characteristics: delivery, accuracy, timeliness, and
jitter.

o Applications:

 Business: Sharing resources (printers, files), customer


relationship management (CRM), supply chain
management (SCM), e-commerce.

 Home: Internet access, online gaming, home automation,


streaming media.

 Mobile: GPS, mobile banking, social media, real-time


communication.

 Examples:

o Sending an email from your laptop to a friend's smartphone.

o Downloading a file from a web server.

o Making a video call using an application like Zoom or Google


Meet.

o Streaming a movie on Netflix.

 Types (Implicit in flow, discussed later): Simplex, Half-Duplex, Full-


Duplex.

3. Fundamental Characteristics of Data Communication


Hamza Zahoor What's App 0341-8377-917

 Definition: For data communication to be effective and efficient, it must


possess certain fundamental characteristics. These ensure that the
data arrives at the correct destination, is free from errors, arrives
promptly, and has a consistent arrival time.

 Characteristics:

1. Delivery: The system must deliver data to the correct


destination. Data must be received by the intended device or
user and only by that device or1 user.

 Example: When you send a message to a specific contact


on WhatsApp, it should only be received by that contact.

2. Accuracy: The system must deliver data accurately. Data


alteration in transmission and delivery often makes the data
unusable.

 Example: If you send a financial transaction amount of


$100, the receiver should get exactly $100, not $10 or
$1000. Error detection and correction mechanisms are
crucial here.

3. Timeliness: The system must deliver data in a timely manner.


Data delivered late is useless. This is particularly important for
real-time transmissions such as video and audio.

 Example: In a live video conference, delays can lead to


choppy video and audio, making the conversation difficult
or impossible to understand.

4. Jitter: Jitter refers to the variation in packet arrival time. It is the


uneven delay in the delivery of audio or video packets.

 Example: If packets of a video stream arrive with


significant variations in their inter-arrival times, the video
playback will appear choppy or stuttering, even if all
packets eventually arrive. Minimizing jitter is essential for
smooth multimedia experiences.

4. Components of Data Communication

 Definition: A data communication system is composed of five key


components that work together to facilitate the transfer of data.

 Components:
Hamza Zahoor What's App 0341-8377-917

1. Message: The information or data to be communicated. This can


be text, numbers, pictures, audio, video, or any combination of
these.

 Example: An email, a downloaded image, a voice message.

2. Sender (Source): The device that sends the data message. It can
be a computer, a workstation, a telephone, a video camera, etc.

 Example: Your smartphone when you send a text message;


your computer when you upload a file.

3. Receiver (Sink/Destination): The device that receives the data


message. It can be a computer, a workstation, a telephone, a
television, etc.

 Example: Your friend's phone receiving your text message;


a server receiving your uploaded file.

4. Transmission Medium (Channel): The physical path by which a


message travels from sender to receiver. It can be wired (e.g.,
twisted-pair cable, coaxial cable, fiber-optic cable) or wireless
(e.g., radio waves, microwaves, infrared).

 Example: The Ethernet cable connecting your computer to


a router; the Wi-Fi signals in your home.

5. Protocol: A set of rules that governs data communication. It


represents an agreement between the communicating devices
on how data should be transmitted and received. Without a
protocol, two devices may be connected but unable to
communicate.

 Example: HTTP (Hypertext Transfer Protocol) for web


Browse; TCP (Transmission Control Protocol) for reliable
data transfer; IP (Internet Protocol) for addressing and
routing.

5. Data Representation

 Definition: Data needs to be represented in a format that can be


understood and processed by computers and transmitted over
networks. Computers internally work with binary data (0s and 1s).

 Methods of Representation:
Hamza Zahoor What's App 0341-8377-917

1. Text: Represented using encoding schemes.

 ASCII (American Standard Code for Information


Interchange): Uses 7 bits to represent 128 characters
(English alphabet, numbers, punctuation).

 EBCDIC (Extended Binary Coded Decimal Interchange


Code): IBM's 8-bit character encoding.

 Unicode: A universal character encoding standard that


supports almost all scripts and symbols in the world. It
uses variable bits (e.g., UTF-8, UTF-16, UTF-32). UTF-8 is
widely used on the internet.

 Example: The letter 'A' in ASCII is represented as


01000001.

2. Numbers: Represented as binary numbers. For example, decimal


10 is binary 1010.

3. Images: Composed of pixels (picture elements). Each pixel is a


tiny dot that has a specific color and intensity.

 Representations:

 Bitmap (Raster Graphics): Stores individual pixel


values. Examples: JPEG, GIF, PNG.

 Vector Graphics: Stores mathematical descriptions of


lines and shapes. Examples: SVG, AI.

 Example: A black and white image might represent black


as 0 and white as 1 for each pixel. Color images use
multiple bits per pixel (e.g., 24-bit for True Color,
representing millions of colors).

4. Audio: Analog sound waves are converted into digital signals by


sampling and quantization.

 Sampling: Taking measurements of the analog signal at


regular intervals.

 Quantization: Assigning a discrete numerical value to each


sampled measurement.
Hamza Zahoor What's App 0341-8377-917

 Example: WAV, MP3. A song played on a computer is stored


as a sequence of binary digits that represent the sampled
and quantized audio waveform.

5. Video: Essentially a series of images (frames) displayed rapidly


to create the illusion of motion, combined with synchronized
audio.

 Example: MPEG, AVI. A video file contains a sequence of


still images (frames) along with their corresponding audio,
all encoded digitally.

6. Data Flow (Simplex, Half Duplex, Full Duplex)

 Definition: Data flow refers to the direction in which data can move
between two devices in a communication system. This characteristic
defines the capability of the communication channel.

 Types of Data Flow:

1. Simplex:

 Definition: Communication is unidirectional. Data flows in


only one direction from sender to receiver. The receiver
cannot send data back to the sender.

 Analogy: A one-way street.

 Example:

 Traditional television broadcasting: The broadcast


station sends signals to your TV, but your TV cannot
send signals back to the station.

 Radio broadcasting: Radio stations transmit to your


receiver, but your receiver doesn't transmit back.

 Keyboard to computer: A keyboard sends input to the


computer, but the computer doesn't send data back
to the keyboard in the same communication channel.

2. Half-Duplex:

 Definition: Communication is bidirectional, but not


simultaneously. Data can flow in both directions, but only
one device can transmit at a time. When one device is
sending, the other can only receive, and vice-versa.
Hamza Zahoor What's App 0341-8377-917

 Analogy: A walkie-talkie conversation.

 Example:

 Walkie-talkies: Users press a button to talk and


release it to listen. Only one person can talk at a
time.

 CB (Citizens Band) radio.

 Older hub-based Ethernet networks: While


technically the medium supports both directions, due
to collision domains, only one device transmits at a
time.

3. Full-Duplex:

 Definition: Communication is bidirectional and


simultaneous. Data can flow in both directions at the same
time.

 Analogy: A two-way street or a telephone conversation.

 Example:

 Telephone conversations: Both parties can speak and


hear each other simultaneously.

 Modern Ethernet networks (using switches): Devices


can send and receive data at the same time.

 Internet Browse: Your computer can send requests


(upload data) while simultaneously receiving web
pages (download data).

Computer Networks - BS 3rd Semester Notes (Continued)

Week 2: Network Fundamentals and Topologies

1. What Is Network?

 Definition: A network (specifically, a computer network) is a collection


of interconnected autonomous computers and devices that are able to
exchange data and share resources. The connection can be established
Hamza Zahoor What's App 0341-8377-917

through physical links (cables) or wireless means (radio waves). The


fundamental purpose of a network is to enable communication and
resource sharing among geographically dispersed devices.

 Key Concepts:

o Interconnected Devices: Not just computers, but also printers,


servers, smartphones, IoT devices, etc.

o Autonomous: Each device on the network can operate


independently, but also cooperates for communication.

o Resource Sharing: Sharing hardware (printers, scanners),


software (applications, databases), and data (files, information).

o Communication: Enabling email, instant messaging, video calls,


web Browse, etc.

 Examples:

o Local Area Network (LAN): Computers in an office building


connected to share a printer and internet access.

o Wide Area Network (WAN): The Internet, connecting millions of


computers globally.

o Home Network: Your Wi-Fi router connecting your laptop,


smartphone, smart TV, and printer.

 Benefits of Networking:

o Resource Sharing: Cost-effective sharing of expensive


peripherals (printers, scanners) and software.

o Communication: Facilitates rapid and efficient communication


(email, instant messaging, video conferencing).

o Data Sharing: Centralized storage and easy access to shared files


and databases.

o Increased Productivity: Enables collaboration and efficient


workflow.

o Entertainment: Online gaming, streaming services.

o Reliability: Data can be replicated on multiple machines,


providing redundancy.
Hamza Zahoor What's App 0341-8377-917

2. Network Criterion

 Definition: When evaluating the performance and suitability of a


network, several key criteria are considered. These criteria help in
designing, selecting, and managing networks effectively.

 Criteria:

1. Performance:

 Definition: Measured in terms of throughput, delay, and


reliability. It indicates how well the network performs its
intended functions.

 Metrics:

 Throughput (Bandwidth): How much data can be


transmitted over a given period (e.g., bits per second
- bps, Mbps, Gbps). Higher throughput generally
means better performance.

 Delay (Latency): How long it takes for data to travel


from source to destination. Lower delay is desirable,
especially for real-time applications.

 Jitter: Variation in packet arrival time.

 Utilization: The percentage of time the network is


busy transmitting data.

 Factors Affecting Performance: Number of users, type of


transmission medium, capabilities of connected hardware,
and the efficiency of software protocols.

2. Reliability:

 Definition: A measure of how often a network component


or the entire network fails, and how well it recovers from
failures. It also refers to the accuracy of data delivery.

 Metrics:

 Error Rate: The frequency of errors in data


transmission.

 Mean Time Between Failures (MTBF): Average time a


system works without failure.
Hamza Zahoor What's App 0341-8377-917

 Robustness: The ability of the network to function


even if some components fail.

 Factors Contributing to Reliability: Redundant paths, error


detection and correction mechanisms, fault-tolerant
hardware, and robust protocols.

3. Security:

 Definition: Protecting data from unauthorized access,


modification, or destruction. It involves maintaining
confidentiality, integrity, and availability of network
resources and data.

 Aspects:

 Confidentiality: Preventing unauthorized disclosure of


information.

 Integrity: Ensuring data has not been altered during


transmission or storage.

 Availability: Ensuring legitimate users can access the


network and its resources when needed.

 Measures: Firewalls, encryption, authentication (passwords,


biometrics), access control lists, intrusion detection
systems.

4. Scalability:

 Definition: The ability of a network to expand and


accommodate more users, devices, and applications
without significant degradation in performance.

 Considerations: Can the network easily add more nodes,


extend its geographical reach, or support new services?

 Example: A network designed for 100 users should be able


to scale up to 1000 users by adding more hardware and
reconfiguring existing resources, rather than requiring a
complete overhaul.

5. Manageability/Maintainability:

 Definition: How easy it is to configure, monitor,


troubleshoot, and upgrade the network.
Hamza Zahoor What's App 0341-8377-917

 Considerations: Availability of network management tools,


ease of troubleshooting, documentation, and the
complexity of configuration.

 Example: A well-designed network is easy for


administrators to diagnose problems, perform updates, and
implement changes without causing significant downtime.

3. Types of Connection (Point-to-Point, Multipoint)

 Definition: The way devices are connected to each other in a network


defines the type of connection, impacting how data is transmitted and
shared.

 Types:

1. Point-to-Point Connection:

 Definition: A dedicated link or channel is established


between two specific devices (nodes). The entire capacity
of the link is reserved for transmission between these two
devices.

 Characteristics:

 Exclusive use of the medium.

 No sharing of the link with other devices.

 Typically more expensive for wide-area connections


due to dedicated lines.

 Simpler control and less contention for the medium.

 Analogy: A direct phone call between two people.

 Example:

 A computer directly connected to a printer via a USB


cable.

 A traditional leased line connecting two branch


offices of a company.

 Fiber optic links connecting two major data centers.

2. Multipoint (Multidrop) Connection:


Hamza Zahoor What's App 0341-8377-917

 Definition: More than two specific devices share a single


link or channel. The capacity of the link is shared, either
spatially (different devices use different segments of the
cable) or temporally (devices take turns using the whole
capacity).

 Characteristics:

 Shared medium, leading to potential contention.

 Requires some form of access control mechanism


(e.g., token passing, polling) to manage simultaneous
transmissions.

 Cost-effective for connecting multiple devices in a


local area.

 Analogy: A conference call where multiple people are on


the same line, but only one can speak at a time.

 Example:

 An old bus topology network where multiple


computers are connected to a single coaxial cable.

 A wireless access point (WAP) connecting multiple


Wi-Fi devices.

 Shared Ethernet segments (though less common with


modern switches).

4. Physical Topologies (Mesh, Star, Bus, Ring, Hybrid)

 Definition: Network topology refers to the physical or logical


arrangement of connections (nodes and links) in a network. Physical
topology refers to the actual layout of cables and devices, while logical
topology refers to how data flows through the network. This section
focuses on physical topologies.

 Types of Physical Topologies:

1. Mesh Topology:

 Definition: Every device has a dedicated point-to-point link


to every other device in the network.

 Advantages:
Hamza Zahoor What's App 0341-8377-917

 High Reliability/Fault Tolerance: If one link fails,


communication can still occur via alternative paths.

 Security/Privacy: Dedicated links mean no shared


channel for eavesdropping.

 Robustness: Failure of one link does not disable the


entire network.

 Easy Fault Identification: Problems can be easily


isolated.

 Disadvantages:

 Expensive: Requires a large number of cables and I/O


ports. For n devices, it requires n(n-1)/2 links.

 Complex Installation: Wiring is complex and time-


consuming.

 Scalability Issues: Adding new devices requires many


new connections.

 Example: Often used in backbone networks or critical


systems (e.g., telephone exchange networks) where
reliability is paramount. Not practical for most LANs.

2. Star Topology:

 Definition: All devices are connected to a central controller,


typically a hub or a switch. Each device has a dedicated
point-to-point link to the central device.

 Advantages:

 Easy Installation and Configuration: Simple to set up.

 Less Cabling (compared to mesh): Each device only


needs one link.

 Easy Fault Isolation: If a link fails, only that device is


affected; the rest of the network remains operational.

 Scalability: Easy to add new devices by connecting


them to the central hub/switch.

 Disadvantages:
Hamza Zahoor What's App 0341-8377-917

 Single Point of Failure: If the central hub/switch fails,


the entire network goes down.

 Dependent on Central Device: Performance is heavily


reliant on the central device's capacity.

 Cost of Central Device: The central hub/switch can be


a significant cost.

 Example: Most modern wired LANs in homes and offices


use a star topology with a central Ethernet switch.

3. Bus Topology:

 Definition: All devices are connected to a single common


backbone cable (a "bus"). Data is transmitted along this
backbone, and all devices receive it, but only the intended
recipient processes it. Terminators are used at both ends of
the bus to prevent signal reflection.

 Advantages:

 Easy Installation: Simple to set up for small networks.

 Less Cabling: Requires less cable than mesh or star


for a small number of devices.

 Cost-Effective: Inexpensive for small networks.

 Disadvantages:

 Single Point of Failure: If the backbone cable breaks,


the entire network segment goes down.

 Difficult Fault Isolation: Troubleshooting can be


challenging as a problem anywhere on the bus can
affect the whole network.

 Limited Scalability: Performance degrades


significantly with more devices due to collisions.

 Reconfiguration Difficult: Adding new devices may


require temporarily shutting down the network.

 Example: Older Ethernet networks (10Base2, 10Base5)


used bus topology. Rarely used in new installations due to
its limitations.
Hamza Zahoor What's App 0341-8377-917

4. Ring Topology:

 Definition: Each device is connected to exactly two other


devices, forming a single continuous loop or ring. Data
travels in one direction around the ring, passing through
each device until it reaches its destination. 1

 Advantages:

 No Central Hub Needed: Distributes control among


devices.

 Orderly Communication: Data access is controlled,


avoiding collisions.

 Good for Fiber Optics: Suitable for fiber optic cabling,


often used in WANs.

 Disadvantages:

 Single Point of Failure: A single cable break or device


failure can disrupt the entire network.

 Difficult Troubleshooting: Isolating a fault can be


challenging.

 Adding/Removing Devices: Requires breaking the


ring, which can temporarily disrupt the entire
network.

 Cost: More expensive than bus due to point-to-point


links.

 Example: Token Ring networks (historically significant, but


largely obsolete). Still found in some specialized high-
speed networks or SONET rings in telecommunications.

5. Hybrid Topology:

 Definition: A combination of two or more basic topologies.


This approach leverages the advantages of different
topologies while mitigating their disadvantages.

 Characteristics: Often chosen for large, complex networks


to meet specific requirements.

 Advantages:
Hamza Zahoor What's App 0341-8377-917

 Flexibility: Can be designed to optimize performance


and reliability for specific needs.

 Scalability: Easier to expand than single topologies.

 Reliability: Can incorporate redundancy from different


topologies.

 Disadvantages:

 Complex Design and Implementation: More


challenging to set up and manage.

 Expensive: Involves integrating different types of


hardware and cabling.

 Examples:

 Star-Bus Hybrid: Several star networks (e.g.,


individual departments in an office) are connected
together via a bus backbone. This is very common in
large office buildings.

 Star-Ring Hybrid: Star networks connected to a ring


backbone.

5. Categories of Networks (LAN, MAN, WAN)

 Definition: Networks are often categorized based on their geographical


span, which influences their design, technology, and applications.

 Categories:

1. LAN (Local Area Network):

 Definition: Connects devices in a limited geographical area,


such as a home, office building, or a campus. They are
typically owned by a single organization or individual.

 Characteristics:

 Geographical Scope: Small (a few meters to a few


kilometers).

 Data Rate: High (typically 10 Mbps to 10 Gbps, or


even higher for enterprise LANs).
Hamza Zahoor What's App 0341-8377-917

 Transmission Media: Twisted-pair cable, coaxial cable,


fiber optic cable, Wi-Fi.

 Error Rate: Low.

 Ownership: Private.

 Example:

 A home Wi-Fi network connecting laptops,


smartphones, and a smart TV.

 An office network connecting all computers and


printers within a single building.

 A university campus network connecting various


departments.

 Technologies: Ethernet, Wi-Fi (IEEE 802.11).

2. MAN (Metropolitan Area Network):

 Definition: Spans a city or a large campus, typically


connecting multiple LANs together within that metropolitan
area. It is larger than a LAN but smaller than a WAN.

 Characteristics:

 Geographical Scope: City-wide (tens of kilometers).

 Data Rate: Moderate to high (usually higher than


WANs, but lower than LANs).

 Transmission Media: Fiber optic cable, sometimes


high-speed copper.

 Ownership: Can be private or public (e.g., by a


telecom provider).

 Example:

 A cable TV network providing internet and TV


services across a city.

 A city-wide network connecting different government


buildings or university campuses.

 Fibre-optic backbone connecting multiple offices of a


large corporation within a city.
Hamza Zahoor What's App 0341-8377-917

 Technologies: Often uses technologies like FDDI (Fiber


Distributed Data Interface), ATM (Asynchronous Transfer
Mode), or modern Ethernet derivatives (e.g., Metro
Ethernet).

3. WAN (Wide Area Network):

 Definition: Connects devices across a large geographical


area, such as states, countries, or even continents. WANs
typically involve combining multiple LANs and MANs. The
Internet is the prime example of a global WAN.

 Characteristics:

 Geographical Scope: Large (hundreds to thousands


of kilometers).

 Data Rate: Generally lower than LANs, but improving


rapidly (from Kbps to Gbps).

 Transmission Media: Fiber optic cable (often undersea


cables), satellite links, microwave links, telephone
lines.

 Error Rate: Higher than LANs, due to longer distances


and multiple intermediate devices.

 Ownership: Typically owned and operated by


telecommunication companies (ISPs) or large
organizations.

 Example:

 The Internet.

 A multinational corporation connecting its offices in


different countries.

 A public telephone network spanning an entire


country.

 Technologies: MPLS (Multiprotocol Label Switching), Frame


Relay, X.25, PPP, cellular technologies (3G, 4G, 5G).

6. Protocols and Standards


Hamza Zahoor What's App 0341-8377-917

 Definition: For devices to communicate effectively in a network, they


must "speak the same language." This is where protocols and
standards come in.

o Protocol: A set of rules that governs data communication. It


defines what is communicated, how it is communicated, and
when it is communicated.2 Protocols are essential for the
interoperability of heterogeneous devices.

o Standard: A formally accepted set of rules or specifications


developed by an authorized body. Standards ensure that
products from different manufacturers can work together.

 Key Concepts (Protocols):

o Syntax: The format of data (e.g., bit order, field format).

o Semantics: The meaning of each section of bits (e.g., what a


specific value in a field signifies).

o Timing: When data should be sent, how fast it can be sent, and
the sequence of events.

 Examples (Protocols):

o HTTP (Hypertext Transfer Protocol): Governs how web browsers


and web servers communicate.

o FTP (File Transfer Protocol): Rules for transferring files between


computers.

o TCP (Transmission Control Protocol): Provides reliable, ordered,


and error-checked delivery of data.

o IP (Internet Protocol): Handles addressing and routing of data


packets across networks.

o SMTP (Simple Mail Transfer Protocol): Used for sending emails.

 Key Concepts (Standards):

o De Facto Standards: Standards that have been adopted through


widespread use, even without formal endorsement by a
standards body (e.g., HTTP initially).

o De Jure Standards: Standards that have been legalized or


mandated by an official body (e.g., IEEE 802.3 for Ethernet).
Hamza Zahoor What's App 0341-8377-917

 Standards Organizations (Examples):

o ISO (International Organization for Standardization): Develops


international standards for various industries, including the OSI
model.

o IEEE (Institute of Electrical and Electronics Engineers): Develops


standards, especially for local area networks (e.g., 802.3 for
Ethernet, 802.11 for Wi-Fi).

o ITU-T (International Telecommunication Union -


Telecommunication Standardization Sector): Focuses on
telecommunications standards.

o ANSI (American National Standards Institute): Coordinates and


accredits U.S. standards.

o EIA (Electronic Industries Alliance): Develops standards for


electronics, including physical layer interfaces (e.g., RS-232).

o IETF (Internet Engineering Task Force): Develops and promotes


Internet standards, particularly the TCP/IP protocol suite (RFCs -
Request for Comments).

Computer Networks - BS 3rd Semester Notes (Continued)

Week 3: Layered Architecture and Network Models

1. Layered Architecture

 Definition: A layered architecture in networking divides the complex


task of communication into smaller, more manageable sub-tasks or
layers. Each layer performs a specific set of functions and interacts
with the layers directly above and below it. This modular approach
simplifies design, implementation, and troubleshooting of network
protocols.

 Why Layered Architecture?

o Modularity: Breaking down a complex system into independent


layers makes design and development easier. Each layer can be
developed and optimized independently.
Hamza Zahoor What's App 0341-8377-917

o Interoperability: Different vendors can develop hardware and


software for specific layers, ensuring compatibility as long as
they adhere to the interface specifications.

o Flexibility: Changes in one layer don't necessarily affect other


layers, allowing for easier upgrades and modifications (e.g.,
changing the physical transmission medium doesn't require
redesigning the application layer).

o Troubleshooting: Problems can be isolated to a specific layer,


simplifying fault detection and resolution.

o Standardization: Promotes the development of standardized


protocols for each layer.

 How it Works:

o Services: Each layer provides services to the layer above it and


requests services from the layer below it.

o Peers: When a message is sent from source to destination, each


layer at the source performs functions related to its role, then
passes the data down. At the destination, the process is
reversed; each layer receives data from the layer below,
performs its functions, and passes it up. Communication logically
happens between "peer" layers on the source and destination.

o Encapsulation: As data moves down the layers at the sender,


each layer adds its own header (and sometimes a trailer) to the
data received from the layer above. This process is called
encapsulation. The header contains control information relevant
to that specific layer's protocol.

o Decapsulation: At the receiver, as data moves up the layers,


each layer removes and processes its corresponding header (and
trailer) before passing the remaining data to the layer above.

2. Network Models

 Definition: Network models are conceptual frameworks that describe


the functions of a network. They standardize the way communication
tasks are broken down into layers, enabling different systems to
communicate effectively. The two most prominent network models are
the OSI (Open Systems Interconnection) model and the TCP/IP
(Transmission Control Protocol/Internet Protocol) model.
Hamza Zahoor What's App 0341-8377-917

3. The OSI Model

 Definition: The Open Systems Interconnection (OSI) model is a


conceptual framework created by the International Organization for
Standardization (ISO) in 1984. It describes how network protocols
should interact to enable communication between different systems.
It's a seven-layer model, primarily used as a teaching tool and a
reference for understanding network functionality, though the TCP/IP
model is more widely implemented.

 Purpose: To define a set of standards that allows different computer


systems to communicate, regardless of their underlying hardware and
software platforms.

 Key Principles:

o Each layer should perform a well-defined function.

o Each layer should select functions that facilitate international


standardization.

o The layer boundaries should be chosen to minimize information


flow across interfaces.

o The number of layers should be large enough not to group


distinct functions, but small enough to avoid unnecessary
complexity.

4. Layers in the OSI Model (Brief Introduction)

 The OSI model consists of seven distinct layers, stacked one on top of
the other, each responsible for a specific part of the communication
process.

1. Physical Layer (Layer 1):

 Function: Deals with the physical transmission of raw bit


streams over a physical medium. It defines hardware
specifications, cabling, voltages, data rates, and physical
connectors.

 PDU (Protocol Data Unit): Bits

 Examples: Cables (Ethernet, fiber optic), connectors (RJ-


45), network interface cards (NICs), hubs, repeaters.

2. Data Link Layer (Layer 2):


Hamza Zahoor What's App 0341-8377-917

 Function: Provides reliable node-to-node data transfer. It


handles physical addressing (MAC addresses), error
detection and correction, and flow control to manage data
rate. It's often divided into two sub-layers: Logical Link
Control (LLC) and Media Access Control (MAC).

 PDU: Frames

 Examples: Ethernet, PPP (Point-to-Point Protocol),


switches, bridges.

3. Network Layer (Layer 3):

 Function: Responsible for logical addressing (IP


addresses) and routing of packets across different
networks (inter-networking). It determines the best path for
data to travel from source to destination.

 PDU: Packets

 Examples: IP (Internet Protocol), routers, ICMP (Internet


Control Message Protocol).

4. Transport Layer (Layer 4):

 Function: Provides end-to-end communication between


processes on different hosts. It ensures reliable and orderly
delivery of data segments, including segmentation,
reassembly, error recovery, and flow control. It can be
connection-oriented (TCP) or connectionless (UDP).

 PDU: Segments (for TCP) or Datagrams (for UDP)

 Examples: TCP (Transmission Control Protocol), UDP (User


Datagram Protocol).

5. Session Layer (Layer 5):

 Function: Establishes, manages, and terminates sessions


between applications. It provides dialogue control (who
sends when) and synchronization (checkpoints for long
transfers).

 PDU: Data
Hamza Zahoor What's App 0341-8377-917

 Examples: NetBIOS, RPC (Remote Procedure Call). While


theoretically important, its functions are often integrated
into application or transport layers in practice.

6. Presentation Layer (Layer 6):

 Function: Translates data into a format that the


Application layer can understand. It handles data
encryption/decryption, compression/decompression, and
data formatting (e.g., ASCII to EBCDIC conversion).

 PDU: Data

 Examples: JPEG, MPEG, ASCII, EBCDIC, SSL/TLS (though


SSL/TLS often operates across multiple layers, including
transport and presentation).

7. Application Layer (Layer 7):

 Function: Provides network services directly to end-user


applications. It allows users to interact with the network.

 PDU: Data

 Examples: HTTP (web Browse), FTP (file transfer), SMTP


(email), DNS (domain name resolution), Telnet.

5. TCP/IP Protocol Suite

 Definition: The TCP/IP protocol suite is the foundational set of


protocols that govern the Internet. It was developed by the U.S.
Department of Defense (DoD) for ARPANET (the precursor to the
Internet). Unlike the conceptual OSI model, TCP/IP is a pragmatic,
implemented standard. It's often described as a four-layer or five-layer
model.

 Key Characteristics:

o Practical & Widely Used: It's the de facto standard for


internetworking.

o Robustness & Flexibility: Designed to be resilient to network


failures and to work across diverse hardware.

o Connectionless Network Layer: IP is connectionless, making it


highly adaptable.
Hamza Zahoor What's App 0341-8377-917

o End-to-End Reliability: Achieved by the transport layer (TCP),


not by lower layers.

 TCP/IP Layers (Five-Layer Version):

1. Physical Layer (Layer 1):

 OSI Equivalent: Physical Layer.

 Function: Same as OSI Physical layer. Deals with the


actual transmission of bits.

 Examples: Ethernet, Wi-Fi.

2. Data Link Layer (Layer 2):

 OSI Equivalent: Data Link Layer.

 Function: Same as OSI Data Link layer. Handles framing,


physical addressing (MAC), and error control within a local
network.

 Examples: Ethernet, PPP.

3. Network Layer (Layer 3) / Internet Layer:

 OSI Equivalent: Network Layer.

 Function: Responsible for logical addressing (IP


addresses) and routing of datagrams across different
networks. It's the core of internetworking.

 PDU: Datagrams (or packets).

 Protocols: IP (IPv4, IPv6), ICMP, ARP (Address Resolution


Protocol), RARP (Reverse ARP).

4. Transport Layer (Layer 4) / Host-to-Host Layer:

 OSI Equivalent: Transport Layer.

 Function: Provides communication between applications


on different hosts. It handles segmentation/reassembly,
multiplexing/demultiplexing, and (for TCP) reliable, ordered
delivery and flow control.

 PDU: Segments (TCP) or User Datagrams (UDP).

 Protocols:
Hamza Zahoor What's App 0341-8377-917

 TCP (Transmission Control Protocol):


Connection-oriented, reliable, flow control,
congestion control.

 UDP (User Datagram Protocol): Connectionless,


unreliable, minimal overhead, faster.

5. Application Layer (Layer 5) / Process Layer:

 OSI Equivalent: Session, Presentation, and Application


Layers combined.

 Function: Provides high-level services directly to user


applications. It encapsulates the functions of the upper
three OSI layers.

 PDU: Data.

 Protocols: HTTP, FTP, SMTP, DNS, SSH, Telnet, SNMP.

 Comparison: OSI vs. TCP/IP

Feature OSI Model TCP/IP Model

Layers 7 Layers 4 or 5 Layers (depending on


interpretation)

Origin Theoretical/Conceptual Practical/Implemented

Approach Top-down design, then Protocols developed, then


protocols model described

Reliability Can be provided at multiple Primarily at Transport Layer


layers (TCP)

Strictness More rigid in defining layer More flexible and adaptable


services

Network Connection-oriented and Primarily connectionless (IP)


Layer connectionless

Application Separate Combines


Layer Presentation/Session layers Presentation/Session into
Application

Usage Reference model, teaching Dominant model for the


tool Internet
Hamza Zahoor What's App 0341-8377-917

Export to Sheets

6. Circuit Switching

 Definition: Circuit switching is a type of network switching in which a


dedicated communication path (circuit) is established between two
communicating nodes for the entire duration of their communication.
Once the circuit is established, all data flows along this dedicated path
until the connection is terminated.

 Phases of Circuit Switching:

1. Circuit Establishment: Before communication can begin, a


dedicated circuit must be established. This involves sending
setup signals through the network to reserve resources
(bandwidth, switches) along a path from source to destination.
This process takes time.

2. Data Transfer: Once the circuit is established, data can flow


between the two devices. The circuit provides a dedicated, fixed
bandwidth, guaranteeing consistent quality of service (QoS).
Data transmission is uninterrupted, and there's no waiting or
contention for the medium.

3. Circuit Disconnection: After data transfer is complete, the


circuit is terminated, and the reserved resources are released
back into the network for use by other connections.

 Characteristics:

o Dedicated Path: A continuous physical or logical path is


established.

o Guaranteed Bandwidth: Resources are reserved, ensuring a


fixed bandwidth.

o Fixed Delay: Once the circuit is established, propagation delay


is consistent.

o No Congestion during Transfer: Since resources are reserved,


no queuing or contention occurs during data transfer.

o Inefficient Resource Utilization: Bandwidth is reserved even if


no data is being sent (e.g., during silences in a phone call). This
can lead to wasted bandwidth.
Hamza Zahoor What's App 0341-8377-917

o Connection Setup Delay: A setup time is required before


actual data transfer can begin.

 Examples:

o Traditional Public Switched Telephone Network (PSTN):


When you make a traditional phone call, a circuit is established
between your phone and the recipient's phone for the duration of
the call.

o ISDN (Integrated Services Digital Network): A set of


communication standards for simultaneous digital transmission
of voice, video, data, and other network services over the
traditional circuits of the public switched telephone network.

 When to Use: Ideal for applications that require constant data flow
and minimal delay variations, such as real-time voice and video
communication, where consistent quality is more important than
efficient bandwidth utilization.

Computer Networks - BS 3rd Semester Notes (Continued)

Week 4: Applications, Multiplexing, and Switching

1. Applications

 Definition: In the context of computer networks, "applications" refer


to software programs that utilize network services to perform specific
tasks or enable user interaction over a network. These applications
operate at the Application Layer (Layer 7 in OSI, or the combined
Application Layer in TCP/IP) and rely on the underlying network
infrastructure and protocols to function.

 Key Role: Applications are the primary interface through which end-
users interact with the network. They provide the actual utility and
value of a network.

 Examples:

o Email (SMTP, POP3, IMAP): Allows users to send and receive


electronic messages globally.

o Web Browse (HTTP/HTTPS): Enables access to information


and resources on the World Wide Web.
Hamza Zahoor What's App 0341-8377-917

o File Transfer (FTP, SFTP, SCP): Facilitates the transfer of files


between computers.

o Remote Login (Telnet, SSH): Allows a user to log into a


remote computer and execute commands.

o Voice over IP (VoIP): Enables real-time voice communication


over the Internet (e.g., Skype, Zoom calls).

o Video Conferencing: Real-time video and audio communication


between multiple participants.

o Online Gaming: Multiplayer games that connect players across


the Internet.

o Streaming Media (e.g., Netflix, YouTube): Delivering audio


and video content over the network for real-time playback.

o Domain Name System (DNS): Translates human-readable


domain names (e.g., https://www.google.com/search?
q=google.com) into IP addresses.

o Network Management (SNMP): Tools for monitoring and


managing network devices.

 Relationship with Protocols: Each network application typically


relies on specific application-layer protocols (and underlying
transport/network layer protocols) to perform its functions. For
instance, a web browser uses HTTP to communicate with a web server,
which in turn relies on TCP/IP for reliable data transfer.

2. Statistical Multiplexing

 Definition: Statistical Multiplexing (also known as Asynchronous


Time-Division Multiplexing - ATDM) is a multiplexing technique where
the shared bandwidth is allocated dynamically based on the demand of
each input stream. Unlike traditional TDM, which assigns fixed time
slots, statistical multiplexing only assigns time slots to channels that
actually have data to send.

 Mechanism:

o A multiplexer at the sender's end collects data from multiple


input lines.
Hamza Zahoor What's App 0341-8377-917

o It identifies which input lines have data to send.

o It then creates frames (or packets) that contain data from only
the active lines, along with control information to identify the
source of each data block.

o The frames are transmitted over the shared high-speed link.

o At the receiver's end, a demultiplexer reads the control


information in the frames and directs the data to the appropriate
output lines.

 Key Characteristics:

o Dynamic Bandwidth Allocation: Bandwidth is assigned on


demand, leading to more efficient utilization.

o No Fixed Time Slots: Time slots are not pre-assigned; they are
given to active users.

o Overbooking Possible: The sum of peak input rates can


exceed the capacity of the shared link because it's assumed not
all sources will transmit at their peak simultaneously. This is
where the "statistical" aspect comes from, relying on statistical
averages of traffic.

o Buffering: If the sum of instantaneous input rates temporarily


exceeds the link capacity, data is buffered. This can introduce
variable delays.

o Statistical Gain: Achieves higher efficiency than TDM,


especially for bursty data traffic (e.g., computer data where
transmission is intermittent).

 Advantages:

o Higher Efficiency: Better utilization of bandwidth for bursty


data.

o Cost-Effective: Can support more users over a given link


capacity.

 Disadvantages:

o Variable Delay: Data can experience queuing delays if there's


contention for the link.
Hamza Zahoor What's App 0341-8377-917

o Complexity: More complex to implement than TDM or FDM due


to buffering and addressing requirements.

o Overhead: Requires additional overhead in frames to identify


the source of data.

 Example:

o Packet-switched networks (like the Internet): Data is


broken into packets, and multiple packets from different sources
share a common communication link. A router (a form of
statistical multiplexer) forwards packets based on their
destination, using the link's bandwidth dynamically.

o Broadband Internet access: Your ISP statistically multiplexes


your data with that of many other users over a shared
infrastructure.

o Voice and Data Integration: Used in technologies that carry


voice and data traffic together, like VoIP.

3. Packet Switching

 Definition: Packet switching is a network communication method in


which data is divided into small, independent units called packets
before transmission. Each packet contains a portion of the data along
with control information, including source and destination addresses.
These packets are then transmitted independently across the network,
potentially taking different routes, and are reassembled at the
destination.

 Mechanism:

1. Segmentation: The sender breaks down the message into


fixed-size or variable-size packets.

2. Addressing: Each packet is given a header containing the


source address, destination address, sequence number (for
reassembly), and other control information.

3. Routing: Packets are sent into the network and routed


independently by network devices (routers) based on their
destination address and the current network conditions. Routers
Hamza Zahoor What's App 0341-8377-917

temporarily store packets in buffers and forward them to the next


hop.

4. Reassembly: At the destination, the packets arrive (possibly out


of order) and are reassembled into the original message using
their sequence numbers. Missing or erroneous packets can be
retransmitted.

 Key Characteristics:

o No Dedicated Path: No fixed path is established; packets


choose paths dynamically.

o Shared Bandwidth: Network resources are shared among all


users.

o Store-and-Forward: Routers temporarily store packets before


forwarding them, leading to variable delays.

o Efficiency: Highly efficient for bursty data traffic.

o Robustness: If one path or router fails, packets can be rerouted


via alternative paths.

o Congestion Possible: Can experience congestion and packet


loss if network traffic exceeds capacity.

 Advantages:

o Efficient Bandwidth Utilization: Resources are not reserved;


they are used only when needed.

o Fault Tolerance/Robustness: Rerouting capability makes the


network resilient to failures.

o Cost-Effective: More economical than circuit switching for many


applications.

o Flexibility: Supports various data rates and types of services.

 Disadvantages:

o Variable Delay: Packets can experience queuing delays, leading


to jitter.

o Overhead: Each packet carries a header, adding overhead.

o Complexity: Routers and protocols are more complex.


Hamza Zahoor What's App 0341-8377-917

o Out-of-Order Delivery: Packets may arrive out of sequence,


requiring reordering at the destination.

 Types of Packet Switching:

o Datagram Packet Switching (Connectionless): Each packet


is treated independently, like a postcard. The network layer does
not maintain any connection state. This is how the Internet (IP)
works.

o Virtual Circuit Packet Switching (Connection-oriented): A


logical path (virtual circuit) is established before data transfer. All
packets for a given communication follow this pre-established
path, though the underlying physical links are still shared. This is
more like a phone call over a packet network. Examples include
Frame Relay and X.25.

 Example: The Internet, which is built on the IP protocol. When you


send an email, stream a video, or browse a website, your data is
broken into IP packets and sent across the Internet.

4. Message Switching

 Definition: Message switching is a network communication method


where the entire message is treated as a single unit and sent from
source to destination. Each intermediate node (switch) in the network
receives the entire message, stores it (if necessary), inspects its
header, and then forwards it to the next hop. This is often referred to
as "store-and-forward" at the message level.

 Mechanism:

1. Store-and-Forward: An entire message is sent to an


intermediate node, stored in its entirety, and then forwarded
when the next link is available.

2. No Packetization: The message is not broken into smaller


packets.

3. Variable Length Messages: Messages can be of arbitrary


length.

 Key Characteristics:
Hamza Zahoor What's App 0341-8377-917

o No Dedicated Path: Similar to packet switching, no dedicated


path is established.

o Full Message Storage: Each intermediate node must have


enough storage to hold the entire message.

o Variable Delay: Delays can be significant, especially for long


messages, due to the store-and-forward nature.

o No Simultaneous Transmission: Only one message can


occupy a link at a time.

 Advantages:

o Efficient Bandwidth for Bursty Traffic: Resources are used


only when needed.

o Reduced Congestion (potentially): If a link is busy, the


message is stored, preventing the link from being overloaded.

o Traffic Prioritization: Can implement message prioritization.

 Disadvantages:

o Long Delays: Storing entire messages at each hop can lead to


very long end-to-end delays.

o Requires Large Storage: Intermediate nodes need substantial


buffer space, especially for large messages.

o Not Suitable for Real-time Applications: The variable and


potentially long delays make it unsuitable for voice or video.

o Inefficient for Small Messages: Overhead for routing an entire


small message is disproportionately high.

 Example: Historically, telegraph networks used message switching.


More modern examples are email systems (SMTP servers store and
forward entire emails) or voice mail systems (voice messages are
stored on a server and then forwarded). It's rarely used for general
data communication due to the advent of packet switching.

5. Message Switching versus Packet Switching

Feature Message Switching Packet Switching


Hamza Zahoor What's App 0341-8377-917

Data Unit Entire message Fixed or variable-sized


packets

Storage at Entire message must be Only current packet needs


Node stored before forwarding to be stored (buffer)

Delay Potentially very long and Variable, but generally


variable (store-and-forward of much lower and more
full message) predictable

Real-time Poor (not suitable for real- Good (suitable for real-time
Support time) due to smaller units)

Overhead Header per message Header per packet (more


overall overhead for small
segments)

Resource Can be inefficient for large Highly efficient for bursty


Usage messages traffic

Robustnes Less robust if a node fails More robust (packets can


s (entire message lost) be rerouted)

Primary Legacy systems, specific Modern data networks, the


Use applications like email, Internet, VoIP
voicemail

Export to Sheets

6. Packet Switching versus Circuit Switching

Feature Packet Switching Circuit Switching

Path No dedicated path (connectionless) Dedicated, physical


Establishmen or virtual circuit established path established for
t (connection-oriented) duration

Bandwidth Dynamic; shared among all users Fixed; dedicated to


Allocation the connection

Resource No reservation; resources used on Resources


Reservation demand (bandwidth,
switches) are
reserved
Hamza Zahoor What's App 0341-8377-917

Efficiency Highly efficient for bursty traffic Inefficient for bursty


traffic (idle time
wastes bandwidth)

Delay Variable delay (queuing, Fixed, predictable


processing) delay after setup

Real-time Good, but requires QoS Excellent


Support mechanisms to handle jitter (guaranteed
bandwidth and fixed
delay)

Robustness Very robust; rerouting possible on Less robust; circuit


failure failure breaks
connection

Setup Time Minimal per-packet processing; no Significant setup


connection setup time (datagram) time required to
or small setup for virtual circuit establish circuit

Cost Generally more cost-effective More expensive due


to dedicated
resources

Primary Use Internet, data networks, VoIP, video Traditional telephone


streaming networks, dedicated
leased lines

Export to Sheets

7. How do Loss and Delay occur?

 Definition: In packet-switched networks, the reality of shared


resources and finite capacities leads to two primary performance
impairments: packet loss and delay. Understanding their causes is
crucial for network design and troubleshooting.

 Causes of Packet Loss:

1. Buffer Overflow (Congestion): This is the most common


reason. When packets arrive at a router or switch faster than it
can process or forward them, and its internal buffer (queue)
becomes full, newly arriving packets are dropped. This happens
Hamza Zahoor What's App 0341-8377-917

during periods of high network traffic or insufficient buffer


capacity.

2. Corrupted Packets: If a packet gets corrupted during


transmission (e.g., due to noise on the link), its checksum might
not match. The receiving device (e.g., a router or the end host)
will detect the error and discard the packet.

3. Link Failure: A physical cable break or a malfunctioning


network interface can cause packets to be dropped because they
cannot reach the next hop.

4. Hardware/Software Failure: Malfunctioning routers, switches,


or software bugs can lead to incorrect packet handling and drops.

5. TTL Expiration: Every IP packet has a Time-to-Live (TTL) field.


Each router decrements the TTL. If TTL reaches zero before the
packet reaches its destination, the router discards the packet to
prevent it from looping indefinitely in the network.

6. Security Measures: Firewalls or intrusion detection systems


might intentionally drop packets deemed malicious or violating
security policies.

 Causes of Delay (Latency):

1. Processing Delay (Nodal Processing Delay):

 Definition: The time it takes for a router or switch to


process an incoming packet. This includes checking for bit
errors, determining the output link, and performing header
parsing.

 Factors: Router's processing power, software efficiency.

 Typical Value: Usually on the order of microseconds.

2. Queuing Delay:

 Definition: The time a packet spends waiting in a router's


output queue (buffer) before it can be transmitted onto the
outgoing link. This is the most variable and significant
component of delay in congested networks.

 Factors: Level of network congestion, traffic intensity,


buffer size, queuing discipline (e.g., FIFO, priority queuing).
Hamza Zahoor What's App 0341-8377-917

 Example: Imagine a busy toll booth. Cars (packets) wait in


a line (queue) until the toll collector (router) is free.

3. Transmission Delay (Transmission Time):

 Definition: The time required to push all of the packet's


bits onto the transmission medium. It depends on the
packet's size and the link's bandwidth (data rate).

 Formula: Transmission Delay = Packet Size (bits) /


Bandwidth (bits/second)

 Example: A 1000-byte packet on a 1 Mbps link: (1000 * 8


bits) / (1 * 10^6 bits/sec) = 0.008 seconds = 8
milliseconds.

4. Propagation Delay:

 Definition: The time it takes for a bit to travel from the


beginning of the link to the end of the link. It depends on
the distance between the two devices and the propagation
speed of the signal in the medium.

 Formula: Propagation Delay = Distance / Propagation


Speed (speed of light in the medium, typically 2/3 speed of
light in vacuum for copper/fiber).

 Factors: Physical distance, type of transmission medium.

 Example: Signal travelling across a continent or via


satellite. Even at light speed, a signal takes time to cross
vast distances.

8. Delay in Packet-Switched Networks

 Definition: The total end-to-end delay in a packet-switched network is


the sum of the processing, queuing, transmission, and propagation
delays experienced by a packet as it travels from source to destination,
across all the links and through all the intermediate routers.

 Total Delay Formula (for a path with N routers): Total Delay = (N


+ 1) * Propagation Delay (per link) + N * Processing Delay (per router)
+ N * Transmission Delay (per link) + Sum of Queuing Delays (at each
router)
Hamza Zahoor What's App 0341-8377-917

o Note: The number of links is usually (N+1) if N is the number of


routers (assuming source and destination are also nodes).
Transmission delay often applies to each link segment.

 Variability of Delay:

o Queuing delay is the most variable component. In uncongested


networks, it might be negligible. In congested networks, it can
become very large, leading to significant fluctuations in end-to-
end delay (jitter).

o Processing, transmission, and propagation delays are


generally fixed (or less variable) for a given path and packet size.

 Implications of Delay and Jitter:

o Real-time applications (VoIP, video conferencing, online


gaming): Highly sensitive to both absolute delay and jitter. High
delay causes noticeable lag, while high jitter causes choppy
audio/video and game stuttering.

o Non-real-time applications (file transfer, email): More


tolerant to delay and jitter, as long as data eventually arrives
reliably.

 Mitigation Strategies:

o Increased Bandwidth: Reduces transmission delay and


queuing delay.

o Quality of Service (QoS): Prioritizes certain types of traffic


(e.g., VoIP packets) over others to reduce their queuing delay.

o Traffic Shaping/Policing: Controls the rate at which traffic is


sent to prevent congestion.

o Larger Buffers (with limits): Can absorb bursts of traffic but


increase potential maximum queuing delay.

o Faster Processors in Routers: Reduces processing delay.

Computer Networks - BS 3rd Semester Notes (Continued)

Week 5: Signals, Impairment, and Performance

1. Analog and Digital Signals


Hamza Zahoor What's App 0341-8377-917

 Definition: Signals are the means by which data is transmitted. Data


can be represented in either analog or digital form, and signals can be
analog or digital.

o Analog Data: Continuous, infinite range of values (e.g., human


voice, video).

o Digital Data: Discrete states or values (e.g., text, integers).

o Analog Signal: A continuous wave that changes smoothly over


time. It has infinite possible values in a range.

o Digital Signal: A discrete signal that has a finite number of


defined values, typically represented by a sequence of voltage
pulses. It changes in discrete steps.

 Relationship between Data and Signals:

o Analog data can be represented by an analog signal (e.g.,


microphone converts sound waves into an electrical analog
signal).

o Analog data can be represented by a digital signal (e.g., a


modem converts analog voice into a digital stream).

o Digital data can be represented by an analog signal (e.g., a


modem converts digital computer data into an analog signal for
transmission over a phone line).

o Digital data can be represented by a digital signal (e.g., a


computer transmits binary data as electrical pulses over an
Ethernet cable).

2. Periodic Analog Signals

 Definition: A periodic analog signal is one that completes a pattern


within a measurable time frame, called a period (T), and repeats that
pattern over subsequent identical periods.

 Characteristics of Periodic Analog Signals:

1. Period (T) and Frequency (f):

 Period: The time in seconds required for one full cycle.


Measured in seconds (s).
Hamza Zahoor What's App 0341-8377-917

 Frequency: The number of periods or cycles per second.


Measured in Hertz (Hz).

 Relationship: f=1/T or T=1/f.

 Example: If a signal completes 10 cycles in 1 second, its


frequency is 10 Hz, and its period is 0.1 seconds.

2. Amplitude: The maximum displacement or intensity of the


signal from its average value. It measures the signal's energy or
strength. Measured in volts, amps, or watts.

3. Phase: Describes the position of the waveform relative to time


zero. It's measured in degrees or radians. A phase shift indicates
how much the waveform is shifted horizontally.

o Sine Wave: The most fundamental form of a periodic analog


signal. It's characterized by its peak amplitude, frequency, and
phase. Any composite analog signal can be decomposed into a
series of simple sine waves (Fourier analysis).

o Composite Periodic Signal: An analog signal composed of


multiple sine waves. According to Fourier analysis, any
composite signal can be represented as a sum of simple sine
waves with different frequencies, amplitudes, and phases.

 Bandwidth of an Analog Signal: The difference between


the highest and lowest frequencies contained within the
signal's composite form.

3. Digital Signals

 Definition: A digital signal is a sequence of discrete voltage pulses.


Unlike analog signals, digital signals have a finite number of defined
states (typically two: high voltage for '1' and low voltage for '0').

 Characteristics of Digital Signals:

1. Bit Rate (Data Rate): The number of bits transmitted per


second. Measured in bits per second (bps). Higher bit rates mean
more data can be transmitted in a given time.

2. Bit Length: The distance a single bit occupies on the


transmission medium. Related to propagation speed and bit
duration.
Hamza Zahoor What's App 0341-8377-917

3. Levels: The number of distinct voltage levels used to represent


bits. A two-level signal can represent 1 bit per symbol (0 or 1). A
multi-level signal can represent more bits per symbol (e.g., 4
levels can represent 2 bits per symbol: 00, 01, 10, 11).

o Digital Signal as a Composite Analog Signal: Even a digital


signal can be seen as a composite analog signal with an infinite
number of simple sine waves. The more square the digital signal
(i.e., faster transitions), the more high-frequency components it
contains.

o Bandwidth of a Digital Signal: Theoretically infinite, but


practically, the effective bandwidth is determined by the highest
significant frequency component.

4. Transmission Impairment

 Definition: When a signal travels through a medium, it encounters


imperfections that can degrade its quality. This degradation is known
as transmission impairment. Impairment can lead to distortion of
the signal, causing errors in the received data.

 Types of Transmission Impairment:

1. Attenuation:

 Definition: The loss of energy (strength) of a signal as it


travels through the medium. The longer the distance, the
more energy is lost.

 Cause: Resistance of the medium, absorption by the


medium.

 Effect: The receiver might not be able to detect or


interpret the signal correctly if it becomes too weak.

 Mitigation: Amplifiers (for analog signals) or repeaters


(for digital signals) are used to boost the signal strength
periodically. Attenuation is often measured in decibels (dB).

2. Distortion:

 Definition: The signal changes its form or shape due to


different components of a composite signal having
different propagation speeds or delays through the
medium, or different amplification/attenuation rates.
Hamza Zahoor What's App 0341-8377-917

 Cause: Different frequencies in a composite signal travel


at different speeds (differential delay), or different
frequency components are attenuated differently.

 Effect: The signal's original shape is altered, making it


harder for the receiver to interpret.

 Mitigation: Equalizers are used to compensate for the


different delays or attenuation across frequencies.

3. Noise:

 Definition: Unwanted energy that is added to the signal,


interfering with its interpretation. Noise can be introduced
by external sources or internal to the electronic
components.

 Types of Noise:

 Thermal Noise (White Noise): Random motion of


electrons in a conductor, creating an unwanted
signal. Present in all electronic devices and
transmission media.

 Intermodulation Noise: Occurs when signals at


different frequencies share the same medium, and
their frequencies combine to create unwanted new
frequencies that interfere with the original signal.

 Crosstalk: The effect of one signal interfering with


another (e.g., hearing another conversation on your
phone line). Occurs when wires are too close
together.

 Impulse Noise: A sudden, short-lived burst of high-


energy noise (e.g., from lightning, power surges, or
switching equipment). Very destructive to digital data
as it can corrupt many bits.

 Effect: Corrupts the original signal, leading to bit errors.

 Mitigation: Shielding cables, using proper grounding,


error detection and correction codes, filters, and line
conditioners.

4. Jitter (Revisit):
Hamza Zahoor What's App 0341-8377-917

 Definition: Variations in the delay of packets arriving at


the destination, leading to uneven playback for real-time
streams like audio and video. While discussed as a delay
type in Week 4, it's also a significant impairment of timely
signal delivery.

 Cause: Variable queuing delays in routers, network


congestion, processing load variations.

 Effect: Choppy video, stuttering audio, degraded user


experience.

 Mitigation: Jitter buffers at the receiver, Quality of Service


(QoS) mechanisms.

5. Data Rate Limits

 Definition: The capacity of a communication channel, or the


maximum rate at which data can be reliably transmitted over a given
medium, is limited by factors like bandwidth and noise. Several
theorems and formulas quantify these limits.

 Key Concepts and Formulas:

1. Nyquist Bit Rate (for Noiseless Channels):

 Formula: C=2×B×log2L

 C: Channel capacity (max bit rate in bps)

 B: Bandwidth of the channel (in Hz)

 L: Number of signal levels used to represent data


(e.g., 2 levels for binary, 4 levels for 2 bits/symbol)

 Explanation: This theorem states that for a noiseless


channel, the maximum bit rate is directly proportional to
the bandwidth and the number of signal levels. Increasing
the number of levels allows more bits per symbol, thus
increasing the bit rate. However, increasing levels also
makes signals more susceptible to noise.

 Example: A noiseless channel with a bandwidth of 3000


Hz using 2 signal levels can achieve a maximum bit rate of
2×3000×log22=6000×1=6000 bps. If 4 levels are used,
it's 2×3000×log24=6000×2=12000 bps.
Hamza Zahoor What's App 0341-8377-917

2. Shannon Capacity (for Noisy Channels):

 Formula: C=B×log2(1+S/N)

 C: Channel capacity (max bit rate in bps)

 B: Bandwidth of the channel (in Hz)

 S/N: Signal-to-Noise Ratio (SNR), which is the ratio of


signal power (S) to noise power (N). It's often
expressed in decibels (SNRdB) and then converted to
a linear ratio: S/N=10(SNRdB/10).

 Explanation: This theorem provides the theoretical


maximum data rate for a noisy channel. It shows that
increasing bandwidth or improving the signal-to-noise ratio
increases capacity. This limit is independent of the number
of signal levels; it tells you the absolute theoretical
maximum capacity. You can't exceed this even with ideal
encoding.

 Example: A channel with 3000 Hz bandwidth and an


SNRdB of 30 dB. First, convert SNRdB to S/N:
S/N=10(30/10)=103=1000. Then, C=3000×log2
(1+1000)≈3000×log2(1001)≈3000×9.96≈29880 bps.

o Practical Implications:

 The Shannon capacity sets an upper bound; actual


achievable data rates are always lower due to practical
limitations.

 The Nyquist formula is used to determine how many bits


per symbol are needed for a desired bit rate, given a
certain bandwidth in a noiseless scenario.

 Together, they guide engineers in designing


communication systems that maximize data rates within
given bandwidth and noise constraints.

6. Performance

 Definition: Network performance refers to the efficiency and


effectiveness of a network in delivering data. It is a critical aspect of
network design and management, and various metrics are used to
quantify it.
Hamza Zahoor What's App 0341-8377-917

 Key Performance Metrics (Revisited and Expanded):

1. Bandwidth (Throughput):

 Definition: The maximum rate at which data can be


transmitted over a communication channel. It's often
referred to as the capacity of the link. Measured in bits per
second (bps), Kbps, Mbps, Gbps.

 Throughput (Actual): The actual rate at which data is


transferred successfully over a period. It's often less than
the theoretical bandwidth due to network congestion,
overhead, errors, etc.

 Example: Your internet plan might advertise "100 Mbps


bandwidth," but your actual download speed (throughput)
might be 80 Mbps due to Wi-Fi interference or server load.

2. Latency (Delay):

 Definition: The total time taken for data to travel from the
source to the destination. As discussed in Week 4, it
comprises processing delay, queuing delay, transmission
delay, and propagation delay.

 Importance: Crucial for real-time applications where


responsiveness is key. Lower latency is better.

 Example: High latency (ping) in online games leads to


noticeable lag.

3. Jitter:

 Definition: The variation in the delay of received packets.


It's the fluctuation in latency.

 Importance: Extremely important for real-time audio and


video streams. Low jitter is better.

 Example: High jitter makes voice calls sound choppy and


video streams freeze or stutter.

4. Packet Loss Rate:

 Definition: The percentage of packets that fail to reach


their destination.
Hamza Zahoor What's App 0341-8377-917

 Importance: High packet loss significantly degrades


performance, requiring retransmissions and impacting user
experience. Lower loss is better.

 Example: Lost packets in a video call can lead to missing


frames or distorted audio.

5. Reliability:

 Definition: The ability of the network to deliver data


without errors and to remain operational even in the event
of component failures.

 Metrics: Error rate, uptime percentage, Mean Time


Between Failures (MTBF).

 Importance: Essential for critical applications where data


integrity and continuous service are paramount.

6. Utilization:

 Definition: The percentage of time a network resource


(e.g., a link or a router) is busy transmitting data.

 Importance: While high utilization might seem good,


overly high utilization (e.g., consistently above 70-80%)
can lead to increased queuing delays and packet loss due
to congestion.

o Trade-offs in Performance:

 Often, there are trade-offs between different performance


metrics. For example, increasing buffer sizes to reduce
packet loss can increase latency.

 Network design aims to optimize these metrics based on


the specific application requirements. For instance, VoIP
prioritizes low latency and jitter over high bandwidth, while
file transfer prioritizes high throughput and low loss.

Computer Networks - BS 3rd Semester Notes (Continued)

Week 6: Signal Conversion and Transmission Modes

1. Digital to Digital Conversion (Line Coding)


Hamza Zahoor What's App 0341-8377-917

 Definition: The process of converting digital data (sequences of bits)


into digital signals. This is done to prepare data for transmission over a
digital medium (like a twisted-pair cable or fiber optic).

 Purpose/Goals of Line Coding:

1. Reduce DC Component: Avoid direct current (DC) components


in the signal, which can interfere with electrical components and
prevent long-distance transmission over certain media.

2. Self-Synchronization: Include timing information within the


signal itself, allowing the receiver to synchronize its clock with
the sender's. This prevents bit errors due to timing drift.

3. Error Detection: Some codes can detect errors in the received


bit stream.

4. Noise Immunity: Design signals to be less susceptible to noise.

5. Bandwidth Efficiency: Use the available bandwidth effectively


to transmit more bits per second.

6. Low Complexity/Cost: Simple to implement.

 Common Line Coding Schemes (Types):

o Unipolar (NRZ):

 NRZ (Non-Return-to-Zero): A positive voltage


represents '1', and zero voltage represents '0' (or vice-
versa).

 Characteristics: Simple, uses bandwidth efficiently.

 Problem: Significant DC component, lacks self-


synchronization for long strings of 0s or 1s.

 Example: NRZ-L (level), NRZ-I (invert on 1).

o Polar: Uses two voltage levels (positive and negative).

 NRZ: (e.g., NRZ-L: positive for '1', negative for '0'; NRZ-I:
invert on '1', no change on '0'). Still has synchronization
issues.

 RZ (Return-to-Zero): Signal returns to zero voltage in the


middle of each bit interval.
Hamza Zahoor What's App 0341-8377-917

 Characteristics: Improves synchronization slightly (more


transitions than NRZ), but uses twice the bandwidth of NRZ
and has a DC component.

 Biphase (Manchester and Differential Manchester):

 Manchester: Transition in the middle of each bit


interval (low-to-high for '0', high-to-low for '1').

 Differential Manchester: Transition in the middle


for clock, and transition at the beginning of the bit
interval based on the bit value (no transition for '1',
transition for '0').

 Characteristics: Excellent self-synchronization


(always a transition), no DC component.

 Disadvantage: Requires twice the bandwidth of


NRZ due to more transitions. Widely used in
Ethernet.

o Bipolar (AMI, Pseudoternary): Uses three voltage levels:


positive, negative, and zero.

 AMI (Alternate Mark Inversion): '0' is represented by


zero voltage. '1's alternate between positive and negative
voltages.

 Characteristics: No DC component, some error detection


(if two consecutive '1's have same polarity).

 Problem: Long strings of '0's still cause synchronization


issues.

 Pseudoternary: Opposite of AMI. '1' is zero voltage, '0's


alternate between positive and negative.

o Multilevel schemes (e.g., 2B1Q, 8B6T, 4D-PAM5): Encode


multiple bits into a single signal element.

 Purpose: Increase bit rate for a given bandwidth (higher


efficiency).

 Example: 2B1Q (2 Binary 1 Quaternary) encodes 2 bits


into 1 quaternary (4-level) signal element. Used in DSL.
Hamza Zahoor What's App 0341-8377-917

o Block Coding (e.g., 4B/5B, 8B/10B): Converts a block of


digital data bits into a longer block of code bits.

 Purpose: Introduce enough transitions for synchronization,


provide error detection, or minimize DC component.

 Mechanism: Adds redundancy. For instance, 4B/5B maps


every 4 data bits to a 5-bit code word, ensuring sufficient
transitions.

2. Analog to Digital Conversion (Digitization)

 Definition: The process of converting an analog signal (like voice or


video) into a digital signal. This is essential for transmitting analog
data over digital networks and for digital processing.

 Technique: Pulse Code Modulation (PCM) is the most common


method.

 Steps in PCM:

1. Sampling:

 Definition: Taking discrete amplitude measurements of


the analog signal at regular intervals.

 Nyquist Theorem: To accurately reconstruct the original


analog signal, the sampling rate must be at least twice the
highest frequency present in the analog signal (fs≥2×fmax
).

 Example: For voice with a highest frequency of 4000 Hz,


the sampling rate should be at least 8000 samples/second.

2. Quantization:

 Definition: Assigning a discrete numerical value (from a


finite set of values) to each sampled amplitude. This
involves rounding the continuous analog sample to the
nearest predefined level.

 Effect: Introduces quantization error (noise), as the


original sample might not perfectly match a predefined
level.

 Resolution: The number of bits used to represent each


sample (e.g., 8 bits for 256 levels, 16 bits for 65,536
Hamza Zahoor What's App 0341-8377-917

levels). More bits lead to finer resolution and less


quantization error.

3. Encoding (Digital Encoding):

 Definition: Converting the quantized values into a binary


code (a sequence of 0s and 1s).

 Example: If 8 bits are used per sample, each sample is


represented by an 8-bit binary code.

 Output: A continuous stream of binary digits representing the original


analog signal.

 Bit Rate of PCM: BitRate=SamplingRate×Numberofbitspersample.

o Example (Voice): 8000 samples/sec×8 bits/sample=64 kbps


(This is the standard for uncompressed digital voice).

3. Transmission Modes

 Definition: How bits are organized for transmission over a data link,
particularly concerning the timing and order of bits.

 Types:

1. Parallel Transmission:

 Definition: Multiple bits are sent simultaneously over


multiple parallel wires (or channels).

 Characteristics:

 Requires N separate wires to send N bits at a time.

 Faster for short distances (e.g., within a computer


system or over very short external cables).

 Problem: Skew (bits arriving at slightly different


times on different wires) becomes significant over
longer distances, making it impractical for long-haul
data communication.

 Example: Printer cables (LPT ports), internal computer


buses.

2. Serial Transmission:
Hamza Zahoor What's App 0341-8377-917

 Definition: Bits are sent one after another, sequentially,


over a single communication channel.

 Characteristics:

 Requires only one communication channel.

 Slower per clock cycle than parallel but can achieve


high speeds over long distances due to lack of skew
issues.

 Dominant mode for data communication over


networks.

 Example: USB, Ethernet, Fibre Optics, Wi-Fi.

 Types of Serial Transmission (Synchronization):

1. Asynchronous Transmission:

 Definition: Data is sent character by character (or byte by


byte). Each character is framed with start and stop bits to
mark its beginning and end.

 Characteristics:

 No common clock signal between sender and


receiver.

 Start bit (0) alerts the receiver to the arrival of a new


character.

 Stop bit(s) (1) indicates the end of the character and


prepares for the next.

 Idle time between characters is possible.

 Overhead: Adds extra bits (start/stop) to each


character, reducing efficiency.

 Advantages: Simple, inexpensive, flexible (idle time


allows variable character intervals).

 Disadvantages: Inefficient for large data blocks due to


overhead, slower than synchronous.

 Example: Traditional modems, older serial ports (RS-232).

2. Synchronous Transmission:
Hamza Zahoor What's App 0341-8377-917

 Definition: Data is sent in continuous blocks (frames)


without start/stop bits. The sender and receiver must be
perfectly synchronized using a shared clock signal or by
embedding timing information within the data stream.

 Characteristics:

 Bits are streamed continuously.

 Clocking: Provided by a separate clock line or by


encoding the clock within the data (e.g., Manchester
encoding).

 Framing: Special bit patterns (flags) mark the


beginning and end of frames.

 Efficiency: Very efficient for large data blocks as


there is less overhead per bit.

 Advantages: High speed, highly efficient for large data


transfers.

 Disadvantages: More complex, requires precise


synchronization, retransmission of entire frame if error
occurs.

 Example: Ethernet, SDH/SONET, ISDN, High-Level Data


Link Control (HDLC).

4. Digital-to-Analog Conversion (Modulation)

 Definition: The process of converting digital data into an analog


signal. This is necessary when digital data needs to be transmitted
over an analog medium (e.g., telephone lines, radio waves). The device
performing this conversion is a Modem (Modulator-Demodulator).

 Techniques (Types of Modulation):

1. ASK (Amplitude Shift Keying):

 Concept: The amplitude (strength) of a carrier analog


signal is varied to represent digital bits. Frequency and
phase remain constant.

 Example: High amplitude for '1', low (or zero) amplitude


for '0'.
Hamza Zahoor What's App 0341-8377-917

 Use Case: Often used for optical fiber communication or


short-range radio frequency (RF) links.

2. FSK (Frequency Shift Keying):

 Concept: The frequency of a carrier analog signal is varied


to represent digital bits. Amplitude and phase remain
constant.

 Example: One frequency for '1', another frequency for '0'.

 Use Case: Used in early modems, half-duplex voiceband


modems, and some wireless applications.

3. PSK (Phase Shift Keying):

 Concept: The phase of a carrier analog signal is varied to


represent digital bits. Amplitude and frequency remain
constant.

 Example: Phase change of 0 degrees for '0', 180 degrees


for '1' (BPSK - Binary PSK). Can use multiple phase shifts
(e.g., QPSK for 4 phases, representing 2 bits per symbol).

 Use Case: Widely used in wireless communication (Wi-Fi,


cellular), satellite communication, and DSL.

4. QAM (Quadrature Amplitude Modulation):

 Concept: Combines amplitude and phase shifting to


represent multiple bits per symbol, achieving higher data
rates.

 Example: 16-QAM uses 16 different combinations of


amplitude and phase, representing 4 bits per symbol.

 Use Case: Very common in high-speed modems (cable,


DSL), Wi-Fi (newer standards), and cellular networks, where
spectral efficiency is critical.

5. Analog-to-Analog Conversion (Analog Modulation)

 Definition: The process of converting one analog signal (e.g., voice,


music) into another analog signal, typically by modulating a high-
frequency carrier wave. This is done to shift the signal to a different
frequency range for efficient transmission (e.g., over radio waves) or to
allow multiple signals to share a medium using FDM.
Hamza Zahoor What's App 0341-8377-917

 Purpose:

o Frequency Translation: Shift the baseband signal to a higher


frequency band suitable for transmission over a particular
medium (e.g., radio frequency for broadcasting).

o Multiplexing: Allow multiple analog signals to share a single


transmission medium using Frequency Division Multiplexing
(FDM).

o Overcoming Medium Limitations: Adjust the signal


characteristics to better suit the propagation properties of the
medium.

 Techniques (Types of Analog Modulation):

1. AM (Amplitude Modulation):

 Concept: The amplitude of a high-frequency carrier wave


is varied in proportion to the amplitude of the analog
message signal.

 Characteristics: Simple to implement, but susceptible to


noise.

 Use Case: Traditional AM radio broadcasting.

2. FM (Frequency Modulation):

 Concept: The frequency of a high-frequency carrier wave


is varied in proportion to the amplitude of the analog
message signal. The amplitude of the carrier remains
constant.

 Characteristics: More immune to noise than AM, higher


fidelity.

 Use Case: FM radio broadcasting, television sound.

3. PM (Phase Modulation):

 Concept: The phase of a high-frequency carrier wave is


varied in proportion to the amplitude of the analog
message signal.

 Characteristics: Similar to FM, often used in combination


with FM for digital communication.
Hamza Zahoor What's App 0341-8377-917

 Use Case: Primarily used for digital modulation (e.g., PSK),


but also has analog applications.

Computer Networks - BS 3rd Semester Notes (Continued)

Week 7: Transmission Media and Data Link Layer Introduction

1. Transmission Media

 Definition: Transmission media are the physical pathways or channels


through which data travels from a sender to a receiver. They can be
broadly classified into two categories: guided (wired) and unguided
(wireless).

 Role: Essential component of the Physical Layer (Layer 1) of network


models, providing the physical link for signal propagation.

2. Guided Media

 Definition: Guided media (also known as wired or bounded media)


use a physical conductor to transmit signals. The signals are confined
to a specific path within the medium.

 Types:

1. Twisted-Pair Cable:

 Description: Consists of two insulated copper wires


twisted together. Twisting reduces crosstalk and
electromagnetic interference.

 Types:

 UTP (Unshielded Twisted-Pair): Most common


type, no metallic shield, less expensive, prone to
noise.

 STP (Shielded Twisted-Pair): Has a metallic braid


or foil shield to reduce noise, more expensive,
thicker.

 Categories (UTP): Cat 3 (old telephone), Cat 5/5e (100


Mbps, 1 Gbps), Cat 6/6a (1 Gbps, 10 Gbps), Cat 7/7a (10
Gbps and beyond).

 Connectors: RJ-45 (for Ethernet), RJ-11 (for telephone).


Hamza Zahoor What's App 0341-8377-917

 Advantages: Inexpensive (UTP), easy to install, widely


available.

 Disadvantages: Susceptible to noise (UTP), limited


bandwidth/distance for higher speeds.

 Applications: LANs (Ethernet), telephone networks.

2. Coaxial Cable:

 Description: Consists of a central copper conductor


surrounded by an insulating layer, a metallic shield (braid
or foil), and an outer insulating jacket.

 Characteristics: Better shielding than UTP, higher


bandwidth than twisted-pair over longer distances.

 Types:

 RG-59: For cable TV.

 RG-58: For thin Ethernet (10Base2).

 RG-11: For thick Ethernet (10Base5).

 Advantages: Higher bandwidth than twisted-pair, good


noise immunity.

 Disadvantages: More expensive and difficult to install


than UTP, less common in modern LANs.

 Applications: Cable TV, older Ethernet LANs (bus


topology), some short-haul telephone trunks.

3. Fiber-Optic Cable:

 Description: Transmits data as pulses of light through thin


strands of glass or plastic (optical fibers).

 Components: Core (light path), Cladding (reflects light


back into core), Jacket (protection).

 Types:

 Multi-mode Fiber (MMF): Larger core, multiple


light paths, cheaper transceivers, good for shorter
distances (e.g., within a building).
Hamza Zahoor What's App 0341-8377-917

 Single-mode Fiber (SMF): Smaller core, single


light path, expensive transceivers, good for very long
distances and high bandwidth (e.g., inter-city,
undersea cables).

 Advantages:

 Extremely High Bandwidth: Supports very high


data rates (Gbps to Tbps).

 Long Distances: Can transmit signals over tens or


hundreds of kilometers without repeaters.

 Immunity to EMI: Not affected by electromagnetic


interference or noise.

 Security: Very difficult to tap without detection.

 Low Attenuation: Less signal loss than copper


cables.

 Disadvantages: More expensive to install, requires


specialized equipment and expertise for termination,
fragile (glass core).

 Applications: Backbone networks, high-speed LANs,


WANs, Internet backbone, Fiber-to-the-Home (FTTH).

3. Unguided Media: Wireless

 Definition: Unguided media (also known as wireless or unbounded


media) transmit electromagnetic waves through open space without a
physical conductor.

 Characteristics: Broadcast nature, susceptible to interference, signal


strength degrades with distance.

 Types (based on frequency range/application):

1. Radio Waves:

 Description: Electromagnetic waves in the frequency


range of 3 KHz to 1 GHz.

 Characteristics: Omnidirectional (signals broadcast in all


directions), can penetrate walls.
Hamza Zahoor What's App 0341-8377-917

 Applications: AM/FM radio, cordless phones, older


wireless LANs, Bluetooth.

2. Microwaves:

 Description: Electromagnetic waves in the frequency


range of 1 GHz to 300 GHz.

 Characteristics: Unidirectional (require line-of-sight


communication), higher frequencies mean more
bandwidth.

 Types:

 Terrestrial Microwave: Parabolic antennas on


towers, line-of-sight. Used for long-distance
telephone, cellular backhaul.

 Satellite Microwave: Communication via satellites


in orbit. Used for broadcasting, global communication
(data, TV, voice).

 Advantages: Suitable for long-distance, no cabling


required, high bandwidth.

 Disadvantages: Requires line-of-sight (terrestrial),


susceptible to weather conditions (rain fade), security
concerns (eavesdropping).

3. Infrared:

 Description: Electromagnetic waves with frequencies


from 300 GHz to 400 THz.

 Characteristics: Short-range, line-of-sight (or diffuse),


cannot penetrate walls, good for security within a room.

 Applications: TV remote controls, short-range wireless


keyboards/mice, IrDA ports on older devices.

 Advantages: Secure (within a room), no interference


between rooms.

 Disadvantages: Limited range, blocked by obstacles.

4. Data Link Layer (Introduction)


Hamza Zahoor What's App 0341-8377-917

 Definition: The Data Link Layer (Layer 2) in the OSI model (and
often integrated into the "Network Access Layer" in TCP/IP) is
responsible for reliable node-to-node data transfer across a physical
link. It ensures that data packets (which it calls "frames") are
transmitted and received accurately between two directly connected
devices.

 Main Responsibilities/Functions:

1. Framing: Divides the stream of bits from the Network layer into
manageable units called frames. Adds a header and trailer to
each frame (containing control information like
source/destination physical addresses, frame delimiters, error
detection codes).

2. Physical Addressing (MAC Addressing): Adds the physical


address (MAC address) of the sender and receiver to the frame
header. This address is unique to each network interface card
(NIC).

3. Flow Control: Regulates the rate of data transmission to


prevent a fast sender from overwhelming a slow receiver.
Ensures the receiver's buffer doesn't overflow.

4. Error Control: Detects and/or corrects errors that may occur


during transmission over the physical medium. This includes
mechanisms for error detection (e.g., CRC) and retransmission of
damaged or lost frames.

5. Media Access Control (MAC): For shared media (like bus


topologies or wireless networks), it determines which device has
the right to transmit at any given time to avoid collisions. This is
handled by the MAC sublayer.

 Sublayers (IEEE 802 Standards):

o Logical Link Control (LLC) Sublayer: Handles flow control,


error control, and defines SAPs (Service Access Points) to
communicate with the Network layer. (IEEE 802.2)

o Media Access Control (MAC) Sublayer: Manages access to


the shared physical medium (e.g., CSMA/CD for Ethernet,
CSMA/CA for Wi-Fi). It includes the physical addressing. (IEEE
802.3, 802.11)
Hamza Zahoor What's App 0341-8377-917

 Devices: Switches, Bridges.

 Protocols: Ethernet (IEEE 802.3), PPP (Point-to-Point Protocol), HDLC


(High-Level Data Link Control).

5. Block Coding

 Definition: A line coding technique where a block of 'k' data bits is


mapped into a longer block of 'n' code bits (where n > k). This is
represented as an (n, k) block code. The added (n-k) bits are
redundant and are used to achieve desired properties like
synchronization or error detection.

 Purpose:

o Synchronization: Ensure sufficient signal transitions for the


receiver's clock to synchronize, especially with long strings of 0s
or 1s (which can cause synchronization loss in NRZ).

o Error Detection: The redundancy allows the detection of


certain types of errors.

o DC Component Reduction: Design codes to minimize or


eliminate the DC component.

 Mechanism:

o The sender divides the outgoing bit stream into blocks of 'k' bits.

o Each 'k'-bit block is transformed into an 'n'-bit codeword using a


predefined mapping table.

o These 'n'-bit codewords are then transmitted using a suitable line


coding scheme (e.g., NRZ-I).

 Redundancy: The added (n-k) bits do not carry new information but
provide the desired line characteristics.

 Example:

o 4B/5B Encoding: A widely used block coding scheme where


every 4 data bits are encoded into a 5-bit codeword.

 There are 24=16 possible 4-bit data words.

 There are 25=32 possible 5-bit codewords.


Hamza Zahoor What's App 0341-8377-917

 16 of these 5-bit codewords are chosen for data encoding.


The remaining 16 are either unused or used for control
signals (e.g., idle, start of frame, end of frame).

 Benefit: The 5-bit codewords are specifically chosen to


avoid long sequences of zeros, thereby guaranteeing at
least two 1s in every 5-bit sequence (e.g., 0000 is mapped
to 11100, not 00000), which ensures sufficient transitions
for synchronization when using NRZ-I.

 Application: Used in conjunction with NRZ-I in 100BASE-


TX Ethernet (Fast Ethernet) and FDDI.

o 8B/10B Encoding: Every 8 data bits are encoded into a 10-bit


codeword. Provides even better synchronization and DC balance.
Used in Gigabit Ethernet and Fibre Channel.

6. Linear Block Codes

 Definition: A category of block codes used for error detection and/or


correction, where the encoding process involves linear operations
(addition modulo 2) on the data bits. This means that the XOR sum of
any two valid codewords in the code is also a valid codeword.

 Key Concept: The encoder uses a generator matrix (G) to transform


'k' data bits into 'n' codeword bits. The redundant bits (parity bits) are
generated based on the data bits.

 Minimum Distance (Hamming Distance): The minimum number of


bit positions in which any two valid codewords differ. This is crucial for
error detection and correction capabilities:

o Error Detection: To detect up to 's' errors, the minimum


distance must be at least s+1.

o Error Correction: To correct up to 't' errors, the minimum


distance must be at least 2t+1.

 Types/Examples:

o Parity Check Code: The simplest linear block code. Adds a


single parity bit to a block of data bits.

 Even Parity: The parity bit is set so that the total number
of '1's in the codeword (data + parity) is even.
Hamza Zahoor What's App 0341-8377-917

 Odd Parity: The parity bit is set so that the total number
of '1's in the codeword is odd.

 Detection: Can detect any single bit error. Cannot correct


errors and cannot detect an even number of errors.

o Hamming Codes: More powerful linear block codes that can


detect multiple errors and correct single-bit errors. They are
constructed based on specific rules for placing parity bits.

o CRC (Cyclic Redundancy Check): While often considered a


separate category, CRC is also a type of linear block code
(specifically, a cyclic code). Its properties make it highly effective
for detecting burst errors.

7. Cyclic Codes

 Definition: A special subclass of linear block codes that have an


additional property: if a codeword is a valid codeword, then a cyclic
shift (circular shift) of that codeword is also a valid codeword. This
mathematical property allows for efficient implementation using shift
registers.

 Key Concept: Based on polynomial arithmetic (binary numbers


represented as polynomials). Both the sender and receiver agree on a
generator polynomial (G(x)).

 Mechanism (Simplified):

1. Sender:

 Appends 'n-k' zeros to the 'k' data bits.

 Divides the resulting polynomial by the generator


polynomial G(x) using modulo-2 division.

 The remainder (of length n-k) is the Frame Check


Sequence (FCS) or CRC checksum.

 The FCS is appended to the original data bits to form the


'n'-bit codeword.

2. Receiver:

 Divides the received 'n'-bit codeword by the same


generator polynomial G(x).
Hamza Zahoor What's App 0341-8377-917

 If the remainder is zero, the frame is assumed to be error-


free.

 If the remainder is non-zero, errors are detected.

 Advantages:

o Excellent Error Detection: Extremely good at detecting burst


errors (multiple consecutive bit errors).

o Efficient Implementation: Can be implemented easily in


hardware using shift registers and XOR gates.

 Disadvantages: Primarily for error detection; error correction


capabilities are limited (though some specialized cyclic codes exist for
correction).

 Applications: Widely used in almost all digital communication


networks: Ethernet, Wi-Fi, USB, Token Ring, ATM, and many others.

 Common CRC Polynomials:

o CRC-8, CRC-16 (e.g., CRC-CCITT), CRC-32 (most common,


used in Ethernet). The longer the CRC, the better its error
detection capability.

8. Checksum

 Definition: A simple error detection method where a value


(checksum) is calculated based on the content of a data block and
appended to it. The receiver performs the same calculation; if the
calculated checksum matches the received checksum, the data is
assumed to be correct.

 Mechanism:

1. Sender:

 The data is divided into equal-sized segments (e.g., 16-bit


words).

 All segments are added together using one's complement


arithmetic.

 The sum is then complemented (all 0s become 1s, and all


1s become 0s) to produce the checksum.

 The checksum is appended to the data and sent.


Hamza Zahoor What's App 0341-8377-917

2. Receiver:

 The received data segments (including the checksum) are


added together using one's complement arithmetic.

 If the result is all 1s (or zero if not complemented), the


data is considered error-free. If not, an error is detected.

 Advantages:

o Simple to Implement: Computationally less intensive than


CRC.

 Disadvantages:

o Less Robust: Not as powerful as CRC in detecting complex


errors, especially burst errors. It cannot detect all errors. For
example, if two bits are swapped (one 0 to 1 and another 1 to 0),
the sum might remain the same.

 Applications: Primarily used in higher layers, especially in the


Transport Layer (TCP, UDP) and Network Layer (IP header
checksum), for detecting errors in headers and data segments. It's
less common for error detection over the physical link due to its lower
robustness compared to CRC.

Week 8: Flow, Error, Multiple Access, and LANs

1. Flow and Error Control

 Definition: Essential mechanisms implemented primarily at the Data


Link Layer and Transport Layer to ensure reliable and efficient data
transfer.

o Flow Control: Manages the rate of data transmission between a


sender and receiver to prevent a fast sender from overwhelming
a slower receiver's buffer.

o Error Control: Deals with detecting and, in some cases,


correcting errors that occur during data transmission. This
ensures data integrity.

 Why are they needed?


Hamza Zahoor What's App 0341-8377-917

o Flow Control: Receivers have finite buffer space. Without flow


control, a sender could transmit data faster than the receiver can
process or store it, leading to buffer overflow and packet/frame
loss.

o Error Control: Transmission media are noisy. Errors (bit flips)


can occur, corrupting data. Error control ensures that the
received data is identical to the sent data, or that errors are at
least detected.

 Relationship: Often implemented together, as retransmissions (part


of error control) affect the flow of data.

 Flow Control Mechanisms:

1. Stop-and-Wait ARQ (Automatic Repeat Request):

 Mechanism: The sender sends one frame at a time and


then waits for an acknowledgment (ACK) from the receiver.
If an ACK is received, the next frame is sent. If a timeout
occurs or a Negative ACK (NAK) is received, the frame is
retransmitted.

 Advantages: Simple to implement.

 Disadvantages: Inefficient, especially for long-distance


links with high propagation delays, due to idle time while
waiting for ACKs.

2. Sliding Window Protocol (Go-Back-N ARQ and Selective


Repeat ARQ):

 Mechanism: Allows the sender to transmit multiple


frames before waiting for an ACK. Both sender and receiver
maintain a "window" of acceptable sequence numbers.

 Go-Back-N ARQ:

 Concept: Sender can transmit up to 'N' frames


without waiting for ACKs. If an error is detected
(timeout, NAK received for a frame), the sender
retransmits that frame and all subsequent frames
that were already sent.

 Advantages: More efficient than Stop-and-Wait,


simpler receiver logic than Selective Repeat.
Hamza Zahoor What's App 0341-8377-917

 Disadvantages: Inefficient retransmissions if many


frames are lost or damaged (retransmitting already
correctly received frames).

 Selective Repeat ARQ:

 Concept: Sender transmits multiple frames. If an


error is detected, only the specific damaged or lost
frame is retransmitted. The receiver stores correctly
received out-of-order frames.

 Advantages: Most efficient in terms of


retransmissions, maximizes throughput.

 Disadvantages: More complex receiver logic (needs


larger buffers to store out-of-order frames and
reassemble).

 Error Control Mechanisms:

1. Error Detection:

 Parity Check: Simplest, detects single-bit errors.

 Checksum: Used in IP, TCP, UDP for detecting errors in


headers/segments. Less robust than CRC.

 CRC (Cyclic Redundancy Check): Most common and


robust for detecting burst errors in data link layer. (Covered
in Week 7).

2. Error Correction:

 Forward Error Correction (FEC): Sender adds enough


redundant information (e.g., using Hamming codes, Reed-
Solomon codes) so that the receiver can detect and correct
a certain number of errors without retransmission.

 Advantages: No retransmission delay, good for real-


time applications or high-latency links.

 Disadvantages: Adds significant overhead,


increases bandwidth usage.

 ARQ (Automatic Repeat Request): (Already covered in


Flow Control) Relies on detection of errors and then
Hamza Zahoor What's App 0341-8377-917

requests retransmission of the affected data. This is the


most common method in data networks.

2. Noiseless Channels

 Definition: Theoretical channels that are assumed to be free from any


form of noise or interference. In such channels, signals are not
impaired, and data can be transmitted without errors.

 Key Concept: The Nyquist Bit Rate formula applies to noiseless


channels, determining the maximum achievable data rate based solely
on bandwidth and the number of signal levels.

 Formula: C=2×B×log2L

o C: Capacity (bits per second)

o B: Bandwidth (Hz)

o L: Number of signal levels

 Relevance: While purely noiseless channels don't exist in practice,


this concept helps in understanding the theoretical limits of a
medium's capacity and in comparing different modulation schemes'
efficiency without the complexity of noise.

3. Noisy Channels

 Definition: Real-world communication channels that are subject to


various forms of noise and interference (thermal noise, impulse noise,
crosstalk, etc.). Signals transmitted over noisy channels are impaired,
leading to potential bit errors.

 Key Concept: The Shannon Capacity formula applies to noisy


channels, determining the theoretical maximum achievable data rate
given the bandwidth and the signal-to-noise ratio.

 Formula: C=B×log2(1+S/N)

o C: Capacity (bits per second)

o B: Bandwidth (Hz)

o S/N: Signal-to-Noise Ratio (power ratio, not dB)

 Implications:
Hamza Zahoor What's App 0341-8377-917

o Noise inherently limits the maximum achievable data rate and


necessitates error control mechanisms.

o For a given bandwidth, higher SNR allows for higher data rates.

o Even with infinite signal power, a finite bandwidth limits the


capacity.

o Even with infinite bandwidth, noise prevents infinite capacity if


the signal power is finite.

 Relevance: Guides the design of real-world communication systems,


indicating the fundamental trade-offs between bandwidth, signal
power, noise, and achievable data rates.

4. Multiple Access

 Definition: In a network where multiple devices share a single


common transmission medium (e.g., a wireless channel, an older bus
Ethernet cable), a Multiple Access Protocol (MAC protocol) is
needed to determine which device can transmit at any given time. This
prevents collisions (when two or more devices transmit simultaneously,
causing data corruption) and ensures fair access to the shared
medium.

 Goal: Efficiently share the single broadcast channel among multiple


competing nodes.

 Categories of Multiple Access Protocols:

1. Random Access Protocols (Contention-based):

 Concept: Nodes transmit whenever they have data. If a


collision occurs, they retransmit after a random delay.

 Examples:

 ALOHA: Simplest, transmits frames whenever ready.


If ACK not received, assumes collision and
retransmits.

 CSMA (Carrier Sense Multiple Access): "Listen


before talk." A station first "senses" the channel. If
busy, it waits. If idle, it transmits.

 CSMA/CD (Collision Detection): Used in


wired Ethernet. Stations listen while
Hamza Zahoor What's App 0341-8377-917

transmitting. If a collision is detected (signal


corruption), all transmitting stations stop, send
a jamming signal, and then wait a random
back-off time before retransmitting.

 CSMA/CA (Collision Avoidance): Used in


Wireless LANs (Wi-Fi). Due to "hidden
terminal" problem and inability to detect
collisions while transmitting (half-duplex nature
of wireless transceivers), stations try to avoid
collisions. Mechanisms include:

 RTS/CTS (Request To Send/Clear To


Send): Optional handshake to reserve
the channel.

 Network Allocation Vector (NAV):


Stations update their internal timer to
defer access when they hear RTS/CTS or
data frames.

 ACKs: Positive ACKs confirm reception of


data. No ACK implies collision/loss.

 Interframe Space (IFS): Different


waiting times before transmitting, giving
priority to certain frames.

2. Controlled Access Protocols:

 Concept: Stations consult with each other or a central


controller to determine who has the right to transmit. No
collisions.

 Examples:

 Reservation: Stations reserve slots for future


transmission.

 Polling: A primary station "polls" secondary stations


one by one to grant them permission to transmit.

 Token Passing: A special packet called a "token"


circulates among stations. Only the station holding
the token can transmit. After transmitting, it passes
Hamza Zahoor What's App 0341-8377-917

the token to the next station. Used in Token Ring and


Token Bus.

3. Channelization Protocols:

 Concept: Divides the single channel into multiple smaller


channels, which are then allocated to different users.

 Examples:

 FDMA (Frequency Division Multiple Access):


Divides the bandwidth into distinct frequency bands.
Each user gets a unique frequency band.

 TDMA (Time Division Multiple Access): Divides


time into time slots. Each user gets a unique time
slot on a shared frequency.

 CDMA (Code Division Multiple Access): Assigns a


unique code to each user. Users transmit
simultaneously on the same frequency, but their data
is spread using their unique code, allowing receivers
to separate the signals using the same code.

5. Connecting Devices

 Definition: Hardware devices used to interconnect network segments,


extend network reach, or manage traffic flow at different layers of the
OSI model.

 Types (by OSI Layer):

1. Physical Layer Devices (Layer 1):

 Hub (Multiport Repeater):

 Function: Connects multiple devices in a star


topology. Receives a signal on one port and
broadcasts it to all other ports.

 Characteristics: Acts as a shared medium (creates


a single collision domain and single broadcast
domain). No intelligence for traffic management.

 Disadvantage: Can lead to network congestion and


collisions. Obsolete for modern LANs.
Hamza Zahoor What's App 0341-8377-917

 Repeater:

 Function: Regenerates (re-amplifies and reshapes) a


weak signal to extend its range.

 Characteristics: Operates purely on the bit level; no


intelligence. Does not segment network.

 Use: Extends cable lengths beyond maximum


specifications.

2. Data Link Layer Devices (Layer 2):

 Bridge:

 Function: Connects two or more LAN segments.


Learns MAC addresses and forwards frames
selectively based on destination MAC address.

 Characteristics: Divides a single collision domain


into multiple collision domains. Creates a single
broadcast domain. Filters traffic.

 Advantage: Reduces collisions, improves


performance compared to hubs.

 Disadvantage: Limited number of ports, does not


filter broadcast traffic. Mostly replaced by switches.

 Switch (Multiport Bridge):

 Function: Essentially a high-speed, multi-port


bridge. Learns MAC addresses of connected devices
and builds a MAC address table. Forwards frames
only to the intended destination port.

 Characteristics: Each port creates its own collision


domain. Creates a single broadcast domain (by
default).

 Advantages: Significantly improves network


performance, reduces collisions, allows full-duplex
communication on each port.

 Applications: Dominant device in modern LANs.

3. Network Layer Devices (Layer 3):


Hamza Zahoor What's App 0341-8377-917

 Router:

 Function: Connects different networks (LANs, WANs)


together. Uses logical (IP) addresses to determine the
best path for forwarding packets between networks.

 Characteristics: Operates at the Network Layer.


Divides broadcast domains (each interface creates a
new broadcast domain). Filters traffic based on IP
addresses.

 Advantages: Enables internetworking, provides


network segmentation, supports complex routing
decisions, security features (firewalls).

 Applications: Connects local networks to the


Internet, connects different subnets within an
organization.

4. Higher Layer Devices:

 Gateway:

 Function: Generally refers to any device that


connects two disparate networks that use different
protocols. Often operates at the Application Layer.

 Example: A router connecting a LAN to the Internet


acts as a gateway. An email gateway translates
between different email protocols.

 Firewall:

 Function: A network security system that monitors


and controls incoming and outgoing network traffic
based on predefined security rules. Can operate at
various layers (packet filtering at Network, proxy at
Application).

6. Wired LAN (Ethernet)

 Definition: Ethernet (IEEE 802.3 standard) is the most dominant wired


Local Area Network (LAN) technology. It defines the physical and data
link layer specifications for wired networks.

 History & Evolution:


Hamza Zahoor What's App 0341-8377-917

o Early Ethernet (10Base5, 10Base2): Used bus topology,


coaxial cable, 10 Mbps speed. Shared medium, used CSMA/CD.

o Modern Ethernet (10Base-T, 100Base-TX, 1000Base-T,


10GbE, 40GbE, 100GbE):

 Topology: Primarily uses Star topology with switches as


central devices.

 Medium: Twisted-pair (UTP) and Fiber Optic cables.

 Speed: Has evolved from 10 Mbps to 100 Mbps (Fast


Ethernet), 1 Gbps (Gigabit Ethernet), 10 Gbps (10 Gigabit
Ethernet), and beyond.

 Access Method: Still uses CSMA/CD in half-duplex mode


(e.g., if a hub is used, but hubs are rare). In modern
switched Ethernet, full-duplex communication is dominant,
and CSMA/CD is largely bypassed because collisions are
eliminated at the switch port.

 Key Characteristics:

o Frame Format: Defines a standard frame format for


encapsulating data (Preamble, Start Frame Delimiter, Destination
MAC, Source MAC, Length/Type, Data, Pad, Frame Check
Sequence (CRC)).

o MAC Addressing: Uses 48-bit (6-byte) physical addresses (MAC


addresses) for unique identification of network interfaces.

o Reliability: Ethernet itself is inherently unreliable at the data


link layer (connectionless, best-effort delivery of frames).
Reliability (error recovery, flow control) is primarily handled by
higher layers (e.g., TCP at the Transport Layer).

o Full-Duplex Operation: Modern switches allow simultaneous


sending and receiving, eliminating collisions on individual links.

 Types (common examples):

o 10Base-T: 10 Mbps over UTP (Cat 3 or higher), max 100m.

o 100Base-TX (Fast Ethernet): 100 Mbps over UTP (Cat 5 or


higher), max 100m. Uses 4B/5B encoding.
Hamza Zahoor What's App 0341-8377-917

o 1000Base-T (Gigabit Ethernet): 1 Gbps over UTP (Cat 5e or


higher), max 100m. Uses advanced encoding (PAM-5).

o 1000Base-LX/SX (Gigabit Fiber): 1 Gbps over fiber optic (LX


for long-wavelength/SMF, SX for short-wavelength/MMF).

o 10 Gigabit Ethernet (10GbE): Over fiber or specialized copper,


widely used in data centers and backbone.

7. Wireless LAN (Wi-Fi)

 Definition: Wireless Local Area Network (WLAN), commonly known as


Wi-Fi, is a technology that allows devices to connect to a network and
the Internet using radio waves. It is defined by the IEEE 802.11
family of standards.

 Components:

o Wireless Access Point (WAP/AP): A central device that


connects wireless devices to a wired network. Acts as a bridge.

o Wireless NICs: Adapters in client devices (laptops,


smartphones) that enable wireless communication.

 Key Characteristics:

o Medium: Radio waves (unguided media).

o Topology: Typically a Star topology, with the AP as the central


hub.

o Access Method: CSMA/CA (Carrier Sense Multiple Access


with Collision Avoidance). Due to the "hidden terminal"
problem and difficulty of detecting collisions in wireless, Wi-Fi
avoids collisions rather than detecting them.

 RTS/CTS (Request to Send/Clear to Send): Optional


mechanism to reserve the channel, especially for hidden
terminals.

 ACKs: All data frames require an ACK to confirm successful


reception. If no ACK, assume loss and retransmit.

 Interframe Space (IFS): Used to prioritize access to the


medium.
Hamza Zahoor What's App 0341-8377-917

o Half-Duplex: Most Wi-Fi transceivers are half-duplex (cannot


transmit and receive simultaneously on the same frequency).

o Mobility: Allows users to roam within the coverage area while


maintaining connectivity.

 IEEE 802.11 Standards (Evolution):

o 802.11b (1999): 11 Mbps, 2.4 GHz band.

o 802.11a (1999): 54 Mbps, 5 GHz band.

o 802.11g (2003): 54 Mbps, 2.4 GHz band (backward compatible


with 802.11b).

o 802.11n (Wi-Fi 4, 2009): Up to 600 Mbps, 2.4/5 GHz bands.


Introduced MIMO (Multiple-Input, Multiple-Output) for spatial
multiplexing.

o 802.11ac (Wi-Fi 5, 2013): Up to Gbps speeds, 5 GHz band.


Enhanced MIMO, wider channels.

o 802.11ax (Wi-Fi 6, 2019): Up to 9.6 Gbps, 2.4/5 GHz bands.


Introduced OFDMA (Orthogonal Frequency Division Multiple
Access) for multi-user efficiency, TWT (Target Wake Time) for
power saving.

o 802.11be (Wi-Fi 7, upcoming): Even higher speeds, use of 6


GHz band, further enhancements.

 Security: WEP (obsolete), WPA, WPA2 (most common), WPA3.


Encryption and authentication are critical due to the broadcast nature
of wireless.

Week 9: Network Layer: Logical Addressing and Internetworking

1. Network Layer: Logical Addressing

 Definition: The Network Layer (Layer 3) in the OSI model (and the
Internet Layer in TCP/IP) is primarily responsible for logical addressing
and routing packets from a source host to a destination host across
possibly multiple different networks. It handles the end-to-end delivery
of packets.

 Logical Addressing:
Hamza Zahoor What's App 0341-8377-917

o Concept: To enable communication across diverse networks, a


universal addressing scheme independent of the underlying
physical network technology is required. This is called logical
addressing.

o IP Address (Internet Protocol Address): The primary logical


address used in the Internet. Unlike physical (MAC) addresses
which are flat and assigned by manufacturers, IP addresses are
hierarchical and assigned by network administrators (or ISPs).

o Hierarchy: An IP address typically consists of two parts: a


network ID and a host ID. The network ID identifies the specific
network segment, and the host ID identifies a particular device
within that segment. This hierarchy is crucial for efficient routing.

o Role in Routing: Routers use the network ID portion of an IP


address to determine which network segment a packet is
destined for, and then forward the packet accordingly.

2. IPv4 Addressing

 Definition: Internet Protocol version 4 (IPv4) is the current


dominant version of the Internet Protocol. It uses a 32-bit logical
address.

 Address Format:

o A 32-bit binary number, usually represented in dotted-decimal


notation (four decimal numbers, each from 0-255, separated by
dots).

o Example: 192.168.1.10

 Address Classes (Classful Addressing - Historical but important


for understanding):

o Originally, IPv4 addresses were divided into classes (A, B, C, D, E)


based on the first few bits of the address, which determined the
default network and host portions.

o Class A: First bit 0. Network ID = first 8 bits. Large networks.


(e.g., 0.0.0.0 to 127.255.255.255)

o Class B: First two bits 10. Network ID = first 16 bits. Medium


networks. (e.g., 128.0.0.0 to 191.255.255.255)
Hamza Zahoor What's App 0341-8377-917

o Class C: First three bits 110. Network ID = first 24 bits. Small


networks. (e.g., 192.0.0.0 to 223.255.255.255)

o Class D: Multicast addresses.

o Class E: Experimental.

o Limitations of Classful Addressing: Inefficient use of address


space (e.g., a Class B network uses 65,534 addresses even if
only 200 hosts are needed), led to exhaustion of IPv4 addresses.

 Classless Addressing (CIDR - Classless Inter-Domain Routing):

o Definition: The modern approach to IPv4 addressing, which has


largely replaced classful addressing. It uses a subnet mask to
explicitly define the network and host portion of an IP address,
rather than relying on inherent class boundaries.

o CIDR Notation: An IP address followed by a slash and a number


(e.g., 192.168.1.0/24). The number after the slash indicates the
number of bits in the network prefix (or subnet mask).

o Subnet Mask: A 32-bit number that identifies the network


portion of an IP address. It has 1s for the network bits and 0s for
the host bits.

 Example: For 192.168.1.0/24, the subnet mask is


255.255.255.0 (which is
11111111.11111111.11111111.00000000 in binary).

o Advantages: More efficient use of IP address space, supports


flexible network sizing, enables hierarchical routing.

 Special IPv4 Addresses:

o Network Address: All host bits are 0. Identifies the network


itself. (e.g., 192.168.1.0/24)

o Broadcast Address: All host bits are 1. Used to send data to all
hosts on a specific network. (e.g., 192.168.1.255/24)

o Loopback Address: 127.0.0.1 (or 127.0.0.0/8). Used for testing


network stack on a local machine.

o Private IP Addresses (RFC 1918):

 Ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.


Hamza Zahoor What's App 0341-8377-917

 Purpose: Reserved for use within private networks (LANs).


They are not routable on the public Internet.

 NAT (Network Address Translation): Used to translate


private IP addresses to public IP addresses when devices in
a private network need to access the Internet.

 IPv4 Address Exhaustion: The primary reason for the development


of IPv6, as the 32-bit address space was insufficient for the growing
number of internet-connected devices.

3. IPv6 Addressing

 Definition: Internet Protocol version 6 (IPv6) is the next


generation of the Internet Protocol, designed to replace IPv4. Its
primary motivation was to address the IPv4 address exhaustion
problem.

 Address Format:

o A 128-bit logical address.

o Represented in hexadecimal notation, grouped into eight 16-


bit segments, separated by colons.

o Example: 2001:0DB8:85A3:0000:0000:8A2E:0370:7334

o Simplification Rules:

 Leading zeros in any 16-bit segment can be omitted (e.g.,


0000 becomes 0).

 A single contiguous sequence of all-zero segments can be


replaced by a double colon :: (can only be used once in an
address).

 Example (simplified): 2001:DB8:85A3::8A2E:370:7334

 Advantages over IPv4:

o Vastly Larger Address Space: 2128 addresses provides an


essentially unlimited number of addresses for the foreseeable
future.

o Simplified Header: More efficient processing by routers due to


a streamlined header with fewer fields.
Hamza Zahoor What's App 0341-8377-917

o Improved Security: IPSec (IP Security) is built-in and


mandatory (though often selectively applied) for IPv6, providing
authentication and encryption.

o Auto-configuration: Supports stateless auto-configuration


(SLAAC), allowing devices to automatically generate their own IP
addresses.

o Better Support for Mobility: Designed with mobility in mind.

o No Broadcasts: Replaced by multicast (to groups) and anycast


(to closest of a group), reducing network overhead.

 Types of IPv6 Addresses:

o Unicast Address: Identifies a single network interface.

 Global Unicast: Globally unique, routable on the Internet


(like public IPv4). Starts with 2000::/3.

 Link-Local: Used for communication only within a single


local network segment (like APIPA for IPv4). Starts with
FE80::/10. Not routable.

 Unique Local: Routable within a private network, not


routable on the global Internet (like private IPv4). Starts
with FC00::/7.

o Multicast Address: Identifies a group of interfaces. Packets


sent to a multicast address are delivered to all interfaces in the
group. Starts with FF00::/8.

o Anycast Address: Identifies a group of interfaces, but packets


sent to an anycast address are delivered to the closest interface
in the group (based on routing protocols).

o Loopback Address: ::1

o Unspecified Address: :: (all zeros), used as a source address


when a device doesn't have an IP address yet.

 Transition from IPv4 to IPv6:

o Dual Stack: Devices run both IPv4 and IPv6 protocol stacks
simultaneously.
Hamza Zahoor What's App 0341-8377-917

o Tunneling: IPv6 packets are encapsulated within IPv4 packets to


traverse IPv4-only networks.

o Translation (NAT64): Translates between IPv6 and IPv4


addresses.

4. Internetworking and Subnetting

 Internetworking:

o Definition: The process of connecting disparate networks (LANs,


WANs) to create a larger, unified network. The Internet is the
quintessential example of internetworking.

o Role of IP: The Internet Protocol (IP) is the key protocol that
enables internetworking by providing a universal logical
addressing scheme and routing capabilities across different
physical network technologies.

o Role of Routers: Routers are the primary devices that perform


internetworking by forwarding packets between different
networks based on their IP addresses.

 Subnetting:

o Definition: The practice of dividing a single large network (a


single IP address range) into smaller, logical subnetworks
(subnets). Each subnet has its own unique network ID.

o Purpose:

1. Efficient IP Address Utilization: Allows for better


allocation of IP addresses, preventing waste of addresses
from large classful blocks.

2. Reduced Network Congestion: Breaking a large network


into smaller subnets reduces the size of broadcast
domains. Broadcasts are contained within their subnet,
leading to less unnecessary traffic on other segments.

3. Improved Network Performance: Smaller broadcast


domains and reduced traffic lead to better overall
performance.
Hamza Zahoor What's App 0341-8377-917

4. Enhanced Security: Subnets can be isolated and


protected by firewalls, providing more granular security
control.

5. Easier Network Management: Simplifies


troubleshooting and administration by segmenting the
network into logical units.

o How it Works:

 Instead of using the default classful subnet mask, the


network administrator "borrows" bits from the host portion
of the IP address to create additional network bits.

 The subnet mask is then used to differentiate between


the network part, the subnet part, and the host part of the
IP address.

 Example: A Class C network 192.168.1.0/24 (default


255.255.255.0) can be subnetted. If you borrow 3 bits from
the host portion, the new subnet mask is 255.255.255.224
(/27). This creates 8 subnets, each capable of supporting
30 hosts.

 Number of subnets = 2number of borrowed bits

 Number of usable hosts per subnet =


2number of host bits−2 (subtracting network and
broadcast addresses)

o VLSM (Variable Length Subnet Masking):

 Definition: An extension of subnetting that allows using


different subnet mask lengths within the same major
network address.

 Purpose: Provides even greater flexibility and efficiency in


IP address allocation by allowing network administrators to
create subnets of varying sizes to match the specific needs
of different network segments.

 Advantage: Minimizes IP address waste, especially critical


in public IP address allocation.

Computer Networks - BS 3rd Semester Notes (Continued)


Hamza Zahoor What's App 0341-8377-917

Week 10: Address Mapping and Routing Protocols

1. Address Mapping

 Definition: Address mapping is the process of translating one type of


address into another. In networking, it primarily involves converting a
logical address (IP address) to a physical address (MAC
address), and vice versa. This translation is crucial because the
Network Layer uses logical addresses for routing, while the Data Link
Layer uses physical addresses for frame delivery on a local network
segment.

 Why it's needed:

o IP addresses are used for end-to-end communication across the


internet.

o MAC addresses are used for hop-by-hop delivery within a local


network segment (LAN).

o When an IP packet needs to be sent to a device on the same


local network, the sender needs to know the destination's MAC
address to put into the Ethernet frame.

o When a router forwards a packet to the next hop on its routing


path, it needs to find the MAC address of that next hop (either
another router or the final destination host if it's on the directly
connected network).

 Key Protocols for Address Mapping:

1. ARP (Address Resolution Protocol):

 Function: Maps an IPv4 address to a MAC address. It's


used by a host to find the MAC address of another host or a
router on the same local network, given its IP address.

 How it works:

1. A source host needs to send an IP packet to a


destination IP address (DIP) on the same LAN, but it
only knows the DIP.

2. The source broadcasts an ARP Request onto the


local network. The request contains the DIP and asks,
"Who has this IP address? Tell me your MAC."
Hamza Zahoor What's App 0341-8377-917

3. The host with the matching IP address replies with an


ARP Reply, containing its MAC address.

4. The source host receives the ARP Reply and caches


the IP-to-MAC mapping in its ARP table for future
use.

 Dynamic Resolution: ARP provides dynamic resolution,


meaning mappings are learned on demand and are
temporary.

2. RARP (Reverse Address Resolution Protocol):

 Function: Maps a MAC address to an IPv4 address. It's


used by diskless workstations or devices that don't have
their IP address pre-configured.

 How it works: A diskless station broadcasts an RARP


Request containing its MAC address, asking an RARP server
for its IP address. The RARP server responds with the
corresponding IP address.

 Status: RARP is largely obsolete, replaced by more flexible


protocols like BOOTP (Bootstrap Protocol) and DHCP
(Dynamic Host Configuration Protocol) for dynamic IP
address assignment.

3. DNS (Domain Name System):

 While not directly mapping IP to MAC, DNS is a crucial


mapping service in networking.

 Function: Maps human-readable domain names (e.g.,


https://www.google.com/search?q=google.com) to IP
addresses (e.g., 142.250.190.46).

 Why it's needed: Users remember names more easily


than numbers. Before a computer can connect to a
website, it must resolve the domain name to an IP address.

2. ICMP Protocol

 Definition: The Internet Control Message Protocol (ICMP) is a


network-layer protocol used by network devices, including routers, to
send error messages and operational information indicating, for
example, that a requested service is not available or that a host or
Hamza Zahoor What's App 0341-8377-917

router could not be reached. It's often considered an integral part of IP,
not a separate protocol running on top of IP.

 Purpose:

o Error Reporting: Informs the source host about problems


encountered in delivering an IP datagram.

o Network Diagnostics: Used for troubleshooting and testing


network connectivity.

 Key Characteristics:

o Unreliable: ICMP messages are sent as IP datagrams and are


therefore unreliable (no guarantee of delivery).

o Not for Applications: ICMP is typically not used directly by user


applications. Instead, it informs the Network layer of issues.

 Common ICMP Message Types (Examples):

1. Destination Unreachable:

 Purpose: Sent by a router when it cannot deliver a


datagram to its destination.

 Codes: Indicate specific reasons (e.g., "network


unreachable," "host unreachable," "port unreachable,"
"fragmentation needed and DF bit set").

 Example: If you try to connect to a server that is offline,


your router might send you an ICMP Destination
Unreachable message.

2. Time Exceeded (TTL Exceeded):

 Purpose: Sent by a router when the Time-to-Live (TTL)


field of an IP datagram reaches zero. This prevents packets
from looping indefinitely in the network.

 Example: The traceroute (or tracert) command uses ICMP


Time Exceeded messages to map the path a packet takes
to a destination.

3. Redirect:
Hamza Zahoor What's App 0341-8377-917

 Purpose: Sent by a router to a host on its directly


connected network, informing the host about a better
(shorter) route to a specific destination.

 Example: If a host sends packets to Router A, but Router A


knows Router B is a more direct path to the destination,
Router A can send an ICMP Redirect to the host.

4. Echo Request/Reply (Ping):

 Purpose: Used to test connectivity and measure round-


trip time between two hosts.

 ping command: Sends an ICMP Echo Request; if the


destination is reachable, it sends an ICMP Echo Reply. This
is one of the most common network diagnostic tools.

5. Source Quench (Deprecated):

 Historically used to tell a sender to slow down its


transmission rate due to congestion. Largely replaced by
TCP's congestion control mechanisms.

3. Routing Protocol

 Definition: Routing protocols are sets of rules and algorithms that


routers use to exchange routing information with each other. This
information allows routers to build and maintain routing tables, which
contain the paths (routes) to various network destinations and
determine the best path for forwarding IP packets.

 Purpose: To enable routers to learn about network topologies,


available paths, and the "cost" (metric) associated with those paths, so
they can make informed decisions about where to send packets to
reach their ultimate destination efficiently.

 Key Concepts:

o Routing Table: A database on a router that stores information


about known network destinations and the next-hop router (or
directly connected interface) to reach those destinations.

o Metric: A value used by routing protocols to determine the


"best" path to a destination. Lower metrics typically indicate
better paths. Common metrics include hop count, bandwidth,
delay, load, cost, or a combination.
Hamza Zahoor What's App 0341-8377-917

o Convergence: The state where all routers in a network have


consistent and up-to-date routing tables. Faster convergence
means faster network adaptation to changes.

o Autonomous System (AS): A collection of IP networks and


routers under the control of one or more network operators that
presents a common, clearly defined routing policy to the
Internet.

 Categories of Routing Protocols:

1. Interior Gateway Protocols (IGPs):

 Purpose: Used for routing within an Autonomous System


(AS). They focus on finding the best paths within a single
administrative domain.

 Examples:

 RIP (Routing Information Protocol): Distance-


Vector protocol, uses hop count as metric, simpler,
scales poorly for large networks.

 OSPF (Open Shortest Path First): Link-State


protocol, uses cost based on bandwidth, scales well,
faster convergence, more complex.

 EIGRP (Enhanced Interior Gateway Routing


Protocol): Cisco proprietary, hybrid protocol, fast
convergence, complex metrics.

2. Exterior Gateway Protocols (EGPs):

 Purpose: Used for routing between different Autonomous


Systems (ASs). They exchange routing information
(reachability information for entire networks/ASs) and
enforce routing policies across different administrative
domains.

 Example:

 BGP (Border Gateway Protocol): The only EGP


used on the Internet. It's a Path-Vector protocol. BGP
routers exchange reachability information and policy
rules rather than just metrics. It's highly complex and
crucial for the Internet's global routing.
Hamza Zahoor What's App 0341-8377-917

Week 11: Unicast Routing, Transport Layer (UDP, TCP)

1. Unicast Routing Protocol

 Definition: Unicast routing protocols are specific types of routing


protocols (both IGPs and EGPs) that are designed to find paths for
unicast traffic. Unicast communication involves sending data from a
single source to a single destination.

 Goal: To determine the single best path for a packet to travel from a
source host to a single destination host across the network.

 How they work:

o Routers running unicast routing protocols exchange information


about network prefixes (IP address ranges) and the metrics to
reach them.

o They use algorithms (e.g., Distance-Vector, Link-State) to


calculate the shortest or most preferred path to each destination.

o This information is then populated into the router's IP routing


table.

 Types of Unicast Routing Protocols (Revisiting from Week 10


with more detail):

1. Distance-Vector Routing Protocols:

 Concept: Each router periodically exchanges its entire


routing table with its directly connected neighbors. Routers
then update their own tables based on the information
received, always choosing the path with the lowest
"distance" (metric).

 "Routing by rumor": Routers learn routes from their


neighbors' advertisements.

 Metric: Typically hop count (number of routers to reach


destination).

 Advantages: Simple to configure and manage, low


processing overhead.

 Disadvantages:
Hamza Zahoor What's App 0341-8377-917

 Slow Convergence: Takes longer for changes (e.g.,


link failures) to propagate through the network.

 Routing Loops: Prone to routing loops (packets


endlessly circling) if updates are slow or
inconsistencies occur.

 Count-to-Infinity Problem: A serious issue where a


route failure can lead to infinite loops in metrics.

 Example: RIP (Routing Information Protocol)

 Uses hop count (max 15 hops, 16 is unreachable).

 Periodic updates (e.g., every 30 seconds).

 Small networks only.

2. Link-State Routing Protocols:

 Concept: Each router builds a complete "map" or topology


of the entire network. It does this by:

1. Discovering Neighbors: Sends Hello packets to


identify directly connected routers.

2. Exchanging Link-State Advertisements (LSAs):


Each router originates LSAs containing information
about its directly connected links (status, cost) and
sends them to all other routers in the AS (flooding).

3. Building Link-State Database (LSDB): Each


router compiles all received LSAs to form a complete
network topology database.

4. Running SPF (Shortest Path First) Algorithm


(Dijkstra's Algorithm): Each router independently
runs this algorithm on its LSDB to calculate the
shortest path to all other destinations.

5. Populating Routing Table: The calculated best


paths are inserted into the routing table.

 "Routing by map": Each router has a comprehensive


view of the network.

 Metric: Usually cost based on bandwidth.


Hamza Zahoor What's App 0341-8377-917

 Advantages:

 Fast Convergence: Rapidly adapts to network


changes.

 Loop-Free Paths: Algorithm guarantees loop-free


paths.

 Better Scaling: More suitable for large and complex


networks.

 More Robust: Less prone to errors.

 Disadvantages: More complex to configure and manage,


higher processing and memory requirements for routers.

 Example: OSPF (Open Shortest Path First)

 Supports hierarchical routing (areas).

 Uses Dijkstra's algorithm.

 Widely used in large enterprise networks.

3. Path-Vector Routing Protocols:

 Concept: Each router sends updates that include the


destination network prefix and the entire path (sequence of
ASs) that packets must traverse to reach that destination.
Routers make routing decisions based on these paths,
policies, and metrics.

 Metric: Not based on simple hop count or link cost, but on


AS paths and policy decisions.

 Advantages: Highly scalable, provides granular policy


control over routing, prevents routing loops at the AS level
by detecting own AS in path.

 Disadvantages: Very complex to configure and manage,


higher overhead than IGPs.

 Example: BGP (Border Gateway Protocol)

 The routing protocol of the Internet.

 Focuses on inter-AS routing and policy enforcement.

2. Transport Layer: UDP and TCP


Hamza Zahoor What's App 0341-8377-917

 Definition: The Transport Layer (Layer 4) in the OSI model (and the
"Transport Layer" or "Host-to-Host Layer" in TCP/IP) provides end-to-
end communication between processes (applications) running on
different hosts. It handles multiplexing, demultiplexing, and ensures
reliable or unreliable data transfer.

 Key Functions:

1. Process-to-Process Delivery (Port Addressing): Extends


host-to-host delivery (provided by Network Layer) to application-
to-application delivery using port numbers.

2. Multiplexing and Demultiplexing: Allows multiple


applications to share a single network connection.

 Multiplexing: Combining data from multiple application


processes into a single stream for transmission.

 Demultiplexing: Delivering incoming data segments to


the correct application process based on port numbers.

3. Error Control (for TCP): Ensures that all data segments arrive
at the destination correctly and in order.

4. Flow Control (for TCP): Prevents the sender from


overwhelming the receiver.

5. Congestion Control (for TCP): Prevents the network from


becoming overloaded.

 Two Main Transport Layer Protocols:

1. UDP (User Datagram Protocol):

 Type: Connectionless and unreliable protocol.

 "Best-effort" delivery: It sends data without establishing


a connection, acknowledgment, flow control, or error
recovery (beyond basic checksum).

 Segment Header: Minimal overhead (Source Port,


Destination Port, Length, Checksum).

 Advantages:

 Fast: No connection setup, no acknowledgments,


minimal overhead.
Hamza Zahoor What's App 0341-8377-917

 Low Latency: Suitable for real-time applications


where speed is more critical than perfect reliability.

 Simple: Less complex to implement.

 Disadvantages:

 Unreliable: No guaranteed delivery, no order


guarantee, no duplicate protection.

 No Flow Control: Sender can overwhelm receiver.

 No Congestion Control: Can contribute to network


congestion.

 Applications:

 VoIP (Voice over IP), Video Conferencing: Small


data loss is acceptable for perceived continuity.

 Online Gaming: Real-time updates are more


important than guaranteed delivery.

 DNS (Domain Name System): Quick, small queries


and responses.

 SNMP (Simple Network Management Protocol):


Network management.

2. TCP (Transmission Control Protocol):

 Type: Connection-oriented and reliable protocol.

 Guaranteed delivery: Provides full-duplex, reliable,


ordered, and error-checked delivery of data segments.

 Three-way Handshake: Establishes a connection before


data transfer (SYN, SYN-ACK, ACK).

 Flow Control: Uses a sliding window mechanism to


prevent receiver overflow.

 Congestion Control: Dynamically adjusts transmission


rate to prevent network congestion.

 Error Control: Uses sequence numbers,


acknowledgments (ACKs), and retransmissions (ARQ) to
ensure all segments arrive correctly and in order.
Hamza Zahoor What's App 0341-8377-917

 Segment Header: Much larger header than UDP,


containing sequence numbers, ACK numbers, window size,
flags (SYN, ACK, FIN, RST, PSH, URG), etc.

 Advantages:

 Reliable Data Transfer: Guarantees delivery and


order.

 Flow Control: Prevents receiver buffer overflow.

 Congestion Control: Adapts to network conditions.

 Disadvantages:

 Higher Overhead: Connection setup,


acknowledgments, and larger header add overhead.

 Slower: Due to reliability mechanisms.

 Applications:

 HTTP/HTTPS (Web Browse): Ensures web pages


load completely.

 FTP (File Transfer Protocol): Guarantees file


integrity.

 SMTP (Email): Ensures emails are delivered


correctly.

 SSH (Secure Shell): Reliable remote access.

3. Process-to-Process Delivery

 Definition: Refers to the Transport Layer's ability to deliver a message


from a specific application process on the source host to a specific
application process on the destination host. The Network Layer (IP)
handles host-to-host delivery, but it doesn't know which application on
a host should receive the data.

 Role of Port Numbers:

o Concept: The Transport Layer uses port numbers (16-bit


integers) to identify specific application processes running on a
host.

o Client/Server Model:
Hamza Zahoor What's App 0341-8377-917

 Server Processes: Typically use well-known port


numbers (0-1023) assigned by IANA (Internet Assigned
Numbers Authority). E.g., HTTP (port 80), HTTPS (port 443),
FTP (port 21/20), SMTP (port 25), DNS (port 53).

 Client Processes: Typically use ephemeral


(dynamic/private) port numbers (1024-65535)
assigned randomly by the operating system for the
duration of the communication.

o Socket Address: A combination of an IP address and a port


number (e.g., 192.168.1.10:80). This uniquely identifies a
specific process on a specific host for communication.

 Multiplexing and Demultiplexing (Revisit):

o Multiplexing (at Sender): The Transport Layer takes data from


multiple application processes (identified by their source port
numbers) and combines them into segments, adding the
appropriate source and destination port numbers to the segment
header.

o Demultiplexing (at Receiver): The Transport Layer at the


destination host receives segments, reads the destination port
number in the header, and delivers the segment's data payload
to the correct application process listening on that port.

4. User Datagram Protocol (UDP)

 Definition: Already covered above as one of the two main Transport


Layer protocols.

 Key points for notes:

o Connectionless: No setup, no teardown.

o Unreliable: No guarantees of delivery, order, or duplication.

o Minimal Overhead: Small header (8 bytes).

o Checksum: Optional checksum for error detection, but no


recovery mechanism.

o No Flow Control, No Congestion Control: Sender sends data


as fast as it can.
Hamza Zahoor What's App 0341-8377-917

o Suitable for: Applications where speed and low overhead are


more important than reliability, and where occasional data loss is
acceptable or handled by the application layer.

5. TCP (Transmission Control Protocol)

 Definition: Already covered above as one of the two main Transport


Layer protocols.

 Key points for notes:

o Connection-Oriented: Establishes, maintains, and terminates


connections using a three-way handshake.

o Reliable: Guarantees delivery of all segments.

 Sequence Numbers: Orders segments and detects


missing/duplicate segments.

 Acknowledgments (ACKs): Confirms receipt of data.

 Retransmission: Resends unacknowledged segments.

o Full-Duplex: Allows simultaneous bidirectional data transfer.

o Stream-Oriented: Presents data to the application as a


continuous stream of bytes, hiding segmentation details.

o Flow Control (Sliding Window): Prevents receiver buffer


overflow.

o Congestion Control: Prevents network congestion (slow start,


congestion avoidance, fast retransmit, fast recovery).

o Error Control: Through checksums and ARQ.

o Higher Overhead: Due to connection management and


reliability mechanisms.

o Suitable for: Applications requiring high reliability and ordered


data delivery, where some delay is acceptable.

Week 12: Congestion and Flow Control

1. Congestion
Hamza Zahoor What's App 0341-8377-917

 Definition: Network congestion occurs when the demand for network


resources (such as bandwidth, router buffer space, or CPU processing
power) exceeds the available capacity. This leads to degraded network
performance.

 Symptoms of Congestion:

1. Increased Delay (Latency): Packets spend more time waiting


in router queues (queuing delay).

2. Increased Packet Loss: Router buffers overflow, causing


routers to drop incoming packets.

3. Reduced Throughput: The effective data rate through the


network decreases, even though the sending rate might be high.

4. Retransmissions: Packet loss triggers retransmissions, which


further adds to the traffic and exacerbates congestion (a positive
feedback loop).

5. Jitter: Variability in delay increases.

 Causes of Congestion:

1. Insufficient Bandwidth: The capacity of a link is too low for the


aggregate traffic.

2. Limited Buffer Space: Routers have finite memory to buffer


packets.

3. Slow Processing Routers: Routers cannot process packets fast


enough, leading to queue buildup.

4. Excessive Traffic: Too many senders trying to transmit data


simultaneously.

5. Hot Spots: A specific router or link becomes a bottleneck due to


concentrated traffic.

6. Incorrect Routing: Packets might be routed suboptimally,


leading to certain links being overloaded.

 Congestion Collapse: A severe state of network congestion where


network throughput drops to nearly zero due to an endless cycle of
retransmissions filling the network. This was a significant problem in
the early Internet before robust congestion control mechanisms were
developed.
Hamza Zahoor What's App 0341-8377-917

2. Congestion Control

 Definition: Congestion control refers to the mechanisms and


algorithms used to prevent or reduce network congestion and ensure
network stability. Its goal is to allow the network to operate efficiently
at high load and to recover gracefully from periods of overload. It is
primarily implemented at the Transport Layer (TCP) and also
involves network layer components.

 Distinction from Flow Control:

o Flow Control: Prevents a fast sender from overwhelming a


slow receiver (point-to-point, end-to-end between two hosts).

o Congestion Control: Prevents a fast sender from


overwhelming the network (many-to-one, from sender to
network).

 Approaches to Congestion Control:

1. Open-Loop Congestion Control (Prevention):

 Concept: Policies are applied to prevent congestion from


occurring in the first place, without relying on feedback
from the network about current congestion levels.

 Methods:

 Retransmission Policies: Design retransmission


timers carefully.

 Window Policies: Use appropriate window sizes


(e.g., in TCP).

 Admission Control: Refuse new connections if the


network is likely to become congested.

 Routing Algorithms: Choose routes that avoid


congested areas.

 Scheduling: Prioritize packets at routers (e.g., QoS).

 Layer: Can be implemented at various layers.

2. Closed-Loop Congestion Control (Remedy):


Hamza Zahoor What's App 0341-8377-917

 Concept: Network elements (routers or receivers) detect


congestion and provide feedback to the senders, which
then reduce their transmission rate.

 Methods:

 Backpressure: A congested node informs the


previous node to slow down. (Not typically used in IP
networks).

 Choke Packet: A router experiencing congestion


sends a "choke packet" (e.g., ICMP Source Quench,
though deprecated) back to the source to tell it to
reduce its rate.

 Implicit Signaling (TCP Congestion Control):


TCP senders infer congestion from network events
(e.g., packet loss or increased RTT) and adjust their
sending rate. This is the dominant method for the
Internet.

 TCP Congestion Control Mechanisms (Key Algorithms): TCP


implements several intertwined algorithms to manage congestion:

1. Slow Start:

 Concept: When a TCP connection begins (or after a


prolonged idle period/timeout), the sender starts with a
very small congestion window (cwnd) (e.g., 1 or 2
segments). It increases cwnd exponentially (by 1 segment
for each ACK received) until a threshold (ssthresh) is
reached or loss occurs.

 Purpose: To quickly determine the network's capacity


without overwhelming it immediately.

2. Congestion Avoidance:

 Concept: Once cwnd reaches ssthresh, TCP switches to a


linear increase strategy. cwnd is increased by one segment
for each Round-Trip Time (RTT) (or every time all
segments in the current window are acknowledged).

 Purpose: To probe for additional bandwidth cautiously and


avoid creating new congestion.
Hamza Zahoor What's App 0341-8377-917

3. Fast Retransmit:

 Concept: If a receiver gets three duplicate ACKs for a


segment, it indicates that the next expected segment was
likely lost (rather than waiting for a timeout). The sender
immediately retransmits the missing segment without
waiting for a timeout.

 Purpose: To recover from single packet losses quickly


without invoking Slow Start.

4. Fast Recovery:

 Concept: After a Fast Retransmit, TCP enters Fast


Recovery (bypassing Slow Start) and reduces its cwnd by
half, then resumes congestion avoidance.

 Purpose: To continue data transmission quickly after a


minor loss event. <!-- end list -->

o Timeout: If a retransmission timeout occurs (indicating severe


congestion), TCP resets cwnd to 1 and restarts Slow Start.

3. Flow Control

 Definition: Flow control is a mechanism that prevents a sender from


transmitting data at a rate faster than the receiver can process and
absorb it. It ensures that the receiver's buffer does not overflow,
leading to data loss. Flow control is primarily a point-to-point (or
end-to-end between two hosts) mechanism.

 Distinction from Congestion Control:

o Flow Control: Deals with the capacity of the receiver's buffer.

o Congestion Control: Deals with the capacity of the network


path between sender and receiver.

 Mechanism (TCP Flow Control - Sliding Window):

o TCP uses a sliding window protocol to implement flow control.

o Receiver Window (rwnd): The receiver advertises its available


buffer space (its "receiver window") to the sender in TCP ACK
segments.
Hamza Zahoor What's App 0341-8377-917

o Sender's Window: The sender's effective window size is the


minimum of its congestion window (cwnd) (from congestion
control) and the receiver window (rwnd) (from flow control).
This ensures the sender doesn't overload either the network or
the receiver.

o How it works:

1. The receiver tells the sender how many bytes it can


currently receive (the rwnd value).

2. The sender will not send more data than allowed by the
rwnd.

3. As the receiver processes data from its buffer, its rwnd


increases, and it advertises the new, larger window size to
the sender, allowing the sender to transmit more data.

o Zero Window: If the receiver's buffer becomes full, it advertises


a rwnd of zero. The sender then stops sending data until the
receiver advertises a non-zero window. This prevents buffer
overflow at the receiver.

 Advantages:

o Prevents receiver buffer overflow.

o Ensures reliable data transfer by managing the rate between two


communicating endpoints.

 Disadvantages: Can lead to reduced throughput if the receiver is


consistently slow or if its advertised window is too small.

Computer Networks - BS 3rd Semester Notes (Continued)

Week 13: Application Layer Protocols - Web & Email

1. Application Layer (Revisited)

 Definition: The Application Layer (Layer 7) is the topmost layer in


the OSI model (and the combined Application Layer in TCP/IP). It
provides network services directly to end-user applications. It's the
layer users interact with, enabling various network applications to
function.

 Role:
Hamza Zahoor What's App 0341-8377-917

o Provides user interfaces and services to access network


resources.

o Handles data formatting, encryption, and compression (often


relying on Presentation Layer functions, which are often
integrated into the Application Layer in TCP/IP).

o Interacts with the Transport Layer (TCP/UDP) to send and receive


data.

 Examples of Protocols: HTTP, HTTPS, FTP, SMTP, POP3, IMAP, DNS,


SSH, Telnet, SNMP.

2. HTTP (Hypertext Transfer Protocol)

 Definition: The foundation of data communication for the World Wide


Web. It's an Application Layer protocol for transmitting hypermedia
documents, such as HTML.

 Characteristics:

o Client-Server Model: A web browser (client) sends requests to


a web server, and the server sends responses back.

o Stateless: Each request from a client to the server is treated as


an independent transaction. The server does not retain
information about past client requests.

 Implication: For persistent information (like shopping


carts), mechanisms like cookies (client-side data) or
session IDs (server-side data linked to a cookie) are used.

o Connectionless (originally): In HTTP 1.0, a new TCP


connection was established for each request/response pair and
then closed.

o Persistent Connections (HTTP 1.1 and later): Allows


multiple requests and responses to be sent over a single,
persistent TCP connection, reducing overhead.

o Port: Default port is 80 (for non-secure HTTP).

 HTTP Message Types:

o Request Message: Sent by the client to the server.

 Components:
Hamza Zahoor What's App 0341-8377-917

 Request Line: Method (GET, POST, HEAD, PUT,


DELETE, etc.), URL, HTTP Version.

 Headers: Provide additional information (e.g., Host,


User-Agent, Accept-Language, Connection).

 Body (optional): Contains data for methods like


POST (e.g., form data).

o Response Message: Sent by the server to the client.

 Components:

 Status Line: HTTP Version, Status Code (e.g., 200


OK, 404 Not Found, 500 Internal Server Error),
Reason Phrase.

 Headers: Provide additional information (e.g.,


Server, Content-Type, Content-Length, Set-Cookie).

 Body (optional): Contains the requested resource


(e.g., HTML page, image).

 HTTPS (Hypertext Transfer Protocol Secure):

o Definition: HTTP operating over SSL/TLS (Secure Sockets


Layer/Transport Layer Security). It encrypts the
communication between the client and server.

o Purpose: Provides confidentiality (prevents eavesdropping),


integrity (prevents tampering), and authentication (verifies
server identity, sometimes client identity).

o Port: Default port is 443.

o Key Concept: Uses public-key cryptography (for initial


handshake and key exchange) and symmetric-key cryptography
(for bulk data encryption). Relies on digital certificates issued by
Certificate Authorities (CAs) to verify server identity.

3. FTP (File Transfer Protocol)

 Definition: An Application Layer protocol used for transferring files


between a client and a server on a computer network.

 Characteristics:
Hamza Zahoor What's App 0341-8377-917

o Client-Server Model: Client initiates connections and requests


file transfers from the server.

o Two TCP Connections: FTP uses two separate TCP connections:

1. Control Connection (Port 21): Used for sending


commands (e.g., login, list directory, get file, put file) and
receiving responses. This connection remains open
throughout the FTP session.

2. Data Connection (Port 20 by default for active mode,


or dynamically assigned for passive mode): Used for
the actual transfer of file data. This connection is opened
and closed for each file transfer.

o Active Mode vs. Passive Mode:

 Active Mode: Client sends its IP and port to the server via
the control connection. The server then initiates the data
connection from its port 20 to the client's specified port.
Often problematic with firewalls.

 Passive Mode (preferred): Client sends a PASV


command to the server. The server then tells the client
which arbitrary port to connect to for the data connection.
The client initiates both connections. More firewall-friendly.

 Security: FTP transmits credentials (username/password) and data in


plaintext, making it insecure.

o Secure Alternatives: SFTP (SSH File Transfer Protocol) or


FTPS (FTP over SSL/TLS) are used for secure file transfer.

 Use Cases: Uploading/downloading files to/from web servers,


transferring large files.

4. Electronic Mail (Email) Protocols

 Definition: A suite of Application Layer protocols that enable the


sending, receiving, and managing of electronic messages.

 Components of Email System:

o Mail User Agent (MUA): The email client software (e.g.,


Outlook, Gmail web interface) that users interact with.
Hamza Zahoor What's App 0341-8377-917

o Mail Transfer Agent (MTA): Mail servers (e.g., Postfix,


Exchange) that transfer emails between different email servers.

o Mail Access Agent (MAA): Protocols used by MUAs to retrieve


emails from their local mail server.

 Key Email Protocols:

1. SMTP (Simple Mail Transfer Protocol):

 Purpose: Primarily used for sending emails from a client


to a mail server, or between mail servers.

 Characteristics:

 Uses TCP Port 25 for server-to-server


communication.

 Uses TCP Port 587 (submission port) for client-to-


server sending (with authentication).

 Push Protocol: Client or server pushes the email to


the next hop.

 Originally designed for text-only messages; MIME


(Multipurpose Internet Mail Extensions) extended it
for multimedia attachments.

 Operation: A series of commands and responses between


client/server (e.g., HELO, MAIL FROM, RCPT TO, DATA,
QUIT).

2. POP3 (Post Office Protocol version 3):

 Purpose: Used by an MUA to retrieve emails from a


mail server.

 Characteristics:

 Uses TCP Port 110 (secure: 995 for POP3S).

 "Store and Forward" Model: By default, emails are


downloaded to the client and deleted from the
server. This is why it's called "post office" – you pick
up your mail and it's gone.

 Simple: Limited features.


Hamza Zahoor What's App 0341-8377-917

 Disadvantage: Hard to synchronize email across multiple


devices.

3. IMAP (Internet Message Access Protocol):

 Purpose: Used by an MUA to access and manage


emails on a mail server.

 Characteristics:

 Uses TCP Port 143 (secure: 993 for IMAPS).

 "Sync" Model: Emails are kept on the server by


default. Clients synchronize their view with the
server.

 Advanced Features: Allows creating folders,


searching, marking messages as read/unread, and
accessing emails from multiple devices.

 Advantage: Ideal for users who access email from various


devices.

Week 14: Application Layer Protocols - DNS & DHCP

1. DNS (Domain Name System)

 Definition: A hierarchical and decentralized naming system for


computers, services, or any resource connected to the Internet or a
private network. It translates human-readable domain names (like
www.example.com) into machine-readable IP addresses (like
192.0.2.1 or 2001:db8::1).

 Purpose: Makes the Internet easier to use by allowing users to


remember simple names instead of complex numerical IP addresses.
Essential for almost all Internet services.

 Client-Server Model:

o DNS Resolver (Client): Typically built into operating systems


and used by applications. It sends DNS queries.

o DNS Servers: Store and provide DNS information.

 Hierarchical Structure: DNS is organized as a tree structure with


different levels of domains.
Hamza Zahoor What's App 0341-8377-917

1. Root Servers: At the top of the hierarchy. There are 13 logical


root server addresses globally. They know where to find TLD
servers.

2. TLD (Top-Level Domain) Servers: Manage domains


like .com, .org, .net, .edu, .gov, and country code TLDs
like .pk, .uk. They know where to find authoritative name servers.

3. Authoritative Name Servers: Store the actual DNS records for


specific domain names (e.g., example.com). They are the final
authority for a domain.

 How DNS Resolution Works (Recursive Query Example):

1. A user types www.example.com into a browser.

2. The user's computer (DNS resolver) checks its local DNS cache. If
found, it uses that.

3. If not in cache, the resolver sends a recursive query to its


configured local DNS server (e.g., ISP's DNS server).

4. The local DNS server:

 Checks its cache.

 If not found, it queries a root server. The root server


responds with the IP address of the .com TLD server.

 The local DNS server queries the .com TLD server. The TLD
server responds with the IP address of example.com's
authoritative name server.

 The local DNS server queries the example.com


authoritative name server. This server responds with the IP
address of www.example.com.

5. The local DNS server returns the IP address to the user's


computer, and also caches the record.

6. The user's computer then uses this IP address to connect to


www.example.com.

 DNS Record Types (Resource Records):

o A record: Maps a domain name to an IPv4 address.


(example.com -> 192.0.2.1)
Hamza Zahoor What's App 0341-8377-917

o AAAA record: Maps a domain name to an IPv6 address.


(example.com -> 2001:db8::1)

o CNAME record: Canonical Name. Creates an alias from one


domain name to another. (www.example.com -> example.com)

o MX record: Mail Exchange. Specifies the mail servers


responsible for handling email for a domain.

o NS record: Name Server. Lists the authoritative name servers


for a domain.

o PTR record: Pointer record. Maps an IP address to a domain


name (for reverse DNS lookups).

 Protocol: Uses UDP Port 53 for standard queries (for speed). Uses
TCP Port 53 for zone transfers and larger responses.

2. DHCP (Dynamic Host Configuration Protocol)

 Definition: An Application Layer protocol used to dynamically


assign IP addresses and other network configuration parameters
(subnet mask, default gateway, DNS server) to devices (hosts) on a
network.

 Purpose: Automates the process of network configuration for new and


existing devices, reducing manual effort and preventing IP address
conflicts.

 Client-Server Model:

o DHCP Server: Manages a pool of IP addresses and configuration


information.

o DHCP Client: A device requesting network configuration (e.g.,


your laptop, smartphone, smart TV).

 DHCP Operation (DORA Process):

1. Discover (Client Broadcast): When a DHCP client starts up or


needs an IP address, it broadcasts a DHCP Discover message
on the local network (since it doesn't have an IP address yet to
send a unicast).

2. Offer (Server Broadcast/Unicast): Any DHCP server on the


network that receives the Discover message responds with a
Hamza Zahoor What's App 0341-8377-917

DHCP Offer message, proposing an available IP address and


other configuration parameters.

3. Request (Client Broadcast): The client may receive multiple


offers. It selects one offer (typically the first one it receives or a
preferred one) and broadcasts a DHCP Request message,
formally requesting the offered IP address from that specific
server. This broadcast also informs other DHCP servers that their
offers were not accepted.

4. Acknowledge (Server Unicast): The chosen DHCP server


sends a DHCP ACK message to the client, confirming the IP
address lease and providing all the final configuration
parameters. The client then configures its network interface with
these details.

 DHCP Lease:

o IP addresses are usually assigned for a specific period (a "lease


time").

o Clients attempt to renew their lease before it expires. If renewal


fails, they must re-enter the DORA process.

 Benefits:

o Simplified Network Management: Automates IP address


assignment.

o Reduced Configuration Errors: Eliminates manual


misconfigurations.

o Efficient IP Address Management: Allows for reuse of IP


addresses when devices disconnect.

o Supports Mobility: Devices can easily get new IP addresses


when moving between networks.

 Port: Uses UDP Port 67 (server) and UDP Port 68 (client).

Week 15: Introduction to Network Security

1. Network Security
Hamza Zahoor What's App 0341-8377-917

 Definition: Network security encompasses the policies, procedures,


and technologies designed to protect a computer network and its data
from unauthorized access, misuse, modification, or destruction. It aims
to ensure the confidentiality, integrity, and availability (CIA
triad) of network resources.

 Key Goals of Network Security (CIA Triad):

1. Confidentiality: Preventing unauthorized disclosure of


information. Only authorized individuals or systems can access
sensitive data. (e.g., encryption)

2. Integrity: Ensuring that data has not been altered or destroyed


in an unauthorized manner. Data remains accurate and
complete. (e.g., hashing, digital signatures)

3. Availability: Ensuring that legitimate users can access


information and resources when needed. Prevents denial of
service. (e.g., redundancy, strong authentication)

 Threats to Network Security:

o Malware: Viruses, worms, Trojan horses, ransomware, spyware.

o Denial of Service (DoS/DDoS) Attacks: Overwhelming a


system to make it unavailable.

o Unauthorized Access: Hacking, brute-force attacks, exploiting


vulnerabilities.

o Data Interception/Eavesdropping: Sniffing network traffic.

o Data Tampering/Modification: Altering data during


transmission or storage.

o Phishing/Social Engineering: Tricking users into revealing


credentials or installing malware.

o Insider Threats: Malicious or negligent actions by internal


personnel.

o Zero-day Exploits: Exploiting previously unknown software


vulnerabilities.

2. Cryptography
Hamza Zahoor What's App 0341-8377-917

 Definition: The practice and study of techniques for secure


communication in the presence of third parties (adversaries). It's the
art of converting data into an unreadable format (encryption) and back
into a readable format (decryption).

 Fundamental Concepts:

1. Encryption: The process of converting plaintext (readable data)


into ciphertext (unreadable, encrypted data) using an encryption
algorithm and a key.

2. Decryption: The process of converting ciphertext back into


plaintext using the decryption algorithm and the correct key.

3. Key: A piece of information (a string of bits) used by the


encryption/decryption algorithm. The security of encryption
largely depends on the secrecy and strength of the key.

 Types of Cryptography:

1. Symmetric-Key Cryptography (Secret-Key Cryptography):

 Concept: Uses the same key for both encryption and


decryption. Both sender and receiver must possess this
shared secret key.

 Algorithms: AES (Advanced Encryption Standard), DES


(Data Encryption Standard), 3DES.

 Advantages: Very fast for large amounts of data,


computationally efficient.

 Disadvantages: Key distribution problem – securely


sharing the key with the other party is challenging.

 Use Cases: Bulk data encryption (e.g., encrypting files,


securing wireless traffic in WPA2).

2. Asymmetric-Key Cryptography (Public-Key Cryptography):

 Concept: Uses a pair of keys: a public key and a


private key.

 Public Key: Can be freely shared with anyone. Used


for encryption and verifying digital signatures.
Hamza Zahoor What's App 0341-8377-917

 Private Key: Must be kept secret by its owner. Used


for decryption and creating digital signatures.

 Algorithms: RSA, Diffie-Hellman, ECC (Elliptic Curve


Cryptography).

 Properties:

 Data encrypted with the public key can only be


decrypted with the corresponding private key.

 Data encrypted with the private key can only be


decrypted with the corresponding public key.

 Advantages: Solves the key distribution problem of


symmetric crypto (public keys can be exchanged openly),
enables digital signatures and non-repudiation.

 Disadvantages: Much slower and computationally


intensive than symmetric-key algorithms.

 Use Cases: Secure key exchange (e.g., during SSL/TLS


handshake), digital signatures, authentication.

3. Digital Signatures

 Definition: A mathematical technique used to validate the


authenticity and integrity of a digital message or document. It's the
digital equivalent of a handwritten signature.

 Purpose:

o Authentication: Verifies the identity of the sender.

o Integrity: Proves that the message has not been altered since it
was signed.

o Non-repudiation: Prevents the sender from denying that they


sent the message.

 How it works (Simplified):

1. Hashing: The sender generates a hash (a fixed-size unique


fingerprint) of the message using a cryptographic hash function
(e.g., SHA-256).
Hamza Zahoor What's App 0341-8377-917

2. Encryption with Private Key: The sender encrypts the hash


value using their own private key. This encrypted hash is the
digital signature.

3. Transmission: The sender sends the original message along


with the digital signature.

4. Verification (at Receiver):

 The receiver decrypts the digital signature using the


sender's public key to retrieve the original hash value.

 The receiver independently computes a hash of the


received message using the same hash function.

 If the two hash values match, the message is deemed


authentic (from the expected sender) and its integrity is
verified (it hasn't been tampered with).

 Relation to Integrity: Cryptographic hash functions are crucial here.


They produce a unique fixed-size output for any given input. Even a
tiny change in the input produces a drastically different hash, allowing
detection of tampering.

4. VPN (Virtual Private Network)

 Definition: A VPN extends a private network across a public network


(like the Internet), enabling users to send and receive data across
shared or public networks as if their computing devices were directly
connected to the private network.

 Concept: Creates a secure, encrypted "tunnel" over an insecure


public network.

 Purpose:

o Confidentiality: Encrypts all traffic within the tunnel, protecting


it from eavesdropping.

o Integrity: Ensures data is not tampered with during transit.

o Authentication: Verifies the identity of the user or device


connecting to the private network.

o Remote Access: Allows remote users to securely access


internal network resources.
Hamza Zahoor What's App 0341-8377-917

o Bypassing Geo-restrictions: Can make it appear as if the user


is in a different geographical location.

 Key Components:

1. VPN Client: Software on the user's device.

2. VPN Server (VPN Concentrator): A dedicated server or router


on the private network that terminates VPN connections.

3. Tunneling Protocols: Encapsulate and encrypt data packets.

 Common VPN Protocols:

o IPSec (Internet Protocol Security): A suite of protocols that


operate at the Network Layer to provide security services
(authentication, integrity, confidentiality) for IP packets. Often
used for site-to-site VPNs and remote access.

o SSL/TLS VPN: Uses SSL/TLS for tunneling. Often browser-based,


providing secure access to specific applications rather than full
network access. (e.g., OpenVPN, AnyConnect).

o PPTP (Point-to-Point Tunneling Protocol): Older, less secure,


often avoided.

o L2TP (Layer 2 Tunneling Protocol): Often combined with


IPSec (L2TP/IPSec) for better security.

 How it works (Simplified):

1. The VPN client initiates a connection to the VPN server.

2. Authentication takes place (e.g., username/password,


certificates).

3. An encrypted tunnel is established between the client and the


server.

4. All network traffic from the client is then encapsulated and


encrypted within this tunnel and sent over the public network.

5. The VPN server decrypts the traffic and forwards it to the


intended destination on the private network.

6. Responses follow the reverse path through the tunnel.

5. Firewalls
Hamza Zahoor What's App 0341-8377-917

 Definition: A network security system that monitors and controls


incoming and outgoing network traffic based on predefined security
rules. It acts as a barrier between a trusted internal network and
untrusted external networks (like the Internet).

 Purpose:

o Filter Traffic: Allow or deny traffic based on criteria (IP


addresses, port numbers, protocols, application types).

o Enforce Security Policies: Implement an organization's access


control policies.

o Prevent Unauthorized Access: Block malicious traffic and


access attempts.

o Log Activity: Record connection attempts and traffic for


auditing.

 Types of Firewalls:

1. Packet-Filtering Firewalls:

 Concept: Simplest and oldest type. Filters individual


packets based on information in the network and transport
layer headers (source/destination IP, source/destination
port, protocol type).

 Characteristics: Fast, low overhead.

 Disadvantages: Stateless (doesn't remember past


packets), vulnerable to IP spoofing, cannot inspect
application layer content.

2. Stateful Inspection Firewalls:

 Concept: The most common type. Keeps track of the


"state" of active connections. It understands that a
response packet is part of an already established outbound
connection and allows it through.

 Characteristics: More intelligent, provides better security


than packet filtering.

 Advantages: Monitors TCP connections, provides more


granular control, better protection against some attacks.
Hamza Zahoor What's App 0341-8377-917

3. Application-Level Gateways (Proxy Firewalls):

 Concept: Acts as an intermediary (proxy) between the


client and server. The client connects to the proxy, and the
proxy establishes a separate connection to the actual
server. It filters traffic at the Application Layer.

 Characteristics: Can inspect actual application-layer data


(e.g., HTTP content, FTP commands).

 Advantages: High level of security, content filtering,


strong authentication.

 Disadvantages: Performance overhead, requires specific


proxies for each application, transparent to users.

4. Next-Generation Firewalls (NGFW):

 Concept: Combine traditional firewall functions with


advanced features like deep packet inspection (DPI),
intrusion prevention systems (IPS), application awareness,
and threat intelligence.

 Advantages: Comprehensive security, able to detect and


block sophisticated threats.

5. Personal Firewalls: Software-based firewalls running on


individual host computers (e.g., Windows Defender Firewall).

6. Network Security Policies

 Definition: A set of rules, procedures, and guidelines that define how


an organization manages and protects its network resources. They
specify what is and isn't allowed on the network.

 Importance: Essential for effective network security. Without clear


policies, security measures can be inconsistent, ineffective, and lead to
vulnerabilities.

 Key Aspects of Network Security Policies:

1. Access Control Policy: Who can access what resources, from


where, and when (e.g., strong passwords, multi-factor
authentication, least privilege).
Hamza Zahoor What's App 0341-8377-917

2. Acceptable Use Policy (AUP): Defines how users can and


cannot use network resources (e.g., no illegal activities, no
excessive bandwidth consumption).

3. Password Policy: Rules for password length, complexity, and


change frequency.

4. Data Classification Policy: Categorizing data based on its


sensitivity (e.g., public, internal, confidential, restricted).

5. Incident Response Policy: Procedures for detecting,


responding to, and recovering from security incidents.

6. Remote Access Policy: Rules for connecting to the network


from outside (e.g., VPN usage, allowed devices).

7. Software Installation Policy: Guidelines on installing software


on network devices and user machines.

8. Physical Security Policy: Protecting network hardware from


unauthorized physical access.

9. Auditing and Monitoring Policy: How network activity is


logged and reviewed.

 Implementation: Policies are typically documented, communicated to


all users, and enforced through technical controls (firewalls, access
control lists, intrusion detection systems) and administrative
procedures. Regular review and updates are crucial.

You might also like